Skip to content

fix(qwen3_omni): read router_aux_loss_coef from text_config#9763

Open
Anai-Guo wants to merge 1 commit into
modelscope:mainfrom
Anai-Guo:fix-qwen3omni-router-aux-loss-coef-9757
Open

fix(qwen3_omni): read router_aux_loss_coef from text_config#9763
Anai-Guo wants to merge 1 commit into
modelscope:mainfrom
Anai-Guo:fix-qwen3omni-router-aux-loss-coef-9757

Conversation

@Anai-Guo

Copy link
Copy Markdown
Contributor

What / Why

In the Qwen3-Omni thinker forward (swift/model/models/qwen.py), the MoE
auxiliary-loss coefficient is read from the top-level composite config:

loss += self.config.router_aux_loss_coef * aux_loss.to(loss.device)

For the Qwen3-Omni thinker, the router hyperparameters live in the thinker's
text_config, not on the top-level composite config. The two sibling accesses
in the same function already go through text_config:

  • output_router_logitsself.config.text_config.output_router_logits
  • vocab_sizeself.config.get_text_config().vocab_size

so router_aux_loss_coef was the lone inconsistent access. Reading it off the
composite config scales the aux-loss term with the wrong coefficient (and can
AttributeError when the attribute is absent at the top level).

Fix

Read the coefficient from text_config, matching the sibling
output_router_logits access:

loss += self.config.text_config.router_aux_loss_coef * aux_loss.to(loss.device)

Fixes #9757

🤖 Generated with Claude Code

In the Qwen3-Omni thinker forward, the MoE auxiliary-loss coefficient was
read from the top-level composite config (self.config.router_aux_loss_coef),
but the router hyperparameters live in the thinker'"'"'s text_config. The sibling
router setting output_router_logits is already read from
self.config.text_config, and vocab_size uses self.config.get_text_config(),
so this was the lone inconsistent access. Align it with text_config so the
aux-loss term is scaled by the correct coefficient.
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Qwen3 Omni bug

1 participant