Update llama.py
This commit is contained in:
parent
0c449485b6
commit
b283a6bf08
1 changed files with 6 additions and 4 deletions
|
|
@ -1385,14 +1385,16 @@ class FastLlamaModel:
|
|||
# Now patch lm_head and embed_tokens
|
||||
if train_embed_tokens:
|
||||
print("Unsloth: Casting embed_tokens to float32")
|
||||
model.model.model.embed_tokens.to(torch.float32)
|
||||
model.model.model.embed_tokens.requires_grad_(True)
|
||||
assert(hasattr(model.model.model.embed_tokens, "modules_to_save"))
|
||||
model.model.model.embed_tokens.modules_to_save.default.to(torch.float32)
|
||||
model.model.model.embed_tokens.modules_to_save.default.requires_grad_(True)
|
||||
pass
|
||||
|
||||
if train_lm_head:
|
||||
print("Unsloth: Casting lm_head to float32")
|
||||
model.model.lm_head.to(torch.float32)
|
||||
model.model.lm_head.requires_grad_(True)
|
||||
assert(hasattr(model.model.lm_head, "modules_to_save"))
|
||||
model.model.lm_head.modules_to_save.default.to(torch.float32)
|
||||
model.model.lm_head.modules_to_save.default.requires_grad_(True)
|
||||
pass
|
||||
|
||||
return model
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue