Repository navigation
[Fix] Shard MoE WNA16 and Quark INT4-FP8 weights by the MoE placement - #41807
Merged
Merged
Conversation
ch-wan
requested review from
Alisehen,
AniZpZ,
BBuf,
Edwardf0t1,
FlamingoPg,
HaiShaw,
OrangeRedeng,
b8zhong and
mmangkad
as code owners
September 30, 2026 03:07
This was referenced Sep 30, 2026
ch-wan
force-pushed
the
cheng/hot-fix/weight-cache-moe-dp-fingerprint
branch
from
September 30, 2026 04:24
ea4c1ed to
29921f3
Compare
ch-wan
requested review from
Ying1123,
alexnails,
hanming-lu,
hnyls2002,
liusy58,
merrymercy and
xiezhq-hermann
as code owners
September 30, 2026 04:24
ch-wan
requested review from
alphabetc1,
huangtingwei9988,
hzh0425,
ispobock and
yizhang2077
as code owners
September 30, 2026 04:24
ch-wan
force-pushed
the
cheng/hot-fix/moe-wna16-ep-shard-rank
branch
2 times, most recently
from
September 30, 2026 05:05
3fb1054 to
623f068
Compare
ch-wan
force-pushed
the
cheng/hot-fix/weight-cache-moe-dp-fingerprint
branch
from
September 30, 2026 20:25
29921f3 to
49b65a8
Compare
Base automatically changed from
cheng/hot-fix/weight-cache-moe-dp-fingerprint
to
main
September 30, 2026 20:25
Both loaders split expert weights into `moe_tp_size` shards of `intermediate_size_per_partition`, but picked the shard with the full TP rank: `moe_wna16` indexed `view(layer.moe_tp_size, ...)[tp_rank]` for the qzeros, and `quark_int4fp8_moe` narrowed at `shard_size * tp_rank`. Under EP or MoE-DP the MoE-TP width is smaller than the TP width, so every rank with `tp_rank >= moe_tp_size` indexed past the shards and failed to load. Both now read `layer.moe_tp_rank`, the rank the layer shards by. Without EP or MoE-DP it equals the TP rank, so nothing changes there. The WNA16 qzeros are written outside the layer's weight loader, at the checkpoint expert id. Under EP that id runs past the rank's `num_local_experts` slots, so they now go to the local slots the layer's own loader picks, EPLB replicas included. Quark's scale writes still index by the checkpoint expert id, so Quark under EP is still unsupported; that path is HIP-only and not exercised here.
ch-wan
force-pushed
the
cheng/hot-fix/moe-wna16-ep-shard-rank
branch
from
September 30, 2026 20:25
623f068 to
dcd6a6b
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.
This PR is part of a stack (oldest at bottom):
Motivation
Both loaders split expert weights into
moe_tp_sizeshards ofintermediate_size_per_partition, but pick the shard with the full TP rank:moe_wna16indexesview(layer.moe_tp_size, ...)[tp_rank]for the qzeros;quark_int4fp8_moenarrows atshard_size * tp_rank.Under EP or MoE-DP the MoE-TP width is smaller than the TP width, so every rank with
tp_rank >= moe_tp_sizeindexes past the shards and fails to load.The WNA16 qzeros have a second problem under EP. They are written outside the layer's weight loader, at the checkpoint expert id, and that id runs past the rank's
num_local_expertsslots.Modifications
layer.moe_tp_rank, the rank the layer itself shards by. Without EP or MoE-DP it equals the TP rank, so nothing changes there._local_expert_ids).w13,w2): under an EP layout, the shard matches the non-EP load for the same MoE-TP rank, and each EP rank writes only its own experts.Quark's scale writes still index by the checkpoint expert id, so Quark under EP is still unsupported. That path is HIP-only and is not exercised here.
Accuracy Tests
H200,
QuantTrio/Qwen3-VL-30B-A3B-Instruct-AWQ --quantization moe_wna16, GSM8K 200 questions:--tp 2--tp 2 --ep-size 2IndexError)test/registered/unitat this PR's head, compared withmain: no new failures.Speed Tests and Profiling
Not applicable.
Checklist
Review and Merge Process
/tag-and-rerun-ci,/tag-run-ci-label,/rerun-failed-ciCI States
Latest PR Test (Base): 🚫 Run #36772541781
Latest PR Test (Extra): 🚫 Run #36772541304
Latest PR Test (AMD ROCm 10): ❌ Run #36772541631