mirror of
https://github.com/deepseek-ai/DeepGEMM.git
synced 2026-11-05 00:47:26 +00:00
[PR #381] Add B200-Calibrated Sparse-Routing Adaptive Wave Sizing #404
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
deepseek-ai/DeepGEMM#404
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/deepseek-ai/DeepGEMM/pull/381
Author: @qinqinwo
Created: 7/15/2026
Status: 🔄 Open
Base:
main← Head:feature/imbalance-aware-block-m📝 Commits (5)
3f25a3aMegaMoE: imbalance-aware block_m selection (opt-in, strict fallback)458dd21MegaMoE: add calibrated adaptive wave sizingaf06265MegaMoE: narrow adaptive waves to stable sparse routingc343597Docs: add B200 performance results in English5daaaabFix adaptive receive-stat cache isolation📊 Changes
7 files changed (+714 additions, -49 deletions)
View changed files
➕
ADAPTIVE_WAVE.md(+93 -0)📝
csrc/apis/mega.hpp(+115 -1)📝
csrc/jit_kernels/heuristics/mega_moe.hpp(+127 -42)📝
csrc/jit_kernels/impls/sm100_fp8_fp4_mega_moe.hpp(+6 -2)➕
scripts/bench_adaptive_wave_ab.sh(+113 -0)➕
scripts/bench_mega_moe_wave_size.sh(+68 -0)📝
tests/test_mega_moe.py(+192 -4)📄 Description
MegaMoE processes a fixed number of local experts in each L1→L2 scheduler wave.
The upstream heuristic derives that number from the mean tokens per expert. That
is a good general fallback, but it cannot see the realized routing distribution.
Set
DG_MEGA_MOE_ADAPTIVE_WAVE=1to enable the opt-in B200 FP8×FP4 policy. The policy:cumulative_local_expert_recv_statsfrom the preceding window;synchronous device-to-host copy on the steady-state path;
intermediate 2048) and
127.5 < expected tokens/expert <= 128.5band;balanced and moderate-skew routing retain the upstream size;
outside the calibrated tier, or when the requested tier exceeds ring capacity.
The deliberately narrow gate is based on same-process, order-balanced 8×B200
measurements. A broader lower bound was rejected after the 96 tokens/expert
point regressed 1.48% under high skew. A balanced-routing wave-12 candidate was
also removed after an independent 6x30 repeat regressed 1.28% with 0/6 wins.
Other broad candidate policies looked promising in process-per-config sweeps,
but did not survive interleaved A/B validation.
Validation
Correctness and configuration invariance:
Robust baseline/adaptive A/B (four measurements per side by default,
alternating order, taking the slowest of all eight ranks in each repetition,
then reporting the median):
B200 performance
The final-source validation used 8×B200, six alternating baseline/adaptive
measurements per case, and 30 profiled kernel calls per measurement. Distributed
latency is reduced as
median_repeat(max_rank(latency)): each repetition firsttakes the slowest of all eight ranks, then the six slowest-rank samples are
reduced by their median.
The common-token sweep used 256 experts, top-k 8, EP 8, hidden 7168, and
intermediate hidden 2048. Values below are observed baseline/adaptive deltas:
Only the 512-token, alpha-1.5 cell changes the production kernel configuration
(upstream wave 16 to adaptive wave 8). Its exact-delivery-source result was
352.642 → 348.225 µs, a 1.268% speedup with 5/6 wins. The same wave-8 branch
was positive across six independent runs and multiple B200 nodes: 0.634%,
1.365%, 2.231%, 1.580%, 2.072%, and 1.268% (median 1.473%).
Every other cell retains the upstream block and wave configuration. Their
approximately -1.23% to +0.93% variation is the measured same-configuration
noise band and is not attributed to the policy. Two broader candidates were
explicitly rejected: 384-token high-skew wave 8 regressed 1.481% with 0/6 wins,
and 512-token balanced wave 12 regressed 1.276% with 0/6 wins in an independent
repeat.
Forced-wave calibration is available separately:
DG_MEGA_MOE_FORCE_EXPERTS_PER_WAVEandDG_MEGA_MOE_FORCE_BLOCK_Marebenchmark-only overrides. They fail loudly on invalid values and are not used by
the production adaptive policy.
co-author with agent.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.