Skip to content

[RFC #7240] Route the fused qk-norm/rope/cache/quant op, completing V4.1's API surface - #7725

Closed
zufayu wants to merge 1 commit into
ROCm:mainfrom
zufayu:codex/aklr-route-fused-qk
Closed

zufayu wants to merge 1 commit into
ROCm:mainfrom
zufayu:codex/aklr-route-fused-qk

Conversation

@zufayu

@zufayu zufayu commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

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:

stage op PR
qk-norm → rope → cache → quant → shuffle fused_qk_norm_rope_cache_quant_shuffle this one
sparse prefill mla_sparse_prefill_v41 #7715
paged decode mla_decode_fwd_v4_nm #7716
paged decode (persistent) mla_decode_fwd_v4_nm_ps #7717
inverse rope + group quant inverse_rope_group_quant #7716
wo_a / projection GEMM batched_gemm_a8w8_mxscale(_bpreshuffle) #7719

I argued for holding this one back. Both reasons failed checking.

"Nineteen parameters is too coarse a contract." Counted properly it is twelve tensors and seven shape/strategy scalars. For an op reading q, k, v, two weight sets, the rope cache, two KV caches and two scale sets, that is not unusual. Judging contract granularity by parameter count was the wrong instrument.

"Routing one member drags in a family." There are six nearby entry points — differing in quant granularity (block / pts), rope dimensionality (mrope_3d), and a 2way variant. ATOM imports exactly one of them, in two files:

2  fused_qk_norm_rope_cache_quant_shuffle
   <- atom/model_ops/attention_mha.py
   <- atom/plugin/vllm/attention/layer_mha.py

The other five serve paths outside this surface and can stay unrouted without leaving a hole.

This contract returns None, and that is a constraint on dispatch

It is the first routed op that delivers entirely through mutation — q, k and the KV caches are written in place.

That matters beyond documentation. Code that read a falsy return as "the provider declined" would fall through to native after the provider had already written — running the work twice, the second pass over the first's output. Numbers would be wrong, nothing would raise.

Nothing in dispatch inspects return values today. The test added here is what says so:

assert in_place(destination, "written") is None
assert destination == ["written"]      # the in-place write survived
assert native_calls == []              # and native did not also run

Mutation-checked: making dispatch treat a falsy result as a decline turns it red on exactly the native-fallback assertion.

Mount point

Public entry point. @compile_ops wraps _fused_qk_norm_rope_cache_quant_shuffle_hip, not the function callers import.

Decode path

Same consideration as #7716 / #7717 / #7719: provider obligations in #7240, pinned by #7713, framework-side gap at ROCm/ATOM#3157. With no Provider enabled, every call routes native.

Testing

pytest -q tests/test_plugin*.py — 99 passed, black / ruff clean. Baseline gains one entry, the existing eight untouched, generated with the gate's own scanner. Verified on MI355X.

PR Self-Review

Reviewed revision

5f9d9977c8

Behavior and intent

One decorator, one baseline entry, one test. Nothing enabled means native, so no behaviour change on merge.

The judgement worth reviewing is routing a five-stage fused op at all. A Provider must implement the whole fusion or decline — there is no partial service. That is inherent to the op existing, not something routing introduces: splitting it into five contracts would be asking AITER to give up the kernel. But a reviewer who thinks the fusion boundary itself is wrong should say so here rather than after a Provider has implemented against it.

Validation and unverified scope

Plugin suite 99 passed, gate green with the baseline regenerated by its own scanner, route verified live on MI355X, the None-return behaviour mutation-checked.

Unverified: no Provider serves this contract, so the mutation semantics — which tensors a Provider may write, and when — are stated by the op's docstring rather than checked by anything. For a contract that delivers only through mutation that gap is larger than for the others in this series.

PR-specific question

Should the other five family members be routed too? ATOM imports none of them, so this PR says no. If another model path turns out to use one, routing it later costs a baseline entry — but the family's internal boundaries would then need the same scrutiny v4/v41 got.

Changed op tests

None. aiter/ops/fused_qk_norm_rope_cache_quant.py gains a decorator and an import, tests/plugin_contracts.json one entry, tests/test_plugin.py one test. No file under op_tests/ is touched.

🤖 Generated with Claude Code

…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#7716/ROCm#7717/ROCm#7719: obligations in ROCm#7240, pinned by ROCm#7713, framework gap at
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
zufayu requested a review from a team November 10, 2026 09:36
@github-actions github-actions Bot changed the title [JIT] [RFC #7240] Route the fused qk-norm/rope/cache/quant op, completing V4.1's API surface [RFC #7240] Route the fused qk-norm/rope/cache/quant op, completing V4.1's API surface Nov 10, 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 7725 --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

Copy link
Copy Markdown

NOT READY FOR HUMAN REVIEW

PR Self-Review

Revision 5f9d9977c864 · mode shadow

Author self-review accepted. Readiness report:

Author answers

  • PASS — current-SHA answers are present and structurally specific
Show the author's self-review answers

Behavior and intent

One decorator, one baseline entry, one test. Nothing enabled means native, so no behaviour change on merge.

The judgement worth reviewing is routing a five-stage fused op at all. A Provider must implement the whole fusion or decline — there is no partial service. That is inherent to the op existing, not something routing introduces: splitting it into five contracts would be asking AITER to give up the kernel. But a reviewer who thinks the fusion boundary itself is wrong should say so here rather than after a Provider has implemented against it.

Validation and unverified scope

Plugin suite 99 passed, gate green with the baseline regenerated by its own scanner, route verified live on MI355X, the None-return behaviour mutation-checked.

Unverified: no Provider serves this contract, so the mutation semantics — which tensors a Provider may write, and when — are stated by the op's docstring rather than checked by anything. For a contract that delivers only through mutation that gap is larger than for the others in this series.

PR-specific question

*Should the other five family members be routed too?* ATOM imports none of them, so this PR says no. If another model path turns out to use one, routing it later costs a baseline entry — but the family's internal boundaries would then need the same scrutiny `v4`/`v41` got.

Changed op tests

None. `aiter/ops/fused_qk_norm_rope_cache_quant.py` gains a decorator and an import, `tests/plugin_contracts.json` one entry, `tests/test_plugin.py` one test. No file under `op_tests/` is touched.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

PR state

  • PASS — pull request is marked ready for review

Copilot findings

  • PASS — no active Copilot finding lacks a substantive author reply
  • ADVISORY — Copilot did not review the current head SHA

Code and op-test hygiene

  • PASS — no committed artifact or conflict marker detected

Required CI

  • PASS — Black: passed
  • PASS — Ruff: passed
  • PASS — Repository dependency: passed
  • FAIL — Aiter Test Gate: failed
  • Required CI failed; fix it before requesting human review.

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

zufayu commented Nov 10, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by #7728, which carries these five commits unchanged.

Combined because all five 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 yields invalid JSON (the markers cut through object bodies). Verified locally: merging #7715 then #7716 conflicts.

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.

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

2 participants