Skip to content

fix: MoE lora adapter layout#1395

Merged
thomasdhc merged 5 commits intomainfrom
akoumparouli/fix_hf_moe_adapters
Feb 27, 2026
Merged

fix: MoE lora adapter layout#1395
thomasdhc merged 5 commits intomainfrom
akoumparouli/fix_hf_moe_adapters

Conversation

@akoumpa
Copy link
Copy Markdown
Contributor

@akoumpa akoumpa commented Feb 26, 2026

What does this PR do ?

TestMoELoRASaveRestoreMergeHF covers -- the exact workflow from issue #1226:

  1. test_peft_loads_adapter -- Grouped LoRA tensors are converted to per-expert HF format, saved as adapter_model.safetensors + adapter_config.json, and PeftModel.from_pretrained() loads them without error.
  2. test_merge_changes_all_expert_weights -- After merge_and_unload(), every expert's gate_proj, up_proj, and down_proj weights differ from the base (all 24 = 2 layers x 4 experts x 3 projections).
  3. test_merge_values_are_numerically_correct -- The merged weight values exactly satisfy W_merged = W_base + (lora_B @ lora_A) * (alpha / r), verifying the LoRA delta is correctly applied.
  4. test_merge_removes_lora_params -- After merge, no lora_ parameters or modules remain in the model.

Changelog

  • Add specific line by line info of high level changes in this PR.

Before your PR is "Ready for review"

Pre checks:

  • Make sure you read and followed Contributor guidelines
  • Did you write any new necessary tests?
  • Did you add or update any necessary documentation?

If you haven't finished some of the above items you can still open "Draft" PR.

Additional Information

  • Related to # (issue)

Signed-off-by: Alexandros Koumparoulis <akoumparouli@nvidia.com>
@copy-pr-bot
Copy link
Copy Markdown

copy-pr-bot Bot commented Feb 26, 2026

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@akoumpa
Copy link
Copy Markdown
Contributor Author

akoumpa commented Feb 26, 2026

/ok to test 8915726

Signed-off-by: Alexandros Koumparoulis <akoumparouli@nvidia.com>
@akoumpa
Copy link
Copy Markdown
Contributor Author

akoumpa commented Feb 26, 2026

/ok to test 750f55a

Signed-off-by: Alexandros Koumparoulis <akoumparouli@nvidia.com>
@akoumpa
Copy link
Copy Markdown
Contributor Author

akoumpa commented Feb 26, 2026

/ok to test dad2a6f

Signed-off-by: Alexandros Koumparoulis <akoumparouli@nvidia.com>
@akoumpa
Copy link
Copy Markdown
Contributor Author

akoumpa commented Feb 26, 2026

/ok to test 90eae91

Copy link
Copy Markdown
Contributor

@HuiyingLi HuiyingLi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

r0.3.0 Add for cherry-pick into release branch r0.3.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LoRA adapter merging gives loss/output the similar to base (untrained) model

4 participants