Skip to content

Merge upstream public release 26/11/26 (deepseek-ai/DeepGEMM#525) - #71

Merged
zyongye merged 5 commits into
vllm-project:devfrom
zyongye:merge/upstream-1126
Nov 28, 2026
Merged

zyongye merged 5 commits into
vllm-project:devfrom
zyongye:merge/upstream-1126

Conversation

@zyongye

@zyongye zyongye commented Nov 27, 2026

Copy link
Copy Markdown
Member

Merges upstream main up to the 26/11/26 public release (deepseek-ai/DeepGEMM#525) into dev. This also brings in deepseek-ai#471, which adds FP8 epilogue updates and 128-byte paged sparse MQA strides. deepseek-ai#478 is already on dev as #48.

The merge commit's parents are dev and upstream 09e7d8e. Please merge with "Create a merge commit" rather than squash, so that the next sync can use upstream's history as its merge base. #30 was squashed, so git had lost that link and this merge had to be redone with the right base.

What changes for callers

  • Mega MoE: upstream renamed it to *_inference (fp8_fp4_mega_moe_inference, bf16_mega_moe_inference, get_symm_buffer_for_mega_moe_inference, MegaMoEInferenceSymmetricBuffer, …).
    • The old names stay as aliases with their old keyword arguments: fp8_fp4_mega_moe, bf16_mega_moe, fp4_fp4_mega_moe, nvfp4_mega_moe, SymmBuffer, NVFP4SymmBuffer, transform_weights_for_mega_moe, get_block_m_for_*, and _C.get_symm_buffer_size_for_{,nvfp4_}mega_moe.
    • deep_gemm.mega remains a compatibility package, so vLLM's step5 import_module(f"{dg.__name__}.mega") still works.
    • New options: fused RMSNorm (rms_weights, rms_eps) and FP32 y, both SM100 only.
  • Symmetric buffer: every SM100 Mega MoE buffer now starts with upstream's fixed MegaMoESignals region, which includes a 128 MiB source-slot reservation. So buffers grow by about 128 MiB.
    • All SM100 kernels (FP8xFP4, FP8xFP8, BF16, NVFP4, FP4xFP4) share this layout, and NVFP4SymmBuffer now subclasses SymmetricBuffer.
    • So base= sharing works across all of them, in both directions, as step5 and Muse Spark use it.
  • Epilogues:
    • New deep_gemm.epilogue.FP8CastWithClamp(sfd, clamp_value=None, clamped_count=None) and FP8StochasticRounding(sfd).
    • FP8Quantization stays as an alias.
    • The fork's 128x4 SFD layout (use_128x4_sfd_layout) is kept.
  • GEMM bias: a contiguous [1, N] c that is not d becomes a bias on SM100 (upstream). On SM90 and SM120 it still accumulates as a normal C, which is the fork's choice.
  • mega_mhc: shifted mode only (upstream), and a cooperative launch. Upstream requires the full SM count; the fork accepts any count up to it, so vLLM's DBO compute-SM split keeps working.
  • deep_gemm.experimental: upstream's experimental fused kernels, exposed through the stable ABI with upstream's Python signatures.
  • Mega MoE activation_clamp: must now be > 0 (upstream). Unset means infinity.

Upstream features on the stable-ABI bindings

Upstream adds its APIs through pybind11; here they are translated to TORCH_LIBRARY and the _C.py facade:

  • Experimental ops: seven experimental_* ops; the V41F per-stream state uses the fork's stream/capture helpers.
  • Epilogue args: epilogue classes cross the op boundary as (kind, alpha, sfd, aux). Every GEMM and einsum schema gains Tensor? epilogue_aux=None.
  • FP8CastWithClamp: its per-stream launch tag is keyed like mega_gate/mega_mhc.
  • mega_mhc split barriers: per-stream, stable ABI.

Fork Mega MoE on upstream's new protocol (SM100)

Upstream's new dispatch drops the pre-pull grid sync and NVLink barrier: counts are published by the last SM, source slots are +1/zero, expert blocks are balanced, and combine readiness uses combine_ready_count.

  • FP8xFP4 / FP8xFP8: upstream's kernel, plus the fork's SwiGLU alpha/beta, swiglustep and SiTU.
    • SiTU is now an activation mode of this kernel; the separate SiTU kernel copy is removed.
    • With default SwiGLU, the SASS is identical to upstream's.
  • BF16: upstream's kernel, plus the fork's alpha/beta, swiglustep, post-expert RMSNorm and TRT-LLM weight layout.
    • Its dispatch uses the barrier-free FP8xFP4 protocol. Upstream's own BF16 kernel still grid-syncs and barriers before pulling.
    • Post-norm partials are now read coherently, not via ld.global.nc.
    • Gamma is applied once after the reduction. Output therefore differs from dev by FP32 rounding (≤ 2.7e-4 relative per token).
  • NVFP4: ported to layout::inference, the new scheduler and the barrier-free protocol, with partial activation TMA maps.
    • Compact dispatch now means only the SMs that own tokens join the count exchange. The old 32×32 limit is gone.
    • DG_NVFP4_MOE_* overrides still work.
  • FP4xFP4 (Muse Spark): the same port, with batched pulls and partial activation maps.
    • The post-norm per-CTA combine path is kept.
    • Combine readiness replaces the NVLink barrier before reduction.
  • SM90 is untouched. SM90 Mega MoE keeps running on frozen copies of the previous layout/mega_moe.cuh, scheduler/mega_moe.cuh and heuristics (heuristics/mega_moe_sm90.hpp). All SM90 kernel files are byte-identical to dev; upstream's two cosmetic SM90 edits are reverted.

Fork deviations from upstream (deliberate)

  • FP8 token pulls: FP8 tokens of up to 8 KiB are pulled in one chunk, as dev did. Upstream splits 6–8 KiB tokens into two chunks.
    • With two chunks, hidden 7168 / intermediate 2048 / top-8 ran 6–11% slower at EP8 (SiTU and SwiGLU, T ≥ 1024).
    • With one chunk it matches dev; on DSV4 shapes the difference is noise.
  • mega_mhc: accepts num_sms <= device SMs (see above).
  • Bias detection: SM100 only (see above).
  • Tuning knobs: DG_MEGA_MOE_STORE_BLOCK_M and DG_MEGA_MOE_BYTES_PER_PULL, env-only, like the NVFP4 knobs.
  • Arange helper: the fork's JIT arange helper is renamed dg_arange_int64_kernel, so bench_kineto(..., 'gemm_') doesn't match it.

Testing

All on GB200 (SM100) with torch 2.14 (cu130) and CUDA 13.1, 4 GPUs per node.

Test Result
test_layout, test_bf16, test_fp8_fp4 (incl. bias, FP8 clamp/SR), test_einsum (incl. 128x4 SFD, clamp count, FP8 SR), test_attention (DG_MQA_NUM_CASES=40), test_hyperconnection, test_mega_gate, test_mega_mhc, test_lazy_init --num-processes 4, test_mega_moe_block_config pass
tests/experimental/* (all 6) pass
test_mega_moe_inference --emu-reference (EP4) pass: FP8xFP4, FP8xFP8, SwiGLU alpha/beta, swiglustep, SiTU (β = 0 and β > 0), RMSNorm with BF16 and FP32 y, FP32 y, masked/hot/empty routing, --sweep, CUDA graph replays
BF16 Mega MoE vs dev, identical seeded inputs (EP4, T ∈ {1, 37, 512, 2049}) bitwise identical for SwiGLU (with and without shared experts), alpha/beta, swiglustep and hidden 7168; post-expert norm ≤ 2.7e-4 relative per token (gamma order)
BF16 post-expert norm reference (eager and CUDA graph), test_bf16_mega_moe_trtllm (default and swiglustep) pass
test_nvfp4_mega_moe: --check-api (T = 0/1/17/129/1000), default MiniMax shapes, --x-scales --shared-dtype bf16, swiglustep masked, --mma-type fp8xfp8 pass
test_fp4_fp4_mega_moe: default, Muse Spark (alphas, a2, post-norm), shared experts masked; signal-region-zero, graph replay and shared-base checks pass
test_locality_domain fails identically on dev: MLOPart is unavailable on these nodes

Not run (no hardware): SM90 and SM120. Their files are unchanged apart from the shared host code, which builds.

Mega MoE performance vs dev up to EP32

  • Method: each cell is merged us / dev us (ratio): the kernel time of the slowest rank, from bench_kineto. Both builds ran alternately in the same allocation, using dev's own test scripts.
  • Ranks: EP4 = 1 node, EP32 = 8 nodes, over NVL72.
  • Shapes per family:
    • FP8: hidden 7168 / intermediate 3072 / 384 experts / top-6 / 1 shared.
    • SiTU: 7168 / 2048 / 384 / top-8 / 1 shared.
    • swiglustep (FP8xFP8): 4096 / 1280 / 288 / top-8.
    • BF16: 4096 / 1536 / 128 / top-8 / 1 shared.
    • NVFP4: the test's MiniMax M3 defaults.
    • FP4xFP4: 6144 / 2048 / 256 / top-8; ms adds alphas, a2 scales and post-norm.
  • FP4xFP4 timing fix: the FP4xFP4 test's timing barrier is now a device-side all-reduce, as in test_mega_moe, for both builds. With the host dist.barrier(), per-rank times varied 3×.
  • Summary: merged is at most 1.01× of dev everywhere except the cell marked ¹. Decode-size batches gain 5–32%.
Full table
family tokens/rank EP4 EP8 EP16 EP32
fp8xfp4 16 344 / 362 (0.95) 247 / 270 (0.91) 160 / 184 (0.87) 97 / 117 (0.83)
fp8xfp4 128 519 / 535 (0.97) 286 / 308 (0.93) 180 / 203 (0.89) 113 / 134 (0.84)
fp8xfp4 1024 644 / 659 (0.98) 454 / 470 (0.97) 430 / 450 (0.96) 392 / 401 (0.98)
fp8xfp4 4096 1563 / 1606 (0.97) 1416 / 1434 (0.99) 1396 / 1420 (0.98) 1390 / 1386 (1.00)
fp8xfp8 16 616 / 635 (0.97) 431 / 454 (0.95) 258 / 286 (0.90) 148 / 171 (0.87)
fp8xfp8 128 927 / 945 (0.98) 488 / 514 (0.95) 277 / 303 (0.91) 157 / 183 (0.86)
fp8xfp8 1024 1012 / 1030 (0.98) 586 / 603 (0.97) 517 / 528 (0.98) 438 / 444 (0.99)
fp8xfp8 4096 1866 / 1905 (0.98) 1621 / 1633 (0.99) 1546 / 1560 (0.99) 1508 / 1510 (1.00)
situ 16 278 / 299 (0.93) 181 / 206 (0.88) 121 / 146 (0.83) 73 / 100 (0.73)
situ 128 355 / 379 (0.94) 208 / 230 (0.90) 142 / 161 (0.88) 101 / 116 (0.87)
situ 1024 484 / 496 (0.98) 395 / 405 (0.98) 392 / 405 (0.97) 478 / 385 (1.24)¹
situ 4096 1344 / 1344 (1.00) 1350 / 1350 (1.00) 1371 / 1370 (1.00) 1377 / 1374 (1.00)
swiglustep 16 160 / 187 (0.86) 106 / 133 (0.80) 78 / 104 (0.75) 49 / 72 (0.68)
swiglustep 128 185 / 210 (0.88) 111 / 138 (0.80) 85 / 110 (0.77) 59 / 81 (0.73)
swiglustep 1024 227 / 249 (0.91) 206 / 222 (0.93) 213 / 233 (0.91) 206 / 226 (0.91)
swiglustep 4096 599 / 612 (0.98) 666 / 673 (0.99) 716 / 722 (0.99) 734 / 743 (0.99)
bf16 16 189 / 210 (0.90) 115 / 136 (0.85) 85 / 105 (0.81) 58 / 71 (0.82)
bf16 128 202 / 221 (0.91) 129 / 147 (0.88) 111 / 123 (0.90) 86 / 102 (0.84)
bf16 1024 361 / 365 (0.99) 302 / 311 (0.97) 301 / 311 (0.97) 294 / 303 (0.97)
bf16 4096 1065 / 1072 (0.99) 1008 / 1007 (1.00) 1057 / 1053 (1.00) 1078 / 1073 (1.00)
nvfp4 16 170 / 176 (0.97) 111 / 119 (0.93) 78 / 86 (0.90) 63 / 70 (0.90)
nvfp4 128 185 / 192 (0.96) 115 / 123 (0.93) 94 / 101 (0.94) 86 / 95 (0.91)
nvfp4 1024 248 / 254 (0.98) 231 / 243 (0.95) 211 / 217 (0.97) 214 / 213 (1.00)
nvfp4 4096 705 / 714 (0.99) 675 / 686 (0.98) 673 / 668 (1.01) 684 / 681 (1.00)
fp4xfp4 16 175 / 197 (0.89) 124 / 146 (0.85) 90 / 115 (0.78) 59 / 78 (0.76)
fp4xfp4 128 218 / 239 (0.91) 136 / 157 (0.87) 118 / 140 (0.84) 100 / 120 (0.83)
fp4xfp4 1024 317 / 332 (0.95) 302 / 317 (0.95) 301 / 342 (0.88) 302 / 338 (0.89)
fp4xfp4 4096 843 / 904 (0.93) 1034 / 1079 (0.96) 1065 / 1146 (0.93) 1075 / 1187 (0.91)
fp4xfp4ms 16 175 / 195 (0.90) 125 / 144 (0.87) 90 / 114 (0.79) 61 / 75 (0.81)
fp4xfp4ms 128 218 / 238 (0.92) 137 / 156 (0.88) 124 / 139 (0.89) 107 / 127 (0.84)
fp4xfp4ms 1024 343 / 377 (0.91) 330 / 360 (0.92) 340 / 371 (0.92) 341 / 376 (0.91)
fp4xfp4ms 4096 939 / 1004 (0.94) 1105 / 1177 (0.94) 1164 / 1253 (0.93) 1210 / 1301 (0.93)

¹ Not reproducible. In that run all 32 ranks measured 466–478 µs. Two reruns of the same config were faster than dev: 370 vs 392 µs at EP32 on another node set, and 359 vs 371 µs with the same per-rank load at EP8. The likely cause was transient NVL72 fabric traffic during that one run.

🤖 Generated with Claude Code

LyricZhao and others added 5 commits September 30, 2026 09:48
Add locality-aware Mega MoE execution, GEMM epilogue classes with BF16
stochastic rounding, wider sparse MQA head support, and packed SF strides.
Improve Indexer and Mega MoE pipelines, update attention and Mega Gate
interfaces, and include runtime and correctness fixes.

Export the current source through the OSS filter while retaining public
release history and the Mega MoE task-info release-ordering fix.

Co-authored-by: Anyi Xu <[email protected]>
Co-authored-by: huahuaquq <[email protected]>
Co-authored-by: TwenTy_ <[email protected]>
Co-authored-by: xyf007 <[email protected]>
Co-authored-by: Yongqi Zhuo <[email protected]>
Co-authored-by: yukuai26 <[email protected]>
Co-authored-by: Zhean Xu <[email protected]>
Add FP8CastWithClamp with optional clamped-element counts, consolidate
GEMM epilogue conversions, and accept 128-byte paged sparse KV strides.
Keep the Mega MoE localizer alive until test teardown and bump the
package version to 2.8.2.

Co-authored-by: xyf007 <[email protected]>
Co-authored-by: yukuai26 <[email protected]>
Co-authored-by: Zhean Xu <[email protected]>
A CUDA graph kernel node keeps the same %gridid on every replay. The
mega_mhc split barriers tag each execution with %gridid, so after a replay
a barrier line still holds encode_state(grid_idx, kNumSplits), which is
exactly the state the next replay waits for. A Mix or Norm waiter whose
m-block init CTA has not started yet proceeds immediately and reads the
previous replay's split partials.

Tag executions with an epoch instead. The epoch and an exit count live in
the unused tail of the first barrier line, so the host-side buffer is
unchanged. Every CTA reads the epoch after cudaGridDependencySynchronize,
and the last CTA to retire resets the exit count and advances the epoch.

Signed-off-by: lightseek-bot <[email protected]>
* Public release 26/11/26

* Add 2026.11.26 News entry for deepseek-ai#525
Brings in upstream main up to 09e7d8e: deepseek-ai#471 (FP8 epilogues, 128-byte paged sparse
MQA strides), deepseek-ai#478 (already on dev as deepseek-ai#48) and deepseek-ai#525 (Mega MoE fused RMSNorm and
low-latency protocol, GEMM bias and FP8 stochastic rounding, experimental fused
kernels, `*_inference` renames).

- Upstream's new host APIs are ported to the stable-ABI TORCH_LIBRARY bindings:
  experimental kernels, FP8CastWithClamp / FP8StochasticRounding epilogues,
  GEMM bias (SM100 only), mega_mhc and Mega MoE inference changes.
- The fork's SM100 Mega MoE kernels move to upstream's new protocol and layout:
  FP8xFP4 (with SiTU folded in), BF16, NVFP4 and FP4xFP4.
- SM90 Mega MoE stays on a frozen copy of the previous layout, scheduler and
  heuristics; SM90 kernel files are unchanged.
- Pre-rename Python names and `deep_gemm.mega` remain as compatibility aliases.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.

4 participants