Commit dded6b5
fix: Restore tied weights after PEFT merge_and_unload for tied embeddings
When training LoRA adapters on models with tie_word_embeddings=true,
the merge_and_unload() operation breaks the weight sharing between
embed_tokens and lm_head. This fix restores the weight tie after
merging by calling tie_weights() if available, or manually assigning
lm_layer.weight = embed_layer.weight.
Fixes test_run_causallm_lora_tied_weights_in_modules_to_save parametrized tests.
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>1 parent b3a8a78 commit dded6b5
1 file changed
Lines changed: 9 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
997 | 997 | | |
998 | 998 | | |
999 | 999 | | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
1000 | 1009 | | |
1001 | 1010 | | |
1002 | 1011 | | |
| |||
0 commit comments