这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/qalora_finetuning/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ python qalora_gptq_finetuning.py \
--qalora_group_size 32 \
--eval_step 10 \
--save_step 100 \
--device "cuda:0" \
--device "auto" \
--lora_r 16 \
--lora_alpha 32 \
--lora_dropout 0.05 \
Expand Down Expand Up @@ -154,4 +154,4 @@ For most use cases, we recommend keeping the base quantized model and the QALoRA
journal={arXiv preprint arXiv:2309.14717},
year={2023}
}
```
```
12 changes: 8 additions & 4 deletions examples/qalora_finetuning/qalora_gptq_finetuning.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def train_model(
quantize: Whether to use quantization
eval_step: Steps between evaluations
save_step: Steps between saving checkpoints
device: Device to use (cuda:0, etc.)
device: Device to use (cuda:0, xpu:0, etc.)
lora_r: LoRA rank
lora_alpha: LoRA alpha
lora_dropout: LoRA dropout rate
Expand Down Expand Up @@ -209,7 +209,7 @@ def train_model(
model.print_trainable_parameters()

# Move model to device if not already there
if device.type != "cuda" or not hasattr(model, "device") or model.device.type != "cuda":
if not hasattr(model, "device") or model.device.type != device.type:
model = model.to(device)

# Load and prepare dataset
Expand Down Expand Up @@ -313,13 +313,17 @@ def train_model(
# Training process options
parser.add_argument("--eval_step", type=int, default=100, help="Evaluation step interval")
parser.add_argument("--save_step", type=int, default=500, help="Save step interval")
parser.add_argument("--device", type=str, default="cuda", help="Device to use for training")
parser.add_argument("--device", type=str, default="auto", help="Device to use for training")

# Hugging Face Hub options
parser.add_argument("--push_to_hub", action="store_true", help="Whether to push the model to Hugging Face Hub")

args = parser.parse_args()

device = args.device
if args.device == "auto":
device = torch.accelerator.current_accelerator().type if hasattr(torch, "accelerator") else "cuda"

# If use_qalora isn't explicitly set in args but passed to train_model
if not args.use_qalora:
args.use_qalora = True # Default to True as in the original code
Expand All @@ -336,7 +340,7 @@ def train_model(
use_qalora=args.use_qalora,
eval_step=args.eval_step,
save_step=args.save_step,
device=args.device,
device=device,
lora_r=args.lora_r,
lora_alpha=args.lora_alpha,
lora_dropout=args.lora_dropout,
Expand Down
Loading