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 dora tune_to_peft_adapter_weights #1884

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
29 changes: 20 additions & 9 deletions torchtune/models/convert_weights.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,15 +260,26 @@ def tune_to_peft_adapter_weights(
# re-use the _FROM_HF mapping for base model weights. We iterate over it twice:
# once to add mappings for LoRA A matrices and once to add mappings for LoRA B matrices.
for k, v in _TO_PEFT_KEYS.items():
full_mapping.update(
{
vv.replace(".weight", f".{k}.weight"): kk.replace(
".weight", f".{v}.weight"
)
for kk, vv in _FROM_HF.items()
if vv is not None
}
)
if k == "magnitude":
full_mapping.update(
{
vv.replace(".weight", f".{k}"): kk.replace(
".weight", f".{v}"
)
for kk, vv in _FROM_HF.items()
if vv is not None
}
)
else:
full_mapping.update(
{
vv.replace(".weight", f".{k}.weight"): kk.replace(
".weight", f".{v}.weight"
)
for kk, vv in _FROM_HF.items()
if vv is not None
}
)

if head_dim is None:
head_dim = dim // num_heads
Expand Down
Loading