Skip to content

feat(plugins): Kimi-K3's MLA DCP query gather on vLLM's TP group, and gemm's workloads at its decode token counts - #276

Merged
zhenhuang12 merged 2 commits into
mainfrom
kyle/core-bucketed-dispatch
Nov 27, 2026
Merged

zhenhuang12 merged 2 commits into
mainfrom
kyle/core-bucketed-dispatch

Conversation

@kyle-256

@kyle-256 kyle-256 commented Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator

Why

  • DCP query gather. In Kimi-K3's MLA decode under DCP8, vLLM 0.34.0 gathers the query on the DCP group, which has no aiter communicator, so it runs RCCL through torch.distributed. Where the DCP group has the TP group's ranks, the TP group does the same gather on aiter's all-gather: decode is 4.0% faster.
  • GEMM at Kimi-K3's decode sizes. Dispatch serves a GEMM only at an m some workload holds. Kimi-K3 decodes with draft tokens, so a decode step's m grows with the running requests in steps of 5 tokens on vLLM (DSpark k4) and 8 on SGLang, not through the few sizes the committed workloads were recorded at: most decode GEMMs of the daily 8K/1K flow found no workload and went back to aiter.

Scope

  • No change under aklr/core. Earlier heads of this PR served token-count ranges from the dispatcher (bucketed axes, RANGE_SAFE) and shortened the FlyDSL launch cache's lookup; both changed aklr/core and are left out. The missing sizes are added as workloads instead.
  • DCP query gather: a route on MLADCPManager._gather_query (vLLM 0.34.0, 0.32.1rc1.dev276) that hands the gather to vLLM's TP group (GroupCoordinator.all_gather). No contract, no kernel; AKLR calls nothing of aiter's. [email protected] turns it off.
  • GEMM workloads: 759 workloads in 14 new schema files under aklr/plugins/aiter/provider/gemm, each beside the file of the main kernel it belongs to (the same kernel, the new workloads alone, so the measured file is untouched). They are the decode-step sizes, up to 480 tokens, that a recorded run of the daily 8K/1K flow (concurrency 1 to 48) reached without a workload on vLLM 0.34.0 and SGLang 0.5.23. Prefill sizes (any token count) are left out: they are worth under 1% end to end.

Verification

Replaying the recorded GEMM calls through dispatch on the CPU, an unmeasured workload counted as qualified:

GEMM calls served main's workloads with this PR still without a workload
vLLM (1.15 M calls) 82 K 508 K 227 K: 212 K prefill sizes, 15 K at the decode sizes CI measured slower (below)
SGLang (304 K calls) 111 K 136 K 2 K

CI on the earlier head (615aa53, 774 workloads in 16 files) timed every workload against aiter: 628 passed, 146 were not faster and are demoted (they stay with aiter), accuracy passed on all 774. Two files had no workload at 1.05x, which validation fails: gemm_n1536_k7168 at m 195 to 235 (10 workloads, 0.89x to 0.90x) and gemm_n3584_k7168 at m 65 to 76 (5 workloads, 0.90x to 0.91x). This head drops those two files; nothing else changed.

DCP route, measured before the rebase onto #352 (8 × MI355X, vLLM 0.34.0, Kimi-K3 TP8 DCP8, DSpark k7, concurrency 4, random 2048 in / 2048 out, 6 rounds, the arms differing in [email protected] alone): 336.4 → 349.8 output tok/s (+4.0%), mean TPOT 5.82 → 5.59 ms, every on round above every off round. Its first eager call equalled the DCP group's own gather byte for byte on all 8 ranks.

Code, on this head. CPU (no GPU): pytest tests/plugins tests/core/contract tests/core/runtime: 1032 passed, 1 failed, test_init_skips_schema_whose_requires_fails[0.3.2-True], which main fails the same way without a GPU; aklr validate --stages audit --base origin/main 0 findings; aklr export check, ruff check pass. GPU, as CI's jobs run them, on one MI355X (the code of this head before its rebase over #359, which moves two other GEMM files): vllm-test's image as it ships, pytest tests/plugins/vllm: 110 passed; the SGLang image on stack.json's AITER, pytest tests/plugins/aiter tests/core/runtime: 560 passed, 4 skipped.

Not run

  • The 759 workloads carry no measurement in the files: CI measures them, and one below the threshold stays with aiter. The only timing is CI's own run on the earlier head (above).
  • No end-to-end run on this head. The Kimi-K3 8K/1K pairs run so far served these sizes through the range dispatch this PR no longer has.
  • The gather's exactness inside CUDA graphs: only its first eager call is compared.

Risk

Affects: on vLLM 0.34.0 and 0.32.1rc1.dev276 with AKLR_VLLM_PLUGIN=1, the DCP query gather of any MLA model whose DCP group has the TP group's ranks; [email protected] at the added sizes of 14 kernels once CI has measured them.
AgentX: none (agentx.yaml has no Kimi-K3 entry).
If wrong: a wrong query after the gather (wrong text); a GEMM size served slower than aiter until its measurement says so.
Undo: [email protected]; the workloads by git revert.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Range-key decoding can crash vLLM worker warmup, and range lookup can bypass recorded exact-key rejections to run an unmeasured candidate.

8 open issues
What changed in this PR

Adds opt-in, power-of-two matching for token-count axes so AKLR can serve eligible kernels at unmeasured shapes instead of falling back.

Changes:

  • Adds bucketed-axis metadata, key normalization, and call-time validation.
  • Introduces exact and range dispatch entries, RANGE_SAFE checks, and measured-span guards.
  • Enables bucketing across op and plugin contracts, updates vLLM warmup handling, and adds CPU tests.
File Description
tests/​core/​contract/​test_fastkey_bucketed.py Adds bucket matching, qualification, and span-guard tests.
aklr/​plugins/​vllm/​warmup.py Updates GEMM warmup point selection for range keys.
aklr/​plugins/​vllm/​models/​kimi_k3/​attn_res/​contract.py Enables token bucketing for attention residuals.
aklr/​plugins/​sglang/​models/​kimi_k3/​contract.py Enables token bucketing across Kimi K3 contracts.
aklr/​plugins/​sglang/​layers/​attn_residual/​contract.py Enables token bucketing for attention residuals.
aklr/​ops/​topk/​contract.py Marks token axes as bucketed in both top-k contracts.
aklr/​ops/​mla_prefill/​contract.py Marks the sparse-prefill token axis as bucketed.
aklr/​ops/​gemm/​contract.py Marks the shared GEMM m axis as bucketed.
aklr/​ops/​fused_moe/​contract.py Marks the routed token axis as bucketed.
aklr/​core/​runtime/​dispatch/​_dispatcher.py Builds exact/range entries and checks eligibility and spans.
aklr/​core/​contract/​spec/​_points.py Adds the bucketed-axis flag and validation.
aklr/​core/​contract/​op.py Clears bucketing when narrowing an axis to a fixed value.
aklr/​core/​contract/​fastkey/​_fast_key_fn.py Validates bucketed-axis bounds and constraints at call time.
aklr/​core/​contract/​fastkey/​_codec.py Adds bucket markers and exact-key normalization.

Review effort: Max

Comment thread aklr/plugins/vllm/warmup.py Resolved
Comment on lines 147 to 148
if key not in best or rank > best[key][0]:
best[key] = (rank, runnable)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in d27bff8: DispatchTable.ranges keeps every qualified RANGE_SAFE kernel of a range with its span, best ranked first, and lookup takes the first one whose span holds the value. Each kernel is warmed on its own key, so inside a capture a range kernel that never ran eagerly falls back as NOT_WARMED. Tests, using your example: test_a_range_is_served_by_the_best_kernel_measured_around_the_value (2400 goes to the 3x kernel, 3000 to the 2x kernel, 2050 is NO_WORKLOAD) and test_a_range_kernel_is_warm_only_once_it_ran.

@@ -76,7 +76,7 @@ def _pool(prefix):
),
op_type="mla_prefill",
axes={
"n_tokens": axis("Query rows.", 1, 16384, is_var=True),
"n_tokens": axis("Query rows.", 1, 16384, is_var=True, bucketed=True),

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in 381f6b7: n_offsets is now any_size=True. The generated fast_key still checks its bounds and n_offsets == n_tokens + 1 on every call. any_size is not rendered in schemas, so the one committed sparse_prefill_mxfp8 schema keeps its name, uuid and text (re-rendered to confirm). It does not declare RANGE_SAFE, so it still serves only the token counts it measured. Covered by test_an_axis_bound_to_n_tokens_plus_one_does_not_split_its_range[sparse_prefill_mxfp8_n_offsets].

@@ -116,7 +116,7 @@
),
op_type="topk",
axes={
"n_tokens": axis("Rows, one per token.", 1, 65536, is_var=True),
"n_tokens": axis("Rows, one per token.", 1, 65536, is_var=True, bucketed=True),

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in 381f6b7: n_plan_rows is now any_size=True, and its bounds and n_plan_rows == n_tokens + 1 are still checked on every call. The 3 committed topk_transform_paged schemas keep their name, uuid and text, and none declares RANGE_SAFE. Covered by test_an_axis_bound_to_n_tokens_plus_one_does_not_split_its_range[topk_transform_paged_n_plan_rows], and through dispatch by test_bucketed_axis_keeps_the_constraints_reading_it (5 tokens are served from a range measured at 4 and 7).

Comment on lines +46 to +73
@pytest.mark.parametrize(("slow_n_tokens", "served"), [(None, True), (3500, False), (5000, True)])
def test_a_schema_serves_a_range_only_if_each_of_its_workloads_there_qualifies(
monkeypatch, slow_n_tokens, served
) -> None:
"""A schema measured at 3072 tokens (2.0x) serves 3000 (same range); a second workload of
its in that range at 0.5x leaves the range unserved, one in another range does not."""
import torch

from aklr.core.runtime.dispatch._dispatcher import DispatchTable

case = OpCase.of("[email protected]")
contract = case.contract
codec = FastKeyCodec.from_contract(contract)

def workload(n_tokens, speedup):
point = case.point.model_copy(update={"axes": {**case.point.axes, "n_tokens": n_tokens}})
w = contract.workload_for(point, {})
return w.model_copy(update={"accuracy": "passed", "speedup": speedup})

workloads = [workload(3072, 2.0)] + ([workload(slow_n_tokens, 0.5)] if slow_n_tokens else [])
schema = contract.narrow(case.point, workloads=[w.model_dump(mode="json", exclude_none=True) for w in workloads],
kernel={"language": "triton", "targets": [{"arch": "gfx950", "hardware": "MI355X"}],
"entry_point": "kernel.py::run", "sources": []}) # fmt: skip
runnable = _Runnable(monkeypatch, True)
table = DispatchTable.from_schemas(
contract, torch.device("cpu"), [(schema, runnable, schema.workloads)], min_speedup=1.0
)
assert (table.runnables.get(_key(codec, case, 3000)) is runnable) is served

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in e578f97: the schema is now also measured at 2100, every case asserts through lookup(3000), and the params have ids (no_slow_workload, slow_workload_in_the_range, slow_workload_in_another_range). The test for a kernel without RANGE_SAFE also asserts through lookup now. With only 3072 measured, the two served cases fail, as you said.

op_type="attn_res",
axes={
"n_tokens": axis("Tokens.", 1, 65536, is_var=True),
# one workgroup per token: vLLM's batch sizes are matched by power-of-two range

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in 0f4af8b: the comment now says n_tokens is bucketed because vLLM's token count changes from step to step, and that a kernel serves a range only when its module declares RANGE_SAFE.

@kyle-256
kyle-256 force-pushed the kyle/core-bucketed-dispatch branch from de4a1b1 to e6af292 Compare November 19, 2026 06:27
@kyle-256 kyle-256 added the ci:gpu-direct Run GPU CI directly on aklr-gpu runners label Nov 19, 2026
@kyle-256
kyle-256 marked this pull request as draft November 19, 2026 15:47
@kyle-256
kyle-256 force-pushed the kyle/core-bucketed-dispatch branch from e6af292 to 18f60db Compare November 23, 2026 01:54
@kyle-256 kyle-256 removed the ci:gpu-direct Run GPU CI directly on aklr-gpu runners label Nov 23, 2026
@kyle-256
kyle-256 force-pushed the kyle/core-bucketed-dispatch branch from 18f60db to a3c9d90 Compare November 23, 2026 12:34
@kyle-256 kyle-256 changed the title feat(core): bucketed token axes, served by power-of-two range for RANGE_SAFE kernels feat(core, plugins/vllm): bucketed token axes, with Kimi-K3's KDA prefill/decode and MLA DCP query gather on vLLM Nov 23, 2026
@kyle-256
kyle-256 marked this pull request as ready for review November 23, 2026 12:46
@kyle-256
kyle-256 force-pushed the kyle/core-bucketed-dispatch branch from a3c9d90 to 0f4af8b Compare November 24, 2026 06:16
@kyle-256
kyle-256 force-pushed the kyle/core-bucketed-dispatch branch from 0f4af8b to 849649f Compare November 25, 2026 00:44
@kyle-256 kyle-256 changed the title feat(core, plugins/vllm): bucketed token axes, with Kimi-K3's KDA prefill/decode and MLA DCP query gather on vLLM feat(core, plugins/vllm): token-count ranges served by kernels declaring their classes; the MLA DCP query gather on vLLM's TP group Nov 25, 2026
@kyle-256 kyle-256 removed the ci:gpu label Nov 25, 2026
@kyle-256
kyle-256 force-pushed the kyle/core-bucketed-dispatch branch from 849649f to 79823e4 Compare November 25, 2026 04:14
@kyle-256
kyle-256 force-pushed the kyle/core-bucketed-dispatch branch from 79823e4 to a6c86dc Compare November 25, 2026 07:45
@kyle-256 kyle-256 removed the ci:gpu label Nov 25, 2026
@kyle-256
kyle-256 marked this pull request as draft November 25, 2026 09:33
@kyle-256 kyle-256 changed the title feat(core, plugins/vllm): token-count ranges served by kernels declaring their classes; the MLA DCP query gather on vLLM's TP group feat(core, plugins/vllm): token-count ranges served by RANGE_SAFE kernels; the FlyDSL launch cache without its key; the MLA DCP query gather on vLLM's TP group Nov 26, 2026
@kyle-256
kyle-256 force-pushed the kyle/core-bucketed-dispatch branch from 8026778 to 7de9d2d Compare November 26, 2026 05:56
@kyle-256
kyle-256 marked this pull request as ready for review November 26, 2026 06:14
@kyle-256 kyle-256 removed ci:gpu ci:priority-high Run the PR's SaFE GPU jobs at high priority (with ci:gpu) labels Nov 26, 2026
@kyle-256
kyle-256 marked this pull request as draft November 26, 2026 07:33
…group

Under DCP8, vLLM 0.34.0's MLA decode gathers each step's query on the DCP group, which has no aiter communicator,
so the gather runs RCCL through torch.distributed. Where the DCP group holds the TP group's ranks, a route on
MLADCPManager._gather_query (vLLM 0.34.0 and 0.32.1rc1.dev276) asks vLLM's TP group for the same gather
(GroupCoordinator.all_gather): in a CUDA graph it then runs the path vLLM's own TP all-gathers take, on aiter's
all-gather, and AKLR calls nothing of aiter's itself.

- The first eager call is compared byte for byte with the DCP group's own gather; a gather of another shape or
  group goes back to vLLM.
- No contract and no kernel: [email protected] turns the route off (the id names the route).
- Measured before the rebase onto #352 (8 MI355X, Kimi-K3 TP8 DCP8, DSpark k7, concurrency 4, random 2048 in /
  2048 out): 336.4 -> 349.8 output tok/s (+4.0%), every round of on above every round of off.
kyle-256 added a commit that referenced this pull request Nov 26, 2026
…oE prefill on MXFP8, sparse MLA prefill, the MoE front and decode GEMMs

Kimi-K3.1-Pro's InferenceX sglang image (lmsysorg/sglang:dev-kimi-k31-pro-mi35x, 0.5.24.dev809) runs its own gfx950
kernels where AKLR had no op, and new decode GEMM shapes. Every route below is declared for 0.5.24.dev809 only; none is
on an aiter function.

- [email protected]: from 2048 tokens the row-sharded front hands sglang's JIT A8W4 experts (k3_a8w4_moe)
  input already in MXFP8. Baseline: AKLR's copy of sglang de0f491836's gate-up, down and reduce kernels
  (_k3_a8w4_gfx950.hip), so CI's sglang 0.5.23 runs it. The kernel keeps stage 2's per-route rows as MXFP6 (e2m3)
  before the top-k sum, as #329 does for Kimi-K3: its out holds main's 20 dB (MOE_MXFP8_SNR).
- [email protected]: sglang's sparse_mla_prefill_gfx950 on the 656-byte fp8_ds_mla rows; baseline
  AKLR's copy of that kernel. The rows are drawn by a new fp8_ds_mla_rows distribution (aklr/core semantics; a new
  kind only, no existing schema changes).
- [email protected]: the latent MoE's fp32 front (6016 x 7168) where sglang's _k3_bf16_gemm runs torch.mm,
  the baseline; not routed to [email protected] (#322).
- [email protected]: 6144 x 7168 (KDA in_proj) and 7168 x 3584 (latent up_proj) at decode, through the aiter provider.
- [email protected] on _forward_fused_hip with an fp32 front (front_fp32), fused_moe's 'interleave' gate mode
  mapped as 'separated' with a schema at K3.1's decode counts, the KDA prefill route declared for 0.5.24.dev809.

Each kernel serves the token counts its schema lists: no range dispatch (#276's is not taken). Workloads carry no
measurements; CI writes them.
@kyle-256 kyle-256 changed the title feat(core, plugins/vllm): token-count ranges served by RANGE_SAFE kernels; the FlyDSL launch cache without its key; the MLA DCP query gather on vLLM's TP group feat(plugins): Kimi-K3's MLA DCP query gather on vLLM's TP group, and gemm's workloads at its decode token counts Nov 26, 2026
@kyle-256
kyle-256 force-pushed the kyle/core-bucketed-dispatch branch from 7de9d2d to 615aa53 Compare November 26, 2026 08:37
@kyle-256
kyle-256 marked this pull request as ready for review November 26, 2026 08:43
kyle-256 added a commit that referenced this pull request Nov 26, 2026
…scratch it hands out, not by sizes

The test picked, in gemm_n2112_k7168 and gemm_n6288_k7168, the schema files with skw.py whose smallest m is past
128 rows, to leave out main's sibling kernel (skw.py too, small m, no _scratch). A schema may hold any m: a file
giving the sibling larger sizes (#276 adds one at 148 to 380 rows) was taken for the K3 kernel and failed on
_scratch. It now picks the files whose sources define _scratch, which is what it tests.
kyle-256 added a commit that referenced this pull request Nov 26, 2026
… attn_res variants, the DSA indexer prefill, indexer GEMMs, the latent-MoE tail

Kimi-K3.1-Pro's InferenceX image runs a vLLM fork reporting 0.0.0+mum.14d1ec2336. This adds its routes and kernels,
each checked against the fork's source.

- KDA prefill and speculative decode ([email protected], [email protected]): vLLM's chunk_kda_prefill
  and fused_recurrent_kda on 0.34.0 and the fork; FlyDSL kernels. Their out dtype is the API's out_dtype (#352).
- [email protected]: the fork's attention-residual calls (rows 0-8, with and without the add, norm or bank write)
  on the attn_res route, the kernel's variants for them.
- [email protected], a new op on the fork only: prefill_indexer's query tile under DCP (MXFP4 query
  quantizer, the ragged-prefill scorer on the staged pages, top-k, the ids made relative); baseline vLLM's tile as it
  runs it. It asks aiter >= 0.1.0.
- [email protected] at 128 x 7168 and 32 x 7168 (the indexer's GEMMs) on the wvSplitKrc route, declared for the fork.
- The latent-MoE tail (#302) declared for the fork; a call its defer_projection branch may make (a resolved quantized
  routed input, a token group on the down-projection, min_sharded_tokens rows) stays on vLLM.

Each kernel serves the token counts its schema lists: no range dispatch (#276's is not taken). Workloads carry no
measurements; CI writes them.
@kyle-256 kyle-256 added the ci:priority-high Run the PR's SaFE GPU jobs at high priority (with ci:gpu) label Nov 26, 2026
kyle-256 added a commit that referenced this pull request Nov 26, 2026
…oE prefill on MXFP8, sparse MLA prefill, the MoE front and decode GEMMs

Kimi-K3.1-Pro's InferenceX sglang image (lmsysorg/sglang:dev-kimi-k31-pro-mi35x, 0.5.24.dev809) runs its own gfx950
kernels where AKLR had no op, and new decode GEMM shapes. Every route below is declared for 0.5.24.dev809 only; none is
on an aiter function.

- [email protected]: from 2048 tokens the row-sharded front hands sglang's JIT A8W4 experts (k3_a8w4_moe)
  input already in MXFP8. Baseline: AKLR's copy of sglang de0f491836's gate-up, down and reduce kernels
  (_k3_a8w4_gfx950.hip), so CI's sglang 0.5.23 runs it. The kernel keeps stage 2's per-route rows as MXFP6 (e2m3)
  before the top-k sum, as #329 does for Kimi-K3: its out holds main's 20 dB (MOE_MXFP8_SNR).
- [email protected]: sglang's sparse_mla_prefill_gfx950 on the 656-byte fp8_ds_mla rows; baseline
  AKLR's copy of that kernel. The rows are drawn by a new fp8_ds_mla_rows distribution (aklr/core semantics; a new
  kind only, no existing schema changes).
- [email protected]: the latent MoE's fp32 front (6016 x 7168) where sglang's _k3_bf16_gemm runs torch.mm,
  the baseline; not routed to [email protected] (#322).
- [email protected]: 6144 x 7168 (KDA in_proj) and 7168 x 3584 (latent up_proj) at decode, through the aiter provider.
- [email protected] on _forward_fused_hip with an fp32 front (front_fp32), fused_moe's 'interleave' gate mode
  mapped as 'separated' with a schema at K3.1's decode counts, the KDA prefill route declared for 0.5.24.dev809.

Each kernel serves the token counts its schema lists: no range dispatch (#276's is not taken). The decode counts are
those a recorded daily 8K/1K run (InferenceX's concurrency-48 recipe, AKLR_EXPORT) reached: 5-256 (fused_moe 50-256,
the MoE front 130-240, 7168 x 3584 35-120); prefill keeps its listed counts, as sglang mixes decode tokens into each
prefill batch and no two batches had the same count. Workloads carry no measurements; CI writes them.
…ecode steps take

Dispatch serves a GEMM only at an m some workload holds. Kimi-K3 decodes with draft tokens, so a decode step's m
grows with the running requests in steps of the tokens a request verifies (5 on vLLM with DSpark k4, 8 on SGLang
with DSpark block 7), not through the few sizes the committed workloads were recorded at: in a recorded 8K/1K run
of the daily e2e flow (concurrency 1 to 48) most decode GEMMs found no workload and went back to aiter.

This adds those m as workloads of the kernels already on main: 759 workloads in 14 schema files, each beside the
file of the kernel it belongs to (the same kernel, the new workloads alone, so the measured file keeps its
fields). They are the decode-step sizes (up to 480 tokens, vLLM's largest CUDA graph) the recorded runs on vLLM
0.34.0 and SGLang 0.5.23 reached without a workload, each given to the committed kernel whose workloads lie
around it. Prefill sizes (any token count) are left out.

The workloads are unmeasured: CI measures them, and one that does not reach the threshold stays with aiter.
Replaying the recorded calls through dispatch on the CPU, every workload counted as qualified: gemm serves 508
thousand of vLLM's 1.15 million GEMM calls (82 thousand before) and 136 thousand of SGLang's 304 thousand (111
thousand before); what remains unserved by a kernel that could take it is prefill (212 thousand on vLLM).

CI's run on the first version of this commit (774 workloads in 16 files) found two files with no workload at
1.05x of aiter, which validation fails: gemm_n1536_k7168 at m 195 to 235 (0.89x to 0.90x) and gemm_n3584_k7168 at
m 65 to 76 (0.90x to 0.91x). Those two files are left out.
@kyle-256
kyle-256 force-pushed the kyle/core-bucketed-dispatch branch from 615aa53 to 2ecc535 Compare November 26, 2026 15:48
@kyle-256

Copy link
Copy Markdown
Collaborator Author

Operator-level and end-to-end numbers for this PR (all on 8 × MI355X, vLLM 0.34.0, Kimi-K3 TP8 DCP8; nothing here changes the code, the head is still 2ecc535).

GEMM workloads (operator level, CI's own measurement on this head). 759 workloads in 14 schema files, each timed against aiter in a CUDA graph: accuracy passed on all 759; 632 pass at ≥ 1.05x and are served, 127 are not faster and stay with aiter (demoted). Speedup over aiter: median 1.14x, best 1.81x (worst 0.64x, among the demoted). The first head had two more files (15 workloads, 0.89x to 0.91x) with no workload at 1.05x; they were removed.

DCP query gather (operator level). Kimi-K3's MLA decode gathers the query 24 times a decode step (once an MLA layer). With the route off ([email protected]: RCCL through torch.distributed) against on (vLLM's TP group, aiter's all-gather), everything else the same, a decode step of the daily 8K/1K flow is shorter by:

tokens in the step (concurrency) 5 (1) 10 (2) 40 (8) 80 (16) 240 (48)
step, route off → on (ms) 16.85 → 16.21 17.89 → 17.21 26.22 → 25.45 33.75 → 33.27 53.53 → 52.22
saved 0.64 ms (3.8%) 0.68 ms (3.8%) 0.77 ms (2.9%) 0.48 ms (1.4%) 1.31 ms (2.4%)

(Measured on a head with #302 and #358 stacked, the two arms differing in that switch alone; 800 to 900 steps a size, the device synchronised before and after each step.)

End to end.

@zhenhuang12
zhenhuang12 merged commit 821836d into main Nov 27, 2026
16 checks passed
zhenhuang12 pushed a commit that referenced this pull request Nov 27, 2026
…ts fp8 attention residual, and the attention-residual and GEMM points main misses (#302)

* feat(plugins/vllm): Kimi-K3's latent-MoE tail as one FlyDSL kernel on ROCmLatentMoERunner._shard_up_proj_tail

Under tensor parallelism vLLM ends each Kimi-K3 latent-MoE layer on ROCm with
four ops in ROCmLatentMoERunner._shard_up_proj_tail: the TP all-reduce of the
routed experts' latent partial, the latent RMSNorm, the addmm of this rank's
up-projection rows into its columns of the shared experts' partial, and the
all-reduce of that shared output. The new contract [email protected]
states the four as one op that every rank of the TP group calls
(ranks="tp_size"); its baseline is vLLM's four ops on vLLM's TP group.

Its one FlyDSL schema (B0, TP 8, hidden 7168, latent 3584) runs them in one
launch and does both TP reductions over peer memory: an uncached buffer each
rank allocates and every rank maps over HIP IPC, set up once over vLLM's TP CPU
group. Below 28 rows the launch takes kernel_small.py, from 28 kernel.py (the
up projection spread over up to 4 sets of workgroups, bulk hand-offs as data
then flag). The schema is unmeasured; its workloads are the row counts 1, 2,
4, 5, 8, 10, 16, 20, 32, 40, 60, 64, 80, 120 and 128, matched exactly.

The route, on vLLM 0.34.0 and 0.32.1rc1.dev276 (the same
latent_moe_runner.py), takes 1 to 128 rows of dense bf16 at TP 8 and hands
anything else back to vLLM. Every decision reads only what is the same on
every rank, so the ranks launch the kernel together. The peer memory is set
up by the first call outside a graph capture. The first eager call of each
row bucket (rows of one bit length) is checked against vLLM's tail on the same
operands; the ranks agree on the verdict, and a bucket any rank finds
different stays with vLLM.

Fail-stop: an in-kernel wait gives up after 10 s, records where it waited and
sets a sticky FAILED word, so no rank hangs. The vLLM plugin gets AFTER_STEP,
a list of watches run after each execute_model on every rank; the op
registers one that every 16 steps has the ranks agree over the CPU group and
raises on all of them at the same step once any rank's wait gave up.

Switches: AKLR_VLLM_MOE_TAIL=0 hands every call back to vLLM;
AKLR_VLLM_MOE_TAIL_CHECK=0 skips the first-call check.

The kernel requires flydsl>=0.3.2, as CI runs; it has been compiled and run on
FlyDSL 0.4.0 only.

Measured on 8 MI355X in the vLLM 0.32.1rc1.dev276 image: 92 layers in one
CUDA graph, cold weights, the slowest rank, us a layer:

    M    B0      vLLM
    1    9.78    40.92
    2    10.40   42.63
    4    11.66   45.25
    5    12.21   44.25
    8    14.26   43.67
    10   16.30   45.85
    16   19.65   45.00
    20   22.99   45.10
    24   25.46   45.35
    32   28.70   46.07
    40   29.93   48.81
    60   35.28   53.06
    64   35.76   53.38
    80   42.10   56.48
    120  49.80   63.69
    128  51.76   64.07

At each M every harness check passes: the same bits on all ranks, within the
contract's bound of the reference, the first-call check against vLLM, AKLR's
dispatch serving the same bits, 100 graph replays each the eager bits, and no
wait gave up. M=24 has no workload in this schema, so here it stays with vLLM.

* feat(fastkey): rows of one page grid that never meet are not an overlap

vLLM keeps a Mamba layer's convolution state and recurrent state in the same
pages: a slot's convolution state, then its recurrent state. Their spans
interleave, so the fast key's overlap test declined every call that writes one
of them in place and reads the other.

Two tensors whose spans meet are now apart when they have the same row stride
in bytes, each row is dense, and the other's row lies, in every page, between
the end of the written one's and the start of the next page. Rows that meet,
or of another stride, still decline.

This changes aklr/core, so validation re-benches every schema.

* feat(plugins): kimi_k3_kda_spec_stage_c, Kimi-K3's KDA layer in a speculative verify step as one FlyDSL launch

In a pure speculative verify step, vLLM's Kimi-K3 runs each KDA layer between
in_proj and o_proj as three kernels: a copy of f_a, the f_b GEMM, and aiter's
fused short convolution + recurrence + gated norm. The new contract
[email protected] states that stage on vLLM's tensors (views of the
in-projection's rows, the conv and recurrent states in their shared Mamba
pages); its baseline is vLLM's f_b GEMM dispatch and aiter's fused kernel.

The route at KimiDecoderLayer._run_self_attn (vLLM 0.34.0 and
0.32.1rc1.dev276) runs vLLM's in_proj, the op, then vLLM's o_proj. Everything
else goes back to vLLM before anything runs: MLA layers, prefill, mixed and
plain decode steps, ragged windows, breakable graphs, and a layer or cache
outside the contract, such as a recurrent state that is not float32 (vLLM
0.34's mamba_ssm_cache_dtype). AKLR_VLLM_KDA_STAGE_C=0 hands every call back.

One FlyDSL kernel (gfx950, 12 heads a rank, DSpark's window of 5), one
schema with a workload at every count of 1-32 sequences, unmeasured. On
MI355X, graph replay, us per layer:

  n_seqs              1     2     4     8    16    24
  stage C          10.6  11.6  12.6  14.1  20.5  30.5
  vLLM f_b + aiter 19.9  18.6  19.6  20.5  24.8  35.5

Against the contract's reference it passes on mixed, padded and chained
windows, and two launches are bitwise equal.

Needs the fast key to take the two caches' interleaved page rows (previous
commit).

* refactor(plugins/vllm): the latent-MoE tail and KDA stage C references in float32, called without decode

#293's contract on main: no decode argument, operands read through to_float32. Stage C's tests' Points carry each
operand's logical dtype.

* feat(plugins/vllm): Kimi-K3's attention residual with an fp8 out, and the K3 attn_res and GEMM points main misses

vLLM's _apply_attn_res asks attn_res for a per-token fp8 out (quant_dtype float8_e4m3fn, with its scale) where the
linear after it takes fp8: about half of Kimi-K3's attention-residual calls. The new contract [email protected]
states that out beside [email protected]'s (its reference in float32, as #293's); the route hands those calls to it
(fnuz fp8 stays with vLLM) and also declares vLLM 0.32.1rc1.dev276, the K3 AgentX image.

124 schemas (unmeasured; CI measures) at the points of the Kimi-K3 AgentX trace that main does not serve, each kept
only where an 11-20 validate on MI355X (vLLM 0.34.0 image, graph mode, paired against the baseline) passed accuracy
and ran >= 1.05x with its lower bound >= 1.0 (310 points measured twice keep the worse):
  kimi_k3_attn_res      74 schemas, 1736 points, 1.05-2.09x
  kimi_k3_attn_res_fp8  44 schemas,  546 points, 1.06-2.20x
  gemm n2112/n6288 k7168 1.14-1.64x, n3584 k7168 1.20x, n20480 k7168 1.13x, n2304 k1536 1.06x, n3072 k512 1.05x

* fix(fastkey): compare the written tensor's storage extent with the others', not their logical sizes

A strided view reaches past its nbytes: a state view one page after its convolution view lands on the
later pages' convolution rows, though the two views' logical sizes end before it. The overlap guard
now compares the extents from the first element to the end of the last (_span) before it asks whether
the two are rows of one page grid apart in every page.

* fix(plugins/vllm): KDA stage C opt-in, tensor-dependent declines asked again, the baseline's float32 scale and staged conv weight

- The route runs only with AKLR_VLLM_KDA_STAGE_C=1, read at each call: over three chained steps of two
  sequences the op and vLLM's served aiter chain are not yet shown to agree.
- The route keeps a shape's verdict only: OUT_OF_CONTRACT, which can come from the step's own tensors (a slot
  table off the fast key's 16-byte alignment), is asked again at the next step, as NOT_WARMED was.
- The baseline compares scale with head_dim ** -0.5 as float32s: the workloads record 0.0883883461356163.
- The baseline's width-major conv weight belongs to the weight tensor, freed with it, and is staged again from
  the weight's values at every call outside a graph capture (validation reloads weights in place); a capture,
  what bench times, reads the copy of the eager call before it.
- state_indices: positive slots distinct, 0 and -1 repeated in vLLM's padding windows; the schema re-rendered
  (uuid unchanged, unmeasured). The drawn distribution stays positive and distinct.
- Tests: the switch, the recheck, the scale, the in-place reload and the staged copy's lifetime; on a GPU, the
  capture, and on gfx950 the kernel on padding windows of 0 and of -1 and a padding row against the reference.

* fix(plugins/vllm): the latent-MoE tail's ranks agree before every collective path; shared written in place; a failed step reported at that step without a host wait

- The route hands the dispatcher aligned, non-overlapping operands and agrees serve or fall back over the TP CPU
  group on each (rows, eps, capture) key's first call; setup agrees after each step that can fail on one rank
  (GPU check, allocation and export, mapping) before the next collective, and releases what it made.
- shared is written in place, as vLLM's addmm_ does: the contract makes it mutable, the reference returns it, and
  both kernels write their own columns in the up stage's epilogue, after the flags.
- Fail-stop: a wait that gives up writes FAILED into every rank's peer buffer; each step copies its rank's word to
  pinned memory on a side stream and the step's output leaves the worker only after that copy is checked in vLLM's
  output thread (no collective, no host wait, nothing inside a capture). PP falls back.
- n_tokens covers the op's own range; the kernel's 128-row cap lives in its workloads and the route's guard.
- Failure-injection tests on spawned gloo ranks.

On 8 MI355X (vLLM 0.34.0 image): within the bound, shared's own columns in place and the others untouched, the
same bits on every rank and over 100 graph replays; a stalled rank's step raises on all 8; setup and alignment
faults agree on all 8; after_step 36 us CPU with the step's GPU work still running (49 of 50 steps), 12.8 us on
the step's stream; 0.5-0.8 us a layer over the head's kernel at M >= 40.

* fix(plugins/vllm): Kimi-K3 attention-residual kernels zero their claim counter in the call, mask with -inf, mix without overflow

In the 12 kernel sources the review found (94 schemas, re-rendered and unmeasured):
- the claim counter is torch.zeros in the call, only where a token past the statically assigned ones can be
  claimed; the rows5 split zeroes its slots' 8-byte tags and reads a partial only under its tag;
- masked lanes score -inf;
- the exponentials are scaled by 2**-4 (exact) instead of left unnormalized, so the mix and its sum of squares
  never exceed the normalized ones; outputs match the previous kernels bit for bit wherever their mix did not
  overflow.

On MI355X: 1348 checks of the review's inputs (claims under a poisoned allocator, 20 eager calls and 20 graph
replays; rows scoring -3.35e38; rows of 2**57) and 50 gfx950 cases pass. Paired with the head's kernels over 120
workloads, graph mode: geomean 0.998, the same bits; the rows5 split at 513-560 tokens is 1.14-1.16x for its
per-call zeroing.

* fix(plugins/vllm): the latent-MoE tail serves vLLM 0.34.0's unpadded calls, whose trunc_size is the hidden width

vLLM 0.34.0 passes a latent MoE with shared experts the shared experts' width as the tail's trunc_size, padded or
not, and keeps states[..., :trunc_size]. The route took any trunc_size as a padded hidden dim, so on Kimi-K3 it
declined every call (seen serving the AgentX recipe on 8 MI355X). Only a size below the hidden width strips columns
now; the test that called HIDDEN padded uses a real truncation, and a new one has None and HIDDEN reach the
dispatcher.

* refactor(plugins/vllm): the latent-MoE tail, KDA stage C and fp8 attention residual on #322's references, baselines and bounds

- [email protected]: KimiK3LatentMoeTailReference (a DistOpReference, every rank's call
  and the rank) and KimiK3LatentMoeTailBaseline (a DistOpBaseline); group.py goes, its peer memory
  set up by the baseline's setup over the default group. No teardown: the buffers live until the
  process ends, as in vLLM, since a rank cannot free its buffer before its peers stop writing to it
  without a collective that a peer stopped at a finding would never join.
- [email protected]: KimiK3KdaSpecStageCReference and KimiK3KdaSpecStageCBaseline on the
  call's keywords; L2_NORM_EPS moves to the reference, which alone reads it. max_violation_fraction
  goes: on MI355X (11-23, before the reference rounded its out) the committed kernel's state_cache
  peaked at 0.19 of its bound and out at 0.34, no element past either.
- The references return their outputs in the declared dtypes, so the bf16 and fp8 outputs' bounds
  add one rounding of the output's dtype (2**-7, 2**-3), as #322 did for the bounds that relied on
  the compare's own allowance: the latent-MoE tail's out and shared, stage C's out and
  kimi_k3_attn_res_fp8's quantized. Float32 and exact bounds are unchanged.
- The tests call the classes and read check()'s failures.
- The 126 schema files of these contracts and of gemm drop max_violation_fraction and
  element_order, rendered by schema_text; their kernels and workloads are unchanged.

* refactor(plugins/vllm): the latent-MoE tail's kernels import their runtime from aklr.core.jit (SA5)

SA5 lets a kernel import nothing of aklr but aklr.core.jit; the tail's kernel.py and
kernel_small.py imported the plugin's runtime module, the per-rank state they run with
(the peer buffers, launch counters and health words) and its constants. The module moves,
unchanged but for one thing, to aklr/core/jit/kimi_k3_latent_moe_tail.py, and the kernels'
one import line follows; the schema file takes its new uuid. The kernels' code and the
workloads are as they were.

The one thing: setup no longer adds the fail-stop watch to the vLLM plugin's AFTER_STEP
(core imports no plugin); the route adds it once its group is set up, as setup did there.

* revert(plugins/vllm): KDA stage C and its fast key change leave this PR

[email protected] is a route without end-to-end evidence: its one schema
holds windows of 5 tokens, and the deployment verifies windows of 8, so the route never
served a step there. Its contract, reference, baseline, route, schema, tests, small
Point and names go, with the AKLR_VLLM_KDA_STAGE_C switch.

The fast key's storage-extent and page-grid overlap tests were added for stage C's
interleaved Mamba pages; they go with it, and aklr/core/contract/fastkey and its test
are main's again. The latent-MoE tail and the attention residual pass their tests
without them.

* refactor(plugins/vllm): the latent-MoE tail's group state lives in its kernel's sources, not in aklr/core

The per-rank state the tail kernel runs with (the peer buffers every rank maps, the launch
counters, the health words and their setup) was aklr/core/jit/kimi_k3_latent_moe_tail.py, one
op's code in the core. It is now runtime.py of the kernel's own sources, as mega_moe keeps its
buffers in its sources, and the kernels import it relatively (SA5):

- The vLLM route sets the group up through the module of the kernel the dispatcher serves the
  call with (api.serving's metadata names the kernel's module; runtime is a module of its
  package), over vLLM's TP group, before that kernel's first call. Where no caller set one up
  (validation's ranks), the kernel's first call sets it up over torch.distributed's default
  group, in a compile function (runtime.default_group). The CPU barrier after a build's first,
  compiling launch is a compile function too (runtime.every_rank_compiled).
- The fail-stop watch, the vLLM plugin's step hook, is the plugin's (failstop.py); it copies
  the group's FAILED word with the runtime's HIP calls. TailGroup keeps only what launches read;
  its unused failed, clear_failed, given_up_waits and close go, with Hip.zero.
- The baseline sets nothing up: vLLM's tail sets its TP group up at its first call.

The route:
- Shapes, dtypes, layouts and the TP size are the op's to judge: the route no longer checks
  them against 8 / 7168 / 3584, and hands vLLM's TP size over. It declines before the
  dispatcher only what vLLM's tail computes otherwise (padded columns stripped, a reduced
  routed output, no latent norm, pipeline stages) and, new, a skipped final all-reduce
  (moe_config.skip_final_all_reduce). Row counts past every committed schema's go back before
  the dispatcher's verdict, which costs a collective at each new count.
- AKLR_VLLM_MOE_TAIL and AKLR_VLLM_MOE_TAIL_CHECK go: [email protected]
  hands every call to vLLM; the first eager call of a row bucket is always checked.
- versions: 0.34.0, the release it was run on.

The kernel's sources otherwise: run_traced (no caller) goes, run returns nothing, the entry
docstring holds no measurement or commit, and requires FlyDSL >= 0.4.2, the version it was
developed and run on. The kernels' device code is unchanged.

* fix(plugins/vllm): the latent-MoE tail's contract states the op, not the kernel; common SQNR bounds

- tp_size takes 2 and 4 too: vLLM runs the tail at any TP size that divides the hidden width.
  latent_size % tp_size goes: vLLM requires no such split; the kernel's own is its schema's.
- out and shared take the GEMM's common bf16 bound (45 dB). The tolerance's absolute part held
  only for partials below 16 in magnitude, the workloads' draws: where a rank's own column cancels
  in the sum over ranks, the kernel's one rounding against vLLM's two (out), or a normalized
  latent rounded apart at a tie (shared), shows in full. The CPU model of the committed kernel's
  layout is at 55 dB (out) and 83 dB or more (shared) from 1 to 128 rows.

* fix(gemm): Kimi-K3's n 2112 / 6288 kernel zeroes the scratch words a launch compares with its tag

The kernel's split launches (tiled.py's two-way K split, which serves its m 600 and 1030
workloads, kernel.py's split-K and skw.py's folds) tell which split folds by comparing scratch
words with the launch's tag (dispatch id and queue), and the call handed them torch.empty
scratch: a word an earlier tensor left there could hold the tag, and a split would fold before
the others wrote their planes. As the attention residual's kernels now do, the call zeroes those
words (aklr/ops/README.md: scratch is written before it is read): the tiles' fold counters after
the partial planes (_scratch; the builders report where they start), and skw.py's scratch whole.
The planes, which every launch writes before it reads them, are not zeroed. The device code is
unchanged; each call with split scratch runs one small fill before the launch.

The schemas require FlyDSL 0.4.2, the version the kernel is run on.

* fix(plugins/vllm): the rows5 attention residual's split build takes the mix's sum of squares from the mix

Past 512 tokens the rows5 kernel spreads each leftover token over 14 column shares, which
exchanged the rows' dots, sums of squares and cross products and took the mix's sum of squares
from those Gram partials, sum w_r^2 |x_r|^2 + 2 sum w_r w_s x_r.x_s. Where rows cancel the terms
are far larger than the result: in a float32 model of the merge, bank rows x and -x at 1024
times the others put 7140 of 7168 columns past the contract's bound, and at 4096 the sum is
negative and the out NaN (the reference, vLLM and the other kernels sum the mix's squares).

The shares now exchange twice: the dots and sums of squares (the scores; the cross products go),
then each share's sum of squares of its own columns of the mix, summed over the token's shares
in slot order; a partner late on either is recomputed from its rows, and p is stored into the
prefix only after both exchanges. The call zeroes both tags of a slot. The float32 model of the
new merge passes the bound at every ratio up to 2**20; a gfx950 test runs the committed kernel at
its split workloads (520, 550) on such rows. The second exchange lengthens the share wave's merge,
which the token waves' second barrier waits for: the split workloads are expected somewhat slower.

* fix(plugins/vllm): the Kimi-K3 attention residual's fp8 bound, overflow-safe reference, export and requires

- kimi_k3_attn_res_fp8's quantized bound is one fp8 code again (2**-3 of the value, 2**-9 below
  the normals): both sides are fp8 values, so the output's own rounding adds nothing.
- The reference takes each mean square of a row scaled down by a power of two first: rows near
  2**58 with a norm passed float32 in their squares and gave 0 where the normalized mix is the norm
  weight. Its results elsewhere are bit for bit the former ones.
- The package exports kimi_k3_attn_res_fp8; the baseline's copy of vLLM's launcher is checked
  against vLLM's in fp8 too (gfx950).
- The contract no longer comments on how a kernel or dispatch serves its tokens.
- One schema of the rows5 kernel goes: it repeated another file's kernel at a subset of its
  workloads.
- The 117 schemas this PR adds require FlyDSL 0.4.2, the version their kernels were developed and
  run on.

* test(plugins/vllm): the latent-MoE tail's committed kernel on 8 gfx950 GPUs

The GPU checks of the tail, run on 8 MI355X by hand so far, as gfx950 tests that spawn 8 ranks of
one torch.distributed group (skipped on fewer than 8 GPUs):

- the kernel computes the op on every rank, at every row count of both builds: the same bits on
  every rank, out and the shared partial's own columns within their bounds of the reference, the
  other columns untouched, 100 graph replays the eager bits, no wait given up; its first call sets
  its group up over the default group, as validation's ranks do;
- through the route and the committed schema every rank serves, and the group the route set up
  through the serving kernel's runtime is the one the kernel reads (the kernel set none up), with
  the fail-stop watching it;
- a rank late past the kernel's (2 s) wait: every rank finishes, the step's output and the next's
  raise on every rank, through the plugin's step hooks and the group word the kernel wrote; late
  below it, the exact out, the output handed over;
- HIP's allocation, export or mapping failing on one rank: setup is None on every rank, nothing
  left, a clean setup after;
- one rank's operand off alignment or aliased, or its dispatcher without the schema: the group
  serves (or declines) together.

* docs(vllm): the plugin tutorial's fp8 output is kimi_k3_attn_res_fp8's; an op whose ranks call it together

The tutorial said the attention residual's fp8 output was in no contract and _triton.py had no fp8
launcher; this PR adds both. A section on the latent-MoE tail states the rules of an op whose ranks
call it together: the same path on every rank, the kernel's state in its own sources set up by
the route (or by its first call over the default group), the in-kernel 10 s wait that fails the
group, the plugin's AFTER_STEP step watch that stops the step, and AKLR_DISABLE to turn it off.

* test(plugins/vllm): the tail's setup-failure test measures what a failed setup leaves, not the process's first tensors

On 8 MI355X the mapping case failed on every run: it is the first case that gets as far as the group's tensors, and a
process's first GPU tensors cost it 2 MiB of the device once (measured per rank: 2.0 MiB on the 7 ranks that mapped,
at the first such case only; 0 at every later one, mapping failures included). The test makes such tensors before it
measures, and the ranks meet at a CPU collective between the release and the measurement, as a peer that still maps a
rank's buffer keeps its memory.

* fix(plugins/vllm): the latent-MoE tail's baseline sets vLLM's TP group up where its sockets' paths fit

CI's vllm-test aborted the tail's schema: every workload's baseline failed with "ZMQError: ipc path ... is longer
than ...". vLLM's TP group binds its message queue's ZMQ sockets at <VLLM_RPC_BASE_PATH>/<uuid4>, the base by default
the temp directory, and validation gives each task a TMPDIR nested deep enough that the path passes the 107 bytes a
Unix socket path holds. The baseline now sets the group up with VLLM_RPC_BASE_PATH at /tmp (vLLM's default without
TMPDIR) where the temp directory is too long, keeps a base the caller set, and puts the variable back afterwards. A
CPU test sets up a stand-in vLLM under validation's nested TMPDIR, a short one, and a preset base; it fails without
the fix.

* docs(tests): the attention residual's scratch test names aklr/plugins/aiter's README, where #327 moved it

* fix(plugins/vllm): the latent-MoE tail's baseline times its graphs inside vLLM's graph_capture

vLLM's TP all-reduce (aiter's custom all-reduce on ROCm) registers the
buffers a CUDA graph reads as vLLM's graph_capture ends, after the capture
and before any replay. The bench captured the baseline's graph outside it
and replayed it at once, so the replays read unregistered peer addresses:
a GPU memory fault at a null address on all 8 ranks, every workload
candidate_crash in CI's vllm-test. The baseline's profile (the candidate's
clock too) now captures each graph inside graph_capture, on the timing's own
stream; its eager calls stay outside, and with no vLLM TP group yet nothing
changes.

* perf(plugins/vllm): the latent-MoE tail's workloads are the rows it wins at in serving, 6 to 14

validate times the kernel alone, and there it is 1.5 to 4.3 times vLLM's tail at every row count to 128. A served
decode step says otherwise past a few rows. Kimi-K3 on 8 MI355X, vLLM 0.34.0, the daily 8K/1K flow, CUDA graphs
replayed on the eight ranks, each step timed alone, AKLR on with the tail served against the tail left to vLLM:

  rows of the step      6      10     16     20     30     40     80
  step, tail served   16.82  17.39    -    21.53  24.45  26.57  34.08 ms
  step, tail vLLM's   16.56  18.04    -    21.02  22.93  25.41  33.18 ms
  the kernel saves    -0.26  +0.65  -0.15  -0.51  -1.52  -1.16  -0.90 ms

(two servers, one prompt a concurrency: about 0.5 ms of resolution). vLLM's two all-reduces, its norm and its addmm
are not slow when eight ranks step together, and the waits of the kernel's hand-offs outweigh the launches it
saves; the kernel's own time shows none of that.

The schema, the same kernel in one file, now holds 6, 8, 10, 12 and 14 rows: the even graph sizes around the one
where the step gains, all in the kernel's small launch (under 28 rows); 8, 12 and 14 were not timed in serving on
their own. The route's guard is the largest committed row count, so it follows to 14. The tests that drove the
route at 15 to 40 rows use rows up to 14.

* fix(plugins/vllm): the latent-MoE tail's contract names out_dtype as its output's dtype param

Since #352 a contract's api takes an out_dtype only where an output's dtype names it; the tail's route and
kernel take one, so its contract names it (the kernel and its schema file are unchanged).

* test(plugins/vllm): the tail's graph-capture test stands in for the timing module

It imported aklr.core.utils.testing inside the test. Importing that module registers AKLR's profiler with
rocprofiler-sdk, which the vLLM image's SDK refuses once the GPU is up: in vllm-test, where the tests before it
have used the GPU, both cases failed on the import (8 MI355X, tests/plugins/vllm in one process). The test only
needs the two names the baseline reads, which it replaced anyway: it now puts a module holding them in
sys.modules and on aklr.core.utils (the baseline's 'from aklr.core.utils import testing' reads the package's
attribute first), and both are put back afterwards.

* test(plugins/vllm): the tail's route tests ask for the row counts its schema holds

Two of the 8-GPU tests went through the route at 1 to 128 rows, and at 10 and 40. Since the schema kept the
rows the kernel wins at in serving (6 to 14), the route serves no other count, and both failed on a GPU
(served: False at the others). They now ask for the schema's own counts; the test of the kernel itself keeps
1 to 128 rows.

* test(plugins/aiter): the K3 GEMM kernel test tells its kernel by the scratch it hands out, not by sizes

The test picked, in gemm_n2112_k7168 and gemm_n6288_k7168, the schema files with skw.py whose smallest m is past
128 rows, to leave out main's sibling kernel (skw.py too, small m, no _scratch). A schema may hold any m: a file
giving the sibling larger sizes (#276 adds one at 148 to 380 rows) was taken for the K3 kernel and failed on
_scratch. It now picks the files whose sources define _scratch, which is what it tests.

---------

Co-authored-by: kyle-256 <[email protected]>
kyle-256 added a commit that referenced this pull request Dec 1, 2026
…oE prefill on MXFP8, sparse MLA prefill, the MoE front and decode GEMMs

Kimi-K3.1-Pro's InferenceX sglang image (lmsysorg/sglang:dev-kimi-k31-pro-mi35x, 0.5.24.dev809) runs its own gfx950
kernels where AKLR had no op, and new decode GEMM shapes. Every route below is declared for 0.5.24.dev809 only; none is
on an aiter function.

- [email protected]: from 2048 tokens the row-sharded front hands sglang's JIT A8W4 experts (k3_a8w4_moe)
  input already in MXFP8. Baseline: AKLR's copy of sglang de0f491836's gate-up, down and reduce kernels
  (_k3_a8w4_gfx950.hip), so CI's sglang 0.5.23 runs it. The kernel keeps stage 2's per-route rows as MXFP6 (e2m3)
  before the top-k sum, as #329 does for Kimi-K3: its out holds main's 20 dB (MOE_MXFP8_SNR).
- [email protected]: sglang's sparse_mla_prefill_gfx950 on the 656-byte fp8_ds_mla rows; baseline
  AKLR's copy of that kernel. The rows are drawn by a new fp8_ds_mla_rows distribution (aklr/core semantics; a new
  kind only, no existing schema changes).
- [email protected]: the latent MoE's fp32 front (6016 x 7168) where sglang's _k3_bf16_gemm runs torch.mm,
  the baseline; not routed to [email protected] (#322).
- [email protected]: 6144 x 7168 (KDA in_proj) and 7168 x 3584 (latent up_proj) at decode, through the aiter provider.
- [email protected] on _forward_fused_hip with an fp32 front (front_fp32), fused_moe's 'interleave' gate mode
  mapped as 'separated' with a schema at K3.1's decode counts, the KDA prefill route declared for 0.5.24.dev809.

Each kernel serves the token counts its schema lists: no range dispatch (#276's is not taken). The decode counts are
those a recorded daily 8K/1K run (InferenceX's concurrency-48 recipe, AKLR_EXPORT) reached: 5-256 (fused_moe 50-256,
the MoE front 130-240, 7168 x 3584 35-120); prefill keeps its listed counts, as sglang mixes decode tokens into each
prefill batch and no two batches had the same count. Workloads carry no measurements; CI writes them.
kyle-256 added a commit that referenced this pull request Dec 1, 2026
…oE prefill on MXFP8, sparse MLA prefill, the MoE front and decode GEMMs

Kimi-K3.1-Pro's InferenceX sglang image (lmsysorg/sglang:dev-kimi-k31-pro-mi35x, 0.5.24.dev809) runs its own gfx950
kernels where AKLR had no op, and new decode GEMM shapes. Every route below is declared for 0.5.24.dev809 only; none is
on an aiter function.

- [email protected]: from 2048 tokens the row-sharded front hands sglang's JIT A8W4 experts (k3_a8w4_moe)
  input already in MXFP8. Baseline: AKLR's copy of sglang de0f491836's gate-up, down and reduce kernels
  (_k3_a8w4_gfx950.hip), so CI's sglang 0.5.23 runs it. The kernel keeps stage 2's per-route rows as MXFP6 (e2m3)
  before the top-k sum, as #329 does for Kimi-K3: its out holds main's 20 dB (MOE_MXFP8_SNR).
- [email protected]: sglang's sparse_mla_prefill_gfx950 on the 656-byte fp8_ds_mla rows; baseline
  AKLR's copy of that kernel. The rows are drawn by a new fp8_ds_mla_rows distribution (aklr/core semantics; a new
  kind only, no existing schema changes).
- [email protected]: the latent MoE's fp32 front (6016 x 7168) where sglang's _k3_bf16_gemm runs torch.mm,
  the baseline; not routed to [email protected] (#322).
- [email protected]: 6144 x 7168 (KDA in_proj) and 7168 x 3584 (latent up_proj) at decode, through the aiter provider.
- [email protected] on _forward_fused_hip with an fp32 front (front_fp32), fused_moe's 'interleave' gate mode
  mapped as 'separated' with a schema at K3.1's decode counts, the KDA prefill route declared for 0.5.24.dev809.

Each kernel serves the token counts its schema lists: no range dispatch (#276's is not taken). The decode counts are
those a recorded daily 8K/1K run (InferenceX's concurrency-48 recipe, AKLR_EXPORT) reached: 5-256 (fused_moe 50-256,
the MoE front 130-240, 7168 x 3584 35-120); prefill keeps its listed counts, as sglang mixes decode tokens into each
prefill batch and no two batches had the same count. Workloads carry no measurements; CI writes them.
zhenhuang12 pushed a commit that referenced this pull request Dec 1, 2026
…oE prefill on MXFP8, sparse MLA prefill, the MoE front and decode GEMMs

Kimi-K3.1-Pro's InferenceX sglang image (lmsysorg/sglang:dev-kimi-k31-pro-mi35x, 0.5.24.dev809) runs its own gfx950
kernels where AKLR had no op, and new decode GEMM shapes. Every route below is declared for 0.5.24.dev809 only; none is
on an aiter function.

- [email protected]: from 2048 tokens the row-sharded front hands sglang's JIT A8W4 experts (k3_a8w4_moe)
  input already in MXFP8. Baseline: AKLR's copy of sglang de0f491836's gate-up, down and reduce kernels
  (_k3_a8w4_gfx950.hip), so CI's sglang 0.5.23 runs it. The kernel keeps stage 2's per-route rows as MXFP6 (e2m3)
  before the top-k sum, as #329 does for Kimi-K3: its out holds main's 20 dB (MOE_MXFP8_SNR).
- [email protected]: sglang's sparse_mla_prefill_gfx950 on the 656-byte fp8_ds_mla rows; baseline
  AKLR's copy of that kernel. The rows are drawn by a new fp8_ds_mla_rows distribution (aklr/core semantics; a new
  kind only, no existing schema changes).
- [email protected]: the latent MoE's fp32 front (6016 x 7168) where sglang's _k3_bf16_gemm runs torch.mm,
  the baseline; not routed to [email protected] (#322).
- [email protected]: 6144 x 7168 (KDA in_proj) and 7168 x 3584 (latent up_proj) at decode, through the aiter provider.
- [email protected] on _forward_fused_hip with an fp32 front (front_fp32), fused_moe's 'interleave' gate mode
  mapped as 'separated' with a schema at K3.1's decode counts, the KDA prefill route declared for 0.5.24.dev809.

Each kernel serves the token counts its schema lists: no range dispatch (#276's is not taken). The decode counts are
those a recorded daily 8K/1K run (InferenceX's concurrency-48 recipe, AKLR_EXPORT) reached: 5-256 (fused_moe 50-256,
the MoE front 130-240, 7168 x 3584 35-120); prefill keeps its listed counts, as sglang mixes decode tokens into each
prefill batch and no two batches had the same count. Workloads carry no measurements; CI writes them.
kyle-256 added a commit that referenced this pull request Dec 1, 2026
…oE prefill on MXFP8, sparse MLA prefill, the MoE front and decode GEMMs

Kimi-K3.1-Pro's InferenceX sglang image (lmsysorg/sglang:dev-kimi-k31-pro-mi35x, 0.5.24.dev809) runs its own gfx950
kernels where AKLR had no op, and new decode GEMM shapes. Every route below is declared for 0.5.24.dev809 only; none is
on an aiter function.

- [email protected]: from 2048 tokens the row-sharded front hands sglang's JIT A8W4 experts (k3_a8w4_moe)
  input already in MXFP8. Baseline: AKLR's copy of sglang de0f491836's gate-up, down and reduce kernels
  (_k3_a8w4_gfx950.hip), so CI's sglang 0.5.23 runs it. The kernel keeps stage 2's per-route rows as MXFP6 (e2m3)
  before the top-k sum, as #329 does for Kimi-K3: its out holds main's 20 dB (MOE_MXFP8_SNR).
- [email protected]: sglang's sparse_mla_prefill_gfx950 on the 656-byte fp8_ds_mla rows; baseline
  AKLR's copy of that kernel. The rows are drawn by a new fp8_ds_mla_rows distribution (aklr/core semantics; a new
  kind only, no existing schema changes).
- [email protected]: the latent MoE's fp32 front (6016 x 7168) where sglang's _k3_bf16_gemm runs torch.mm,
  the baseline; not routed to [email protected] (#322).
- [email protected]: 6144 x 7168 (KDA in_proj) and 7168 x 3584 (latent up_proj) at decode, through the aiter provider.
- [email protected] on _forward_fused_hip with an fp32 front (front_fp32), fused_moe's 'interleave' gate mode
  mapped as 'separated' with a schema at K3.1's decode counts, the KDA prefill route declared for 0.5.24.dev809.

Each kernel serves the token counts its schema lists: no range dispatch (#276's is not taken). The decode counts are
those a recorded daily 8K/1K run (InferenceX's concurrency-48 recipe, AKLR_EXPORT) reached: 5-256 (fused_moe 50-256,
the MoE front 130-240, 7168 x 3584 35-120); prefill keeps its listed counts, as sglang mixes decode tokens into each
prefill batch and no two batches had the same count. Workloads carry no measurements; CI writes them.
kyle-256 added a commit that referenced this pull request Dec 1, 2026
…oE prefill on MXFP8, sparse MLA prefill, the MoE front and decode GEMMs

Kimi-K3.1-Pro's InferenceX sglang image (lmsysorg/sglang:dev-kimi-k31-pro-mi35x, 0.5.24.dev809) runs its own gfx950
kernels where AKLR had no op, and new decode GEMM shapes. Every route below is declared for 0.5.24.dev809 only; none is
on an aiter function.

- [email protected]: from 2048 tokens the row-sharded front hands sglang's JIT A8W4 experts (k3_a8w4_moe)
  input already in MXFP8. Baseline: AKLR's copy of sglang de0f491836's gate-up, down and reduce kernels
  (_k3_a8w4_gfx950.hip), so CI's sglang 0.5.23 runs it. The kernel keeps stage 2's per-route rows as MXFP6 (e2m3)
  before the top-k sum, as #329 does for Kimi-K3: its out holds main's 20 dB (MOE_MXFP8_SNR).
- [email protected]: sglang's sparse_mla_prefill_gfx950 on the 656-byte fp8_ds_mla rows; baseline
  AKLR's copy of that kernel. The rows are drawn by a new fp8_ds_mla_rows distribution (aklr/core semantics; a new
  kind only, no existing schema changes).
- [email protected]: the latent MoE's fp32 front (6016 x 7168) where sglang's _k3_bf16_gemm runs torch.mm,
  the baseline; not routed to [email protected] (#322).
- [email protected]: 6144 x 7168 (KDA in_proj) and 7168 x 3584 (latent up_proj) at decode, through the aiter provider.
- [email protected] on _forward_fused_hip with an fp32 front (front_fp32), fused_moe's 'interleave' gate mode
  mapped as 'separated' with a schema at K3.1's decode counts, the KDA prefill route declared for 0.5.24.dev809.

Each kernel serves the token counts its schema lists: no range dispatch (#276's is not taken). The decode counts are
those a recorded daily 8K/1K run (InferenceX's concurrency-48 recipe, AKLR_EXPORT) reached: 5-256 (fused_moe 50-256,
the MoE front 130-240, 7168 x 3584 35-120); prefill keeps its listed counts, as sglang mixes decode tokens into each
prefill batch and no two batches had the same count. Workloads carry no measurements; CI writes them.
kyle-256 added a commit that referenced this pull request Dec 1, 2026
…oE prefill on MXFP8, sparse MLA prefill, the MoE front and decode GEMMs

Kimi-K3.1-Pro's InferenceX sglang image (lmsysorg/sglang:dev-kimi-k31-pro-mi35x, 0.5.24.dev809) runs its own gfx950
kernels where AKLR had no op, and new decode GEMM shapes. Every route below is declared for 0.5.24.dev809 only; none is
on an aiter function.

- [email protected]: from 2048 tokens the row-sharded front hands sglang's JIT A8W4 experts (k3_a8w4_moe)
  input already in MXFP8. Baseline: AKLR's copy of sglang de0f491836's gate-up, down and reduce kernels
  (_k3_a8w4_gfx950.hip), so CI's sglang 0.5.23 runs it. The kernel keeps stage 2's per-route rows as MXFP6 (e2m3)
  before the top-k sum, as #329 does for Kimi-K3: its out holds main's 20 dB (MOE_MXFP8_SNR).
- [email protected]: sglang's sparse_mla_prefill_gfx950 on the 656-byte fp8_ds_mla rows; baseline
  AKLR's copy of that kernel. The rows are drawn by a new fp8_ds_mla_rows distribution (aklr/core semantics; a new
  kind only, no existing schema changes).
- [email protected]: the latent MoE's fp32 front (6016 x 7168) where sglang's _k3_bf16_gemm runs torch.mm,
  the baseline; not routed to [email protected] (#322).
- [email protected]: 6144 x 7168 (KDA in_proj) and 7168 x 3584 (latent up_proj) at decode, through the aiter provider.
- [email protected] on _forward_fused_hip with an fp32 front (front_fp32), fused_moe's 'interleave' gate mode
  mapped as 'separated' with a schema at K3.1's decode counts, the KDA prefill route declared for 0.5.24.dev809.

Each kernel serves the token counts its schema lists: no range dispatch (#276's is not taken). The decode counts are
those a recorded daily 8K/1K run (InferenceX's concurrency-48 recipe, AKLR_EXPORT) reached: 5-256 (fused_moe 50-256,
the MoE front 130-240, 7168 x 3584 35-120); prefill keeps its listed counts, as sglang mixes decode tokens into each
prefill batch and no two batches had the same count. Workloads carry no measurements; CI writes them.
kyle-256 added a commit that referenced this pull request Dec 2, 2026
…oE prefill on MXFP8, sparse MLA prefill, the MoE front and decode GEMMs

Kimi-K3.1-Pro's InferenceX sglang image (lmsysorg/sglang:dev-kimi-k31-pro-mi35x, 0.5.24.dev809) runs its own gfx950
kernels where AKLR had no op, and new decode GEMM shapes. Every route below is declared for 0.5.24.dev809 only; none is
on an aiter function.

- [email protected]: from 2048 tokens the row-sharded front hands sglang's JIT A8W4 experts (k3_a8w4_moe)
  input already in MXFP8. Baseline: AKLR's copy of sglang de0f491836's gate-up, down and reduce kernels
  (_k3_a8w4_gfx950.hip), so CI's sglang 0.5.23 runs it. The kernel keeps stage 2's per-route rows as MXFP6 (e2m3)
  before the top-k sum, as #329 does for Kimi-K3: its out holds main's 20 dB (MOE_MXFP8_SNR).
- [email protected]: sglang's sparse_mla_prefill_gfx950 on the 656-byte fp8_ds_mla rows; baseline
  AKLR's copy of that kernel. The rows are drawn by a new fp8_ds_mla_rows distribution (aklr/core semantics; a new
  kind only, no existing schema changes).
- [email protected]: the latent MoE's fp32 front (6016 x 7168) where sglang's _k3_bf16_gemm runs torch.mm,
  the baseline; not routed to [email protected] (#322).
- [email protected]: 6144 x 7168 (KDA in_proj) and 7168 x 3584 (latent up_proj) at decode, through the aiter provider.
- [email protected] on _forward_fused_hip with an fp32 front (front_fp32), fused_moe's 'interleave' gate mode
  mapped as 'separated' with a schema at K3.1's decode counts, the KDA prefill route declared for 0.5.24.dev809.

Each kernel serves the token counts its schema lists: no range dispatch (#276's is not taken). The decode counts are
those a recorded daily 8K/1K run (InferenceX's concurrency-48 recipe, AKLR_EXPORT) reached: 5-256 (fused_moe 50-256,
the MoE front 130-240, 7168 x 3584 35-120); prefill keeps its listed counts, as sglang mixes decode tokens into each
prefill batch and no two batches had the same count. Workloads carry no measurements; CI writes them.
kyle-256 added a commit that referenced this pull request Dec 2, 2026
…oE prefill on MXFP8, sparse MLA prefill, the MoE front and decode GEMMs

Kimi-K3.1-Pro's InferenceX sglang image (lmsysorg/sglang:dev-kimi-k31-pro-mi35x, 0.5.24.dev809) runs its own gfx950
kernels where AKLR had no op, and new decode GEMM shapes. Every route below is declared for 0.5.24.dev809 only; none is
on an aiter function.

- [email protected]: from 2048 tokens the row-sharded front hands sglang's JIT A8W4 experts (k3_a8w4_moe)
  input already in MXFP8. Baseline: AKLR's copy of sglang de0f491836's gate-up, down and reduce kernels
  (_k3_a8w4_gfx950.hip), so CI's sglang 0.5.23 runs it. The kernel keeps stage 2's per-route rows as MXFP6 (e2m3)
  before the top-k sum, as #329 does for Kimi-K3: its out holds main's 20 dB (MOE_MXFP8_SNR).
- [email protected]: sglang's sparse_mla_prefill_gfx950 on the 656-byte fp8_ds_mla rows; baseline
  AKLR's copy of that kernel. The rows are drawn by a new fp8_ds_mla_rows distribution (aklr/core semantics; a new
  kind only, no existing schema changes).
- [email protected]: the latent MoE's fp32 front (6016 x 7168) where sglang's _k3_bf16_gemm runs torch.mm,
  the baseline; not routed to [email protected] (#322).
- [email protected]: 6144 x 7168 (KDA in_proj) and 7168 x 3584 (latent up_proj) at decode, through the aiter provider.
- [email protected] on _forward_fused_hip with an fp32 front (front_fp32), fused_moe's 'interleave' gate mode
  mapped as 'separated' with a schema at K3.1's decode counts, the KDA prefill route declared for 0.5.24.dev809.

Each kernel serves the token counts its schema lists: no range dispatch (#276's is not taken). The decode counts are
those a recorded daily 8K/1K run (InferenceX's concurrency-48 recipe, AKLR_EXPORT) reached: 5-256 (fused_moe 50-256,
the MoE front 130-240, 7168 x 3584 35-120); prefill keeps its listed counts, as sglang mixes decode tokens into each
prefill batch and no two batches had the same count. Workloads carry no measurements; CI writes them.
@kyle-256
kyle-256 deleted the kyle/core-bucketed-dispatch branch December 3, 2026 02:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:gpu ci:priority-high Run the PR's SaFE GPU jobs at high priority (with ci:gpu)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants