fix(qwen3_omni_moe): put the thinker prefix inside the peft prefix on lora saves - #3630
Open
stanley1208 wants to merge 4 commits into
Open
fix(qwen3_omni_moe): put the thinker prefix inside the peft prefix on lora saves#3630stanley1208 wants to merge 4 commits into
stanley1208 wants to merge 4 commits into
Conversation
… lora saves Fixes NVIDIA-NeMo#3595. On peft saves the adapter prepended "thinker." to every key, including ones already carrying the "base_model.model." outer prefix, so the exported adapter had keys like "thinker.base_model.model.model.layers..." that HF PEFT can't attach. The thinker namespace now goes inside the peft prefix ("base_model.model.thinker.model.layers..."), matching how PEFT names the text modules on the actual HF omni model, same as kimi_k3's _add_hf_text_prefix does for language_model. from_hf inverts it for resume, and its layout detection skips lora keys so an adapter-only dict doesn't disable the thinker prefix for later full saves. Signed-off-by: stanley1208 <stanley.mei08@gmail.com>
Review hardening for the peft prefix fix: from_hf's layout detection keyed off the first expert weight key and skipped lora keys, so a peft adapter carrying modules_to_save-style full weights flipped the thinker flag off (the namespace now sits inside the peft prefix where a plain startswith can't see it), an adapter-only dict never corrected stale flags, and a full omni dict could key off a talker expert first. Detection now considers every expert weight key and recognizes the thinker namespace in either position. Signed-off-by: stanley1208 <stanley.mei08@gmail.com>
Contributor
|
/ok to test a1b63b0 |
This was referenced Aug 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3595.
lora training on qwen3_omni_moe works, but the saved adapter has broken key names. the adapter put
thinker.in front of every key, even ones that already start withbase_model.model., so you getbut hf peft needs
the fix puts
thinker.inside the peft prefix instead, which is how peft actually names the modules on the hf omni model. same approach kimi_k3 uses forlanguage_model..from_hfreverses it, so resuming from a checkpoint still works, and old adapters saved before this fix still load.also made the layout detection in
from_hfsmarter while at it: it now checks every expert weight key and finds the thinker namespace whether it's on the outside (full checkpoints) or inside the peft prefix (adapter saves), instead of trusting the first key it sees.added cpu tests for the key placement, the round trip, and the detection.