Skip to content

fix: FSDP runnable for Qwen3-30b-a3b - #1010

Merged
zhuzilin merged 1 commit into
THUDM:mainfrom
yueming-yuan:fsdp-qwen30-a3b-moe
Dec 3, 2025
Merged

zhuzilin merged 1 commit into
THUDM:mainfrom
yueming-yuan:fsdp-qwen30-a3b-moe

Conversation

@yueming-yuan

Copy link
Copy Markdown
Collaborator

Patch the huggingface model and hack the NCCL hanging issue for FSDP compatibility on MoE models with separate expert parameters (e.g. Qwen 30b a3b).

In the previous implementation, the training will hang at the reduced scatter in the backward of FSDP. The reason is that only partial experts are activated per rank, so only some of them can be involved in the computational graph, which makes the communication ranks not match in NCCL. So they may enter a deadlock.

Theoretically, FSDP does not allow partially activated parameters when use_orig_params=False... (use_orig_params=True will no longer flatter the tensors - which is intuitively slow. So doing this hack.)

FSDP has some constraints when freezing parameters. For use_orig_params=False, each FSDP instance must manage parameters that are all frozen or all non-frozen. For use_orig_params=True, FSDP supports mixing frozen and non-frozen parameters, but it’s recommended to avoid doing so to prevent higher than expected gradient memory usage.

(Note: This bug does not apply to MoE models with a single, combined experts tensor - e.g. GPT-OSS)

@yueming-yuan
yueming-yuan marked this pull request as ready for review December 3, 2025 04:02
@zhuzilin
zhuzilin merged commit a105730 into THUDM:main Dec 3, 2025
Fengzdadi pushed a commit to Fengzdadi/slime that referenced this pull request Dec 19, 2025
Co-authored-by: Yueming Yuan <yy28@illinoi.edu>
Yangruipis pushed a commit to redai-studio/slime that referenced this pull request Feb 28, 2026
Co-authored-by: Yueming Yuan <yy28@illinoi.edu>
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.

2 participants