Skip to content
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

Fix Llama-70B-FSDP model loading issue #752

Merged
merged 1 commit into from
Mar 7, 2024
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
6 changes: 4 additions & 2 deletions examples/language-modeling/run_lora_clm.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
from transformers.trainer_utils import is_main_process

from optimum.habana import GaudiConfig, GaudiTrainer, GaudiTrainingArguments
from optimum.habana.peft.layer import GaudiLoraLayerLinearForward
from optimum.habana.utils import set_seed


Expand Down Expand Up @@ -675,7 +674,10 @@ def compute_metrics(eval_preds):
)
if training_args.gradient_checkpointing:
model.enable_input_require_grads()
tuners.lora.layer.Linear.forward = GaudiLoraLayerLinearForward
if training_args.torch_compile:
from optimum.habana.peft.layer import GaudiLoraLayerLinearForward

tuners.lora.layer.Linear.forward = GaudiLoraLayerLinearForward
lora_model = get_peft_model(model, peft_config)
if training_args.bf16:
lora_model = lora_model.to(torch.bfloat16)
Expand Down
1 change: 1 addition & 0 deletions optimum/habana/transformers/training_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,7 @@ def __post_init__(self):
# accelerate integration for FSDP
if len(self.fsdp) > 0 and not self.fsdp_config["xla"]:
os.environ["ACCELERATE_USE_FSDP"] = "true"
os.environ["FSDP_CPU_RAM_EFFICIENT_LOADING"] = "true"
from accelerate.utils.constants import (
FSDP_AUTO_WRAP_POLICY,
FSDP_SHARDING_STRATEGY,
Expand Down
Loading