Skip to content

[FlyDSL] [MoE] MegaMoEV2: per-bucket small-input knobs for EP8 V4.1-Flash (48 experts a rank, on #8633) - #8758

Merged
yhl-amd merged 2 commits into
ROCm:ghu/mega_small_m_speedup_20261125from
yhl-amd:mega-v41-ep8-small-table
Nov 28, 2026
Merged

yhl-amd merged 2 commits into
ROCm:ghu/mega_small_m_speedup_20261125from
yhl-amd:mega-v41-ep8-small-table

Conversation

@yhl-amd

@yhl-amd yhl-amd commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

EP8 DeepSeek-V4.1-Flash (48 routed experts a rank, shared expert computed apart) gets a per-bucket small-input knob table on top of _tune_v41_flash_ep8_small, as the default for that layout (no switch, no environment variable).

  • FusedStage1Knobs.en_order (default 0): inside the run of one expert's m-tiles that lies wholly in an XCD's slice, GEMM1 (bit 1) / GEMM2 (bit 2) units go in (expert, n)-major order, so those m-tiles read each weight tile at about the same time; bit 4 reads such grouped units' weights through the cache. A bijection on the slice's units: only the order changes. Refused with pair_tiles (bit 1) and without plan_local.
  • _V41_FLASH_EP8_SMALL_KNOBS: en_order, 256-wide GEMM1 tiles and cached W1 at 256 / 512 tokens, lean GEMM1 / GEMM2 epilogues, dispatch CUs and waves per EU. At 64 / 128 tokens en_order's GEMM1 order takes the place of pair_tiles. No knob changes what ranks exchange or what a tile computes.
  • Other layouts unchanged (en_order 0; the pinned digests take it only when set). The V4.1-Flash EP8 digest is re-pinned.

Dependencies / merge order

Tests

Update: bucket 32 runs the bucket-64 knobs (57fd7f4)

Root cause. nearest_token_bucket sends 24..47 rows a rank to bucket 32 (at c128 that is 4..7 requests a rank, about half of the decode steps). Its entry (64 dispatch CUs, 2 waves per EU, b_nt 1, g2_epi_lean 1) came from the c512 replay search; in serving it is slower than the bucket-64 entry, so a rank with 42 rows ran its MegaMoE slower than one with 48.

Change. One table entry: bucket 32 takes the bucket-64 knobs (128 dispatch CUs, one wave per EU, streamed W1 b_nt 3, full GEMM2 epilogue) and keeps its 256-wide GEMM2 blocks, so its config is now equal to bucket 64's field for field. No tile shape, protocol or numerics knob changes. No pinned digest case falls in bucket 32, so the digests stay.

Correctness (gfx950, 8 GPUs).

  • --suite routes --network v41_flash --compare-untuned: ALL PASS, 48 cases, 0 mismatched rows against the configs selected without the table (graph, alternation, epoch wrap pass too).
  • Old against new bucket-32 entry, 24/30/36/42 rows a rank, uniform and Zipf 0.4/0.8/1.2 routes: 0 mismatched rows, repeat-exact.

Kernel time (MegaMoE call, CUDA graph of 50 calls, max over ranks, median of 7 interleaved rounds for uniform / Zipf 1.2 and 3 for Zipf 0.4 / 0.8):

rows a rank uniform Zipf 0.4 Zipf 0.8 Zipf 1.2
24 163.5 -> 155.2 us (-5.1%) -5.3% +6.1% +5.0%
30 163.7 -> 155.4 us (-5.1%) -6.2% +7.7% +7.6%
36 166.4 -> 157.8 us (-5.1%) -6.2% +5.9% +8.6%
42 168.0 -> 159.6 us (-5.0%) -4.4% 0.0% +5.5%
18 / 48 (buckets 16 / 64, control) 0.0% 0.0%

The new entry is faster on balanced routes and slower on strongly skewed ones (Zipf >= 0.8, where the call itself is about half as long because few experts are hot). Serving with dynamic EPLB keeps the ranks' expert load balanced, and there the serving numbers below are what decides.

Serving. DeepSeek-V4.1-Flash, MI355X DEP8, InferenceX AgentX, 900 s per run, SA-compliant serving config (48 routed experts a rank / topk 6, FP8 shared expert computed apart, draft not fused, no draft lm_head FP8, dynamic EPLB); the arms differ only in this bucket-32 entry (measured on our serving stack's equivalent table, same knob values), run order A, B, B, A:

  • c128: interactivity p90 220.75 -> 225.5 (+2.15%; both B runs above both A runs), TPOT p90 -2.1%, output throughput +0.55%, total throughput +0.22%. Pure-decode step time (max over ranks) for steps whose busiest rank has 4..7 requests: -0.45 ms a step (-4.6%); other steps within +-0.1 ms; all decode steps -0.22 ms (-2.4%).
  • c512: the entry is rarely selected there (a rank runs more than 47 rows on most decode steps); a dedicated c512 A/B of this entry is still to run.
  • GSM8K (5-shot, without golden acceptance length): 0.9280, within run-to-run spread of the baseline.

Performance

DeepSeek-V4.1-Flash, MI355X DEP8, InferenceX AgentX c512, 900 s per run, SA-compliant serving config (48 routed experts a rank / topk 6, FP8 shared expert computed apart, draft not fused, no draft lm_head FP8, dynamic EPLB), one machine. The arms differ only in aiter's MegaMoE files: #8633 head vs #8633 + this PR (+ #8759 as a third arm), run in the order #8633, this PR, #8759, #8759, this PR, #8633.

run 1 run 2 mean total tok/s/GPU interactivity p90 (mean)
#8633 288,311 290,022 289,167 131.05
#8633 + this PR 293,271 294,627 293,949 (+1.65%) 133.45 (+1.8%)

Both runs with the table are ahead of both #8633 runs in throughput and p90. Pure-decode step time by small-input bucket (max over ranks, matched by requests a rank, both runs of each arm): 64 -2.0%, 128 -2.8%, 256 -2.1%, 32 0.0% (these four are about 64% of the run's time); 8 / 16 together 0.5% of the time, within their run-to-run spread. Outputs are bit-identical to #8633's (above), so accuracy is #8633's; GSM8K of the #8759 arm (which includes this table) 0.9318 (5-shot, without golden acceptance length).

On the earlier stack the table was searched on (before #8633's small-input changes), the same c512 comparison gave +1.3% / p90 +4.6%.

🤖 Generated with Claude Code

…xperts a rank)

The EP8 DeepSeek-V4.1-Flash small-input kernel ran _tune_v41_flash_ep8_small
alone. Add a per-bucket knob table on top of it, _V41_FLASH_EP8_SMALL_KNOBS,
the default for the 48-expert layout (no switch):

- en_order (FusedStage1Knobs, default 0): the GEMM1 (bit 1) and GEMM2 (bit 2)
  units of the run of one expert's m-tiles that lies wholly inside an XCD's
  slice go in (expert, n)-major order, so the run's m-tiles read each weight
  tile at about the same time and share it in the L2; bit 4 reads such
  grouped units' weights through the cache. The remap is a bijection on the
  slice's units that keeps every unit in its own expert's m-tiles and leaves
  the m-tiles cut by the slice ends in place: only the order changes. Its
  GEMM1 order runs on m-tile units, so it is refused together with
  pair_tiles (at 64 and 128 tokens it takes their place); it reads the
  experts from the local plan, so it needs plan_local.
- The table: en_order, 256-wide GEMM1 tiles and cached W1 at 256 / 512
  tokens, the lean GEMM1 / GEMM2 epilogues, dispatch CUs and waves per EU.
  None of them changes what ranks and launches exchange or what a tile
  computes.

Other layouts keep en_order 0: their kernels and configs are unchanged (the
pinned config digests take en_order only when set; the V4.1-Flash EP8
digest is re-pinned).

Tests:
- tests/test_mega_moe_v41_ep8_small_knobs.py: each bucket is the tune plus
  exactly its table entry, one launch protocol across buckets (the same as
  without the table), every en_order buildable, the other fused layouts
  unchanged.
- op_tests/multigpu_tests/test_mega_moe_v2.py --suite routes
  --network v41_flash --compare-untuned (8 GPUs): every small-input case
  again with the configs selected without the table, bit for bit.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@yhl-amd

yhl-amd commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

GPU validation on top of #8633 (head 6420f64), gfx950 / MI355X, 8 GPUs; details in the description's Tests and Performance sections.

No bucket is slower on #8633 in serving, so the table is unchanged. Marking ready; merge after #8633.

@yhl-amd
yhl-amd marked this pull request as ready for review November 26, 2026 18:33
…64 knobs

nearest_token_bucket sends 24..47 rows a rank to bucket 32. Its table entry
(64 dispatch CUs, 2 waves per EU, b_nt 1, g2_epi_lean 1) was searched on c512
decode replays; in serving at c128 (4..7 requests a rank) it is slower than the
bucket-64 entry, so 42 rows a rank ran slower than 48. Bucket 32 now takes the
bucket-64 entry (128 dispatch CUs, one wave per EU, streamed W1 b_nt 3, full
GEMM2 epilogue) and keeps its 256-wide GEMM2 blocks: its config is now equal
to bucket 64's field for field. Only dispatch / occupancy / load-hint /
epilogue knobs change, so the outputs are unchanged.

No pinned digest case falls in bucket 32, so the digests stay.

Tests (gfx950, 8 GPUs):
- test_mega_moe_v2.py --suite routes --network v41_flash --compare-untuned:
  ALL PASS, 0 mismatched rows against the configs selected without the table.
- The old and the new bucket-32 entry at 24/30/36/42 rows a rank (uniform
  and Zipf 0.4/0.8/1.2 routes): 0 mismatched rows.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@yhl-amd

yhl-amd commented Nov 27, 2026

Copy link
Copy Markdown
Contributor Author

Pushed 57fd7f4 on top of the table commit: bucket 32 (24..47 rows a rank) now runs the bucket-64 knobs.

  • Why: with nearest-bucket selection, c128 decode steps with 4..7 requests a rank land in bucket 32, whose entry (64 dispatch CUs, 2 waves per EU, b_nt 1) was slower in serving than the bucket-64 entry, so 42 rows a rank ran slower than 48.
  • What: one table entry; bucket 32's config is now equal to bucket 64's field for field. Only dispatch / occupancy / load-hint / epilogue knobs change.
  • Correctness (gfx950, 8 GPUs): --suite routes --network v41_flash --compare-untuned ALL PASS (0 mismatched rows); old vs new entry at 24/30/36/42 rows, uniform and Zipf 0.4/0.8/1.2 routes, 0 mismatched rows.
  • Kernel time: -4.4% to -6.2% on uniform / Zipf 0.4 routes, +0% to +8.6% on strongly skewed Zipf >= 0.8 routes (details in the description).
  • Serving (DeepSeek-V4.1-Flash, MI355X DEP8, AgentX c128, 900 s, A/B/B/A, SA-compliant config, dynamic EPLB): interactivity p90 +2.15%, decode steps with 4..7 requests a rank -0.45 ms each.

The description has a new "Update" section with the data.

@yhl-amd
yhl-amd merged commit 2824eb1 into ROCm:ghu/mega_small_m_speedup_20261125 Nov 28, 2026
yhl-amd added a commit that referenced this pull request Nov 28, 2026
[FlyDSL] [MoE] MegaMoEV2: EP8 V4.1-Flash DSpark draft MoE on the small-input route, BF16 return on every draft route (on #8758)
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.

1 participant