Skip to content

[MLA] [RFC #7240] Route mla_sparse_prefill_v41 through the kernel provider interface - #7783

Open
zhiding512 wants to merge 1 commit into
mainfrom
zhiding512/route-mla-sparse-prefill-v41
Open

zhiding512 wants to merge 1 commit into
mainfrom
zhiding512/route-mla-sparse-prefill-v41

Conversation

@zhiding512

@zhiding512 zhiding512 commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Route mla_sparse_prefill_v41 through aiter.plugin, so a kernel provider can serve it. This adds one decorator on the public function and records its v1 contract in tests/plugin_contracts.json. The signature and the OPUS native path do not change.

Motivation

mla_sparse_prefill_v41 is the DeepSeek-V4.1 MXFP8 sparse attention. ATOM calls it for prefill and decode when the KV cache is FP8 (sparse_attn_v41_paged_2src). An out-of-tree FlyDSL implementation for gfx950 already implements this contract: flydsl-sparse-mla-provider in coderfeli/plugin_poc, entry point plugins.aiter.sparse_mla:provider. The op is not routed today, so that provider's select() is never reached, and no framework can enable it.

Changes

  • aiter/ops/mla_sparse_prefill.py: adds @_route(op="mla_sparse_prefill_v41") above the existing torch_compile_guard, the same way gemm_a8w8_blockscale is routed. Version 1 is the default, as the route() docstring asks.
  • tests/plugin_contracts.json: the v1 baseline for the op, generated with routed_contracts() from tests/test_plugin_contracts.py. The five existing entries are unchanged.
  • aiter/plugin/README.md: the routed-op table now lists six ops.

mla_sparse_prefill_v4 is not routed. It has the same arity, but its second parameter is q_rope instead of q_scale, and no provider serves it.

Testing

  • Unit tests added or updated (the contract baseline)
  • Performance benchmarks run
  • Tested on MI250X
  • Tested on MI300X

Documentation

  • Docstrings updated
  • User guide updated (aiter/plugin/README.md)
  • Performance guide updated
  • No documentation change is needed, with the reason stated below

Dependencies

  • No new third-party dependencies added
  • New dependencies are listed and justified below

Breaking Changes

None. Without a plugin.configure(...) call, or under AITER_PLUGINS=0, dispatch goes straight to the OPUS native and records nothing. Once a framework enables a provider, any call the provider declines still runs OPUS. Examples: a GPU other than gfx950, a shape outside the provider's coverage, or a forced backend or num_kv_splits.

PR Self-Review

Reviewed revision

994ffaaa179da304c74517635dcd5d5cb7354261

Behavior and intent

With no provider enabled, behavior is the same as before. The change makes mla_sparse_prefill_v41 a recorded public contract. From now on, changing its signature requires a version bump and a baseline update, enforced by tests/test_plugin_contracts.py, and an enabled provider can serve the calls it accepts.

Validation and unverified scope

CPU only, with the GPUs hidden (ROCR_VISIBLE_DEVICES=):

  • python3 -m pytest -q tests/test_plugin.py tests/test_plugin_contracts.py tests/test_plugin_discovery.py tests/test_plugin_overhead.py (the "Kernel Provider Interface" gate): 98 passed.
  • python3 -m pytest -q tests/test_plugin_selector_arity.py: 4 passed.
  • The provider's own test, with this checkout first on PYTHONPATH so it reads this baseline: tests/sparse_mla_provider_test.py in the provider repo, 25 passed. The provider's selector unpacks the same 15 parameters as the committed baseline, and the second one it binds is q_scale.
  • black and ruff are clean on the changed file.

Unverified: GPU. No provider runs in this PR. End-to-end serving through the provider in ATOM has not been run yet. The ATOM side is ROCm/ATOM#3179, a draft stacked on ROCm/ATOM#3114.

PR-specific question

Which exact workload keys consume these configuration changes, and what evidence shows that unrelated shapes keep their previous selection?

No workload key changes. tests/plugin_contracts.json is the baseline of routed-op contracts, not a tuned-kernel config. No shape, CSV row or kernel choice reads it at runtime; only tests/test_plugin_contracts.py does. Kernel selection stays the same for every shape:

  • With no provider enabled, which is every deployment today, _dispatch returns native(*args, **kwargs) before it looks at the call. The native is the same torch_compile_guard-wrapped OPUS function as before. This free path is covered by tests/test_plugin_overhead.py.
  • With a provider enabled, any call it declines also runs that native.
  • The five existing baseline entries are unchanged, so no other op's contract moved.

Changed op tests

None.

…vider interface

Decorate the public mla_sparse_prefill_v41 with the plugin route, above its
torch_compile_guard as gemm_a8w8_blockscale does, and record its v1 contract in
tests/plugin_contracts.json. The signature and the OPUS native path are
unchanged; with no provider enabled dispatch goes straight to native.

mla_sparse_prefill_v4 is not routed: it has the same arity, but its second
parameter is q_rope, and no provider serves it.

Co-authored-by: Cursor <[email protected]>
@zhiding512
zhiding512 requested review from a team and a balanced review from Copilot November 11, 2026 00:20
@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 7783 --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

aiter-bot commented Nov 11, 2026 •

Copy link
Copy Markdown

NOT READY FOR HUMAN REVIEW

PR Self-Review

Revision 994ffaaa179d · 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

With no provider enabled, behavior is the same as before. The change makes `mla_sparse_prefill_v41` a recorded public contract. From now on, changing its signature requires a version bump and a baseline update, enforced by `tests/test_plugin_contracts.py`, and an enabled provider can serve the calls it accepts.

Validation and unverified scope

CPU only, with the GPUs hidden (`ROCR_VISIBLE_DEVICES=`):

- `python3 -m pytest -q tests/test_plugin.py tests/test_plugin_contracts.py tests/test_plugin_discovery.py tests/test_plugin_overhead.py` (the "Kernel Provider Interface" gate): 98 passed.
- `python3 -m pytest -q tests/test_plugin_selector_arity.py`: 4 passed.
- The provider's own test, with this checkout first on `PYTHONPATH` so it reads this baseline: `tests/sparse_mla_provider_test.py` in the provider repo, 25 passed. The provider's selector unpacks the same 15 parameters as the committed baseline, and the second one it binds is `q_scale`.
- black and ruff are clean on the changed file.

Unverified: GPU. No provider runs in this PR. End-to-end serving through the provider in ATOM has not been run yet. The ATOM side is ROCm/ATOM#3179, a draft stacked on ROCm/ATOM#3114.

PR-specific question

*Which exact workload keys consume these configuration changes, and what evidence shows that unrelated shapes keep their previous selection?*

No workload key changes. `tests/plugin_contracts.json` is the baseline of routed-op contracts, not a tuned-kernel config. No shape, CSV row or kernel choice reads it at runtime; only `tests/test_plugin_contracts.py` does. Kernel selection stays the same for every shape:

- With no provider enabled, which is every deployment today, `_dispatch` returns `native(*args, **kwargs)` before it looks at the call. The native is the same `torch_compile_guard`-wrapped OPUS function as before. This free path is covered by `tests/test_plugin_overhead.py`.
- With a provider enabled, any call it declines also runs that native.
- The five existing baseline entries are unchanged, so no other op's contract moved.

Changed op tests

None.

PR state

  • PASS — pull request is marked ready for review

Copilot findings

  • PASS — no active Copilot finding lacks a substantive author reply

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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are recorded for the change adding provider routing to mla_sparse_prefill_v41.

No open issues 🎉

What changed in this PR

This PR enables kernel providers to serve mla_sparse_prefill_v41 through aiter.plugin, while preserving its public signature and native OPUS fallback.

Changes:

  • Adds provider routing to the public mla_sparse_prefill_v41 function.
  • Records its version 1 signature and fingerprint in the contract baseline.
  • Updates the plugin documentation to list six routed operations.
File Description
tests/​plugin_contracts.json Adds the version 1 contract for mla_sparse_prefill_v41.
aiter/​plugin/​README.md Adds the operation to the routed-op table and updates the count.
aiter/​ops/​mla_sparse_prefill.py Imports and applies the routing decorator above the existing compile guard.

Review effort: Balanced

@zufayu

zufayu commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

Current next action is with the author before review:

  • The PR currently conflicts with main.
  • Aiter Test Gate is failing, including standard-test shards 2 and 5.

Please rebase and resolve the conflict, triage the failing tests, and post exact-head validation results. Re-request review once the branch is mergeable and the required CI is clear.

@zufayu zufayu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewed the code on current head 994ffaa. The routing decorator preserves the existing public signature and native OPUS fallback, and the provider contract/interface tests cover the new boundary. The two failing standard-test files are unrelated FlyDSL MoE/HGEMM tests, not this MLA routing change. Approving the code as-is; the author still needs to resolve the merge conflict and required CI must be green before merge.

@zufayu
zufayu requested a review from kaiyang-1 November 17, 2026 13:28

@kaiyang-1 kaiyang-1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! Two things before this can move forward:

  1. The branch is 200+ commits behind main and conflicts in aiter/ops/mla_sparse_prefill.py and tests/plugin_contracts.json. Please rebase onto main.
  2. mla_sparse_prefill_v41 is already routed on main (#7728), as version 2 with backend kept out of the contract. This PR's v1 contract (with backend) is the one main moved away from. Could you check whether anything is still missing after the rebase? If not, this PR can probably be closed.

The two failing MI35X shards (test_flydsl_moe_a16wfp4.py, test_flydsl_hgemm.py) are unrelated to this change. The first is fixed on main (#7774), so a rebase will clear it.

This branch has not been deployed

No deployments
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.

5 participants