Skip to content

fix(qwen3_omni_moe): put the thinker prefix inside the peft prefix on lora saves - #3630

Open
stanley1208 wants to merge 4 commits into
NVIDIA-NeMo:mainfrom
stanley1208:fix/qwen3-omni-thinker-prefix
Open

fix(qwen3_omni_moe): put the thinker prefix inside the peft prefix on lora saves#3630
stanley1208 wants to merge 4 commits into
NVIDIA-NeMo:mainfrom
stanley1208:fix/qwen3-omni-thinker-prefix

Conversation

@stanley1208

@stanley1208 stanley1208 commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

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 with base_model.model., so you get

thinker.base_model.model.model.layers.0.self_attn.q_proj.lora_A.weight

but hf peft needs

base_model.model.thinker.model.layers.0.self_attn.q_proj.lora_A.weight

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 for language_model.. from_hf reverses it, so resuming from a checkpoint still works, and old adapters saved before this fix still load.

also made the layout detection in from_hf smarter 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.

… 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>
@stanley1208
stanley1208 requested a review from a team as a code owner August 22, 2026 10:41
@copy-pr-bot

copy-pr-bot Bot commented Aug 22, 2026

Copy link
Copy Markdown

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.

@svcnvidia-nemo-ci svcnvidia-nemo-ci added the waiting-on-maintainers Waiting on maintainers to respond label Aug 24, 2026
@akoumpa

akoumpa commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

/ok to test a1b63b0

@akoumpa akoumpa removed the waiting-on-maintainers Waiting on maintainers to respond label Aug 24, 2026
@svcnvidia-nemo-ci svcnvidia-nemo-ci added the waiting-on-maintainers Waiting on maintainers to respond label Aug 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-request waiting-on-maintainers Waiting on maintainers to respond

Projects

None yet

Development

Successfully merging this pull request may close these issues.

qwen3_omni_moe peft save puts the thinker. prefix outside base_model.model

3 participants