Skip to content

[Prototype] Give the version handshakes a window that names its removal release - #7450

Closed
zufayu wants to merge 8 commits into
ROCm:mainfrom
zufayu:codex/aklr-version-windows
Closed

zufayu wants to merge 8 commits into
ROCm:mainfrom
zufayu:codex/aklr-version-windows

Conversation

@zufayu

@zufayu zufayu commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Part 5 of the series implementing the dispatch design behind RFC #7240. This one
answers open question 5 — deprecation windows, the last of the RFC's
questions that had no code behind it.

part content status
1 config snapshot, eligible-list cache, enable-order fix, configure() #7437
2 generated per-op binder + the CI benchmark producing the Q6 number #7440
3 provider-error isolation, free kill-switch path, Decision.config_source #7443
4 op registry + the four observability reads #7446
5 (this PR) version handshake windows (Q5) here

Stacks on #7446. Review the last commit only. #7086 and #7123 are untouched.

The gap

Dispatch had no windows at all. A provider whose api_version did not equal
AITER's exactly was skipped; a provider declaring an older op_version was
simply not eligible. Both failures were silent about what to do next — you
learned the deadline by being broken by it.

What this adds

SUPERSEDED_API_VERSIONS = {}                              # old API version -> removing release
route(op="rmsnorm", version=2, supersedes={1: "aiter 0.6"})  # old op version -> release

A provider inside the window loads and serves, warning once and naming the
release that removes its version. One outside is skipped with a reason that
names the versions this AITER does accept. Both warn once per subject rather
than once per call, so a deprecation is visible without being noise.

status() gains api_versions_accepted and deprecations, so what is on
borrowed time, and until when, is data rather than a log line somebody had to
have been watching for.

Who may grant a window

Only AITER. supersedes is declared on route(), next to the contract itself.

AITER owns the op contract, so only AITER can say that a provider written
against an older version is still acceptable for calls on this one — that is a
compatibility assertion about the contract, and the contract is AITER's. A
provider cannot grant itself a grace period, and a contract cannot supersede its
own version (ValueError). Declaring it at the route makes the assertion
explicit and dated instead of implied by whatever the version check happens to
allow.

What is deliberately left to maintainers

The policy. The design proposes two aiter minor releases; this code encodes
no duration. The release string is free-form, because what the mechanism
requires is only that the window exists, is declared, and is named at runtime.
Maintainers can change the policy — or anchor it on time instead of releases —
without touching this.

The missing reason string. An enabled provider on an op version the contract
no longer accepts falls back with reason no-provider. That is literally true —
no provider was eligible — but it does not distinguish that case from nothing
being installed, and the window makes it newly common. The design enumerates no
reason for it, so none is invented here; a test records the gap instead.

Testing

pytest -q tests/ — 210 passed, 6 added. CPU-only. black --check and
ruff check clean. Hot-path cost is unchanged: version matching happens while
building the eligible list, which is cached per (op, config generation).

🤖 Generated with Claude Code

zufayu and others added 8 commits October 28, 2026 16:58
Installing a provider never makes it the default: dispatch now serves a
provider only when it is explicitly enabled (AITER_PLUGIN_ENABLE) or
forced (AITER_PLUGIN_FORCE). This makes the ownership boundary concrete:
AITER owns the op contract and execution rules, providers own their
kernels and qualification evidence, frameworks and users own enablement.

- document the ownership boundary in the module docstring
- isolate invalid candidates returned by select(): fall back to native
  with reason "invalid-candidate" instead of raising AttributeError
- document that entry points must target an instance or zero-arg factory
- tests: installed-but-not-enabled is inert (select never called);
  non-candidate select() results fall back to native

Co-Authored-By: Claude Code <[email protected]>
Dispatch read four environment variables per call and rebuilt a set and a
frozenset each time, costing 2.49us of the hot path (measured). It also stored
enabled providers in a frozenset, which destroyed the enable list order, so
candidates were tried in alphabetical provider-name order instead of the
configured preference order.

Configuration is now an immutable snapshot built at first dispatch. Dispatch
reads one reference per call, so a call always runs against exactly one
generation; configure() and reload_config() build a new snapshot and swap the
reference under the config lock, leaving the hot path lock-free. Measured cost
of the gates drops to 0.048us. The eligible provider list is cached per
(op, config generation), get-or-build, and a build race is benign.

enabled is now an ordered tuple and the eligible list is built by walking it,
so the enable list order is the preference order it was specified to be.

Also:
- configure(*, source, enable, disable): source is required provenance; enable
  replaces the previous framework default, disable unions with the user's. All
  keyword-only, since a required parameter cannot follow a defaulted one.
- reload_config() re-reads the environment deliberately. Mid-process changes
  are not otherwise observed.
- A reload producing an identical snapshot does not bump the generation; a
  no-op bump would flush the eligible cache and churn provider resources.
- An empty environment value counts as unset, so AITER_PLUGIN_ENABLE="" falls
  through to the framework default rather than denying everything.

test_provider_arbitration_is_deterministic asserted that alpha wins from
"alpha, zebra" -- alphabetical order already produced that, so the test passed
against the bug. It is replaced by a case whose enable order contradicts
alphabetical order.

Co-Authored-By: Claude Code <[email protected]>
inspect.Signature.bind is generic: it re-derives the parameter mapping on every
call. Measured against the two signatures ROCm#7123 routes, that is 4.57us for
rmsnorm and 6.05us for pertoken_quant -- on its own more than any plausible
dispatch budget, and the step that dominated the hot path.

The signature is already known when route() decorates the op, so the binder is
now generated once, at decoration. The generated function produces exactly what
bind() + apply_defaults() produce, raises the same TypeError on a malformed
call, and costs 0.076us / 0.083us. Defaults travel through the generated
function's namespace rather than through source text, because a default such as
dtypes.fp32 has no parseable repr. Signatures with *args/**kwargs, or with a
parameter that would collide with an injected default, fall back to
Signature.bind.

This sits below the API boundary: providers receive the same canonical
arguments, callers call the same way, and api_version does not move.

tests/test_plugin_overhead.py measures the whole path and prints the numbers,
which is what RFC ROCm#7240's first milestone actually asks for. On a Xeon
Platinum 8480C with Python 3.12.12, overhead over a direct native call:

    provider serves        1.79us
    no provider enabled    1.42us
    AITER_PLUGINS=0        1.19us
    one Signature.bind     4.85us

So the 1us design budget is not met yet, and the per-step projection that
suggested it would be (~0.9us) was optimistic: it omitted the Python call chain
and the per-call bookkeeping that only an end-to-end measurement sees. Decision
construction plus the ContextVar set is 0.787us of what remains, and is now the
largest single item.

The gate asserts what can be defended on unknown hardware: the whole aiter-side
overhead must cost less than one Signature.bind of the same signature, measured
in the same process. That fails the moment generic canonicalization, a per-call
getenv, or a rebuilt provider list returns, on any runner. The 1us budget is
reported rather than asserted until CI runner hardware is characterised.

Co-Authored-By: Claude Code <[email protected]>
…g layer

Three changes that share the dispatch path.

**A misbehaving provider no longer denies service to a well-behaved one.** A
select() exception, and a candidate that is not a KernelCandidate or is owned by
somebody else, both removed the whole op from provider routing: the first one
encountered returned to native and the remaining providers were never asked.
That is correct with one provider and wrong with several. Both are now
pre-execution misbehaviour that removes that provider from this call only.

Native fallback happens when no provider serves. Reason precedence is two tiers:
either provider error outranks provider-declined -- a decline is normal
operation, an error is something someone must fix -- and within the error tier
the first one encountered is recorded, each keeping its own reason string.
Ranking provider-select-error against invalid-candidate would be arbitrary: both
mean the provider is broken, and either ranking still depends on iteration
order.

**The kill switch is now a free path.** With AITER_PLUGINS=0 dispatch checks one
cached flag and calls native, recording nothing: the feature is off, so there is
nothing to observe. Measured overhead over a direct native call drops from
1.19us to 0.141us. A per-op disable still records its Decision -- that op was
routed and deliberately turned off, which is what an operator is watching.

**Decision carries config_source**, naming the layer that produced the route:
"env", "configure:<source>", or "default-deny". An op-disabled route names the
layer that disabled it rather than the enable layer, so disabled_ops is now a
mapping from op name to its source; when both the framework and the user disable
an op, the user's act is the one named.

Measured on a Xeon Platinum 8480C, Python 3.12.12, overhead over a direct native
call: the serving path moves from 1.79us to 1.96us, paying one function call for
the isolation boundary and one more Decision field. The kill-switch path is
8.4x cheaper.

Co-Authored-By: Claude Code <[email protected]>
RFC ROCm#7240 fixes what is observable but not how it is delivered. One record,
four reads: every layer consumes the same frozen Decision, and there are no
separate formats.

    last_decision()    per call        what served this call (already existed)
    status()           introspection   why is, or is not, X routed
    explain(op, ...)   introspection   the same question without executing
    decision_counts()  aggregation     what ran, how often, with what outcome
    on_decision(cb)    aggregation     inline, native routes included
    route-change log   audit trail     did routing flip when config changed

Reporting anything per op presumes routed ops are enumerable, which nothing
made true: Op and the contract lived only in route()'s closure. route() now
registers the op, and a duplicate op name is an error at import. Silent
last-wins would make routing depend on import order, which is exactly what the
enable list exists to avoid, and two routes claiming one name make op_version
unable to describe the contract anyway.

status() reports installed providers including the ones that were skipped and
why -- an installed provider that never serves is the first thing an operator
asks about, and that answer was previously only in the logs.

explain() dry-runs gates, eligibility and selection and returns the Decision the
call would produce plus why each provider declined. It never calls run(), never
records a Decision, and never counts one. It relies on select() being pure,
which is already a provider obligation.

on_decision() callbacks are called inline. A callback exception is swallowed,
logged once per callback rather than once per call, and counted in status(): a
telemetry bug must never break a kernel launch.

The route-change log is scoped to the config generation. Within one generation
the route is a deterministic function of the call arguments, so call-to-call
variation is provider behaviour -- visible in decision_counts() -- and not an
audit event. One line per op per generation, only when the route differs.

Every Decision now goes through a single _record(), so the four reads cannot
drift apart.

Cost, measured on a Xeon Platinum 8480C with Python 3.12.12: the serving path
moves from 1.96us to 2.42us. The layer is 0.46us, of which the counter
increment is the largest single piece at 0.166us, the route-change check 0.063us
and the empty callback loop 0.038us. This is the number the design estimated at
0.110us by counting the increment alone.

Co-Authored-By: Claude Code <[email protected]>
A CUDA graph replay runs no Python, so a captured op contributes one count for
the whole life of the graph however many times it replays. The counts are a
complete record of what was decided; read as a call mix they are wrong by
orders of magnitude for captured decode.

Co-Authored-By: Claude Code <[email protected]>
RFC ROCm#7240's open question 5 asks for deprecation windows. Dispatch had none: a
provider whose api_version did not equal AITER's exactly was skipped, and a
provider declaring an older op_version was simply not eligible. Both failures
were silent about what to do next.

SUPERSEDED_API_VERSIONS maps a still-accepted provider API version to the
release that removes it. A provider inside the window loads and warns once,
naming that release; one outside is skipped with a reason naming the versions
this aiter does accept.

route(supersedes={old_version: release}) does the same for an op contract. A
provider still on the old version serves and warns once, naming the release that
stops accepting it. Only AITER can make that declaration: AITER owns the
contract, so only AITER can say that a provider written against an older version
is still acceptable for calls on this one. A provider cannot grant itself a
grace period, and a contract cannot supersede its own version.

Both warn once per subject rather than once per call, and the warning always
names the removal point, so nobody learns a deadline from a crash.

The policy -- the design proposes two aiter minor releases -- stays with
maintainers. What the mechanism requires is only that the window exists, is
declared, and is named at runtime; the release string is free-form so the
policy can change without the code changing.

status() gains "api_versions_accepted" and "deprecations", so what is on borrowed
time and until when is data, not a log line somebody has to have been watching
for.

One thing deliberately not invented: an enabled provider on an op version this
contract no longer accepts falls back with reason "no-provider", which is
literally true but does not distinguish it from nothing being installed. The
design enumerates no reason for that case; a test records the gap rather than
inventing a string for it.

Co-Authored-By: Claude Code <[email protected]>
@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every PR:

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

Extended tests (opt-in via labels):

Label Tests
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 gfx1201 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 7450 --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.

@aiter-bot

Copy link
Copy Markdown

NOT READY FOR HUMAN REVIEW

PR Self-Review

Revision 4c8e2655e5ba · 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. What changes in dependency, cache or compilation behavior, and how did you verify both a clean build and an existing-cache path?
  4. For every changed op_tests/ file, what behavior does it cover and why is it not redundant? Write None if no op test changed.

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

Missing or invalid answers

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

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

@zufayu

zufayu commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

Folded into #7465, which now carries this work with its commits intact. The series was split by when it was written; it is now split by who reviews it — the interface (#7465), the CI gate (#7466), and routing plus the jit/core.py change (#7484).

@zufayu zufayu closed this Nov 5, 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