Skip to content

Commit

Permalink
do not upcast adapters when using FSDP+QLoRA (#1654)
Browse files Browse the repository at this point in the history
  • Loading branch information
pacman100 authored May 23, 2024
1 parent 9a7efbd commit e4ed7a3
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion trl/trainer/sft_trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,14 @@ def make_inputs_require_grad(module, input, output):

model.get_input_embeddings().register_forward_hook(make_inputs_require_grad)

model = get_peft_model(model, peft_config)
if (
"autocast_adapter_dtype" in list(inspect.signature(get_peft_model).parameters)
and getattr(model, "is_loaded_in_4bit", False)
and is_sharded_qlora
):
model = get_peft_model(model, peft_config, autocast_adapter_dtype=False)
else:
model = get_peft_model(model, peft_config)
if (
args is not None
and args.bf16
Expand Down

0 comments on commit e4ed7a3

Please sign in to comment.