Skip to content

[RFC #7240] Route the three attention entry points frameworks call - #7807

Merged
zufayu merged 4 commits into
mainfrom
codex/route-attention-entrypoints
Nov 12, 2026
Merged

zufayu merged 4 commits into
mainfrom
codex/route-attention-entrypoints

Conversation

@zufayu

@zufayu zufayu commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

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, SGLang 2026-11-10, ATOM 2026-11-11), every hit read rather than counted:

op routed as vLLM SGLang ATOM
pa_fwd_asm pa_fwd _aiter_ops.py:4737 base_attention.py:160, full_attention_backend.py:2847
pa_decode_bf16_asm pa_decode_bf16 attention_mha.py:877
pa_persistent_fwd pa_persistent_fwd attention_mha.py:821, full_attention_backend.py:2806

Why the route goes on the public entry point

Each of these is an ordinary Python implementation over a private _*_asm binding, and each has exactly one public spelling. That makes them the simple case: unlike mla_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, so pa_fwd_asm is routed as pa_fwd with no rename and no downstream change at all. The merged precedent is rmsnorm, which sits on _rms_norm_fwd_dispatch:

Routed here rather than on either public spelling or on a backend binding … this is where the op begins

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, _tuned or _gfx1250. A contract named pa_fwd_asm would 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 while op= does no work, and the first route put straight onto a backend-named function would be the one to discover it.

Mutation-checked:

mutation caught by
route pa_fwd_asm as op="pa_fwd_asm" the suffix gate, naming it
baseline and route scan disagree the existing baseline test
remove the two backend-named routes, leaving only neutral ones the vacuity gate (not actually constraining anything)

Documentation

pa_fwd_asm had no docstring; it gains one. pa_decode_bf16_asm documented its kernarg conventions at length without saying what it returns; it now does. Both state the fact a signature cannot carry — whether out is 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 with routed_contracts() (three entries, +21 lines, no reformatting of the rest). black clean; ruff check clean — 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_v1 and mla_prefill_ps_asm_fwd are used by all three frameworks and belong in this family, but both are bare @compile_ops stubs — 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_shuffle exists as a thin wrapper over its _hip stub 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_asm appears 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

`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]>
@zufayu
zufayu requested a review from a team November 11, 2026 06:27
@github-actions

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every PR:

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

Extended tests (opt-in via labels):

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

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

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

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

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

@aiter-bot

aiter-bot commented Nov 11, 2026 •

Copy link
Copy Markdown

WAITING ON AUTHOR

PR Self-Review

Revision 69af1b971246 · mode shadow

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

Questions to answer in the PR description

  1. What behavior does this PR change, and why is the existing behavior insufficient?
  2. What did you validate, and what remains unverified? Include commands, hardware/configuration and results.
  3. Which exact workload keys consume these configuration changes, and what evidence shows that unrelated shapes keep their previous selection?
  4. For every changed op_tests/ file, what behavior does it cover and why is it not redundant? Write None if no op test changed.

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

Missing or invalid answers

  • FAIL — missing ### Reviewed revision in the PR description
  • FAIL — missing ### Behavior and intent in the PR description
  • FAIL — missing ### Validation and unverified scope in the PR description
  • FAIL — missing ### PR-specific question in the PR description
  • FAIL — missing ### Changed op tests in the PR description
  • FAIL — Reviewed revision must contain at least the first 7 characters of the current head SHA
  • FAIL — Behavior and intent has no substantive answer
  • FAIL — Validation and unverified scope has no substantive answer
  • FAIL — PR-specific question has no substantive answer

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

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]>
@zufayu

zufayu commented Nov 11, 2026

Copy link
Copy Markdown
Contributor Author

Reworked. The first version had a defect I should have caught from my own #7791.

What was wrong: @route sat directly on pa_fwd_asm, so that function's entire signature became the contract — including kernelName, which pins one asm kernel. A provider has its own kernel and no way to satisfy that, so the contract would have had every provider decline any call passing it. The op name was neutral; the backend came in through an argument instead. pa_fwd and pa_decode_bf16 both carried it.

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 kernelName word for word. I applied it there and not here.

New structure — 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
call behaviour
pa_fwd_asm(...) routes — a provider serves it, framework unchanged
pa_fwd_asm(..., kernelName="xyz") runs that asm kernel, no routing
pa_fwd(...) routes
pa_fwd(..., backend="asm") runs asm, no routing

An ordinary old-spelling call still routes, which is the point: the _asm there is an artifact of pa_fwd having had no public spelling (#7150 lists it among the thirty names with no neutral counterpart), not a caller asking for that backend. An explicit pin is a caller asking, and it gets exactly that.

Both public signatures are byte-identical to origin/main — checked by AST, not by eye. pa_persistent_fwd is already neutral and takes no pin; unchanged beyond its route.

The gate now has two halves, because the first half would not have caught this:

  • a contract may not carry a parameter no provider can honour (backend, kernelName)
  • a route may not sit on a backend-named function — that is how kernelName got in while the op name looked clean

Mutation-checked: moving the route back onto pa_fwd_asm fails the second; splicing backend into a baseline signature fails the first; emptying the guarded-name list fails its own liveness check.

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. black and ruff check clean. Contract baseline regenerated — pa_fwd and pa_decode_bf16 lost kernelName from their signatures, which is the whole diff there.

zufayu and others added 2 commits November 11, 2026 11:27
#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]>
@zufayu
zufayu merged commit 6b96036 into main Nov 12, 2026
@zufayu
zufayu deleted the codex/route-attention-entrypoints branch November 12, 2026 02:14
zufayu added a commit that referenced this pull request Nov 12, 2026
#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]>
vpietila-amd pushed a commit that referenced this pull request Nov 12, 2026
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants