Skip to content

[Fix] moe: Preserve CUTLASS routing metadata and execution budgets - #45917

Merged
ch-wan merged 1 commit into
mainfrom
cheng/hot-fix/cutlass-moe-complete-maps
Oct 23, 2026
Merged

ch-wan merged 1 commit into
mainfrom
cheng/hot-fix/cutlass-moe-complete-maps

Conversation

@ch-wan

@ch-wan ch-wan commented Oct 22, 2026 •

Copy link
Copy Markdown
Collaborator

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

Motivation

CUTLASS routing must define every permutation entry when routes are negative or nonlocal. Clearing maps, preparing activation-sized copies and materializing rounded scores separately adds work even when all routes are valid. The effective FP8 backend also needs to reach TopK and dispatch before they choose route layout and token-count ownership.

Changes

  • Publish the effective FP8 routing policy before TopK/dispatch, preserving raw signed IDs and the correct local token bound for native FP8/W4A8 consumers.

  • Share one complete CUDA route producer between FP8 and W4A8. It writes invalid output-map entries as -1, unused input-map capacity as token zero, and the appropriate grouped-GEMM M/N layout. One CTA owns each expert cursor; no separate expert cursor allocation or clear is needed. Non-CUDA and DeepEP paths retain their existing producers.

  • Reuse W4A8's existing maps, normalize exceptional ID layouts once, and mask dynamic scale loads before reading inactive rows. Valid inputs avoid the previous activation/ID copies.

  • Use a native checked weighted reduction that excludes inactive payloads and NaN scores before access. The FP8 caller opts into the original score-to-output-dtype rounding before FP32 slot-order accumulation. Cached backend/type admission, strided-score support, the Triton fallback, current-stream execution and compile/fake behavior are retained.

  • Complete the routing-policy interface for all four plain MXFP4 adapters without changing their inheritance or loading lifecycle. Derive native block-FP8 cardinality from materialized routes, including deferred finalize; widen FP16 scores to FP32 in one copy and preserve supported score storage. Keep Llama4's native per-tensor scaling convention after materialization.

CI cadence

The mapped shuffle/reduction microbenchmark now runs in nightly-test-1-gpu-large. FP8 and W4A8 correctness, map-completion and graph replay tests remain in base CI.

Across the stack, six existing CUDA file registrations move from base CI to extra/nightly, removing 854 estimated GPU-seconds from the default gate (registration estimates, not a measured wall-time saving). All test bodies, cases, inputs, assertions and tolerances are unchanged. Full before/after discovery validates 2,535 files and 3,077 registrations, with every moved file selected in its enabled destination suite. Configured hooks pass; native tests were not rerun for this registration-only update.

Validation

  • Actual-class adapter construction checks pass (8 tests with 18 construction cases), as do 25 focused routing tests. At integrated e6670af1ad on 1× B300 with the pinned providers, the registered block/per-tensor FP8 test passes both cases, including deferred finalize, FP16 score admission, borrowed inputs, and valid/partial/inactive/recovery CUDA Graph replay. The same native test on the preceding source fails at the missing runner cardinality and native FP16-score check. The fixture follows actual loader weight order and retains the existing numerical tolerance; this is native-entry coverage, not a full Llama4 serving run.

Performance comparisons use main b008ec3de6 before #44480, #44991, #44993 and #44994 merged. The integrated candidate also includes intervening main changes; the measured improvement is not attributed solely to this PR.

  • Configured hooks and focused policy/dispatch unit tests pass. On 1× NVIDIA B300, the registered FP8/W4A8 routing/reduction files passed 16 tests and 143 subtests; this is not blanket native W4A8 admission.
  • 1× NVIDIA H200 full native W4A8 comparisons at d1990d57 cover M32/512 with E2 and M512 with E128, static/dynamic scales, strict rtol=0.01, atol=0.001 checks, output bits and graph replay. All measured graph pairs improve; eager allocation peaks decrease by 512 or 4096 bytes and capture live allocations match. These measurements precede the main rebase.
  • Fresh 1× NVIDIA B300 MXFP8 comparison: b008ec3d versus composed f3a1165, BF16 M512/H256/I256/E2/topk2. All eight balanced CUDA-graph pairs improve 7.14–7.26%, using 16 captured calls × 8 replays and 21 samples per worker. Medians are 40.073 → 37.184 µs per entry; observed kernels are 14 → 12, both native grouped GEMMs remain, eager allocated peak is 2048 bytes lower and capture live bytes match. Performance scope is captured GPU execution; retained positive uncaptured eager/CPU-overhead observations are not claimed as improvements. The later LoRA int64 repair does not change this CUTLASS implementation.

B300 validation used PyTorch 2.14.1+cu130, Triton 3.8.0, sgl-kernel 0.4.10, FlashInfer 0.7.2, CUDA 13.0 and NVCC 13.0.88. The B300 W4A8 full-entry experiment stopped on an architecture error and numerical/graph failure in the unchanged baseline, before candidate admission; H200 W4A8 results are not transferred to Blackwell. A separate Torch-profiler diagnostic failed trace parsing after timing completed and supplies no accepted timing result. No serving, historical graph-pool peak or universal hardware claim is made.

Rebase validation (before the CI registration fix)

This five-PR stack was rebased without conflicts onto main 8b9f72417f. All five patches retain their stable patch IDs relative to the preceding published stack; the newer main commits do not touch the stack's changed files. The existing removal of the unused materialized_routing parameter and its three call-site arguments in #45917 is preserved.

Each rebased PR commit passed its configured pre-commit checks independently. The final stack passes git diff --check, and all 72 changed Python files parse successfully. CPU test suites, native GPU tests and performance measurements were not rerun for this rebase. Previously reported results, including those at integrated e6670af1ad, remain evidence for those earlier revisions with their stated limits.

Prior CI registration fix

The GGUF weighting test now uses the existing nightly-musa-1-gpu suite with nightly=True; at that revision, its CUDA kernel-unit registration was unchanged. The previous nonexistent MUSA suite caused global registry validation to fail before CPU, CUDA and AMD tests could run.

The original collection failure was reproduced. Full registration collection and suite validation now pass on the GGUF component (2,533 files / 3,075 registrations) and the integrated stack (2,535 files / 3,077 registrations), including enabled MUSA nightly and CUDA selection. Configured pre-commit checks pass for the corrected test. This update changes one registration line and is propagated through the existing stack.

CPU CI follow-up

Run 39935811691 exposed an upstream Flux2 import test registered in the CPU suite, whose environment lacks the diffusion dependencies. The import chain also queries the active GPU. #45915 moves that check to the existing CUDA diffusion unit suite, which installs those dependencies, while retaining its XPU registration and the real subprocess check that blocks Intel Triton imports. This registration fix is propagated through the stack.

#45917 also updates the MoE CPU fixtures to use the production CompressedTensors/Quark method wrappers and to resolve the FP8 routing policy through the initialization hook. Existing backend, EP mapping and zero-valued/default routing assertions remain intact. The three original fixture failures were reproduced before the fix; both complete files now pass on CPU (26 tests, 55 subtests).

The Flux2 import check passes on 1× NVIDIA B300 with PyTorch 2.14.1+cu130, Triton 3.8.0 and Diffusers 0.37.0; its five Intel-XPU numerical cases are skipped on CUDA and were not rerun on XPU. Full integrated registry collection validates 2,535 files / 3,077 registrations, including the enabled diffusion/XPU selections and the preceding GGUF MUSA fix. Configured checks pass for the changed files. Only three test files change across this follow-up; production code is unchanged. A fresh full CI result is not claimed.

Merge preparation

Rebased this component onto main 8b9b992e41 for squash merge. The preceding stack components are already merged into main; only this component is replayed here. No test suites or performance measurements were rerun for this merge. Earlier validation sections describe their named revisions.


CI States

Latest PR Test (Base): 🚫 Run #40012110502
Latest PR Test (Extra): 🚫 Run #40012110499
Latest PR Test (AMD ROCm 10): ❌ Run #40012110584

@ch-wan
ch-wan force-pushed the cheng/hot-fix/cutlass-moe-complete-maps branch 2 times, most recently from a3a3a6c to 4532436 Compare October 23, 2026 06:06
@ch-wan
ch-wan force-pushed the cheng/hot-fix/moe-temporary-workspace branch 2 times, most recently from 2189f68 to 7316774 Compare October 23, 2026 09:03
@ch-wan
ch-wan force-pushed the cheng/hot-fix/cutlass-moe-complete-maps branch from 4532436 to 22687df Compare October 23, 2026 09:03
@ch-wan
ch-wan force-pushed the cheng/hot-fix/moe-temporary-workspace branch from 7316774 to 2caaca3 Compare October 23, 2026 09:58
@ch-wan
ch-wan force-pushed the cheng/hot-fix/cutlass-moe-complete-maps branch from 22687df to c8f926b Compare October 23, 2026 09:59
@ch-wan
ch-wan force-pushed the cheng/hot-fix/moe-temporary-workspace branch from 2caaca3 to 5e16afe Compare October 23, 2026 11:36
@ch-wan
ch-wan force-pushed the cheng/hot-fix/cutlass-moe-complete-maps branch from c8f926b to 1aa9634 Compare October 23, 2026 11:36
@github-actions github-actions Bot added the blackwell SM100/SM120 label Oct 23, 2026
@ch-wan
ch-wan force-pushed the cheng/hot-fix/moe-temporary-workspace branch from 5e16afe to 06e0958 Compare October 23, 2026 19:21
@ch-wan
ch-wan force-pushed the cheng/hot-fix/cutlass-moe-complete-maps branch from 1aa9634 to d5ee31a Compare October 23, 2026 19:22
@ch-wan
ch-wan force-pushed the cheng/hot-fix/moe-temporary-workspace branch from 06e0958 to eb2e647 Compare October 23, 2026 19:30
@ch-wan
ch-wan requested a review from hnyls2002 as a code owner October 23, 2026 19:30
Base automatically changed from cheng/hot-fix/moe-temporary-workspace to main October 23, 2026 19:31
@ch-wan
ch-wan force-pushed the cheng/hot-fix/cutlass-moe-complete-maps branch from d5ee31a to 491587f Compare October 23, 2026 19:31
@ch-wan
ch-wan merged commit ac3db73 into main Oct 23, 2026
87 of 101 checks passed
@ch-wan
ch-wan deleted the cheng/hot-fix/cutlass-moe-complete-maps branch October 23, 2026 19:32
@ch-wan
ch-wan restored the cheng/hot-fix/cutlass-moe-complete-maps branch October 23, 2026 19:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant