Repository navigation
[FlyDSL] perf(mega_moe): gfx1250 decode megakernel - dispatch, GEMM1, GEMM2 and combine in one launch - #7345
GwilliamHu wants to merge 1 commit into
Conversation
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: |
NOT READY FOR HUMAN REVIEWPR Self-ReviewRevision 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
Edit the Missing or invalid answers
Shadow mode reports what would block but keeps the status successful. Set |
bff56e5 to
12db182
Compare
12db182 to
9b0a534
Compare
9b0a534 to
17f9005
Compare
bb7e534 to
f9caf81
Compare
…e, 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]>
…-dev-1201-iod - D_MOE_LOC sets AITER_MOE_LOC on D (LLM-Booster #875). It is off by default and needs aiter's IOD placement (ROCm/aiter#8728 + #8997), which lives on aiter `zejun/k3-455-dev-1201-iod`. On K3 only W13 is placed. - The aiter decode megakernel (ROCm/aiter#7345, #865) lives on aiter `zejun/k3-455-dev-1201`. The two do not combine yet: they conflict in 21 hunks of the S1F / GEMM builder, so they are A/B'd on separate builds. The IOD install script now defaults AITER_REF to the -iod branch. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ark draft window, per-request log, MoRIIO hop timing, tools (#4106) * scheduler: ATOM_SPEC_REQUEST_LOG, one line per finished request with its speculative acceptance Diagnostics for LLM-Booster #878 (DSpark acceptance falls in long-context turns). Each `Sequence` counts the speculative steps it verified and the drafts offered and accepted across them, at the same point and under the same condition as `EngineStats.update_spec`. When the env names a path prefix, `_mark_finished` appends one JSON line per request to `<prefix>.dp<rank>.<pid>.jsonl`: prompt / cached / output tokens, k, steps, drafted, accepted and the finish reason. That relates acceptance to context length offline. Off by default; written once per request, never per token; a failed write warns and turns it off for that engine. Co-Authored-By: Claude Opus 5.5 <[email protected]> * recipes: 455-k3 — lossless sampling on D at every point (to validate at c512 / c1024), megakernel and spec-log knobs - D_LOSSLESS now defaults to 1 at every point. c192 was measured (R9c); c512 and c1024 are validated on this branch (LLM-Booster #874). - D_MEGAKERNEL=1 sets AITER_MEGAKERNEL=1 on D: aiter's decode megakernel (ROCm/aiter#7345, LLM-Booster #865). It is off by default, to be A/B'd at c192, also with the shared expert off its side stream (ATOM_DUAL_STREAM_MOE_TOKEN_THRESHOLD=0), since the megakernel needs no kernel running beside it. - D_SPEC_LOG sets ATOM_SPEC_REQUEST_LOG on D: per-request acceptance against context length (LLM-Booster #878). Co-Authored-By: Claude Opus 5.5 <[email protected]> * recipes: 455-k3 — keep lossless sampling's default at c192 only; c512 / c1024 are #874's LLM-Booster #874 (lossless sampling at c512 / c1024) and the c1024 point now belong to gbyu. This branch therefore no longer changes their default: D_LOSSLESS is on at c192 only, as on k3-455-dev. The knob stays. Co-Authored-By: Claude Opus 5.5 <[email protected]> * diagnostics: a P/D request's wait for its KV, hop by hop (LLM-Booster #883); ATOM_REQUEST_LOG At c192 a request waits ~0.5 s on D before its first decode. D's own metrics put ~96% of it in pd_kv_transfer_seconds: the MoRIIO write-mode hand-off after P has finished. This change logs where that hand-off goes. - ATOM_SPEC_REQUEST_LOG becomes ATOM_REQUEST_LOG, one JSON line per finished request. Besides the speculative counters it records ttft_ms and e2e_ms; on a P/D consumer it also records park_ms (began waiting for the remote KV) and kv_ms (the scheduler found it arrived). It is written once per request and only when the env names a path prefix. - Under ATOM_MORIIO_TRANSFER_STATS: - On the producer, each push's stats line gains queue_ms (from the write request arriving to the write service taking it) and its PP stage. - On the consumer, each receive logs gate_ms (until the forwards queued before it finish and the write is asked for), report_ms (until the last producer stage reports) and pickup_ms (until an engine step takes it). Co-Authored-By: Claude Opus 5.5 <[email protected]> * recipes: 455-k3 — request_log_report.py (#878) and pd_timeline_report.py (#883) Two stdlib-only readers for the new diagnostics: - request_log_report.py: DSpark acceptance and tokens per forward by context-length bin, from ATOM_REQUEST_LOG. - pd_timeline_report.py: where a P/D request's wait for its KV goes, from the MoRIIO transfer stats and write timeline lines (ATOM_MORIIO_TRANSFER_STATS=1) and the request log. Co-Authored-By: Claude Opus 5.5 <[email protected]> * recipes: 455-k3 — replay_turns.py, to tell length from content in DSpark's acceptance drop (#878) DSpark acceptance falls as c192's agentic trajectories deepen (0.34 to 0.27). The draft's own card reports only a small drop on ~95k-token documents (AA-LCR 3.23 against a 3.73 mean, at temperature 1.0), and it trained on single-turn and chat prompts. So the deep turns' content (tool output, ~150 turns deep) may matter more than their length. The tool replays three categories of recorded turns through the router: - early turns; - deep turns; - the deep turns cut to a short history: the system prompt, the first user message, then the newest whole exchanges, never starting with a tool result. It then joins D's ATOM_REQUEST_LOG to report the acceptance per category. It is stdlib-only. On R5b's events the selection takes 8 s and gives: - early: median 56 KB, turn index 21; - deep: median 435 KB, turn index 156; - deep_cut: median 117 KB, turn index 157. Co-Authored-By: Claude Opus 5.5 <[email protected]> * recipes: 455-k3 — replay_turns.py records what each turn generated (prose or a tool call) and splits acceptance by it Co-Authored-By: Claude Opus 5.5 <[email protected]> * DSpark: ATOM_DSPARK_DRAFT_WINDOW, the newest W context tokens a paged draft block attends (LLM-Booster #878) Kimi-K3's DSpark acceptance collapses past ~120K tokens of context (E17 c192, 12-02: 0.43 at 96-104K, 0.19 at 128-136K, 0.05 past 176K), while the draft's card verifies it only up to AA-LCR's 115K. With rope, q.k depends only on the distance, so attending the newest W tokens keeps every distance the draft sees in that range. Off by default. A windowed variant of the KV index generator (kv_indices_generate_window_triton) writes each row's tokens from its first one; the shared generator is unchanged. CSR MLA decode only, no DCP. Co-Authored-By: Claude Opus 5.5 <[email protected]> * recipes: 455-k3 — c192 defaults to P_TRANSFER_SLOTS=0 (#883) and a 96K DSpark draft window (#878) 12-02, E17 05-08, c192, 1x613 (R11c) against 12-01's R9c: interactivity 64.7 -> 68.2, 438 -> 480 tok/s/GPU, TTFT p50 1.14 -> 0.86 s. D's KV wait 0.43 -> 0.16 s: P staged each finished prefill's KDA state into its transfer slot at the next step of every PP stage. The draft's acceptance at 128-144K 0.185 -> 0.410. c512 / c1024 keep 128 transfer slots and no window. Co-Authored-By: Claude Opus 5.5 <[email protected]> * recipes: 455-k3 — c192 defaults to the MoRIIO write thread on P; record the 12-02 code (aiter heads-mla build) Every 12-02 c192 run (R11b / R11c / R11d) had ATOM_MORIIO_WRITE_THREAD=1 on P; with the transfer slots off it sends each push as soon as it is asked for, not at each PP stage's next step, so the recipe needs it to reproduce the measured hand-off. The note now says which aiter build the 12-02 numbers used and marks the 1x613 numbers as early-window only. Co-Authored-By: Claude Opus 5.5 <[email protected]> * recipes: 455-k3 — 12-02 c192 full-window result with both fixes (R11d: 58.5 interactivity, 530 tok/s/GPU) Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
…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]>
… GEMM2 and combine in one launch One persistent kernel per rank runs a MegaMoE step end to end (AITER_MEGAKERNEL=1): quantize and tally the routed rows, exchange the counts, ship the rows to their experts' ranks, GEMM1, GEMM2 with the EP scatter back to the source ranks, and the top-k reduce. Two layouts share one protocol (megakernel/): - slots: fixed expert slots, for steps whose receive bound is at most SLOTS_RECV (SLOTS_RECV_PLACED by shape with IOD-placed weights); - compact: the staged compact layout, the stage-1 producer running inside the kernel (STREAM), for larger steps below COMPACT_MAX_TOKENS per rank. Larger steps, a quantized combine wire, biases, a post-GEMM2 RMSNorm and a step that hands in shared_add / shared_ready run the staged path. Kimi-K3 SiTUv2 (hidden 3584, inter 3072, top-16), EP8 on two nodes, us a layer, stage-1 fused (S1F) -> megakernel: 120 tokens per rank 206.3 -> 190.6, 640 tokens per rank 301.0 -> 281.0. Also in this change: - s1f_stage1: the producer is split out (_PCtx, s1f_produce, s1f_producer_lds) so the megakernel runs the same code; the stage-1 kernel takes W1's IOD phase table as a trailing argument. - builder: a_cache_modifier / c_cache_modifier / scatter_cache_policy and defer_ep_wait (a caller with tile hooks retires the EP scatter itself). - routing weights are rounded to bf16 in compact / S1F / megakernel (config.route_weight_bits); batched SiTUv2 uses v_tanh_f32. - bench_mega_moe: --routing_dir, --max_tpr / --recv_bound, MoE-only time, power and GFX clock; the prefetched plans carry the step's bound. - warmup_compact_plan compiles and lines up the megakernel of the bound. Rebased onto main as one commit; the branch's history is in #7345. Co-authored-by: Shao <[email protected]> Co-authored-by: XingerZhu <[email protected]> Co-Authored-By: Claude Fable 5.2 <[email protected]>
1839079 to
d300aab
Compare
…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.
…ark draft window, per-request log, MoRIIO hop timing, tools (#4106) * scheduler: ATOM_SPEC_REQUEST_LOG, one line per finished request with its speculative acceptance Diagnostics for LLM-Booster #878 (DSpark acceptance falls in long-context turns). Each `Sequence` counts the speculative steps it verified and the drafts offered and accepted across them, at the same point and under the same condition as `EngineStats.update_spec`. When the env names a path prefix, `_mark_finished` appends one JSON line per request to `<prefix>.dp<rank>.<pid>.jsonl`: prompt / cached / output tokens, k, steps, drafted, accepted and the finish reason. That relates acceptance to context length offline. Off by default; written once per request, never per token; a failed write warns and turns it off for that engine. Co-Authored-By: Claude Opus 5.5 <[email protected]> * recipes: 455-k3 — lossless sampling on D at every point (to validate at c512 / c1024), megakernel and spec-log knobs - D_LOSSLESS now defaults to 1 at every point. c192 was measured (R9c); c512 and c1024 are validated on this branch (LLM-Booster #874). - D_MEGAKERNEL=1 sets AITER_MEGAKERNEL=1 on D: aiter's decode megakernel (ROCm/aiter#7345, LLM-Booster #865). It is off by default, to be A/B'd at c192, also with the shared expert off its side stream (ATOM_DUAL_STREAM_MOE_TOKEN_THRESHOLD=0), since the megakernel needs no kernel running beside it. - D_SPEC_LOG sets ATOM_SPEC_REQUEST_LOG on D: per-request acceptance against context length (LLM-Booster #878). Co-Authored-By: Claude Opus 5.5 <[email protected]> * recipes: 455-k3 — keep lossless sampling's default at c192 only; c512 / c1024 are #874's LLM-Booster #874 (lossless sampling at c512 / c1024) and the c1024 point now belong to gbyu. This branch therefore no longer changes their default: D_LOSSLESS is on at c192 only, as on k3-455-dev. The knob stays. Co-Authored-By: Claude Opus 5.5 <[email protected]> * diagnostics: a P/D request's wait for its KV, hop by hop (LLM-Booster #883); ATOM_REQUEST_LOG At c192 a request waits ~0.5 s on D before its first decode. D's own metrics put ~96% of it in pd_kv_transfer_seconds: the MoRIIO write-mode hand-off after P has finished. This change logs where that hand-off goes. - ATOM_SPEC_REQUEST_LOG becomes ATOM_REQUEST_LOG, one JSON line per finished request. Besides the speculative counters it records ttft_ms and e2e_ms; on a P/D consumer it also records park_ms (began waiting for the remote KV) and kv_ms (the scheduler found it arrived). It is written once per request and only when the env names a path prefix. - Under ATOM_MORIIO_TRANSFER_STATS: - On the producer, each push's stats line gains queue_ms (from the write request arriving to the write service taking it) and its PP stage. - On the consumer, each receive logs gate_ms (until the forwards queued before it finish and the write is asked for), report_ms (until the last producer stage reports) and pickup_ms (until an engine step takes it). Co-Authored-By: Claude Opus 5.5 <[email protected]> * recipes: 455-k3 — request_log_report.py (#878) and pd_timeline_report.py (#883) Two stdlib-only readers for the new diagnostics: - request_log_report.py: DSpark acceptance and tokens per forward by context-length bin, from ATOM_REQUEST_LOG. - pd_timeline_report.py: where a P/D request's wait for its KV goes, from the MoRIIO transfer stats and write timeline lines (ATOM_MORIIO_TRANSFER_STATS=1) and the request log. Co-Authored-By: Claude Opus 5.5 <[email protected]> * recipes: 455-k3 — replay_turns.py, to tell length from content in DSpark's acceptance drop (#878) DSpark acceptance falls as c192's agentic trajectories deepen (0.34 to 0.27). The draft's own card reports only a small drop on ~95k-token documents (AA-LCR 3.23 against a 3.73 mean, at temperature 1.0), and it trained on single-turn and chat prompts. So the deep turns' content (tool output, ~150 turns deep) may matter more than their length. The tool replays three categories of recorded turns through the router: - early turns; - deep turns; - the deep turns cut to a short history: the system prompt, the first user message, then the newest whole exchanges, never starting with a tool result. It then joins D's ATOM_REQUEST_LOG to report the acceptance per category. It is stdlib-only. On R5b's events the selection takes 8 s and gives: - early: median 56 KB, turn index 21; - deep: median 435 KB, turn index 156; - deep_cut: median 117 KB, turn index 157. Co-Authored-By: Claude Opus 5.5 <[email protected]> * recipes: 455-k3 — replay_turns.py records what each turn generated (prose or a tool call) and splits acceptance by it Co-Authored-By: Claude Opus 5.5 <[email protected]> * DSpark: ATOM_DSPARK_DRAFT_WINDOW, the newest W context tokens a paged draft block attends (LLM-Booster #878) Kimi-K3's DSpark acceptance collapses past ~120K tokens of context (E17 c192, 12-02: 0.43 at 96-104K, 0.19 at 128-136K, 0.05 past 176K), while the draft's card verifies it only up to AA-LCR's 115K. With rope, q.k depends only on the distance, so attending the newest W tokens keeps every distance the draft sees in that range. Off by default. A windowed variant of the KV index generator (kv_indices_generate_window_triton) writes each row's tokens from its first one; the shared generator is unchanged. CSR MLA decode only, no DCP. Co-Authored-By: Claude Opus 5.5 <[email protected]> * recipes: 455-k3 — c192 defaults to P_TRANSFER_SLOTS=0 (#883) and a 96K DSpark draft window (#878) 12-02, E17 05-08, c192, 1x613 (R11c) against 12-01's R9c: interactivity 64.7 -> 68.2, 438 -> 480 tok/s/GPU, TTFT p50 1.14 -> 0.86 s. D's KV wait 0.43 -> 0.16 s: P staged each finished prefill's KDA state into its transfer slot at the next step of every PP stage. The draft's acceptance at 128-144K 0.185 -> 0.410. c512 / c1024 keep 128 transfer slots and no window. Co-Authored-By: Claude Opus 5.5 <[email protected]> * recipes: 455-k3 — c192 defaults to the MoRIIO write thread on P; record the 12-02 code (aiter heads-mla build) Every 12-02 c192 run (R11b / R11c / R11d) had ATOM_MORIIO_WRITE_THREAD=1 on P; with the transfer slots off it sends each push as soon as it is asked for, not at each PP stage's next step, so the recipe needs it to reproduce the measured hand-off. The note now says which aiter build the 12-02 numbers used and marks the 1x613 numbers as early-window only. Co-Authored-By: Claude Opus 5.5 <[email protected]> * recipes: 455-k3 — 12-02 c192 full-window result with both fixes (R11d: 58.5 interactivity, 530 tok/s/GPU) Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]> (cherry picked from commit 04c31e3)
Summary
Adds two opt-in single-kernel paths to
MegaMoEGfx1250. Each runs the whole MoE layer as one persistent kernel: fp4 wire quant, dispatch, GEMM1, GEMM2 with EP scatter, the cross-rank combine and the top-k reduce. The staged compact path needs 6-7 launches per layer for the same work (plan, quant, dispatch or S1F, GEMM1, GEMM2, combine sync, reduce).AITER_MEGA_DECODE=N): fixed per-expert slots. It runs every step whose receive bound (recv_token_bound, orworld * max_tokens_per_rankwhen unbounded) is at mostworld * N.AITER_MEGA_LARGE=1): the staged compact layout. It runs every larger step, which covers decode up to 1536 tokens per rank and prefill.Both are the gfx1250 counterpart of the gfx950 MegaMoE (#6881), adapted to gfx1250: wave32, TDM loads and gather stores, and no readable XCC id.
How small_m works (
mega_moe_gfx1250/decode_mega.py,layout="slots")Every CTA of an all-resident grid (CU count × 2, 4 waves each) runs these phases.
started[rank], polls theirs and opens each CTA's send gate. The route waves load their rows first and wait on the gate only for the remote atomic and the stores.running[parity][expert]. Idle lanes address out of bounds, so they cost nothing.(meta, weight)rowmap pair go straight into the slot with SCOPE_SYS stores.src_done[rank].build_gemm_a8w4_tdm_taskbodies with explicit tiles, inside the kernel.g1_ready, and a GEMM2 item's A waves wait on it while its B waves stream W2.comb_flag.How large_m works (
layout="compact")large_m replaces phase 1 with a count-first front end on the staged compact layout: expert-major, each expert padded to
tile_m, sources in rank order inside it. So its rows, m-tiles and GEMMs are the staged path's, and it needs no slots sized for every token.src_donearrived. Its B owners stream W1 meanwhile.a_ready.large_m runs 4 CTAs per CU with t64x256x128 b3 GEMM tiles, the staged GEMMs' tile. The weight-bound GEMM phase needs that occupancy: at 2 CTAs per CU with t64x256x256 it was about 90 µs slower at 2048 tokens/rank.
large_m needs no start handshake: it sends rows only after every peer's X1, which proves every peer has started.
large_m shares
disp_out,ep_rowmapandcomb_inpwith the staged path. Each path writes a peer's copy only after a message from that peer's current launch (large_m's X1, the staged dispatch's count exchange), so neither overwrites what the other still reads.Cross-launch reuse of every region is ordered by the protocol itself (see the module docstring). Generation, parity and the X1 tag come from device-side tickets, so both paths are CUDA-graph safe.
Waits. Every cross-CTA or cross-rank wait traps after a time limit (120 s,
AITER_DMK_TIMEOUT_S), not after a poll count. The ranks' first launches can be seconds apart, because each rank JIT-compiles its own kernel (the rank is baked in). Each launcher's first launch therefore compiles first and meets a host barrier.New knobs on
build_gemm_a8w4_tdm_task, all defaulting to 0 (unchanged):a_cache_modifier,c_cache_modifierandscatter_cache_policy. They are the in-kernel GEMM1 → GEMM2 and GEMM2 → peer hand-offs. Policy 0 on the scatter fails accuracy; GEMM2's A loads can stay at policy 0.Results
4× gfx1250, DSV4-Pro shape (7168 × 3072), E384 + 4 fused shared experts, top-6+1, EP4, fp4 dispatch wire, bf16 combine. Times are µs per layer, graph replay, including the bench's own RMSNorm and residual kernels.
small_m (
bench_mega_moe.py --layers 4,AITER_MEGA_PLAN_PREFETCH=0, before the start handshake):With the start handshake (same instance and inputs for both paths, local-expert weights): 167.2 vs 175.3 at 8 tokens/rank (−4.7%) and 290.3 vs 298.2 at 64 (−2.7%).
large_m (4 layers, same instance and inputs for both paths; every run bitwise equal):
Without the MoE call, the same graph takes 55-96 µs per layer (RMSNorm, residual, launch gaps). So the MoE itself is about 30 µs slower at 256-1024 tokens/rank and 50 µs at 2048.
Where large_m still loses (kernel phase stamps,
AITER_DMK_TRACE): GEMM1 cannot start a tile before every row of every rank has landed. Each 64-row tile holds rows of dozens of tokens, sent one wave per token, so tiles fill only at the end of the send. Below 4096 received tokens, S1F instead ships rows tile by tile and starts GEMM1 per flag tile as they land.Next, in order:
The GEMM tile does not change the output bits, so each megakernel picks its own tiles.
Limitations
warmup_compact_planstill warms those bounds' plans.world * Nrows per local expert: ~191 MB at EP4 with 97 local experts and N=128, plus a2.world * max_tokens_per_rank <= 65535), counts at most 131072 routes per rank, and checks that its X1 rows and LDS scratch fit at admission.Test plan
python3 op_tests/multigpu_tests/test_mega_moe_decode_gfx1250.pyon 4× gfx1250. It is new and skips off gfx1250. It runs both megakernels, with and without a shared expert, at token counts that differ across ranks, and checks:AITER_MEGA_S1F=0.bench_mega_moe.pywithAITER_MEGA_DECODE=128at 8/64/128 tokens per rank: accuracy PASS.🤖 Generated with Claude Code