Repository navigation
[OPUS] [RFC #7240] Route MLA sparse prefill where its two public spellings converge - #7791
Conversation
`mla_sparse_prefill` and `pa_sparse_prefill_opus` are one op under two public names: identical arguments, forwarded unchanged to the same `_opus_sparse_prefill`, the second differing only by pinning the backend the first would have chosen anyway (`_check_backend` admits only "opus"). Every downstream caller on the DSV4.1 prefill path uses the backend-named spelling -- vLLM, SGLang and ATOM all import `pa_sparse_prefill_opus`, none imports the neutral name. Routing either spelling alone would therefore cover nobody, and routing `_opus_sparse_prefill` would put a backend in the contract. So the route goes on the layer both call, which is the pattern `rmsnorm` already uses for `rms_norm` / `rmsnorm2d_fwd`. `backend=` stays above that layer. It picks which native implementation AITER would run, which the dispatcher settles before the op begins; a provider has one kernel rather than a choice of AITER's, so being handed a pin naming AITER's would leave it declining every call from the spelling that pins. No behaviour change and no downstream change: both names take the same path they took before, one frame lower. 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 previous run's merge commit was computed before #7774 landed, so it still carried the FlyDSL 0.5.0 test breakage. Nothing in this branch changes. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
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]>
#7728 added seven contracts, so the baseline conflicted. Resolved by regenerating it with routed_contracts() rather than reconciling the conflict markers -- they cut through the JSON objects themselves, and a mechanical resolution produces something that parses as neither. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
#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 appended three gates to tests/test_plugin_contracts.py and this branch appends one, so the two collide at the end of the file. Both kept: main's gates first, this PR's sparse-prefill contract check after. Baseline regenerated with routed_contracts(): 13 contracts, main's 12 plus mla_sparse_prefill, none lost. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Triton shard 7 failed on 'GnuTLS recv error' fetching composable_kernel, not on anything in this branch. The run could not be re-run through the API, so this takes a fresh one. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Resolving the last conflict I ran black over aiter/ and tests/ wholesale instead of the files this branch touches. That collapsed two @gluon.jit signatures in sparse_mla_fp8.py onto 200-character lines -- lines whose author had marked '# fmt: skip' precisely so a formatter would leave them alone. The local black evidently treats that marker on a multi-line signature differently from the one CI pins, and the file was passing the style gate on main either way, so the change was loss with no gain. Back to main's version. Nothing else in this branch touches that file. 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]>
#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]>
|
@aiter-bot review |
|
aiter-bot — queued behind 2 review(s); expect to start in about 57 min. The box reviews one PR at a time. |
@yhl-amd — please take a look. Triage: if GLM serves but its output is malformed it may be the ATOM framework (@valarLip); if the box, GPU, disk or network is unhealthy it may be the machine (@gyohuangxin). Re-comment |
#6689 added sp_qkv_fused to the baseline. Clean merge -- the two entries are far enough apart in a sorted file not to collide this time. Verified: 17 contracts, main's 16 plus mla_sparse_prefill, none lost. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
@aiter-bot review |
|
aiter-bot — queued behind 3 review(s); expect to start in about 86 min. The box reviews one PR at a time. |
aiter-bot
left a comment
There was a problem hiding this comment.
ROCm/aiter PR #7791 — [OPUS] [RFC #7240] Route MLA sparse prefill where its two public spellings converge
Review (advisory):
Validation (deterministic): NOT RUN — the PR changes runtime code but ships no test target; the changed path is executed at run time (every call of either spelling now passes through the routed layer), and the native path is covered only by the pre-existing op_tests/test_mla_sparse_prefill.py in the automatic standard CI job, not by anything this PR ships
Perf (advisory): NOT RUN — the PR ships no perf target (a routing refactor, no kernel change); the pre-existing op_tests/test_mla_sparse_prefill.py carries a perftest/@benchmark harness for the routed spelling, but no GPU was usable in this environment (no gfx arch visible, auto-validation disabled) — an environment gap, not a PR defect
Size: 142 lines / 4 files
Design (advisory): route the op at the convergence layer beneath the backend pin, so the backend-named spelling pa_sparse_prefill_opus — the one every downstream caller imports — is served by a provider while backend= stays out of the contract; this extends the merged rmsnorm pattern (route where two public names converge) to the first op where one of the two names is itself a backend pin
Human: recommend kaiyang-1 review whether serving the explicitly opus-pinned spelling pa_sparse_prefill_opus through a provider (rather than letting the pin force the native kernel) is the right contract for mla_sparse_prefill in PR #7791 — kaiyang-1 is the top committer of both changed op files
📝 [verified] The description's test section names test_the_sparse_prefill_contract_carries_no_backend_pin as a third test gating the contract this PR records in tests/plugin_contracts.json, but no test by that name exists in either tree — the buildless mutation check it describes is actually the pre-existing generic gate test_no_routed_contract_carries_a_parameter_a_provider_cannot_honour in tests/test_plugin_contracts.py — and together with the description's AI-generation footer this marks the PR's elevated AI-code risk, so the claimed coverage should not be taken at face value. Author must correct the test name in the description.
2 finding(s) posted inline, on the lines they are about:
aiter/ops/pa_sparse_prefill_opus.py:93— is the entry vLLM, SGLang and ATOM all import (per the PR's own scan of their current heads), and this PR…aiter/ops/pa_sparse_prefill_opus.py:93— The PR changes the runtime dispatch of the DSV4.1 sparse prefill's both public spellings…
#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]>
#7791 added mla_sparse_prefill. This branch adds no contract, so the baseline is main's 17 unchanged; the plugin changes and the one registered op survive the merge, checked rather than inferred from a clean auto-merge. 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]>
…lings converge (#7791) * feat(plugin): route MLA sparse prefill where its two spellings converge `mla_sparse_prefill` and `pa_sparse_prefill_opus` are one op under two public names: identical arguments, forwarded unchanged to the same `_opus_sparse_prefill`, the second differing only by pinning the backend the first would have chosen anyway (`_check_backend` admits only "opus"). Every downstream caller on the DSV4.1 prefill path uses the backend-named spelling -- vLLM, SGLang and ATOM all import `pa_sparse_prefill_opus`, none imports the neutral name. Routing either spelling alone would therefore cover nobody, and routing `_opus_sparse_prefill` would put a backend in the contract. So the route goes on the layer both call, which is the pattern `rmsnorm` already uses for `rms_norm` / `rmsnorm2d_fwd`. `backend=` stays above that layer. It picks which native implementation AITER would run, which the dispatcher settles before the op begins; a provider has one kernel rather than a choice of AITER's, so being handed a pin naming AITER's would leave it declining every call from the spelling that pins. No behaviour change and no downstream change: both names take the same path they took before, one frame lower. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * ci: retrigger against main carrying #7774 The previous run's merge commit was computed before #7774 landed, so it still carried the FlyDSL 0.5.0 test breakage. Nothing in this branch changes. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * ci: retrigger after a submodule fetch failure Triton shard 7 failed on 'GnuTLS recv error' fetching composable_kernel, not on anything in this branch. The run could not be re-run through the API, so this takes a fresh one. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * Revert an unrelated reformat of sparse_mla_fp8.py Resolving the last conflict I ran black over aiter/ and tests/ wholesale instead of the files this branch touches. That collapsed two @gluon.jit signatures in sparse_mla_fp8.py onto 200-character lines -- lines whose author had marked '# fmt: skip' precisely so a formatter would leave them alone. The local black evidently treats that marker on a multi-line signature differently from the one CI pins, and the file was passing the style gate on main either way, so the change was loss with no gain. Back to main's version. Nothing else in this branch touches that file. 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]>
…d/mla-sparse-prefill-triton-backend Brings in main up to 85ccf17 through #7680. Conflicts: - aiter/ops/mla_sparse_prefill.py: main routes the op through the plugin interface (#7791). mla_sparse_prefill now dispatches as mla_sparse_prefill_v41 does: enabled providers first, then a native fallback that picks triton or opus from backend=. The routed op (_mla_sparse_prefill_routed, opus) and its contract are unchanged. - op_tests/test_mla_sparse_prefill.py: docstrings. main replaced --total_tokens with --window and passes total_tokens=n, so the gfx950 triton candidate now keys on an empty kv_indices_extend (what the triton backend requires) instead of total_tokens == 0. tests/test_plugin_routed_ops.py: the backend-pin test also covers backend="triton". Signed-off-by: Rony Leppänen <[email protected]>
The problem this solves
An out-of-tree provider that wants to serve DSV4.1's sparse prefill — the hottest path in the model, and the one a competing kernel library would most want to take over — has exactly two options today: fork AITER, or monkey-patch
aiter.ops.pa_sparse_prefill_opus.pa_sparse_prefill_opus. Monkey-patching depends on import order, has no contract check, cannot be enabled per deployment, and is invisible toexplain()/status(). Removing that is what #7240 exists for.Routing was already available; it just was not pointed anywhere the frameworks actually call.
Why routing either public name would have covered nobody
mla_sparse_prefillandpa_sparse_prefill_opusare one op under two names:Both forward the same eleven arguments, unchanged, to the same
_opus_sparse_prefill. The second differs only by pinning the backend the first would have chosen anyway —_check_backend("mla_sparse_prefill", backend, ("opus",))admits nothing else.And the callers are all on one side of that pair. Scanned against current heads (vLLM
2026-11-11, SGLang2026-11-10, ATOM2026-11-11), every import is the backend-named spelling:v1/attention/ops/rocm_aiter_mla_sparse.py:69pa_sparse_prefill_opuskernels/ops/attention/dsv4/opus_sparse_prefill_hip.py:83pa_sparse_prefill_opuskernels/ops/attention/dsv4/unified_kv_kernels/paged_prefill.py:57pa_sparse_prefill_opusmodel_ops/v4_kernels/paged_2src.py:60pa_sparse_prefill_opusNobody imports the neutral name. So routing
mla_sparse_prefillalone reaches no one, and routingpa_sparse_prefill_opuswould put a backend in a contract that providers implement against — the thing the first routed ops (rmsnorm,pertoken_quant) were chosen to avoid.What this does instead
Routes the layer both names call, which is the pattern already merged for
rmsnorm:_mla_sparse_prefill_routedcarries@route(op="mla_sparse_prefill", version=1);mla_sparse_prefillcalls it after its backend check, andpa_sparse_prefill_opuscalls it instead of reaching past into_opus_sparse_prefill.No renames, no deprecations, no downstream change. Both public names keep their signatures and their behaviour; each takes the same path it took before, one frame lower.
Why
backend=is not in the contractIt selects which native implementation AITER would run — a question the dispatcher settles before the op begins. A provider has one kernel, not a choice of AITER's, so handing it a pin naming AITER's would leave it declining every call from the spelling that pins, which here is every downstream caller. Keeping
backend=above the routed layer is what makes the backend-named spelling routable at all.This is consistent with the ownership model: routing is the selection mechanism AITER owns,
backend=is a public op argument of the dispatcher.test_the_sparse_prefill_contract_carries_no_backend_pinfails if it ever leaks into the contract.Tests
test_sparse_prefill_serves_through_either_public_spelling— a provider declaringmla_sparse_prefillserves calls arriving by both names, andselectis asked twice. This is the property the whole change exists for; it is the direct analogue of the existingtest_rmsnorm_provider_serves_through_either_public_spelling.test_the_backend_pin_is_not_part_of_the_sparse_prefill_contract—backend="opus"still routes rather than forcing native.test_the_sparse_prefill_contract_carries_no_backend_pin— buildless; mutation-checked by splicingbackendinto the baseline signature, which fails it.The first two live in
tests/test_plugin_routed_ops.pyand need a built AITER, like the rest of that file; the third runs on every PR without a GPU.Buildless suites pass locally (
test_plugin,test_plugin_contracts,test_plugin_discovery,test_plugin_selector_arity).blackandruff checkclean. Contract baseline regenerated withrouted_contracts()— one entry added, +7 lines, no reformatting of the rest.What this deliberately leaves alone
The same shape exists one version up —
mla_sparse_prefill_v4ispa_sparse_prefill_fp8_opus/mla_sparse_prefill_fp8_asmplusnum_kv_splitsandbackend— but there the pin is load-bearing: that contract really has two native backends, so redirecting a pinned spelling through the dispatcher without its pin would change which kernel runs. That needs a decision rather than a refactor, and it is raised on #7150 rather than settled here.Related: #7240 (the interface), #7728 (routes
mla_sparse_prefill_v41, the sibling that had no backend-named spelling to begin with), #7150 (the naming question this change turns out not to need).🤖 Generated with Claude Code
PR Self-Review
Reviewed revision
4d46c5c7f01329322e36caf59562ce6e44cd5014Behavior and intent
mla_sparse_prefillandpa_sparse_prefill_opusare one op under two public names, and every downstream caller uses the second one. Routing either name alone would therefore reach nobody, and routing the private_opus_sparse_prefillwould put a backend into a contract providers implement against. The route moves to the layer both names call, so a provider serves callers of either without one of them changing a line.The existing behavior is insufficient in a narrow sense: nothing is wrong at runtime today, but no out-of-tree provider can serve this op at all, which is what #7240 exists to make possible.
Validation and unverified scope
Verified on gfx942 (torch 2.9.1, 8 GPUs):
tests/test_plugin*.py);main's 16 plusmla_sparse_prefill— with none lost and none carrying abackendorkernelName, checked by regenerating withrouted_contracts()rather than editing the JSON;main, compared by AST rather than by eye;blackandruff checkclean.Unverified, and the reason: the native opus kernel is not exercised through the new routed layer anywhere in this PR.
op_tests/test_mla_sparse_prefill.pyis the target that does exercise it, and running it here skips all 38 cases:So that file has to run on a gfx950 runner. It was being skipped entirely until
ci:allwas added to this PR, which is the gapaiter-botflagged and the reason the label matters here rather than being routine.The two tests this PR adds use a fake provider, so they pin which callers reach a provider and that the contract carries no backend pin — not that the opus kernel still produces the same numbers.
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. The only selection logic touched is
_check_backend("mla_sparse_prefill", backend, ("opus",)), which stays exactly where it was, above the routed layer. With no provider enabled — every deployment today — dispatch returns the same_opus_sparse_prefillcall with the same eleven arguments it made before, one Python frame lower. Unrelated shapes do not enter into it because nothing in this change reads a shape.Changed op tests
None.
tests/test_plugin_routed_ops.pyis an interface test rather than an op test, and the op-test target that covers the native path,op_tests/test_mla_sparse_prefill.py, is unchanged by design — it already exercises both spellings and should keep passing untouched.