Skip to content

Commit

Permalink
qlora w flash attention fixes (axolotl-ai-cloud#333)
Browse files Browse the repository at this point in the history
  • Loading branch information
winglian committed Aug 2, 2023
1 parent 0cfab25 commit 8612ded
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/axolotl/utils/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,14 @@ def load_llama_adapter(model, cfg):
else:
model = get_peft_model(model, peft_config)

if cfg.flash_attention:
for name, module in model.named_modules():
if "norm" in name:
module.to(torch.float16)
if "lm_head" in name or "embed_tokens" in name:
if hasattr(module, "weight"):
module.to(torch.float16)

model.print_trainable_parameters()

return model, peft_config
Expand Down

0 comments on commit 8612ded

Please sign in to comment.