Skip to content

[CK] [Bugfix] Align batch prefill full-attention dispatch - #6990

Merged
shay-li77 merged 1 commit into
ROCm:mainfrom
lunarwhite:lunarwhite/fix-batch-prefill-full-attention
Nov 6, 2026
Merged

shay-li77 merged 1 commit into
ROCm:mainfrom
lunarwhite:lunarwhite/fix-batch-prefill-full-attention

Conversation

@lunarwhite

@lunarwhite lunarwhite commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

Batch prefill can fail with no matching kernel found when a noncausal window covers the entire KV sequence or when full attention includes a virtual sink. This is to address two pre-existing issues identified during review of PR 6760: #6760 (comment), #6760 (comment)

Technical Details

  • Normalize windows before selecting the Python specialization, matching C++.
  • Route full attention with virtual sinks through CK's existing unlimited-window mask specialization.

Streaming sink_size remains irrelevant to full attention. Kernel arithmetic and the public API are unchanged.

Test Plan

Add 24 BF16 numerical regression cases covering single/multi-query attention, unequal request lengths, shuffled pages, GQA, per-head virtual sinks, oversized windows, and causal/local controls.

The cases run through the existing standalone GPU CI entry point and can also be run with:

python -m pytest -q op_tests/test_batch_prefill.py -k test_batch_prefill_full_attention

Test Result

Local checks passed for 512 dispatch combinations and 24 fixture comparisons against an independent CPU FP64 reference.

GPU validation in CI are passed. The current PR head has a successful GPU run of op_tests/test_batch_prefill.py.

Submission Checklist

@lunarwhite
lunarwhite requested review from a team and a balanced review from Copilot October 27, 2026 05:25
@github-actions

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 6990 --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.

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.

🔵 Needs a closer look

Kernel availability and numerical correctness still require a successful GPU run of the batch-prefill tests on the current PR head.

No open issues 🎉

What changed in this PR

This PR aligns Python and C++ batch-prefill dispatch to prevent no matching kernel found errors for full attention with oversized windows or virtual sinks, without changing kernel arithmetic or the public API.

Changes:

  • Normalize oversized windows before selecting the Python specialization.
  • Route full attention with virtual sinks through CK’s existing unlimited-window mask specialization.
  • Add 24 BF16 regression cases to pytest and the standalone GPU CI entry point.
File Description
op_tests/​test_batch_prefill.py Extends the attention reference and adds full-attention regression coverage.
csrc/​py_itfs_ck/​mha_batch_prefill_kernels.cu Selects the masked specialization for full attention with virtual sinks.
aiter/​ops/​mha.py Aligns window normalization and mask/sink specialization selection with C++.

Review effort: Balanced

@lunarwhite
lunarwhite force-pushed the lunarwhite/fix-batch-prefill-full-attention branch from 3b3c6f4 to e2908f1 Compare October 27, 2026 08:56
Copilot AI balanced review requested due to automatic review settings October 27, 2026 08:56

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.

🟡 Changes recommended

The new tests pass an unsupported reference-helper argument, blocking all 24 numerical comparisons and interrupting standalone CI.

1 open issue

Review effort: Balanced

Comment thread op_tests/test_batch_prefill.py Resolved
Normalize windows before choosing the Python specialization and route
virtual sinks through CK's existing unlimited-window mask kernels.
Keep full attention independent of streaming sink_size and cover the
previously failing dispatches with numerical regression tests.

Signed-off-by: Yuedong Wu <[email protected]>
@lunarwhite
lunarwhite force-pushed the lunarwhite/fix-batch-prefill-full-attention branch from e2908f1 to dee53cb Compare October 27, 2026 09:09
Copilot AI balanced review requested due to automatic review settings October 27, 2026 09:09

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.

🔵 Needs a closer look

A successful GPU regression run on the current head is still needed to confirm CK specialization availability and numerical correctness.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@shay-li77 shay-li77 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.

LGTM

@shay-li77
shay-li77 merged commit 48cd190 into ROCm:main Nov 6, 2026
71 checks passed
@lunarwhite
lunarwhite deleted the lunarwhite/fix-batch-prefill-full-attention branch November 6, 2026 13:23
ruanjm pushed a commit that referenced this pull request Nov 10, 2026
Normalize windows before choosing the Python specialization and route
virtual sinks through CK's existing unlimited-window mask kernels.
Keep full attention independent of streaming sink_size and cover the
previously failing dispatches with numerical regression tests.

Signed-off-by: Yuedong Wu <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants