MegaMoE: add cluster-paired FP4 weight packets - #394
Conversation
🤖 ds-review-bot Code Reviewv6No actionable correctness issues were identified in the changed code. v4v3This MR adds an opt-in cluster-paired FP4 weight-packet layout for FP8xFP4 Mega MoE, implemented across 9 files in three commits (feat c99da9c, test 1097cba, test 779e283). The change is complete, internally consistent, and follows the described access order (expert -> CTA pair -> K tile -> CTA peer). Key elements verified:
The implementation matches the PR description and I found no correctness or consistency defects. Only minor maintainability suggestions are noted below. Note: the review environment permits git-only command execution, so I could not re-run the build/pytest/four-GPU steps; I relied on static review plus the MR's recorded validation results. Files reviewed: 9 |
Addressed all three review suggestions. Changes:
Validation:
Pushed commit: d1e7368 |
Summary
This change adds an optional weight layout for FP8xFP4 Mega MoE:
scale words consumed by that tile;
The packet and scale views share one allocation. Expert ownership remains
sharded by rank, so this does not replicate expert weights.
Motivation
Sparse Mega MoE batches touch many experts but read only a small part of each
expert at a time. In the row-major layout, cooperating CTAs and their scale
loads can be far apart in memory.
The packet layout follows the kernel's actual access order:
expert -> CTA pair -> K tile -> CTA peerThis keeps each CTA pair's weight bodies adjacent and places the matching
scale words directly after each body.
For sparse small-token work, the packet path also uses one output warpgroup
and marks one-use routed weight loads as
EVICT_FIRST. Other workloads keepthe existing production heuristic.
API
The layout is opt-in during the existing model-load weight transform:
The runtime detects the packet layout from its shape and strides. Existing
row-major weights continue to use the original path.
Correctness
On four GB200 GPUs, row-major and packet layouts produced bitwise-identical
output tensors and cumulative expert statistics for every reported workload.
Performance
Configuration: FP8xFP4, EP4, 384 experts, top-k 6, hidden size 7168,
intermediate size 3072, no shared experts, deterministic random routing.
The metric is the maximum rank median from alternating same-process A/B runs.
The small-token candidate includes the packet layout, one output warpgroup,
and
EVICT_FIRSTfor routed packet loads. The large-token comparisons usethe same default compute setting on both sides and differ only in weight
layout.
Reproduce the correctness and alternating A/B measurements with:
Scope and fallback
Validation