Repository navigation
[RFC #7240] Route the three remaining DSV4.1 ops that already have a guard - #7854
Conversation
`per_group_quant_hip`, `mhc_pre` and `mhc_post` are called on the DSV4.1 path by vLLM, SGLang and ATOM, and no provider can serve any of them. All three are ordinary Python implementations that already carry `torch_compile_guard`, so routing underneath it costs nothing: the guard is what Dynamo sees, and the plugin's dispatch never reaches a caller's compiled graph. They need neither #7850 nor the eager snapshot to be safe. `per_group_quant` routes on a neutrally named `_per_group_quant_routed` rather than on `per_group_quant_hip`. That was not the first draft -- test_the_backend_suffix_gate_is_not_vacuous rejected it, correctly: a route's contract is the decorated function's whole signature, so decorating a backend-named function writes that name's shape into what providers implement against. `rmsnorm` sits the same way beneath its two public spellings. All three lacked docstrings, which #7787's gate requires of a routed op. Written from the implementations: `mhc_pre` returns three new tensors and writes nothing (matching its `mutates_args=[]`), `mhc_post` writes `out` and returns None (matching `mutates_args=["out"]`), `per_group_quant` returns `(y, scale)` and writes nothing. Public signatures are byte-identical to main for all three, checked by AST. Nineteen contracts, none carrying a backend parameter, none lost. Left out deliberately: `mla_sparse_prefill_v4`, whose `backend is None` branch chooses between asm and opus by arch and shape with a fallback, and whose asm path is gfx1250-only -- not verifiable on the gfx942 box this was written on, and getting it wrong changes which kernel runs. The four bare `@compile_ops` stubs need a wrapper each, and the wrapper would itself be exposed unless it also carries a guard and a fake; those belong with #7850's mechanism, one at a time. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: Reviews: |
WAITING ON AUTHORPR 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 |
#7791 added mla_sparse_prefill. Clean merge; verified rather than assumed: 20 contracts, main's 17 plus this branch's three, none lost, none carrying a backend or kernelName. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
… cannot be shielded
The other two ops this PR routes, `mhc_pre` and `mhc_post`, carry a
`torch_compile_guard` outside their `@route`, so a caller already reaches
an opaque op and the plugin's dispatch cannot enter its graph.
`per_group_quant` does not: the route sits on `_per_group_quant_routed`,
while the guard sits on `per_group_quant_hip`, a different function. A
decorator-order scan therefore cannot see it as shielded, and it passed no
`fake=`, which leaves it in the state that splits a caller's graph the day a
provider is enabled.
The fake reports shapes only. Both results are freshly allocated in the
native body, so neither aliases an argument and `infer_schema` renders
`-> (Tensor, Tensor)` with nothing to declare about aliasing.
`transpose_scale` shuffles the scale's contents inside the kernel without
moving its shape, so it does not appear in the fake.
Verified:
* `infer_schema(native, mutates_args="unknown")` renders a schema.
* Shapes checked on meta tensors against the native body's two branches:
default -> (m, n // group_size); `scale_layout_m32k4` ->
((m + 31) // 32 * 32, n // 32); `transpose_scale` moves neither.
* `tests/test_plugin_contracts.py` passes on this branch (16), and the
contract fingerprint is unchanged -- the contract is taken from the
native signature, which this does not touch, so no op_version bump.
* Merged locally with #7881, whose registration gate reports
`per_group_quant` as unregistered without this commit and passes with
it (18).
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…guard (#7854) * feat(plugin): route the three remaining ops that already have a guard `per_group_quant_hip`, `mhc_pre` and `mhc_post` are called on the DSV4.1 path by vLLM, SGLang and ATOM, and no provider can serve any of them. All three are ordinary Python implementations that already carry `torch_compile_guard`, so routing underneath it costs nothing: the guard is what Dynamo sees, and the plugin's dispatch never reaches a caller's compiled graph. They need neither #7850 nor the eager snapshot to be safe. `per_group_quant` routes on a neutrally named `_per_group_quant_routed` rather than on `per_group_quant_hip`. That was not the first draft -- test_the_backend_suffix_gate_is_not_vacuous rejected it, correctly: a route's contract is the decorated function's whole signature, so decorating a backend-named function writes that name's shape into what providers implement against. `rmsnorm` sits the same way beneath its two public spellings. All three lacked docstrings, which #7787's gate requires of a routed op. Written from the implementations: `mhc_pre` returns three new tensors and writes nothing (matching its `mutates_args=[]`), `mhc_post` writes `out` and returns None (matching `mutates_args=["out"]`), `per_group_quant` returns `(y, scale)` and writes nothing. Public signatures are byte-identical to main for all three, checked by AST. Nineteen contracts, none carrying a backend parameter, none lost. Left out deliberately: `mla_sparse_prefill_v4`, whose `backend is None` branch chooses between asm and opus by arch and shape with a fallback, and whose asm path is gfx1250-only -- not verifiable on the gfx942 box this was written on, and getting it wrong changes which kernel runs. The four bare `@compile_ops` stubs need a wrapper each, and the wrapper would itself be exposed unless it also carries a guard and a fake; those belong with #7850's mechanism, one at a time. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * [OPUS] [Plugin] Register per_group_quant, the one routed op here that cannot be shielded The other two ops this PR routes, `mhc_pre` and `mhc_post`, carry a `torch_compile_guard` outside their `@route`, so a caller already reaches an opaque op and the plugin's dispatch cannot enter its graph. `per_group_quant` does not: the route sits on `_per_group_quant_routed`, while the guard sits on `per_group_quant_hip`, a different function. A decorator-order scan therefore cannot see it as shielded, and it passed no `fake=`, which leaves it in the state that splits a caller's graph the day a provider is enabled. The fake reports shapes only. Both results are freshly allocated in the native body, so neither aliases an argument and `infer_schema` renders `-> (Tensor, Tensor)` with nothing to declare about aliasing. `transpose_scale` shuffles the scale's contents inside the kernel without moving its shape, so it does not appear in the fake. Verified: * `infer_schema(native, mutates_args="unknown")` renders a schema. * Shapes checked on meta tensors against the native body's two branches: default -> (m, n // group_size); `scale_layout_m32k4` -> ((m + 31) // 32 * 32, n // 32); `transpose_scale` moves neither. * `tests/test_plugin_contracts.py` passes on this branch (16), and the contract fingerprint is unchanged -- the contract is taken from the native signature, which this does not touch, so no op_version bump. * Merged locally with #7881, whose registration gate reports `per_group_quant` as unregistered without this commit and passes with it (18). Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> --------- Co-authored-by: zufayu <[email protected]> Co-authored-by: Claude Opus 5 (1M context) <[email protected]> Co-authored-by: root <[email protected]>
… mHC Five ops that the DSA/MLA paths of vLLM and SGLang call had no route, so no provider could serve them. Each is routed where the op begins, below any pin that picks one of AITER's own implementations; every public signature is unchanged (checked by AST against main), except two annotations that said Tensor for a None default. - mla_decode_fwd: on the public entry, its one spelling with no backend pin. The docstring now says what it returns: (logits, lse), where logits is scratch (or a view of o) and the result is o, written in place. - mla_paged_decode: the decode mode of mla_gluon (has_pe=True, no attn_sink), on a new inner layer. The DSv4 sparse prefill mode that AITER itself runs through mla_gluon (pa_prefill_sparse, sparse_attention_dsv4_bwd) is not routed. The op name is neutral: mla_decode_fwd is already the ASM decode's contract with other arguments. - fp8_paged_mqa_logits: on deepgemm_fp8_paged_mqa_logits, also reached through the old aiter.ops.triton.pa_mqa_logits path SGLang imports. It writes out_logits and returns None. - mla_sparse_prefill_v4: on _mla_sparse_prefill_v4_routed, below backend=, as v41 is; the native body keeps the asm-then-opus default. #7854 left it out because a wrong guess there changes which kernel runs on gfx1250, so pa_sparse_prefill_fp8_opus enters the route only where the default picks opus anyway (not gfx1250, no sink, or H != 128); elsewhere it runs opus directly, as before. - mhc_fused_post_pre: on _mhc_fused_post_pre_routed, below backend= and force_fused=, with a fake and mutates_args=[] since the guard sits on the public function. Above the fused bound the native still calls the routed mhc_post and mhc_pre. The first four join _NOT_REGISTERED (out-buffer in the contract, or unannotated). The baseline gains five entries from routed_contracts(); the existing 23 are untouched. tests/test_plugin*.py on a CPU box without a built AITER: 129 passed, 1 skipped (test_plugin_routed_ops.py needs a build).
… mHC Five ops that the DSA/MLA paths of vLLM and SGLang call had no route, so no provider could serve them. Each is routed where the op begins, below any pin that picks one of AITER's own implementations; every public signature is unchanged (checked by AST against main), except two annotations that said Tensor for a None default. - mla_decode_fwd: on the public entry, its one spelling with no backend pin. The docstring now says what it returns: (logits, lse), where logits is scratch (or a view of o) and the result is o, written in place. - mla_paged_decode: the decode mode of mla_gluon (has_pe=True, no attn_sink), on a new inner layer. The DSv4 sparse prefill mode that AITER itself runs through mla_gluon (pa_prefill_sparse, sparse_attention_dsv4_bwd) is not routed. The op name is neutral: mla_decode_fwd is already the ASM decode's contract with other arguments. - fp8_paged_mqa_logits: on deepgemm_fp8_paged_mqa_logits, also reached through the old aiter.ops.triton.pa_mqa_logits path SGLang imports. It writes out_logits and returns None. - mla_sparse_prefill_v4: on _mla_sparse_prefill_v4_routed, below backend=, as v41 is; the native body keeps the asm-then-opus default. #7854 left it out because a wrong guess there changes which kernel runs on gfx1250, so pa_sparse_prefill_fp8_opus enters the route only where the default picks opus anyway (not gfx1250, no sink, or H != 128); elsewhere it runs opus directly, as before. - mhc_fused_post_pre: on _mhc_fused_post_pre_routed, below backend= and force_fused=, with a fake and mutates_args=[] since the guard sits on the public function. Above the fused bound the native still calls the routed mhc_post and mhc_pre. The first four join _NOT_REGISTERED (out-buffer in the contract, or unannotated). The baseline gains five entries from routed_contracts(); the existing 23 are untouched. tests/test_plugin*.py on a CPU box without a built AITER: 129 passed, 1 skipped (test_plugin_routed_ops.py needs a build).
… mHC Five ops that the DSA/MLA paths of vLLM and SGLang call had no route, so no provider could serve them. Each is routed where the op begins, below any pin that picks one of AITER's own implementations; every public signature is unchanged (checked by AST against main), except two annotations that said Tensor for a None default. - mla_decode_fwd: on the public entry, its one spelling with no backend pin. The docstring now says what it returns: (logits, lse), where logits is scratch (or a view of o) and the result is o, written in place. - mla_paged_decode: the decode mode of mla_gluon (has_pe=True, no attn_sink), on a new inner layer. The DSv4 sparse prefill mode that AITER itself runs through mla_gluon (pa_prefill_sparse, sparse_attention_dsv4_bwd) is not routed. The op name is neutral: mla_decode_fwd is already the ASM decode's contract with other arguments. - fp8_paged_mqa_logits: on deepgemm_fp8_paged_mqa_logits, also reached through the old aiter.ops.triton.pa_mqa_logits path SGLang imports. It writes out_logits and returns None. - mla_sparse_prefill_v4: on _mla_sparse_prefill_v4_routed, below backend=, as v41 is; the native body keeps the asm-then-opus default. #7854 left it out because a wrong guess there changes which kernel runs on gfx1250, so pa_sparse_prefill_fp8_opus enters the route only where the default picks opus anyway (not gfx1250, no sink, or H != 128); elsewhere it runs opus directly, as before. - mhc_fused_post_pre: on _mhc_fused_post_pre_routed, below backend= and force_fused=, with a fake and mutates_args=[] since the guard sits on the public function. Above the fused bound the native still calls the routed mhc_post and mhc_pre. The first four join _NOT_REGISTERED (out-buffer in the contract, or unannotated). The baseline gains five entries from routed_contracts(); the existing 23 are untouched. tests/test_plugin*.py on a CPU box without a built AITER: 129 passed, 1 skipped (test_plugin_routed_ops.py needs a build).
… mHC Five ops that the DSA/MLA paths of vLLM and SGLang call had no route, so no provider could serve them. Each is routed where the op begins, below any pin that picks one of AITER's own implementations; every public signature is unchanged (checked by AST against main), except two annotations that said Tensor for a None default. - mla_decode_fwd: on the public entry, its one spelling with no backend pin. The docstring now says what it returns: (logits, lse), where logits is scratch (or a view of o) and the result is o, written in place. - mla_paged_decode: the decode mode of mla_gluon (has_pe=True, no attn_sink), on a new inner layer. The DSv4 sparse prefill mode that AITER itself runs through mla_gluon (pa_prefill_sparse, sparse_attention_dsv4_bwd) is not routed. The op name is neutral: mla_decode_fwd is already the ASM decode's contract with other arguments. - fp8_paged_mqa_logits: on deepgemm_fp8_paged_mqa_logits, also reached through the old aiter.ops.triton.pa_mqa_logits path SGLang imports. It writes out_logits and returns None. - mla_sparse_prefill_v4: on _mla_sparse_prefill_v4_routed, below backend=, as v41 is; the native body keeps the asm-then-opus default. #7854 left it out because a wrong guess there changes which kernel runs on gfx1250, so pa_sparse_prefill_fp8_opus enters the route only where the default picks opus anyway (not gfx1250, no sink, or H != 128); elsewhere it runs opus directly, as before. - mhc_fused_post_pre: on _mhc_fused_post_pre_routed, below backend= and force_fused=, with a fake and mutates_args=[] since the guard sits on the public function. Above the fused bound the native still calls the routed mhc_post and mhc_pre. The first four join _NOT_REGISTERED (out-buffer in the contract, or unannotated). The baseline gains five entries from routed_contracts(); the existing 23 are untouched. tests/test_plugin*.py on a CPU box without a built AITER: 129 passed, 1 skipped (test_plugin_routed_ops.py needs a build).
… mHC Five ops that the DSA/MLA paths of vLLM and SGLang call had no route, so no provider could serve them. Each is routed where the op begins, below any pin that picks one of AITER's own implementations; every public signature is unchanged (checked by AST against main), except two annotations that said Tensor for a None default. - mla_decode_fwd: on the public entry, its one spelling with no backend pin. The docstring now says what it returns: (logits, lse), where logits is scratch (or a view of o) and the result is o, written in place. - mla_paged_decode: the decode mode of mla_gluon (has_pe=True, no attn_sink), on a new inner layer. The DSv4 sparse prefill mode that AITER itself runs through mla_gluon (pa_prefill_sparse, sparse_attention_dsv4_bwd) is not routed. The op name is neutral: mla_decode_fwd is already the ASM decode's contract with other arguments. - fp8_paged_mqa_logits: on deepgemm_fp8_paged_mqa_logits, also reached through the old aiter.ops.triton.pa_mqa_logits path SGLang imports. It writes out_logits and returns None. - mla_sparse_prefill_v4: on _mla_sparse_prefill_v4_routed, below backend=, as v41 is; the native body keeps the asm-then-opus default. #7854 left it out because a wrong guess there changes which kernel runs on gfx1250, so pa_sparse_prefill_fp8_opus enters the route only where the default picks opus anyway (not gfx1250, no sink, or H != 128); elsewhere it runs opus directly, as before. - mhc_fused_post_pre: on _mhc_fused_post_pre_routed, below backend= and force_fused=, with a fake and mutates_args=[] since the guard sits on the public function. Above the fused bound the native still calls the routed mhc_post and mhc_pre. The first four join _NOT_REGISTERED (out-buffer in the contract, or unannotated). The baseline gains five entries from routed_contracts(); the existing 23 are untouched. tests/test_plugin*.py on a CPU box without a built AITER: 129 passed, 1 skipped (test_plugin_routed_ops.py needs a build).
…ernel plugin interface (#8075) * [Triton] Load an old module path as the module at its new path The backward-compatible finder returned the spec of the new path, so the import system ran the module code a second time under the old name. A module that registers a routed op then raised "already routed" on the second import. * [Plugin] Route the 16-bit GEMMs, the Triton blockscale GEMM and MXFP8 1x32 quant Three new contracts, all at version 1, and one more path into per_group_quant. - gemm_a16w16: routed on `_gemm_a16w16`, the layer that `tgemm.mm`, `gemm_a16w16` and `gemm_a16w16_out` all reach. `gemm_a16w16_out` drops the return value, and the native assert that the result is `out` does not run when a provider serves the call, so `gemm_a16w16_out` now checks it. - gemm_a16w16_activation: the Triton `gemm_a16w16`, routed beneath its torch_compile_guard. It has its own name because `gemm_a16w16` is the tuned contract, and this one also applies an activation and can return split-K partials. - gemm_a8w8_blockscale_out: the Triton `gemm_a8w8_blockscale`. It has its own name because `gemm_a8w8_blockscale` is the CK contract, which has no output buffer. Its `dtype` annotation is now `torch.dtype | None`. - Both Triton routes sit below `backend=`: a call that sets it bypasses routing, as `pa_fwd` does, so no contract carries a backend pin. - per_1x32_mx_quant_hip: the fp8 output, e8m0 scale, unshuffled branch calls the routed per_group_quant. The buffers and the kernel call are the same. None of the three new ops passes fake=; _NOT_REGISTERED gives the reasons. Public signatures are unchanged except the annotation above. tests/plugin_contracts.json is regenerated from routed_contracts(). * [Plugin] Route fused_moe and biased_grouped_topk fused_moe routes on fused_moe_, the layer beneath the public fused_moe, with the torch_compile_guard outside the route as mhc_pre has it. The public function keeps its signature, which sglang reads with inspect.signature; its 19 unannotated parameters and the shared-expert branch to FHMoE stay above the route. fused_moe_ is fully annotated and already guarded, so the route needs no fake and the guard registers the same aiter::fused_moe_ schema. The route takes fused_moe_ as main has it, splitk included (#4740 put it between bias2 and swiglu_limit); the docstring says a provider may ignore it, since AITER reads it only to keep its gfx1201 small-M kernel off split calls. Its docstring says what the signature cannot: the result is returned, or written into `output` and that is returned; activation and quant_type arrive as enum values; the ep_* fields are the stage-2 scatter, which P2P-writes the rows to the peers and returns a placeholder; the activation dtype follows M and the environment (AITER_SITUV2_A8W4/A4W4, AITER_BF16_FP8_MOE_BOUND, GPTOSS_SWIGLU_MXFP4_BF16_BOUND); and a sort registered with register_presorted_moe is consumed below the route, so a provider serving a call must pop it or decline, or the next native call runs on a stale sort. aiter's own callers of fused_moe (asm_moe_tkw1, MegaMoE's expert GEMM) reach the same route and run as before while no provider takes them. MegaMoE's other thread-local, the grouped GEMM's dispatch context, is set only together with stage2_scatter, which a provider without the scatter declines. biased_grouped_topk routes on its public name. It gains `-> None`, which infer_schema needs, and a fake as topk_gating has. Every path (HIP, gfx1250 exact, FlyDSL HERD) writes topk_weights and topk_ids and nothing else, so mutates_args says exactly that (#7926). The docstring also records that AITER_FLYDSL_USE_HERD=1 answers one-group calls with HERD routing rather than the exact top-k, which a provider computing the exact top-k must decline. biased_grouped_topk_hip stays unrouted: its name is a backend's. tests/plugin_contracts.json is regenerated with routed_contracts(). Checked on CPU: tests/test_plugin*.py and test_jit_signature.py pass (129; 2 need a built AITER). The two routes, rebuilt from this source with the plugin and torch_guard modules loaded on their own, register (aiter::fused_moe_ under the guard; aiter_routed::biased_grouped_topk with only the two outputs mutable), run natively with no provider, hand an enabled provider 40 and 9 arguments, and compile to one opaque node under fullgraph=True. Not run here: anything that needs a built AITER or a GPU. * [RFC #7240] Route MLA decode, MQA logits, v4 sparse prefill and fused mHC Five ops that the DSA/MLA paths of vLLM and SGLang call had no route, so no provider could serve them. Each is routed where the op begins, below any pin that picks one of AITER's own implementations; every public signature is unchanged (checked by AST against main), except two annotations that said Tensor for a None default. - mla_decode_fwd: on the public entry, its one spelling with no backend pin. The docstring now says what it returns: (logits, lse), where logits is scratch (or a view of o) and the result is o, written in place. - mla_paged_decode: the decode mode of mla_gluon (has_pe=True, no attn_sink), on a new inner layer. The DSv4 sparse prefill mode that AITER itself runs through mla_gluon (pa_prefill_sparse, sparse_attention_dsv4_bwd) is not routed. The op name is neutral: mla_decode_fwd is already the ASM decode's contract with other arguments. - fp8_paged_mqa_logits: on deepgemm_fp8_paged_mqa_logits, also reached through the old aiter.ops.triton.pa_mqa_logits path SGLang imports. It writes out_logits and returns None. - mla_sparse_prefill_v4: on _mla_sparse_prefill_v4_routed, below backend=, as v41 is; the native body keeps the asm-then-opus default. #7854 left it out because a wrong guess there changes which kernel runs on gfx1250, so pa_sparse_prefill_fp8_opus enters the route only where the default picks opus anyway (not gfx1250, no sink, or H != 128); elsewhere it runs opus directly, as before. - mhc_fused_post_pre: on _mhc_fused_post_pre_routed, below backend= and force_fused=, with a fake and mutates_args=[] since the guard sits on the public function. Above the fused bound the native still calls the routed mhc_post and mhc_pre. The first four join _NOT_REGISTERED (out-buffer in the contract, or unannotated). The baseline gains five entries from routed_contracts(); the existing 23 are untouched. tests/test_plugin*.py on a CPU box without a built AITER: 129 passed, 1 skipped (test_plugin_routed_ops.py needs a build). * [Plugin] Test the ten new routes through a provider, and their pins What a provider depends on and the contract gate cannot see. For each new route, a call through the public name callers use (tgemm's gemm_a16w16, the Triton gemm_a16w16 and gemm_a8w8_blockscale, fused_moe, biased_grouped_topk, mla_decode_fwd, mla_gluon in decode mode, deepgemm_fp8_paged_mqa_logits by both module paths, mla_sparse_prefill_v4 and the opus-pinned name, mhc_fused_post_pre, and per_1x32_mx_quant_hip into per_group_quant) reaches an enabled provider, which is handed the whole contract with the caller's value in its place. Each pin -- backend= on the Triton GEMMs and v4 prefill, the opus name where the default tries asm, force_fused= and backend= on mHC, mla_gluon's prefill mode and a sink -- runs AITER's own body and asks no provider; one case per condition. gemm_a16w16_out refuses a provider answer that is not out and takes one written into it. The old Triton path is the module at the new one. The route modules are imported at collection, so the first _reset_for_testing() keeps their ops in plugin._routed_ops. Run without a GPU (HIP_VISIBLE_DEVICES=-1, aiter built from this branch, FlyDSL 0.5.0): the 26 new cases pass. The file's 5 device tests fail there for want of a GPU, as they do on main. * [Plugin] Address the review of the ten routes - mla_paged_decode is registered. The routed layer writes o in place and returns lse alone, so no result aliases an input. A custom op cannot return Optional[Tensor], so with return_lse=False the op returns an empty fp32 tensor. mla_gluon gives (o, lse) or (o, None) as before. - fp8_paged_mqa_logits stays unregistered. Its native body returns the cache key of the compiled Triton kernel, a str, and bench_deepgemm_attention.py reads it. A custom op cannot return a str. The docstring said "returns None"; it now says what the call returns. - The public fused_moe clears a registered presort when the call ends (drop_presort_after). A call that a provider serves returns before _fused_moe_impl consumes the registration, and the next native call on reused routing buffers would use it. - The Triton gemm_a16w16 and gemm_a8w8_blockscale check, as gemm_a16w16_out does, that a routed call given y returns y. The check is by identity, not data_ptr, because gemm_a8w8_blockscale also runs under torch.compile. - mla_decode_fwd: a provider may return o as the first result only with return_logits=False. New tests: mla_gluon returns the lse that the provider gives; fused_moe leaves no presort after a served call; each Triton GEMM refuses a result that is not y and takes one that is. Run without a GPU (HIP_VISIBLE_DEVICES=-1, aiter built from this branch, FlyDSL 0.5.0): tests/test_plugin*.py 168 passed. The 5 failures are device tests that also fail on main without a GPU. * [Plugin] Route Kimi-K3's MLA prefill, fp8 in_proj GEMM and KDA conv and decode Kimi-K3 on MI355X (vLLM 0.32.1 with aiter 0.1.26; SGLang 0.5.22) calls seven AITER functions that no provider could serve because they had no route. Each is routed on the name the frameworks call, with the backend choice beneath it, and the op names carry no backend: - flash_attn_varlen (flash_attn_varlen_func): the MLA prefill of vLLM's ROCM_AITER_FA backend and SGLang's prefix chunks. Its docstring now opens the function (it used to follow the block_table check, so it was not one) and says what a provider returns: out, or out with the lse and S_dmask the flags ask for, written into `out` when one is passed; the forward only, so a call needing grad is declined. - mla_prefill_ps (mla_prefill_ps_asm_fwd) and mla_reduce (mla_reduce_v1): SGLang's fp8 MLA prefill and the merge after it; mla_reduce_v1 is also where AITER's own split-KV MLA decode merges. Both were @compile_ops bindings; the bindings move to private names with fc_name keeping their symbols, and the public names become routed Python functions over them. - gemm_a8w8_bpreshuffle: vLLM's per-token/per-channel fp8 in_proj. The torch_compile_guard stays outside the route, as on fused_moe_. - causal_conv1d_split_qkv (causal_conv1d_split_qkv_triton_tile_fn): KDA's short convolution in vLLM's prefill; it also writes conv_states. - fused_recurrent_kda and fused_recurrent_kda_packed_decode: KDA decode and its speculative form on gfx950. The packed one is routed ahead of the general one, which a provider is asked about again when the packed one runs natively. All seven join _NOT_REGISTERED with their reasons; the baseline gains seven entries from routed_contracts(), the other 33 untouched. Checked on CPU: tests/test_plugin*.py, 164 passed, 1 skipped (test_plugin_routed_ops.py needs a built AITER). * [Test] test_mha_optional_flydsl: compile the parsed function without its decorators The test parses aiter/ops/mha.py, takes one top-level function and execs it in a namespace that holds only an allow-list of names. With this PR flash_attn_varlen_func gains @_route(op="flash_attn_varlen"), and exec then evaluates the decorator expression, where _route is not bound: NameError at mha.py, in both flash_attn_varlen_func parametrisations (flash_attn_func, which has no decorator, kept passing). mha.py itself imports _route at module level, so the shipped code is unaffected. _top_level_node now strips a function's decorators before returning it. What the tests check is the body's dispatch, and a decorator added later cannot break them the same way.
What this covers
per_group_quant_hip,mhc_preandmhc_postare on the DSV4.1 path in all three downstream engines, and no provider can serve any of them today.per_group_quant_hipper_group_quantmhc_premhc_premhc_postmhc_postWhy these three together
All three are ordinary Python implementations that already carry
torch_compile_guard. Routing underneath it costs nothing: the guard is what Dynamo sees, so the plugin's dispatch never reaches a caller's compiled graph. They need neither #7850's registration mechanism nor #7848's eager snapshot to be safe undertorch.compile— they are safe by construction, the waybatched_gemm_a8w8_mxscaleandmla_sparse_prefill_v41already are.That is also why they are one PR rather than three: the change is the same shape in each, and the risk is the same (none to the public signatures).
The gate caught the first draft
per_group_quantroutes on a neutrally named_per_group_quant_routed, withper_group_quant_hipforwarding to it. My first attempt put@route(op="per_group_quant")directly onper_group_quant_hip, andtest_the_backend_suffix_gate_is_not_vacuousrejected it.It was right to. A route's contract is the decorated function's whole signature, so decorating a backend-named function writes that name's shape into what providers implement against — the mechanism by which
kernelNamereachedpa_fwd's contract in #7807, which is where that gate came from.rmsnormsits the same way beneathrms_normandrmsnorm2d_fwd.Docstrings
None of the three had one, which #7787's gate requires of a routed op, output discipline included. Written from the implementations rather than guessed:
mhc_prereturns(post_mix, comb_mix, layer_input), three new tensors, writing nothing through its arguments — consistent with themutates_args=[]its guard already declares;mhc_postreturns nothing and writesoutin place — consistent withmutates_args=["out"];per_group_quantreturns(y, scale)and writes nothing.Each also records the arguments a provider would otherwise have to guess at: the packed-layout flags on
mhc_*, and onper_group_quantthe fact thatscalemust be None and whatscale_layout_m32k4requires.Verification
Public signatures byte-identical to
mainfor all three, checked by AST. Nineteen contracts after this change:main's sixteen plus three, none lost, none carrying abackendorkernelName. Plugin suites pass;blackandruffclean.Deliberately left out
mla_sparse_prefill_v4. It was in the first draft and I took it out after reading the body. Itsbackend is Nonebranch is not a passthrough — it picks between asm and opus by architecture and head count, with atry/except RuntimeErrorfallback, and the asm path is gfx1250-only. Splitting that into a routed layer below the pin is a restructure whose correctness I cannot check on the gfx942 box this was written on, and getting it wrong silently changes which kernel runs. It wants doing where it can be verified.The four bare
@compile_opsstubs (concat_and_cache_mla,fused_qk_rope_concat_and_cache_mla,mla_prefill_ps_asm_fwd,mla_reduce_v1). Each needs a Python wrapper to route at all, and that wrapper would itself be traced unless it also carries a guard and a fake — the problem #7848 and #7850 exist for. They belong with that mechanism, one at a time, each verified against its own tests.Related: #7240, #7807 (where the gate that caught this came from), #7791 (also adding a contract; the two touch different files).
🤖 Generated with Claude Code
PR Self-Review
Reviewed revision
5b9f4d972203e8611bf33ad831a11df063250f81Behavior and intent
Three ops that all three downstream engines call on the DSV4.1 path cannot be served by any provider. Each already carries
torch_compile_guard, so routing underneath it is safe by construction — the guard is what Dynamo sees, and the plugin's dispatch never enters a caller's compiled graph. Nothing about the runtime behaviour of the three changes; what changes is that a provider can now be asked.Validation and unverified scope
Verified on gfx942 (torch 2.9.1):
main's 16 plus three — none lost, none carrying abackendorkernelName;per_group_quant_hip,mhc_preandmhc_postare byte-identical tomain, compared by AST;per_group_quantis confirmed unused as a name anywhere in the tree, so the neutral contract name collides with nothing;per_group_quant_hipforwards to_per_group_quant_routed, the function carrying@route— checked rather than assumed, because forwarding to the unrouted body would have left SGLang's calls uncovered while looking correct;blackandruff checkclean.Unverified: no test in this PR puts a real tensor through the new layer into any of the three kernels. The
ci:alllabel is on this PR so the downstream suites run;mhc_*andper_group_quanthave no dedicatedop_tests/target to name.Worth recording: the first draft put
@route(op="per_group_quant")directly onper_group_quant_hip, andtest_the_backend_suffix_gate_is_not_vacuousrejected it. That gate came from #7807, where a backend-onlykernelNameargument reached a contract exactly that way. A rule written three PRs ago caught its own author.PR-specific question
Which exact workload keys consume these configuration changes, and what evidence shows that unrelated shapes keep their previous selection?
No configuration or tuning keys change, and no selection logic is touched.
per_group_quant_hip's body moves verbatim to_per_group_quant_routedwith the public name forwarding every argument positionally;mhc_preandmhc_postare not restructured at all, only decorated. With no provider enabled, each of the three makes the same call it made before. Shapes do not enter into it because nothing here reads one.Changed op tests
None.