Repository navigation
[RFC #7240] Route the three attention entry points frameworks call - #7807
Conversation
`pa_fwd_asm` (vLLM, ATOM), `pa_decode_bf16_asm` (ATOM) and `pa_persistent_fwd` (ATOM) are the attention ops downstream imports directly and no provider can serve. Each is an ordinary Python implementation over a private asm binding, with exactly one public spelling -- so unlike `mla_sparse_prefill` there is no second spelling to converge; the route goes straight on the public entry point. Two of the three carry a backend in their Python name. The contract does not: `@route(op=...)` names the operation and is independent of the function it decorates, which is what lets `pa_fwd_asm` be routed as `pa_fwd` without a rename and without one downstream caller changing. `rmsnorm` on `_rms_norm_fwd_dispatch` is the merged precedent. `pa_fwd_asm` gains a docstring and `pa_decode_bf16_asm`'s says what it returns; both now state the fact a signature cannot carry -- whether `out` is written, returned, or both. A new gate pins the rule this relies on: no routed op name may carry a backend suffix. A contract named `_asm` would ask a provider to be a backend it is not, which is what the first routed ops were chosen to avoid. 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 |
The first version put `@route` straight on `pa_fwd_asm`, which made that function's whole signature the contract -- including `kernelName`, a knob that picks one asm kernel. A provider has its own kernel and no way to satisfy that, so a contract carrying it would have the provider decline every call that passes one. The op name was neutral and the backend came in through an argument instead. This is the same reasoning #7791 already applied to `backend=`, written there as: a provider asked to serve this contract "cannot be asked to honour a pin it has no kernel for". It applies to `kernelName` unchanged; I failed to apply it here. So the route moves below both pins: pa_fwd(..., backend=None) neutral name pa_fwd_asm(..., kernelName=None) historical spelling, signature untouched | pin given -> that kernel runs, no routing | no pin -> _pa_fwd_routed(...) @route, carries neither pin | the asm binding An ordinary `pa_fwd_asm(...)` call routes, so a framework is served without changing a line -- the `_asm` there is an artifact of `pa_fwd` having had no public spelling, not a caller asking for that backend. An explicit pin bypasses routing and runs exactly what was asked for. `pa_persistent_fwd` is already neutral and takes no pin; it is unchanged beyond its route. Both public spellings keep their exact signatures (checked against origin/main), so nothing downstream changes. The gate grows a second half: a contract may not carry a parameter a provider cannot honour, and a route may not sit on a backend-named function (which is how `kernelName` got in, while the op name looked clean). Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
Reworked. The first version had a defect I should have caught from my own #7791. What was wrong: This is the reasoning #7791 already states, in a comment I wrote: a provider asked to serve the contract "cannot be asked to honour a pin it has no kernel for". It applies to New structure — the route moves below both pins:
An ordinary old-spelling call still routes, which is the point: the Both public signatures are byte-identical to The gate now has two halves, because the first half would not have caught this:
Mutation-checked: moving the route back onto One casualty worth naming: the previous vacuity test asserted that at least one route sits on a backend-named function. That was true of the old structure and is now false by design, so it had to be inverted rather than kept. A test that encodes the shape of the thing it guards stops being a check the moment the shape is the thing you change. 103 passed. |
#7728 landed seven contracts, which conflicts the baseline (regenerated with routed_contracts(), not reconciled by hand) and brings in one that this PR's own gate rejects: `mla_sparse_prefill_v41` carries `backend`. That is the same defect this PR was reworked to remove from `pa_fwd`, in an op that merged minutes earlier. The gate caught it immediately, which is what it is for -- so the fix belongs here rather than in a PR of its own that this one would then have to wait for. The treatment is `mla_sparse_prefill`'s from #7791: a routed layer below the backend check, carrying no pin. `backend` names which implementation AITER runs, which the dispatcher settles before the op begins; a provider has its own kernel and would have to decline every call passing one. Version 2, and v1 is NOT superseded: a v1 provider was built against fifteen arguments and a v2 call offers fourteen, so the arity check rejecting it is the correct outcome rather than a regression to absorb. The public signature of `mla_sparse_prefill_v41` is byte-identical to main (AST-checked), as are all three attention entry points. Nothing downstream changes. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
#7787 added three gates to tests/test_plugin_contracts.py and this branch adds four; git interleaved them because _routed_docstrings and _routed_function_names open with near-identical bodies, and the automatic resolution was not valid Python. Taken main's file whole and re-appended this PR's additions after it, rather than reconciling markers that cut through two functions at once. Baseline regenerated: 15 contracts, main's 12 plus the three attention entry points, none lost, and none carrying backend or kernelName. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
#7807 landed three attention contracts and a general parameter gate. Only tests/test_plugin_contracts.py conflicted; mla_sparse_prefill.py merged cleanly and both operators survived it -- checked by AST, not by eye: _mla_sparse_prefill_routed (v1) and _mla_sparse_prefill_v41_routed (v2) each sit below their backend check, and all three public spellings still take backend=. Dropped this branch's test_the_sparse_prefill_contract_carries_no_backend_pin. #7807's test_no_routed_contract_carries_a_parameter_a_provider_cannot_honour scans every contract for the same pins, so the narrow version now asserts a strict subset of what main already enforces. Baseline regenerated: 16 contracts, main's 15 plus mla_sparse_prefill, none lost, none carrying a backend parameter. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…7807) * feat(plugin): route the three attention entry points frameworks call `pa_fwd_asm` (vLLM, ATOM), `pa_decode_bf16_asm` (ATOM) and `pa_persistent_fwd` (ATOM) are the attention ops downstream imports directly and no provider can serve. Each is an ordinary Python implementation over a private asm binding, with exactly one public spelling -- so unlike `mla_sparse_prefill` there is no second spelling to converge; the route goes straight on the public entry point. Two of the three carry a backend in their Python name. The contract does not: `@route(op=...)` names the operation and is independent of the function it decorates, which is what lets `pa_fwd_asm` be routed as `pa_fwd` without a rename and without one downstream caller changing. `rmsnorm` on `_rms_norm_fwd_dispatch` is the merged precedent. `pa_fwd_asm` gains a docstring and `pa_decode_bf16_asm`'s says what it returns; both now state the fact a signature cannot carry -- whether `out` is written, returned, or both. A new gate pins the rule this relies on: no routed op name may carry a backend suffix. A contract named `_asm` would ask a provider to be a backend it is not, which is what the first routed ops were chosen to avoid. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * fix(plugin): route beneath the pins, so no pin reaches the contract The first version put `@route` straight on `pa_fwd_asm`, which made that function's whole signature the contract -- including `kernelName`, a knob that picks one asm kernel. A provider has its own kernel and no way to satisfy that, so a contract carrying it would have the provider decline every call that passes one. The op name was neutral and the backend came in through an argument instead. This is the same reasoning #7791 already applied to `backend=`, written there as: a provider asked to serve this contract "cannot be asked to honour a pin it has no kernel for". It applies to `kernelName` unchanged; I failed to apply it here. So the route moves below both pins: pa_fwd(..., backend=None) neutral name pa_fwd_asm(..., kernelName=None) historical spelling, signature untouched | pin given -> that kernel runs, no routing | no pin -> _pa_fwd_routed(...) @route, carries neither pin | the asm binding An ordinary `pa_fwd_asm(...)` call routes, so a framework is served without changing a line -- the `_asm` there is an artifact of `pa_fwd` having had no public spelling, not a caller asking for that backend. An explicit pin bypasses routing and runs exactly what was asked for. `pa_persistent_fwd` is already neutral and takes no pin; it is unchanged beyond its route. Both public spellings keep their exact signatures (checked against origin/main), so nothing downstream changes. The gate grows a second half: a contract may not carry a parameter a provider cannot honour, and a route may not sit on a backend-named function (which is how `kernelName` got in, while the op name looked clean). 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]>
What this unblocks
An out-of-tree provider cannot serve any attention op today. These three are the ones downstream actually imports, scanned at current heads (vLLM
2026-11-11, SGLang2026-11-10, ATOM2026-11-11), every hit read rather than counted:pa_fwd_asmpa_fwd_aiter_ops.py:4737base_attention.py:160,full_attention_backend.py:2847pa_decode_bf16_asmpa_decode_bf16attention_mha.py:877pa_persistent_fwdpa_persistent_fwdattention_mha.py:821,full_attention_backend.py:2806Why the route goes on the public entry point
Each of these is an ordinary Python implementation over a private
_*_asmbinding, and each has exactly one public spelling. That makes them the simple case: unlikemla_sparse_prefill/pa_sparse_prefill_opus(#7791), there is no second spelling to converge, so the route goes straight on the public function.Two of the three carry a backend in their Python name — and the contract does not.
@route(op=...)names the operation, independent of the function it decorates, sopa_fwd_asmis routed aspa_fwdwith no rename and no downstream change at all. The merged precedent isrmsnorm, which sits on_rms_norm_fwd_dispatch:This is also why #7150's renaming work is not a prerequisite for coverage: routing needs a neutral contract name, not a neutral Python name.
The gate this adds
test_no_routed_op_name_carries_a_backend_suffix— no routed contract's name may end in_asm,_ck,_opus,_hip,_triton,_tunedor_gfx1250. A contract namedpa_fwd_asmwould be asking a provider to be the asm kernel, which it is by definition not; that is precisely what the first routed ops (rmsnorm,pertoken_quant) were chosen to avoid, and nothing enforced it until now.Its companion,
test_the_backend_suffix_gate_is_not_vacuous, pins that the decoupling is real: at least one contract must be a neutral name sitting on a backend-named function. Without that, the gate could hold whileop=does no work, and the first route put straight onto a backend-named function would be the one to discover it.Mutation-checked:
pa_fwd_asmasop="pa_fwd_asm"not actually constraining anything)Documentation
pa_fwd_asmhad no docstring; it gains one.pa_decode_bf16_asmdocumented its kernarg conventions at length without saying what it returns; it now does. Both state the fact a signature cannot carry — whetheroutis written, returned, or both — which is the distinction that makes a provider bound to the wrong shape return a plausible wrong answer instead of failing.Verification
tests/test_plugin.py+tests/test_plugin_contracts.py: 29 passed. Contract baseline regenerated withrouted_contracts()(three entries, +21 lines, no reformatting of the rest).blackclean;ruff checkclean — including the import-order fix for the line this PR adds, which was mine to cause and is not an unrelated reformat.Deliberately left out
mla_reduce_v1andmla_prefill_ps_asm_fwdare used by all three frameworks and belong in this family, but both are bare@compile_opsstubs —mla_reduce_v1's body is a docstring and nothing else. Every one of the eight routed contracts sits on a Python implementation;fused_qk_norm_rope_cache_quant_shuffleexists as a thin wrapper over its_hipstub for exactly this reason. Routing a stub directly is new ground and wants its own change, not a rider on this one.fmha_fwd_with_sink_asmappears in #7150's downstream table; at current ATOM head its only occurrence is a comment, so it is not routed here.Related: #7240 (the interface), #7791 (the convergence-point case), #7150 (the rename work this shows routing does not depend on).
🤖 Generated with Claude Code