Support Qwen3.5 MoE INT4-QAT#2156
Open
ShuZihan wants to merge 3 commits into
Open
Conversation
7c0841d to
655d5fb
Compare
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.
Summary
Support Qwen3.5 MoE INT4-QAT for routed experts.
This PR adds:
convert_hf_to_int4_direct.pygate_up_proj/down_projinto per-expert 2Dgate_proj/up_proj/down_projScope
Current support targets routed experts only.
MTP training and visual INT4-QAT are not included in this PR.
Why
Qwen3.5 MoE routed experts can be stored as fused 3D tensors in Hugging Face checkpoints:
The INT4 compressed-tensors / SGLang MoE path expects per-expert 2D weights. This PR adds the missing split path so Qwen3.5 can use the same experts-only INT4-QAT flow.
Test Plan
Unit and static checks:
python3 -m compileall -q tools/convert_hf_to_int4_direct.py slime/backends/megatron_utils/megatron_to_hf/qwen3_5.py slime/backends/megatron_utils/megatron_to_hf/processors/quantizer_compressed_tensors.py slime/backends/megatron_utils/update_weight/common.py tests/test_qwen35_int4_fused_expert_quantizer.pybash -n scripts/low_precision/run-qwen3.5-35B-A3B-int4-qat-rl.shgit diff --check refs/remotes/thudm/main...HEADpython -m pytest tests/test_qwen35_int4_fused_expert_quantizer.py -q7 passedServer validation:
torch_distQwen3.5-35B-A3B_slimeValidated on 4 x H20 141GB. The Qwen3.5-35B-A3B INT4-QAT-RL smoke test completed successfully and saved a checkpoint under
Qwen3.5-35B-A3B_slime.Smoke config:
num-rollout=2,rollout-batch-size=2,n-samples-per-prompt=2,rollout-max-response-len=512.Server reproduction:
Follow-up work: