Skip to content

[RFC #7240] Route the DeepSeek V4.1 op surface: seven contracts - #7728

Merged
zufayu merged 6 commits into
ROCm:mainfrom
zufayu:codex/aklr-route-dsv41-all
Nov 11, 2026
Merged

zufayu merged 6 commits into
ROCm:mainfrom
zufayu:codex/aklr-route-dsv41-all

Conversation

@zufayu

@zufayu zufayu commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

Routes every AITER entry point that ATOM's DeepSeek V4.1 path calls. Seven new contracts, taking the routed set from five to twelve.

Originally five separate PRs (#7715, #7716, #7717, #7719, #7725). Combined because they all rewrite tests/plugin_contracts.json and the new entries land on adjacent lines in sorted order — merging them in sequence conflicts on every one after the first, and the obvious resolution produces invalid JSON (the markers cut through object bodies, leaving each side half a brace). Those five are closed in favour of this.

What is routed

stage in V4.1 attention op
qk-norm → rope → cache → quant → shuffle fused_qk_norm_rope_cache_quant_shuffle
sparse prefill mla_sparse_prefill_v41
paged decode mla_decode_fwd_v4_nm
paged decode, persistent mla_decode_fwd_v4_nm_ps
inverse rope + group quant inverse_rope_group_quant
wo_a / projection GEMM batched_gemm_a8w8_mxscale, ..._bpreshuffle

All mount on the public entry point. Where @compile_ops appears in these files it wraps a private _..._hip or _..._kernel, not the function callers import — the lesson from mounting rmsnorm at _rms_norm_fwd_dispatch.

Scope was checked against what ATOM imports, not against a list

An earlier count of "high-frequency V4.1 ops" mixed in ATOM's own helpers (rmsnorm_tail_ks, fused_metadata) and backend-specific implementations (fused_compress_attn from flydsl, fused_qk_rope_reshape_and_cache from triton). Those last two are the #7150 case — a name or path that names a backend is structurally not something a Provider can serve.

Filtered to AITER public entry points that are backend-neutral, the V4.1 surface is exactly the seven above.

Three contract shapes that had never been routed before

Each gets a test, and each test is mutation-checked.

A workspace the caller owns. mla_decode_fwd_v4_nm_ps takes MlaV4NmPsWorkspace, a NamedTuple of five caller-allocated tensors. Dispatch canonicalizes arguments through generated code, so the handle could plausibly arrive rebuilt, flattened, or copied — any of which breaks the ownership the pattern exists for. It arrives as the same object; the test asserts is, not ==, at select() and again at run(). Mutation: rebuilding NamedTuples after canonicalization turns it red.

Two contracts with an identical fingerprint. batched_gemm_a8w8_mxscale and ..._bpreshuffle take the same five arguments and get the same fingerprint e7294cd3de718c0c — correctly, since the gate reads signatures. What differs is the content of wo_a, at identical shape, dtype and strides. AITER's own docstring says what that costs: "a mismatched kernel reads the right bytes in the wrong order and returns a plausible wrong answer instead of failing." Nothing can catch a kernel bound to the wrong one, so the test asserts only what it can: the pair stays a pair. Mutation: removing either route turns it red — the first draft skipped instead, which let exactly that mistake pass.

A contract that returns None. fused_qk_norm_rope_cache_quant_shuffle delivers entirely through mutation. Code reading 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; the test says so. Mutation: treating a falsy result as a decline turns it red on the native-fallback assertion.

Two judgements I reversed while doing this

backend= does not need a routing rule. I argued for "skip routing when the caller names a backend". Wrong: #7240's ownership split already answers it — routing is the selection mechanism, backend= is a public op argument. On v41 it is degenerate anyway (one accepted value, same implementation either way) and ATOM passes neither.

The 19-argument fused op is not too coarse to route. Counted properly it is twelve tensors and seven shape scalars. And the "it drags in a family" objection did not hold: six nearby entry points exist, ATOM imports exactly one.

Decode path

Five of the seven are decode-only, so a Provider's first call can land inside a graph capture. Provider obligations are in #7240, pinned by #7713; the framework-side gap is ROCm/ATOM#3157. With no Provider enabled — every deployment today — dispatch short-circuits before eligibility and every call routes native. Nothing changes on merge.

Testing

pytest -q tests/test_plugin*.py — 101 passed. black / ruff clean on all seven changed files (two pre-existing findings elsewhere in the tree are untouched). Baseline regenerated with the gate's own routed_contracts() scanner, never hand-edited. On MI355X, plugin.status()["routed_ops"] lists 12.

PR Self-Review

Reviewed revision

a325ea04c0

Behavior and intent

Seven decorators, seven baseline entries, three tests. No production logic changes. With nothing enabled every call routes native, so behaviour is unchanged for current deployments.

The judgement worth reviewing is routing decode-path ops before the framework-side warmup fix lands. The alternative — hold them until ROCm/ATOM#3157 and its vLLM/SGLang equivalents are done — is strictly safer but blocks Provider work on another team's schedule. This takes the other side and documents the risk in three places.

Validation and unverified scope

101 passed; contract gate green with a regenerated baseline; all 12 routes verified live on MI355X; all three new assertions mutation-checked.

Unverified: no Provider serves any of these seven, so select() has never run for them with real tensors. For the workspace contract specifically, the lifetime rules — who may write, when it may be reused — are stated by the op's docstring and checked by nothing.

PR-specific question

Should identical fingerprints across two routed ops be a gate failure rather than something a test documents? It would catch this class generically instead of per-pair, but would also fail on any legitimately identical signature — and this pair is the only evidence available about how common that is.

Changed op tests

None. Five aiter/ files gain a decorator and an import; three test/baseline files are updated. No file under op_tests/ is touched, and no existing routed op's signature moves.

🤖 Generated with Claude Code

@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 7728 --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.

@github-actions github-actions Bot changed the title [JIT] [RFC #7240] Route the DeepSeek V4.1 op surface: seven contracts [RFC #7240] Route the DeepSeek V4.1 op surface: seven contracts Nov 10, 2026
@zufayu
zufayu requested a review from junhaha666 November 10, 2026 10:07
@aiter-bot

aiter-bot commented Nov 10, 2026 •

Copy link
Copy Markdown

WAITING ON AUTHOR

PR Self-Review

Revision a92faa765264 · 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 — Reviewed revision must contain at least the first 7 characters of the current head SHA

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

zufayu and others added 5 commits November 11, 2026 00:53
DeepSeek V4.1's attention path calls six AITER ops and not one of them is
routed: the five ops ROCm#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 ROCm#7240 now states obligations for and
ROCm#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. ROCm#7240 states the rule.

**`backend=` needs no special handling.** It is a contract parameter, not a
routing switch (ROCm#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]>
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 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]>
…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]>
zufayu added a commit that referenced this pull request Nov 11, 2026
…documented

`plugin_contracts.json` pins a routed op's signature, which is names and
arity. It cannot say what a parameter MEANS -- and the pair whose meanings
differ is routinely the pair whose signatures look alike. An out-of-tree
provider implements against the prose or against nothing.

Four of the five routed ops on main had no docstring at all
(`pertoken_quant`, `rmsnorm` v2, `rmsnorm_with_add`,
`gemm_a8w8_blockscale_bpreshuffle`), and the fifth,
`gemm_a8w8_blockscale`, documented its backend dispatch at length without
ever saying what it returns. All five now state parameter meanings, shapes
and -- the fact a signature cannot carry -- whether the op returns a new
tensor or writes into the caller's.

`fused_qk_norm_rope_cache_quant_shuffle` is documented here too. It is not
routed on main; #7728 routes it, and this way that PR does not also have to
carry the prose.

Three gates keep it that way: every routed op has a docstring; every
docstring says what it returns or writes; and the scan is pinned against
the contract baseline so neither gate can pass by finding nothing.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
zufayu added a commit that referenced this pull request Nov 11, 2026
The gate asserted `>= 10` routed ops -- a number taken from a tree where
#7728 had already landed its seven. On `main` there are five, so the gate
failed on the very thing it was added to protect.

A count was the wrong pin anyway: it has to be revised every time an op is
routed, and it is a weaker statement than the one already available. The
cross-check against `plugin_contracts.json` is what actually proves the scan
is live, so a non-empty scan plus that equality is the whole invariant.

Also applies Black, which the repo's style gate runs and which disagrees with
`ruff format` on how to wrap this file's asserts.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@zufayu

zufayu commented Nov 11, 2026

Copy link
Copy Markdown
Contributor Author

The red shard is infrastructure, not this PR, and a rerun does not clear it.

ImportError: cannot import name '_jit_function_cache_key'
  from 'flydsl.compiler.jit_function'
op_tests/test_flydsl_moe_a16wfp4.py:503
FAILED op_tests/test_flydsl_moe_a16wfp4.py::test_stage2_lds_variants_have_distinct_cache_keys

That test imports a private flydsl symbol. It is on main (added 2026-11-10 by #6995) and this PR touches nothing near it — the diff is seven @route decorators plus contract/test files.

Every PR whose shard 2 ran after roughly 01:00Z today fails it, and the ones before pass:

PR shard 2 ran (UTC) result
#7774 11-10 23:16 → 11-11 00:02 success
#7783 11-11 01:56 failure
#7785 11-11 03:33 failure
#7728 (this, rerun) 11-11 04:27 failure

So the break lands between 00:02Z and 01:56Z — about fourteen hours after #6995 merged, which points at the flydsl build CI installs rather than at that PR's code. A private symbol disappearing from a dependency is the shape that fits.

I reran the failed job once; it failed identically, so I am not rerunning again. This needs either the flydsl build restored or that test changed to stop importing a private name — neither belongs in this PR.

Every other check here is green and the review is in.

@zufayu

zufayu commented Nov 11, 2026

Copy link
Copy Markdown
Contributor Author

Correcting my previous comment: the timeline inference in it was wrong, though the conclusion it supported is not.

I claimed the break landed between 00:02Z and 01:56Z and pointed at a change in the flydsl build during that window. That does not hold. The run I used as the "before" case (#7774, shard 2, passing) installed the same flydsl 0.5.0 the failing runs install:

#7774  23:22Z  Successfully installed ... flydsl-0.5.0 ...   -> shard 2 passed
#7728  04:27Z  Downloading flydsl-0.5.0-cp312 ...            -> shard 2 failed

The actual difference is which tests each run selects: #7774's shard-2 log never mentions test_flydsl_moe_a16wfp4.py at all, so that run did not exercise it. There was no window and no regression in between — the test has been failing for every run that includes it.

What the evidence does support:

That still makes this red independent of this PR, which adds seven @route decorators plus contract and test files and touches nothing in that path. But the fix is a version pin or a test that does not reach for a private name — not a rerun, and not anything in this PR.

Apologies for the noise in the first comment; the causal story in it was mine, not the data's.

@zufayu zufayu closed this Nov 11, 2026
@zufayu zufayu reopened this Nov 11, 2026
@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 7728 --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.

Brings in ROCm#7774, which fixes test_flydsl_moe_a16wfp4's import of a private
FlyDSL symbol removed in 0.5.0. That fix has been on main since 05:21Z, but
CI checks out the PR head directly rather than a merge with main, so a
branch cut before it keeps failing however many times the run is repeated.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@zufayu
zufayu merged commit 66ec1ad into ROCm:main Nov 11, 2026
zufayu added a commit that referenced this pull request Nov 11, 2026
#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]>
zufayu added a commit that referenced this pull request Nov 11, 2026
#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]>
zufayu added a commit that referenced this pull request Nov 11, 2026
…cumented (#7787)

* docs(plugin): document every routed contract, and gate that it stays documented

`plugin_contracts.json` pins a routed op's signature, which is names and
arity. It cannot say what a parameter MEANS -- and the pair whose meanings
differ is routinely the pair whose signatures look alike. An out-of-tree
provider implements against the prose or against nothing.

Four of the five routed ops on main had no docstring at all
(`pertoken_quant`, `rmsnorm` v2, `rmsnorm_with_add`,
`gemm_a8w8_blockscale_bpreshuffle`), and the fifth,
`gemm_a8w8_blockscale`, documented its backend dispatch at length without
ever saying what it returns. All five now state parameter meanings, shapes
and -- the fact a signature cannot carry -- whether the op returns a new
tensor or writes into the caller's.

`fused_qk_norm_rope_cache_quant_shuffle` is documented here too. It is not
routed on main; #7728 routes it, and this way that PR does not also have to
carry the prose.

Three gates keep it that way: every routed op has a docstring; every
docstring says what it returns or writes; and the scan is pinned against
the contract baseline so neither gate can pass by finding nothing.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* fix(tests): pin the vacuity gate to the baseline, not to a count

The gate asserted `>= 10` routed ops -- a number taken from a tree where
#7728 had already landed its seven. On `main` there are five, so the gate
failed on the very thing it was added to protect.

A count was the wrong pin anyway: it has to be revised every time an op is
routed, and it is a weaker statement than the one already available. The
cross-check against `plugin_contracts.json` is what actually proves the scan
is live, so a non-empty scan plus that equality is the whole invariant.

Also applies Black, which the repo's style gate runs and which disagrees with
`ruff format` on how to wrap this file's asserts.

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

---------

Co-authored-by: zufayu <[email protected]>
Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
zufayu added a commit that referenced this pull request Nov 12, 2026
…ch (#7848)

A routed op's first call in a process acquired a lock and read an
environment variable, because the config snapshot was built lazily. Dynamo
can trace neither, so that call graph-breaks: the region compiles as two
graphs instead of one, and a framework that permits a single backend
invocation per compilation is handed a second and asserts.

Measured with a counting backend, each case in its own process:

    plain function                      1 graph
    routed op, snapshot unbuilt         2 graphs   <- the break
    routed op, snapshot built           1 graph

Nothing else on the dispatch path breaks, so building the snapshot at
import is the whole fix. The hot path was already a plain global read for
every call after the first; this makes the first one no different.

The lazy branch in _config() stays, because _reset_for_testing clears the
snapshot and a test that clears it must not become the call that rebuilds
it inside somebody's graph.

tests/test_plugin_compile.py pins both halves -- one graph per compiled
region, and nothing left to build when dispatch starts -- in subprocesses,
since the breakage is first-call-only and torch._dynamo state is global.
Removing the fix fails both.

This is the coverage #7465 and #7728 lacked: every test of the interface
so far has been eager, and an eager test cannot see a graph boundary.

Co-authored-by: zufayu <[email protected]>
Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
vpietila-amd pushed a commit that referenced this pull request Nov 12, 2026
…ch (#7848)

A routed op's first call in a process acquired a lock and read an
environment variable, because the config snapshot was built lazily. Dynamo
can trace neither, so that call graph-breaks: the region compiles as two
graphs instead of one, and a framework that permits a single backend
invocation per compilation is handed a second and asserts.

Measured with a counting backend, each case in its own process:

    plain function                      1 graph
    routed op, snapshot unbuilt         2 graphs   <- the break
    routed op, snapshot built           1 graph

Nothing else on the dispatch path breaks, so building the snapshot at
import is the whole fix. The hot path was already a plain global read for
every call after the first; this makes the first one no different.

The lazy branch in _config() stays, because _reset_for_testing clears the
snapshot and a test that clears it must not become the call that rebuilds
it inside somebody's graph.

tests/test_plugin_compile.py pins both halves -- one graph per compiled
region, and nothing left to build when dispatch starts -- in subprocesses,
since the breakage is first-call-only and torch._dynamo state is global.
Removing the fix fails both.

This is the coverage #7465 and #7728 lacked: every test of the interface
so far has been eager, and an eager test cannot see a graph boundary.

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.

3 participants