Skip to content

[Fix] Shard MoE WNA16 and Quark INT4-FP8 weights by the MoE placement - #41807

Merged
ch-wan merged 1 commit into
mainfrom
cheng/hot-fix/moe-wna16-ep-shard-rank
Sep 30, 2026
Merged

ch-wan merged 1 commit into
mainfrom
cheng/hot-fix/moe-wna16-ep-shard-rank

Conversation

@ch-wan

@ch-wan ch-wan commented Sep 30, 2026 •

Copy link
Copy Markdown
Collaborator

This PR is part of a stack (oldest at bottom):

Motivation

Both loaders split expert weights into moe_tp_size shards of intermediate_size_per_partition, but pick the shard with the full TP rank:

  • moe_wna16 indexes view(layer.moe_tp_size, ...)[tp_rank] for the qzeros;
  • quark_int4fp8_moe narrows 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 indexes 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_experts slots.

Modifications

  • Both loaders shard by 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.
  • The WNA16 qzeros go to the local slots that the layer's own loader picks for that expert, EPLB replicas included (_local_expert_ids).
  • Unit tests load both qzeros paths (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 2
parent commit fails at load (IndexError)
this PR 0.945 0.935

test/registered/unit at this PR's head, compared with main: no new failures.

Speed Tests and Profiling

Not applicable.

Checklist

Review and Merge Process

  1. Ping Merge Oncalls to start the process. See the PR Merge Process.
  2. Get approvals from CODEOWNERS and other reviewers.
  3. Trigger CI tests with comments or contact authorized users to do so.
    • Common commands include /tag-and-rerun-ci, /tag-run-ci-label, /rerun-failed-ci
  4. After green CI and required approvals, ask Merge Oncalls or people with Write permission to merge the PR.

CI States

Latest PR Test (Base): 🚫 Run #36772541781
Latest PR Test (Extra): 🚫 Run #36772541304
Latest PR Test (AMD ROCm 10): ❌ Run #36772541631

@ch-wan
ch-wan force-pushed the cheng/hot-fix/weight-cache-moe-dp-fingerprint branch from ea4c1ed to 29921f3 Compare September 30, 2026 04:24
@ch-wan
ch-wan force-pushed the cheng/hot-fix/moe-wna16-ep-shard-rank branch 2 times, most recently from 3fb1054 to 623f068 Compare September 30, 2026 05:05
@ch-wan
ch-wan force-pushed the cheng/hot-fix/weight-cache-moe-dp-fingerprint branch from 29921f3 to 49b65a8 Compare September 30, 2026 20:25
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
ch-wan force-pushed the cheng/hot-fix/moe-wna16-ep-shard-rank branch from 623f068 to dcd6a6b Compare September 30, 2026 20:25
@ch-wan
ch-wan merged commit e289989 into main Sep 30, 2026
8 of 17 checks passed
@ch-wan
ch-wan deleted the cheng/hot-fix/moe-wna16-ep-shard-rank branch September 30, 2026 20:25
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.

1 participant