Skip to content

[data4elm] support resume from lora checkpoint #945

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 13, 2025
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
11 changes: 1 addition & 10 deletions src/lmflow/models/hf_model_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,16 +365,7 @@ def __prepare_model_for_training(

if model_args.use_lora or model_args.use_dora:
model.enable_input_require_grads()
if model_args.lora_model_path is not None:
# Load model from LoRA weights
model = PeftModel.from_pretrained(
model,
model_args.lora_model_path,
is_trainable=True,
)
else:
# New LoRA Finetuning
model = get_peft_model(model, self.peft_config)
model = get_peft_model(model, self.peft_config)
model.print_trainable_parameters()

# We resize the embeddings only when necessary to avoid index errors.
Expand Down
9 changes: 2 additions & 7 deletions src/lmflow/pipeline/finetuner.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
from lmflow.args import OptimizerNames, DatasetArguments, ModelArguments, FinetunerArguments
from lmflow.datasets.dataset import Dataset
from lmflow.pipeline.base_tuner import BaseTuner
from lmflow.pipeline.utils.peft_trainer import PeftTrainer, PeftSavingCallback


logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -499,12 +498,8 @@ def compute_metrics(eval_preds):
# Initialize our Trainer
training_args = finetuner_args

if model_args.use_lora:
FinetuningTrainer = PeftTrainer
trainer_callbacks = [PeftSavingCallback]
else:
FinetuningTrainer = Trainer
trainer_callbacks = []
FinetuningTrainer = Trainer
trainer_callbacks = []
if data_collator is None:
data_collator = default_data_collator

Expand Down
Loading