Repository navigation
[SM100] Mega MoE: support shared experts with blockwise-128 FP8 SFs - #171
Merged
Merged
Conversation
The blockwise-128 recipe (1x128 activation and 128x128 weight SFs, sgl-project#150) rejected shared experts in both host entry points. The kernel already handles shared tiles on that path like routed ones: the L1 epilogue merges the 1x128 amax across the 2-CTA cluster and stores one SF byte per group into the shared L2 SF buffer, and the loaders and MMA reuse each SF word across four K blocks for SharedLinear1/2 as for Linear1/2. This lifts the two asserts. tests/test_mega_moe.py gains `--gran-k 128` (`fp8xfp8` only). The legacy baseline runs per-32 SFs only, so with blockwise-128 the shared expert (the fused output minus a routed-only run on the same inputs) is checked against an FP32 reference of the kernel's quantization: 1x128 inputs, 128x128 weights, the L1 output rounded to BF16 and clamped, SwiGLU, the result re-quantized per 1x128 with UE8M0 SFs. Co-Authored-By: Claude Opus 5.5 <[email protected]>
zcnrex
added a commit
that referenced
this pull request
Nov 28, 2026
Git carried the three PRs' edits through the *_inference renames. Co-Authored-By: Claude Opus 5.5 <[email protected]>
aryatsc
added a commit
to aryatsc/DeepGEMM
that referenced
this pull request
Nov 28, 2026
Brings in sgl-project#170, sgl-project#165, sgl-project#169, sgl-project#178 and sgl-project#171. Conflicts: - csrc/jit_kernels/impls/sm100_fp8_fp4_mega_moe.hpp: the K=64 switch is now `uses_packed_fp4_weights(config.mainloop)` (sgl-project#165); the row-shuffled FP8 x FP4 layout asserts that mainloop instead of `config.use_sm107_k64`. The kernel template takes the mainloop in place of the two K=64 / K=96 flags, followed by this branch's four parameters. - deep_gemm/include/deep_gemm/impls/sm100_fp8_fp4_mega_moe.cuh: sgl-project#165's mainloop plan and validity check replace the K=64 static assert; the base MMA loop is taken from dev (now under `run_base_loop`) with this branch's SFB word order for row-shuffled packed FP4 weights re-applied in it.
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.
Motivation
The blockwise-128 FP8 recipe (
recipe=(1, 1, 128): 1x128 activation and 128x128 weight SFs, #150) rejects shared experts in both host entry points (get_symm_buffer_size_for_mega_moeandfp8_fp4_mega_moe). Models with a shared expert therefore run it as separate GEMMs next to MegaMoE when their routed experts use 128x128 block scales.The kernel already handles shared tiles on the blockwise-128 path the same way as routed ones:
kL2AmaxPer128) merges the 1x128 amax across the 2-CTA cluster. It stores one SF byte per group, into the shared L2 SF buffer for shared tasks (shared_l2_sf_buffer,kNumSharedSFTokensstride).sf_id, reuse each SF word across four 128-wide K blocks forSharedLinear1/2exactly as forLinear1/2.SharedLinear2starts only after every shared L1 block is done, so all bytes of a reused word are written before it is loaded.Changes
csrc/apis/mega_moe.hpp: remove the twoblockwise-128 SFs (recipe gran_k=128) do not support shared expertsasserts.tests/test_mega_moe.py:--gran-k {32,128}. With 128 (fp8xfp8only):Tests
8x B300, EP8,
tests/test_mega_moe.py --num-processes 8 --num-correctness-tests 3 --num-max-tokens-per-rank 4096, default shapes (hidden 7168, intermediate 3072, 384 experts, top-6):--mma-type fp8xfp8 --gran-k 128, 4096 tokens per rank--masked-ratio 0.3--num-shared-experts 2--gran-k 128 --num-shared-experts 0--mma-type fp8xfp8(per-32), 1 shared expert--mma-type fp8xfp4(per-32), 1 shared expert