Skip to content

[main] [3/5] Qwen3.5 support: SharedExpertMLP meta init#4754

Open
wplf wants to merge 1 commit into
NVIDIA:mainfrom
wplf:fix/shared-experts-meta-init-main
Open

[main] [3/5] Qwen3.5 support: SharedExpertMLP meta init#4754
wplf wants to merge 1 commit into
NVIDIA:mainfrom
wplf:fix/shared-experts-meta-init-main

Conversation

@wplf

@wplf wplf commented May 12, 2026

Copy link
Copy Markdown
Member

Qwen3.5 support series

This is part of a 5-PR series adding Qwen3.5-VL support, split for review clarity.

Main PRs (this series):

Dev PRs (corresponding mirrors):


Summary

Add _reset_parameters to SharedExpertMLP so the directly-owned gate_weight is materialized off the meta device when use_shared_expert_gate=True.

Why

Without this, meta-init leaves gate_weight on the meta device and the first forward fails with a meta-tensor error. Submodules already have their own _reset_parameters, so only the directly-owned gate_weight needs handling.

The implementation mirrors the standard per-parameter init pattern:

  • run init_method when config.perform_initialization
  • cast to config.params_dtype
  • set sequence_parallel attribute

Risk

Only fires when use_shared_expert_gate=True and gate_weight is not None — no effect on existing paths.

Notes

Mirror of #4749 (same patch, targeting main instead of dev).

🤖 Generated with Claude Code

@wplf wplf added the Run tests label May 12, 2026
@copy-pr-bot

copy-pr-bot Bot commented May 12, 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.

Add `_reset_parameters` to `SharedExpertMLP` so the directly-owned
`gate_weight` is materialized off the meta device when
`use_shared_expert_gate=True`. Without this, meta-init leaves
`gate_weight` on the meta device and forward fails.

Mirrors the per-parameter init pattern already used in other Megatron
modules (run `init_method` if `perform_initialization`, cast to
`params_dtype`, set `sequence_parallel`).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

Co-Authored-By: BestJuly <19769279+BestJuly@users.noreply.github.com>
@wplf wplf force-pushed the fix/shared-experts-meta-init-main branch from 067dd9c to eab5149 Compare May 13, 2026 10:24
@wplf wplf marked this pull request as ready for review June 4, 2026 11:06
@wplf wplf requested review from a team as code owners June 4, 2026 11:06
@wplf

wplf commented Jun 4, 2026

Copy link
Copy Markdown
Member Author

/ok to test eab5149

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants