Repository navigation
Conversation
ROCm#7715 routed `mla_sparse_prefill_v41`, the one DeepSeek V4.1 op reachable outside a graph capture. These are the next two, chosen because their contracts raise no question this interface has not already answered: nine arguments each, no workspace, no backend parameter, no backend word in the name — the same shape as the five ops already routed. Both mount on the public entry point. `@compile_ops` wraps `_inverse_rope_group_quant_kernel`, not the function callers use, so the route sits on the contract rather than on one backend's implementation. **These are decode-path ops, and that has a consequence worth stating here rather than discovering later.** A framework's warmup runs a prefill-only dummy batch, so a decode-only op is not called during warmup and its first call lands inside `capture_cudagraph()`. Allocation there is safe; reading a result back is not, and the failure poisons the CUDA context rather than raising something a provider author can act on. The obligation this places on providers is in ROCm#7240 and pinned by ROCm#7713. The gap it leaves on the framework side is filed as ROCm/ATOM#3157. Routing them now is still correct: with no provider enabled, dispatch short-circuits before eligibility and every call goes native, so nothing changes for anyone today. What it buys is the contract being in place, so a provider can be written against it while the framework-side warmup is sorted out. The ordering risk is real but it is a deployment-time risk, not a merge-time one, and it is documented in both places a provider author would look. `fused_qk_norm_rope_cache_quant_shuffle` is deliberately not here: nineteen arguments fusing norm, rope, cache, quant and shuffle is a contract-granularity question for ROCm#7240, and routing it first would freeze that granularity into public contract. `mla_decode_fwd_v4_nm_ps` is also held back — it carries a workspace, and no provider has ever served a contract with one, so it deserves a PR that can say something about that rather than riding along in this one. The baseline gains two entries and the existing five are untouched. Generated with the gate's own `routed_contracts()` scanner. `pytest -q tests/test_plugin*.py` — 98 passed. On MI355X, `plugin.status()["routed_ops"]` lists seven ops with both of these among them. 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: |
NOT READY FOR HUMAN REVIEWPR Self-ReviewRevision Author self-review accepted. Readiness report: Author answers
Show the author's self-review answersBehavior and intentValidation and unverified scopePR-specific questionChanged op testsPR state
Copilot findings
Code and op-test hygiene
Required CI
Shadow mode reports what would block but keeps the status successful. Set |
|
Superseded by #7728, which carries these five commits unchanged. Combined because all five rewrite No content is lost; #7728 contains all five commits and the combined baseline was regenerated with the gate's own scanner rather than merged by hand. |
…t means handle. Until now that was an assertion nobody had executed: no routed op had one, so nothing in the tree demonstrated it, and nothing would have noticed if it stopped being true. `mla_decode_fwd_v4_nm_ps` takes `MlaV4NmPsWorkspace`, a NamedTuple of five tensors the caller allocates through `get_mla_v4_nm_ps_workspace`. Routing it makes the claim testable, and the test is the point of this PR rather than the decorator. The question the claim hides is concrete. Dispatch canonicalizes arguments through generated code before handing them to a Provider, and a NamedTuple could plausibly arrive rebuilt, flattened into its fields, or copied. Any of those breaks the ownership the pattern exists for: the Provider would be writing into scratch the caller cannot read back, and nothing would say so. It arrives as the same object. The test asserts `is`, not `==`, on the way into `select()` and again on the way into `run()`, checks the field names survive, and checks that defaults past the workspace are still canonicalized into positional arguments. Mutation-checked by making dispatch rebuild NamedTuples after canonicalization, which turns it red on the first assertion. Worth stating what this does not establish: no Provider has served this contract against real V4.1 tensors, and the workspace's *lifetime* rules -- who may write to it, when it may be reused -- are semantics the contract carries, not something argument passing can check. Decode-path op, so the first-call-under-capture consideration from ROCm#7716 applies here too: provider obligations in ROCm#7240, pinned by ROCm#7713, framework gap filed as ROCm/ATOM#3157. With no Provider enabled, every call routes native and nothing changes on merge. Baseline gains one entry, existing six untouched, generated with the gate's own scanner. `pytest -q tests/test_plugin*.py` -- 99 passed. On MI355X, `plugin.status()["routed_ops"]` lists it. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The last V4.1 op this series routes is `batched_gemm_a8w8_mxscale_bpreshuffle`.
Routing it alone would have been wrong: its non-shuffled sibling
`batched_gemm_a8w8_mxscale` takes the same five arguments and is reached from
the same path, so leaving one unrouted would let a Provider serve half the
pair and look complete. Both are routed here.
They get the same fingerprint, and that is correct rather than a bug in the
gate. The gate reads signatures, and these signatures are identical:
`x, wo_a, x_scale, w_scale, dtype`. What separates them is the *content* of
`wo_a` -- row-major in one, baked into the (16, 16) MFMA-fragment layout in the
other -- with the same shape, dtype and strides either way.
AITER already says what that costs, in the entry point's own docstring:
That is why it is a separate entry rather than a flag: the shuffled weight
has the same shape, dtype and strides as the row-major one, so a mismatched
kernel reads the right bytes in the wrong order and returns a plausible
wrong answer instead of failing.
This is the sharpest case of what ROCm#7240 states about contract granularity.
`v4`/`v41` at least differ in parameter names; here nothing differs. Neither
the contract gate nor the candidate arity check can tell a kernel bound to the
wrong one apart, and there is no downstream mechanism that recovers.
So the test added here does not assert correctness -- nothing available can.
It asserts that the pair stays a pair. The two look like an obvious duplicate,
so the plausible way to break this is a later cleanup routing one and calling
the other redundant; the assertion makes that delete an explanation rather
than a line. First draft of it skipped when an op was missing, which let
exactly that mistake pass -- mutation-checked after the fix: removing either
route turns it red.
Decode-path ops, so the first-call-under-capture consideration from ROCm#7716 and
ROCm#7717 applies: obligations in ROCm#7240, pinned by ROCm#7713, framework gap filed as
ROCm/ATOM#3157. With no Provider enabled every call routes native.
Baseline gains two entries, existing seven untouched. `pytest -q
tests/test_plugin*.py` -- 99 passed. On MI355X both appear in
`plugin.status()["routed_ops"]`.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…rface This is the last op ATOM's DeepSeek V4.1 path imports from AITER that was not routed. With it, every AITER entry point that path calls can be served by a Provider: sparse prefill (ROCm#7715), the two paged decodes (ROCm#7716, ROCm#7717), the inverse-rope quant (ROCm#7716) and both batched mxscale GEMMs (ROCm#7719). I argued earlier for holding this one back, on two grounds that did not survive checking. The first was arity: nineteen parameters fusing five stages looked like a contract too coarse to serve. Counted properly it is twelve tensors and seven shape/strategy scalars, which for an op reading q, k, v, two weight sets, the rope cache, two KV caches and two scale sets is not unusual. The second was that routing one member would drag in a family -- there are six nearby entry points differing in quant granularity, rope dimensionality and a 2way variant. ATOM imports exactly one of them, in two files. The others serve paths outside this surface and can stay unrouted without leaving a hole. Mounted on the public entry point; `@compile_ops` wraps `_fused_qk_norm_rope_cache_quant_shuffle_hip`, not the function callers import. **This contract returns None.** It is the first routed op that delivers entirely through mutation -- q, k, and the KV caches are written in place. That is a real constraint on dispatch, not just on providers: code that reads a falsy return as "the provider declined" would fall through to native after the provider had already written, running the work twice with the second pass over the first's output. Nothing in dispatch inspects return values today, and the test added here is what says so. Mutation-checked by making dispatch treat a falsy result as a decline, which turns it red on the native-fallback assertion. Decode-path op, so the first-call-under-capture consideration applies as in ROCm/ATOM#3157. No Provider enabled means every call routes native. Baseline gains one entry, existing eight untouched. `pytest -q tests/test_plugin*.py` -- 99 passed. Verified on MI355X. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
* Route mla_sparse_prefill_v41, the first DSV4.1 op DeepSeek V4.1's attention path calls six AITER ops and not one of them is routed: the five ops #7484 routed are rmsnorm, pertoken_quant and the two blockscale GEMMs, which the V4.1 path does not touch. A provider can serve nothing on that model today. This routes the one of the six that needs no other decision first. **Why this one.** Five of the six run only on the decode path, which is inside a CUDA graph, and `warmup_model()`'s dummy batch is prefill-only — so their first call lands in a capture, the case #7240 now states obligations for and #7713 pins. `mla_sparse_prefill_v41` is prefill. It is reached outside any capture, so routing it exercises the DSV4.1 contract end to end without depending on anything else landing first. **Mounted where the op begins.** `@compile_ops` wraps only the low-level asm entry point; the public `mla_sparse_prefill_v41` is plain Python, so the route sits on the contract rather than on one backend's implementation — the lesson from routing rmsnorm at `_rms_norm_fwd_dispatch`. **Not folded in with v4.** `mla_sparse_prefill_v4` stays unrouted and will be its own contract when it is. The two take the same fifteen arguments and mean different things by them — v4's second is `q_rope`, v41's is `q_scale` — so a kernel bound to the wrong one passes the arity check and reads a scale tensor as a RoPE component. #7240 states the rule. **`backend=` needs no special handling.** It is a contract parameter, not a routing switch (#7240), and on this op it is degenerate anyway: `"opus"` is the only accepted value, both spellings reach the same implementation, and ATOM's call site passes neither. The baseline gains one entry and the existing five are untouched, which is the property worth checking in the diff. `pytest -q tests/test_plugin*.py` — 98 passed. On MI355X, `plugin.status()["routed_ops"]` lists six ops with `mla_sparse_prefill_v41` among them. No provider serves it yet, so every call still routes native, exactly as the first five did when they landed. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * Route the two decode-path V4.1 ops whose contracts need nothing new outside a graph capture. These are the next two, chosen because their contracts raise no question this interface has not already answered: nine arguments each, no workspace, no backend parameter, no backend word in the name — the same shape as the five ops already routed. Both mount on the public entry point. `@compile_ops` wraps `_inverse_rope_group_quant_kernel`, not the function callers use, so the route sits on the contract rather than on one backend's implementation. **These are decode-path ops, and that has a consequence worth stating here rather than discovering later.** A framework's warmup runs a prefill-only dummy batch, so a decode-only op is not called during warmup and its first call lands inside `capture_cudagraph()`. Allocation there is safe; reading a result back is not, and the failure poisons the CUDA context rather than raising something a provider author can act on. The obligation this places on providers is in ROCm/ATOM#3157. Routing them now is still correct: with no provider enabled, dispatch short-circuits before eligibility and every call goes native, so nothing changes for anyone today. What it buys is the contract being in place, so a provider can be written against it while the framework-side warmup is sorted out. The ordering risk is real but it is a deployment-time risk, not a merge-time one, and it is documented in both places a provider author would look. `fused_qk_norm_rope_cache_quant_shuffle` is deliberately not here: nineteen arguments fusing norm, rope, cache, quant and shuffle is a contract-granularity question for #7240, and routing it first would freeze that granularity into public contract. `mla_decode_fwd_v4_nm_ps` is also held back — it carries a workspace, and no provider has ever served a contract with one, so it deserves a PR that can say something about that rather than riding along in this one. The baseline gains two entries and the existing five are untouched. Generated with the gate's own `routed_contracts()` scanner. `pytest -q tests/test_plugin*.py` — 98 passed. On MI355X, `plugin.status()["routed_ops"]` lists seven ops with both of these among them. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * Route the first contract that carries a workspace, and check what that means handle. Until now that was an assertion nobody had executed: no routed op had one, so nothing in the tree demonstrated it, and nothing would have noticed if it stopped being true. `mla_decode_fwd_v4_nm_ps` takes `MlaV4NmPsWorkspace`, a NamedTuple of five tensors the caller allocates through `get_mla_v4_nm_ps_workspace`. Routing it makes the claim testable, and the test is the point of this PR rather than the decorator. The question the claim hides is concrete. Dispatch canonicalizes arguments through generated code before handing them to a Provider, and a NamedTuple could plausibly arrive rebuilt, flattened into its fields, or copied. Any of those breaks the ownership the pattern exists for: the Provider would be writing into scratch the caller cannot read back, and nothing would say so. It arrives as the same object. The test asserts `is`, not `==`, on the way into `select()` and again on the way into `run()`, checks the field names survive, and checks that defaults past the workspace are still canonicalized into positional arguments. Mutation-checked by making dispatch rebuild NamedTuples after canonicalization, which turns it red on the first assertion. Worth stating what this does not establish: no Provider has served this contract against real V4.1 tensors, and the workspace's *lifetime* rules -- who may write to it, when it may be reused -- are semantics the contract carries, not something argument passing can check. Decode-path op, so the first-call-under-capture consideration from #7716 applies here too: provider obligations in #7240, pinned by #7713, framework gap filed as ROCm/ATOM#3157. With no Provider enabled, every call routes native and nothing changes on merge. Baseline gains one entry, existing six untouched, generated with the gate's own scanner. `pytest -q tests/test_plugin*.py` -- 99 passed. On MI355X, `plugin.status()["routed_ops"]` lists it. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * Route both batched mxscale GEMMs, and pin why they stay two The last V4.1 op this series routes is `batched_gemm_a8w8_mxscale_bpreshuffle`. Routing it alone would have been wrong: its non-shuffled sibling `batched_gemm_a8w8_mxscale` takes the same five arguments and is reached from the same path, so leaving one unrouted would let a Provider serve half the pair and look complete. Both are routed here. They get the same fingerprint, and that is correct rather than a bug in the gate. The gate reads signatures, and these signatures are identical: `x, wo_a, x_scale, w_scale, dtype`. What separates them is the *content* of `wo_a` -- row-major in one, baked into the (16, 16) MFMA-fragment layout in the other -- with the same shape, dtype and strides either way. AITER already says what that costs, in the entry point's own docstring: That is why it is a separate entry rather than a flag: the shuffled weight has the same shape, dtype and strides as the row-major one, so a mismatched kernel reads the right bytes in the wrong order and returns a plausible wrong answer instead of failing. This is the sharpest case of what #7240 states about contract granularity. `v4`/`v41` at least differ in parameter names; here nothing differs. Neither the contract gate nor the candidate arity check can tell a kernel bound to the wrong one apart, and there is no downstream mechanism that recovers. So the test added here does not assert correctness -- nothing available can. It asserts that the pair stays a pair. The two look like an obvious duplicate, so the plausible way to break this is a later cleanup routing one and calling the other redundant; the assertion makes that delete an explanation rather than a line. First draft of it skipped when an op was missing, which let exactly that mistake pass -- mutation-checked after the fix: removing either route turns it red. Decode-path ops, so the first-call-under-capture consideration from #7716 and #7717 applies: obligations in #7240, pinned by #7713, framework gap filed as ROCm/ATOM#3157. With no Provider enabled every call routes native. Baseline gains two entries, existing seven untouched. `pytest -q tests/test_plugin*.py` -- 99 passed. On MI355X both appear in `plugin.status()["routed_ops"]`. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * Route the fused qk-norm/rope/cache/quant op, completing V4.1's API surface This is the last op ATOM's DeepSeek V4.1 path imports from AITER that was not routed. With it, every AITER entry point that path calls can be served by a Provider: sparse prefill (#7715), the two paged decodes (#7716, #7717), the inverse-rope quant (#7716) and both batched mxscale GEMMs (#7719). I argued earlier for holding this one back, on two grounds that did not survive checking. The first was arity: nineteen parameters fusing five stages looked like a contract too coarse to serve. Counted properly it is twelve tensors and seven shape/strategy scalars, which for an op reading q, k, v, two weight sets, the rope cache, two KV caches and two scale sets is not unusual. The second was that routing one member would drag in a family -- there are six nearby entry points differing in quant granularity, rope dimensionality and a 2way variant. ATOM imports exactly one of them, in two files. The others serve paths outside this surface and can stay unrouted without leaving a hole. Mounted on the public entry point; `@compile_ops` wraps `_fused_qk_norm_rope_cache_quant_shuffle_hip`, not the function callers import. **This contract returns None.** It is the first routed op that delivers entirely through mutation -- q, k, and the KV caches are written in place. That is a real constraint on dispatch, not just on providers: code that reads a falsy return as "the provider declined" would fall through to native after the provider had already written, running the work twice with the second pass over the first's output. Nothing in dispatch inspects return values today, and the test added here is what says so. Mutation-checked by making dispatch treat a falsy result as a decline, which turns it red on the native-fallback assertion. Decode-path op, so the first-call-under-capture consideration applies as in ROCm/ATOM#3157. No Provider enabled means every call routes native. Baseline gains one entry, existing eight untouched. `pytest -q tests/test_plugin*.py` -- 99 passed. Verified on MI355X. 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]>
#7715 routed
mla_sparse_prefill_v41, the one DeepSeek V4.1 op reachable outside a graph capture. These are the next two, picked because their contracts raise no question this interface has not already answered: nine arguments each, no workspace, nobackendparameter, no backend word in the name — the same shape as the five ops already routed.mla_decode_fwd_v4_nmaiter/mla.pyinverse_rope_group_quantaiter/ops/inverse_rope_group_quant.pyBoth mount on the public entry point.
@compile_opswraps_inverse_rope_group_quant_kernel, not the function callers use, so the route sits on the contract rather than on one backend's implementation.These are decode-path ops, and that has a consequence
A framework's warmup runs a prefill-only dummy batch, so a decode-only op is never called during warmup and its first call lands inside
capture_cudagraph().Measured on MI355X (gfx950, torch 2.10.0+rocm7.2.4), per-process:
torch.randfails withexpected scalar type Long but found UNKNOWN_SCALAR, naming neither capture nor the provider.Where each half of this is handled:
Why route them before that gap is closed
With no provider enabled — every deployment today — dispatch short-circuits before eligibility and every call goes native. Nothing changes for anyone on merge.
What it buys is the contract being in place, so a provider can be written against it while the framework-side warmup is sorted out. The ordering risk is real, but it is a deployment-time risk rather than a merge-time one, and it is written down in both places a provider author would look.
Two V4.1 ops deliberately left out
fused_qk_norm_rope_cache_quant_shuffle— nineteen arguments fusing norm, rope, cache, quant and shuffle. A provider would have to implement all five or none. That is a contract-granularity question for #7240, and routing it first would freeze the granularity into public contract.mla_decode_fwd_v4_nm_ps— carries aMlaV4NmPsWorkspace. No provider has ever served a contract with a workspace; the RFC's "caller-owned handle is supported in principle" is an unexecuted assertion. It deserves a PR that can say something about that rather than riding along here.The diff worth checking
The baseline gains two entries; the existing five are untouched. Generated with the gate's own
routed_contracts()scanner rather than by hand.Testing
pytest -q tests/test_plugin*.py— 98 passed.blackandruffclean (the one remaining ruff finding,EXE001inaiter/aot/flydsl/gemm.py, predates this branch).On MI355X:
plugin.status()["routed_ops"]lists seven ops with both of these among them.PR Self-Review
Reviewed revision
15606bf4caBehavior and intent
Two decorators and two baseline entries. With nothing enabled, dispatch returns native before eligibility is computed, so behaviour is unchanged for every current deployment.
The judgement worth reviewing is routing decode-path ops ahead of the framework-side warmup fix. The alternative — hold them until ROCm/ATOM#3157 and its vLLM/SGLang equivalents land — keeps the tree strictly safer but blocks provider work on another team's schedule. This PR takes the other side and documents the risk in three places; a reviewer who disagrees should say so, because the reasoning is a judgement call rather than a measurement.
Validation and unverified scope
CPU-only plugin suite 98 passed, contract gate green with the baseline regenerated by its own scanner, routes verified live on MI355X.
Unverified: no provider serves either contract, so
select()has never run for them with real tensors. The numerical path is unchanged because native is what executes. Also unverified here: the capture interaction itself — that is #7713's subject, on a different op.PR-specific question
Is the deployment-time risk acceptable, or should decode-path ops wait for the framework fix? Stated above as a judgement; it is the one thing in this PR that is not settled by a measurement.
Changed op tests
None. Two
aiter/files gain a decorator and an import;tests/plugin_contracts.jsongains two entries. No file underop_tests/is touched and no existing routed op's signature moves.🤖 Generated with Claude Code