Skip to content

[FlyDSL] [gfx1250] MegaMoE S1F: packed A only where its stores fit storecnt - #8889

Merged
coderfeli merged 5 commits into
mainfrom
zxe/fix_s1f_ci
Dec 2, 2026
Merged

coderfeli merged 5 commits into
mainfrom
zxe/fix_s1f_ci

Conversation

@XingerZhu

@XingerZhu XingerZhu commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary

#7921 widens the gfx1250 MegaMoE S1F prefill path to tile 256 and enables packed A (a_preshuffled). That widening is decided only by (world_size, topk) and ignores the hidden size. As a result, DeepSeek-V4-Pro (hidden 7168) hits a ValueError for a storecnt overflow during _precompile, and the server fails to start.

This PR enables packed A only when its stores fit. The decision lives in a single helper, so every call site that depends on it gets the same answer. V4.1-Flash (hidden 5120) behaves as before.

Root cause

Each op of the packed A storer issues OP_STORES = PAY_ITERS + SC_ITERS + 1 VMEM stores: the payload M16×K32 slabs, the e8m0 scale rows, and the rowmap store.

  • s_wait_storecnt has only 6 bits, so the largest value it can encode is 63. This requires OP_STORES + 3 <= 63.
  • Hidden 5120 (V4.1-Flash, fp4 wire): OP_STORES = 44, 44 + 3 = 47, which fits.
  • Hidden 7168 (V4-Pro, fp4 wire): OP_STORES = 61, 61 + 3 = 64, which overflows.

#7921 does not check this constraint, so V4-Pro raises an op's stores overflow the storecnt wait field in make_s1f_stage1 and the server fails to start.

Changes

  • s1f_ctl.py
    • Add s1f_packed_a_op_stores() and s1f_packed_a_fits(), which compute the number of stores in the storer and check that it is <= 63.
    • Add _s1f_packed_a_ok(config), shared by the following call sites:
      • _s1f_gemm_opts(config, tile_m): when packed A does not fit, it does not return the packed-A-related options (a_preshuffled, lds_soa, next_stage_prefetch). Both _launcher and launch_args read the options through it, so the scale pointer layout stays consistent with the kernel compile arguments.
      • _s1f_warps(config, tile_m): when packed A does not fit, tile 256 falls back to 1x4 warps instead of 2x2.
      • s1f_prefill_tile(config, recv_bound): when packed A does not fit, it returns 0 and does not widen; AITER_MEGA_S1F_PREFILL_RECV cannot force the widening either.
    • The key of _S1F_PREFILL_MIN_RECV_BY_SHAPE changes from (world_size, topk) to (world_size, topk, hidden_dim). The only entry for now is (4, 6, 5120): 65536.
  • stages/dispatch_compact.py: _compact_gemm_tiles computes the tile through s1f_prefill_tile, so the compact plan alignment matches the kernel.
  • s1f_stage1.py: OP_STORES is now computed with s1f_packed_a_op_stores(), and the existing overflow check is kept as a backstop.

Behavior changes

  • V4.1-Flash (hidden 5120): same as [FlyDSL] [gfx1250] grouped MoE GEMM1 opts into mega #7921. It still widens to tile 256, enables packed A, and uses 2x2 warps.
  • V4-Pro (hidden 7168): no widening; the plan keeps the default tile, and the packed-A-related options are not enabled. With AITER_TDM_TILE_M=256, tile 256 is still available, but it uses 1x4 warps and no packed A.
  • Any other (world_size, topk, hidden) combination: no widening by default. AITER_MEGA_S1F_PREFILL_RECV must be set explicitly to try it, and it is still subject to the storecnt check.

Performance (if applicable)

Measured by @qichu-yun on MI455X (4 x gfx1250), aiter main 9da592818, dp4ep4, random 8K input / 1K output. Baseline is main with #7921 reverted, since main itself cannot start V4-Pro.

Hardware Workload/configuration Before After Change
MI455X x4 V4-Pro, concurrency 4 242.3 tok/s/GPU, median ITL 32.78 ms 241.5 tok/s/GPU, median ITL 32.88 ms -0.3%
MI455X x4 V4-Pro, concurrency 64 6657.6 tok/s/GPU, median ITL 13.67 ms 6634.5 tok/s/GPU, median ITL 13.65 ms -0.3%

Testing

  • Unit tests added or updated
  • Performance benchmarks run
  • Tested on MI250X
  • Tested on MI300X
  • Tested on MI455X (gfx1250), see the self-review below

Documentation

  • Docstrings updated
  • User guide updated
  • Performance guide updated
  • No documentation change is needed: this is an internal gating fix with no new user-facing option or API.

Dependencies

  • No new third-party dependencies added
  • New dependencies are listed and justified below

Breaking Changes

None. The only behavior change is that shapes whose packed-A stores overflow s_wait_storecnt (V4-Pro, hidden 7168) no longer widen to the packed-A tile 256, which previously made the server fail to start.

PR Self-Review

Reviewed revision

1918576

Behavior and intent

#7921 widens S1F prefill to tile 256 with packed A (a_preshuffled), chosen by (world_size, topk) only. For hidden 7168 (DeepSeek-V4-Pro, fp4 wire) one packed-A storer op issues 61 VMEM stores, and 61 + 3 = 64 exceeds the 6-bit s_wait_storecnt limit of 63, so make_s1f_stage1 raises in _precompile and the server never starts. This PR gates packed A on one helper, s1f_packed_a_fits, shared by _launcher, launch_args, _s1f_warps, s1f_prefill_tile and the compact-plan tile alignment so they always agree. When packed A does not fit, s1f_prefill_tile returns 0 (no default widening) and an explicit tile 256 runs without packed A on 1x4 warps. V4.1-Flash (hidden 5120, 44 + 3 = 47 stores) keeps the packed-A 2x2 tile-256 variant. The prefill threshold table is now keyed by (world_size, topk, hidden_dim).

Validation and unverified scope

Evidence is from @qichu-yun's runs on MI455X (4 x gfx1250), aiter main 9da592818 plus this PR's earlier head dc0a1e886b (its three files are the only change); see their comments on this PR for the full tables.

  • V4-Pro dp4ep4: main exits after 381 s with an op's stores overflow the storecnt wait field. With this PR the server starts and GSM8K 3-shot gives flexible 0.9484 / strict 0.9492, against 0.9507 with [FlyDSL] [gfx1250] grouped MoE GEMM1 opts into mega #7921 reverted (within one stderr, 0.0061). Throughput at 8K/1K is within 0.4% of the [FlyDSL] [gfx1250] grouped MoE GEMM1 opts into mega #7921-reverted baseline (see the performance table above).
  • V4.1-Flash DEP4 (with [Bugfix] gemm_a16w16: return an empty result for M=0 #8879): GSM8K 0.9136 / 0.9136 with this PR, against 0.9098 / 0.9105 on main (within one stderr, 0.0077).
  • Heads 4381906 and 1918576 only merge the latest main into dc0a1e886b (no change to this PR's three files beyond that); the single conflict was in dispatch_compact.py (kept s1f_prefill_tile(config, bound) together with main's new _select_tdm_b_th(b_th) return value). The three changed files compile with python -m py_compile, and the CI style checks pass.
  • Unverified: the post-merge head has not been re-run on hardware; other (world_size, topk, hidden_dim) combinations, including the EP8/EP16 shapes main now runs fused, are not measured with this change and only rely on the new fit check; there is no unit test for s1f_packed_a_fits itself.

PR-specific question

The main boundary is the hidden size and wire format that decide the number of stores per packed-A op (PAY_ITERS + SC_ITERS + 1) against the 6-bit s_wait_storecnt field (max 63, so ops need <= 60 stores). s1f_packed_a_fits computes this from dispatch_token_nbytes and dispatch_scale_nbytes, and every consumer (kernel options, warp grid, prefill tile, scale layout, compact-plan alignment) reads the same helper, so an unsupported shape cannot reach the packed-A kernel, including through AITER_MEGA_S1F_PREFILL_RECV. The existing overflow check in make_s1f_stage1 stays as a backstop. Evidence: V4-Pro fails to start on main and starts with this PR; V4.1-Flash behaves as before.

Changed op tests

None. This PR changes no file under op_tests/; coverage is the end-to-end model runs described above.

…orecnt

#7921 widens S1F prefill to tile 256 with packed A (a_preshuffled) keyed by
(world_size, topk) only. For DeepSeek-V4-Pro (hidden 7168, fp4 wire) one
packed-A storer op issues 61 VMEM stores, 61 + 3 > 63 overflows the 6-bit
s_wait_storecnt field, make_s1f_stage1 raises in _precompile and the server
fails to start.

Gate packed A on one helper (s1f_packed_a_fits) shared by _launcher,
launch_args (scale layout), _s1f_warps, s1f_prefill_tile and the compact
plan tile alignment, so they always agree. When it does not fit,
s1f_prefill_tile returns 0 and the 256 variant runs without packed A on 1x4
warps. The prefill threshold table is now keyed by hidden size as well.

Verified on the V4-Pro MoE shape (EP2, fp4 wire, S1F): forced prefill
widening and AITER_TDM_TILE_M=256 both pass accuracy; V4.1-Flash still
builds the packed-A 2x2 tile-256 variant and passes.
@XingerZhu
XingerZhu requested review from a team and a balanced review from Copilot November 29, 2026 06:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@github-actions

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every PR:

  • ✅ Pre-checks (submodule verification, code formatting)
  • ✅ Aiter standard tests on MI35X
  • ✅ Triton tests on MI35X (only when aiter/ops/triton/** or related paths are changed)

Extended tests (opt-in via labels):

Label Tests
ci:mi300x Run Aiter standard tests on MI300X in PRs; main branch always runs them
ci:gfx1250-ffm-triton Run the five-shard gfx1250 FFM Triton test suite
ci:triton-300x Run an additional Triton test job on MI300X in PRs (added automatically when gfx942 configs change); main branch always runs both MI35X and MI300X
ci:triton-355 Run the full Triton test suite on MI35X, not only the tests the change affects
ci:windows Windows JIT op smoke test on the Radeon R9700 ROCm runner
ci:multi-gpu Aiter multi-GPU tests on the 8-GPU runner
ci:sglang SGLang integration tests: DeepSeek-R1-MXFP4 accuracy, Qwen 3.5 accuracy
ci:atom ATOM benchmark: DeepSeek-R1-0528, GPT-OSS-120B
ci:atom_full ATOM accuracy suite for PR and main models from ATOM models_accuracy.json
ci:vllm vLLM benchmark: DeepSeek-V4-Pro, MiniMax-M3-MXFP4
ci:all All standard extended tests (excludes ci:atom_full)

Only add ci:atom_full for FlyDSL or Triton upgrades.
Add labels via the sidebar or gh pr edit 8889 --add-label <label>

One backend per PR:
A PR changes one kernel backend: [Triton/Gluon] (Triton and Gluon count as one), [HIP], [ASM], [CK], [OPUS] or [FlyDSL]. If the title ends up with two backend tags, split the PR -- as stacked pull requests when one part cannot merge without the other.

PR title tags & labels:
Component tags ([Triton/Gluon], [HIP], [CK], [ASM], ...) are added to the PR title and as PR labels automatically from the changed files and re-synced on every push — change-type tags like [fix]/[Perf], op tags like [MLA], and human labels (ci:*) are left untouched. Add the no-auto-title label to stop the title rewrites; labels stay in sync either way.

Reviews:
A reviewer is usually assigned within one working day after the PR is ready for review (see Code Review Process). If nobody has responded for about a week, mention the area contact listed in CONTACTS.md. Want to help review? See REVIEWERS.md.

@aiter-bot

aiter-bot commented Nov 29, 2026 •

Copy link
Copy Markdown

WAITING ON AUTHOR

PR Self-Review

Revision e7f004135d7e · mode shadow

Waiting for the PR author. The readiness report will appear after the self-review answers are complete for this revision.

Questions to answer in the PR description

  1. What behavior does this PR change, and why is the existing behavior insufficient?
  2. What did you validate, and what remains unverified? Include commands, hardware/configuration and results.
  3. What is the most important boundary or failure mode introduced by this change, and what evidence covers it?
  4. For every changed op_tests/ file, what behavior does it cover and why is it not redundant? Write None if no op test changed.

Edit the PR Self-Review section in the PR description. Include the current revision SHA; this comment refreshes automatically.

Missing or invalid answers

  • FAIL — Reviewed revision must contain at least the first 7 characters of the current head SHA

Shadow mode reports what would block but keeps the status successful. Set AITER_PR_SELF_REVIEW_MODE=enforce only after reviewing real false positives.

@qichu-yun

Copy link
Copy Markdown
Contributor

Verified on MI455X (4 × gfx1250): this PR fixes the DeepSeek-V4-Pro startup failure and leaves DeepSeek-V4.1-Flash unchanged. The test used aiter main 9da592818 with this PR's head dc0a1e886b applied; its three files are the only change.

Model, parallelism aiter Server start GSM8K 3-shot flexible / strict
DeepSeek-V4-Pro, dp4ep4 9da592818 exits after 381 s: an op's stores overflow the storecnt wait field —
DeepSeek-V4-Pro, dp4ep4 9da592818 with #7921 reverted ready 0.9507 / —
DeepSeek-V4-Pro, dp4ep4 9da592818 + this PR ready, no storecnt error 0.9484 / 0.9492
DeepSeek-V4.1-Flash, DEP4 (+ #8879) 9da592818 ready 0.9098 / 0.9105
DeepSeek-V4.1-Flash, DEP4 (+ #8879) 9da592818 + this PR ready 0.9136 / 0.9136

Both differences are within one lm_eval stderr (V4-Pro 0.0061, V4.1-Flash 0.0077). V4-Pro throughput has not been measured with this PR yet.

qichu-yun added a commit to ROCm/ATOM that referenced this pull request Nov 30, 2026
@qichu-yun

Copy link
Copy Markdown
Contributor

Throughput follow-up: with this PR, DeepSeek-V4-Pro runs at the same speed as with #7921 reverted, within 0.4%. Both arms ran on the same MI455X node (4 × gfx1250) with aiter main 9da592818, dp4ep4, 8K/1K random (input 8192, output 1024).

Concurrency aiter Throughput (tok/s/GPU) Median ITL (ms)
4 9da592818 with #7921 reverted 242.3 32.78
4 9da592818 + this PR 241.5 32.88
64 9da592818 with #7921 reverted 6657.6 13.67
64 9da592818 + this PR 6634.5 13.65

Copilot AI balanced review requested due to automatic review settings December 2, 2026 06:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The EP4/top-6 prefill selection change lacks regression coverage for the affected hidden sizes, explicit prefill override, and forced tile 256 behavior.

1 open issue

Review effort: Balanced

yadaish
yadaish previously approved these changes Dec 2, 2026
@XingerZhu XingerZhu assigned Copilot and unassigned Copilot Dec 2, 2026
Copilot AI balanced review requested due to automatic review settings December 2, 2026 06:34
@XingerZhu XingerZhu self-assigned this Dec 2, 2026
GwilliamHu
GwilliamHu previously approved these changes Dec 2, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The exact merged head lacks gfx1250 hardware validation, leaving distributed layout alignment and packed execution versus the tile-256 non-packed fallback requiring maintainer confirmation.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings December 2, 2026 06:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Hardware evidence predates the merge and covers EP4, leaving the current head’s EP8/EP16 S1F/compact-plan alignment and explicit tile-256 fallback unvalidated on multi-GPU gfx1250 hardware.

No open issues 🎉

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings December 2, 2026 09:07

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The merged head lacks gfx1250 multi-GPU validation of producer/GEMM layout agreement and the explicit tile-256 fallback; reported hardware runs cover an earlier head.

No open issues 🎉

Review effort: Balanced

@XingerZhu
XingerZhu dismissed stale reviews from yadaish and GwilliamHu via d9028d0 December 2, 2026 09:19
Copilot AI balanced review requested due to automatic review settings December 2, 2026 09:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Exact-head gfx1250 multi-GPU validation is unavailable, and earlier hardware runs require human review to confirm the merged dispatch/kernel alignment and tile-256 fallback.

No open issues 🎉

Review effort: Balanced

coderfeli
coderfeli previously approved these changes Dec 2, 2026
Copilot AI balanced review requested due to automatic review settings December 2, 2026 09:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@XingerZhu XingerZhu closed this Dec 2, 2026
@XingerZhu XingerZhu reopened this Dec 2, 2026
@github-actions

github-actions Bot commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every PR:

  • ✅ Pre-checks (submodule verification, code formatting)
  • ✅ Aiter standard tests on MI35X
  • ✅ Triton tests on MI35X (only when aiter/ops/triton/** or related paths are changed)

Extended tests (opt-in via labels):

Label Tests
ci:mi300x Run Aiter standard tests on MI300X in PRs; main branch always runs them
ci:gfx1250-ffm-triton Run the five-shard gfx1250 FFM Triton test suite
ci:triton-300x Run an additional Triton test job on MI300X in PRs (added automatically when gfx942 configs change); main branch always runs both MI35X and MI300X
ci:triton-355 Run the full Triton test suite on MI35X, not only the tests the change affects
ci:windows Windows JIT op smoke test on the Radeon R9700 ROCm runner
ci:multi-gpu Aiter multi-GPU tests on the 8-GPU runner
ci:sglang SGLang integration tests: DeepSeek-R1-MXFP4 accuracy, Qwen 3.5 accuracy
ci:atom ATOM benchmark: DeepSeek-R1-0528, GPT-OSS-120B
ci:atom_full ATOM accuracy suite for PR and main models from ATOM models_accuracy.json
ci:vllm vLLM benchmark: DeepSeek-V4-Pro, MiniMax-M3-MXFP4
ci:all All standard extended tests (excludes ci:atom_full)

Only add ci:atom_full for FlyDSL or Triton upgrades.
Add labels via the sidebar or gh pr edit 8889 --add-label <label>

One backend per PR:
A PR changes one kernel backend: [Triton/Gluon] (Triton and Gluon count as one), [HIP], [ASM], [CK], [OPUS] or [FlyDSL]. If the title ends up with two backend tags, split the PR -- as stacked pull requests when one part cannot merge without the other.

PR title tags & labels:
Component tags ([Triton/Gluon], [HIP], [CK], [ASM], ...) are added to the PR title and as PR labels automatically from the changed files and re-synced on every push — change-type tags like [fix]/[Perf], op tags like [MLA], and human labels (ci:*) are left untouched. Add the no-auto-title label to stop the title rewrites; labels stay in sync either way.

Reviews:
A reviewer is usually assigned within one working day after the PR is ready for review (see Code Review Process). If nobody has responded for about a week, mention the area contact listed in CONTACTS.md. Want to help review? See REVIEWERS.md.

@coderfeli
coderfeli merged commit 63fbead into main Dec 2, 2026
163 of 195 checks passed
@coderfeli
coderfeli deleted the zxe/fix_s1f_ci branch December 2, 2026 13:30
XingerZhu added a commit that referenced this pull request Dec 3, 2026
Resolve conflicts with #8889 (s1f_ctl.py, s1f_stage1.py, dispatch_compact.py):
keep the config-based S1F helpers, and redefine s1f_packed_a_fits as
"one storer op's stores <= the 63 a wave can have outstanding" so hidden
7168 (61 stores/op) keeps packed A through the capped WAIT_STEPS.
Fix test_compact_plan_uses_ep_fused_tile config (dispatch_token_nbytes /
dispatch_scale_nbytes), broken on origin/main by #8889.
gbyu-amd pushed a commit that referenced this pull request Dec 3, 2026
…DSpark draft head BF16 tuning, empty-row GEMM fix (#9096)

* MegaMoE gfx1250: decode megakernel (dispatch, GEMM1, GEMM2 and combine in one launch), Kimi-K3 shapes (#7345 @ a559927, head 2026-12-01T13:13:28Z)

Opt-in with AITER_MEGAKERNEL=1. Each step chooses by its receive bound:
- "slots" (fixed per-expert slots) for bounds up to SLOTS_RECV (2048; with
  IOD-placed weights, 3072 for Kimi-K3's 3584 x 3072);
- "compact" up to COMPACT_MAX_TOKENS per rank;
- otherwise the staged path.
Off by default, so nothing changes unless the variable is set. The PR's
tests show the output bitwise equal to the staged path.

Ported onto k3-455-dev as the squashed PR diff (merge base ce334d0). Four
files conflicted:
- s1f_ctl.py: kept k3-455-dev's receive caps (_S1F_MAX_RECV 4096 plus
  #8189's _S1F_MAX_RECV_BY_SHAPE) and its s1f_max_recv(); the PR's base had
  no cap. Both __init__ fields are kept (#8483's _plan_lds, the PR's
  _packed_sc).
- s1f_stage1.py: added the PR's s1f_apre_* helpers. The stage-1 launch keeps
  #8483's SiTUv2 arguments and adds the PR's value_attrs.
- gemm_common_gfx1250.py: kept k3-455-dev's prefetch_kernel_code(max_bytes=...),
  a superset of the PR's.
- dsr1_tuned_grouped_fmoe.csv: kept k3-455-dev's DeepSeek-R1 rows and dropped
  the PR's two DSR1 rows (not Kimi-K3).
Placement is detected from the GEMM builder's signature (BUILDER_LOC), so
without IOD placement the placed paths stay off.

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

* MegaMoE gfx1250 compact plan: re-seal the hist row head from each issuing wave before its TDM store (#8880 @ 4214819, head 2026-11-28T16:07:47Z)

Fixes the intermittent S1F spin trap (HSA_STATUS_ERROR_EXCEPTION 0x1016):
the TDM that sends a hist row to rank w is issued by wave w and could read the
row head before wave 0's LDS tag was visible to it. Every sending wave now
re-seals the tag before its store. Kimi-K3's D runs this compact plan
(dispatch=compact).

(cherry picked from commit 4214819)

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

* bench_mega_moe: SiTUv2, a model-sized instance and a simulated EP size, for Kimi-K3's A/Bs

--act situv2 (with --situ_beta / --situ_linear_beta), --max_tpr / --recv_bound
and --sim_ep N (a rank of an EP-N group on fewer GPUs, e.g. EP8 on one tray
with -e 448 --sim_ep 8), all opt-in. Same commit as on the IOD branch
(zejun/k3-455-dev-1201-iod); here it is merged with #7345's bench: #7345's
routing checks stay, and the step bounds come from resolve_step_bounds, which
equals #7345's inline logic without --sim_ep.

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

* [Config] Kimi-K3 gfx1250 LM head and DSpark draft head BF16 rows (N 163840, K 7168), M 1-256

Neither head had a gfx1250 row, so both ran the default bandwidth-bound
gemm_a16w16 at 3.4-4.3 TB/s (one D decode step at c192: 546-603 us for the
target head, ~360-600 us for the draft head). A FlyDSL hgemm whose M tile
covers every row reads the 2.35 GB weight once: per M bucket (32 / 64 / 96 /
128 / 160 / 192 / 256 rows) the best block_n / block_k / stages / waves of a
tdm or ft sweep, measured with 2 weight copies alternated in a CUDA graph on
one MI455X (bf16 error 3e-3, fp32 3e-6 against an f32 matmul):

  rows      bf16 out          fp32 out
  1-32      1.04-1.16x        1.0-1.12x (rows <= 8 keep production)
  33-64     1.25-1.37x        1.31-1.35x
  65-128    1.43-1.62x        1.53-1.63x
  129-160   2.04-2.44x        2.10-2.43x   (c192's verify / draft rows)
  161-192   2.33-2.49x        2.42-2.66x
  193-256   2.10-2.72x        2.17-2.77x

At c192 (133-175 rows) that is ~300-500 us a head, ~0.6 ms a D step.

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

* tuned_gemm: an empty-row FlyDSL GEMM returns the empty product instead of launching

An idle DP rank's dummy step runs its GEMMs with M = 0, and the lookup pads
M = 0 into a tuned row: with a FlyDSL row there (Kimi-K3's head rows, the
commit before) validate_gemm_gfx1250_config refused the empty dimension and
the engine died at its first prefill ("dimensions, tiles, stages, wave counts
and WMMA sizes must be positive integers"; DP4 one-tray D, 12-02). Return the
[0, N] result (or the caller's buffer) without a launch, as the default
kernel effectively did.

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

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Honglie Yi <[email protected]>
(cherry picked from commit 4c4e333)

Rebase onto main 12-03: main since has #8189's final head, #8889 (packed A only where its stores fit storecnt, tdm_b_th from the tuned row) and #8737 (LDS-to-TDM flush, C staged at the arena tail). Resolved: s1f_ctl.py keeps main's _s1f_gemm_opts / _s1f_packed_a_ok / s1f_prefill_tile(config, ...) / _s1f_warps(config, ...) (this commit's same-purpose _gemm_opts method and (world_size, topk) helpers are dropped) and adds this commit's IOD placement next to main's tdm_b_th: _launcher / _precompile take both, the launcher key and the precompile keys carry (tdm_b_th, placed), make_s1f_stage1 gets tdm_b_th, b_placed, loc_group. s1f_stage1.py: the producer role is this commit's s1f_produce(_PCtx(...)) (its body is main's inline producer, packed A and WAIT_STEPS included); OP_STORES / the storecnt check use main's s1f_packed_a_op_stores / s1f_packed_a_fits (R is 8 there); make_s1f_stage1 takes tdm_b_th and b_placed / loc_group; imports both. dispatch_compact.py: main's 4-tuple _compact_gemm_tiles. mxfp4_preshuffle_gfx1250_tdm.py: main's single C_OFF staging (arena tail, flush scratch at the head) is kept; this commit's a/c cache modifiers, scatter cache policy and defer_ep_wait are added, defer_ep_wait moving C_OFF past the input stages (and growing the arena) instead of this commit's C_EP_OFF / C_Q_OFF; the kernel name carries both suffixes. kimik3_bf16_tuned_gemm.csv: the 504 LM / draft head rows replayed by key. Multi-GPU MegaMoE / megakernel not run on the rebased tree.

Rebase onto main 12-03: after #8483 was updated to its PR head 21120ee (which adds its own bench_mega_moe flags --max_tokens_per_rank / --activation / --situ_beta), op_tests/multigpu_tests/bench_mega_moe.py keeps this commit's version (--max_tpr / --recv_bound / --act / --situ_beta / --sim_ep cover the same knobs); taking both would define --situ_beta twice.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants