Skip to content

[Prototype] Snapshot plugin configuration and honour the enable list order - #7437

Closed
zufayu wants to merge 3 commits into
ROCm:mainfrom
zufayu:codex/aklr-config-snapshot
Closed

zufayu wants to merge 3 commits into
ROCm:mainfrom
zufayu:codex/aklr-config-snapshot

Conversation

@zufayu

@zufayu zufayu commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Part 1 of a series implementing the dispatch design behind RFC #7240. Each part
is reviewable on its own; together they close the RFC's first milestone, whose
bar is that hot-path cost is measured, not designed.

part content status
1 (this PR) config snapshot, eligible-list cache, enable-order fix, configure() / reload_config() here
2 generated per-op binder + the CI budget benchmark that produces the Q6 number next
3 provider-error isolation, free kill-switch path, Decision.config_source planned
4 op registry + observability APIs (status, explain, decision_counts, on_decision) planned

Stacks on #7086 — its two commits appear in this diff because the prototype
branch is not in this repository. Review the last commit only.
Both #7086 and #7123 are untouched.

What this changes

Configuration is snapshotted. Dispatch read four environment variables per
call and rebuilt a set and a frozenset each time. It now reads one immutable
snapshot reference, 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; the hot path stays lock-free. The eligible provider list
is cached per (op, config generation), get-or-build, and a build race is
benign.

Measured, CPU-only, Xeon Platinum 8480C / Python 3.12.12, min of 9 x 200k:

step before after
gates (kill / disable / force / enable) 2.49us 0.048us
eligible-provider list rebuilt per call cached

The enable list order now decides. Enabled providers were kept in a
frozenset, which destroyed the order, so candidates were tried in alphabetical
provider-name order rather than the configured preference order. enabled is now
an ordered tuple and the eligible list is built by walking it.

test_provider_arbitration_is_deterministic asserted that alpha wins from
AITER_PLUGIN_ENABLE="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.

New configuration API.

aiter.plugin.configure(*, source: str, enable: Sequence[str] = (),
                       disable: Sequence[str] = ()) -> None
aiter.plugin.reload_config() -> None

source is required provenance, so every route names an owner. enable
replaces the previous framework default; disable unions with the user's, so a
framework opt-out and a user opt-out never cancel each other. All parameters are
keyword-only — a required parameter cannot follow a defaulted one.

Behaviour changes worth noting in review

  • Mid-process environment changes are no longer observed. reload_config()
    re-reads deliberately. Two existing tests changed environment variables
    mid-test and expected immediate effect; they now call reload_config(). This
    is the intended semantics, not a workaround — a new test pins it from both
    sides.
  • A reload producing an identical snapshot does not bump the generation. A
    no-op bump would flush the eligible cache, spend a route-change scan per op,
    and churn provider resources for nothing.
  • An empty environment value counts as unset, so AITER_PLUGIN_ENABLE=""
    falls through to the framework default instead of denying everything. The way
    to deny everything is AITER_PLUGINS=0.

Testing

pytest -q tests/test_plugin.py — 20 passed (12 existing, 8 added). CPU-only,
no GPU required. black --check and ruff check clean.

🤖 Generated with Claude Code

zufayu and others added 3 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]>
@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 7437 --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 a436e356f61f · 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