Skip to content

[HIP] PA decode PS reduce: optional query_start_loc for ragged (varlen) output - #6444

Merged
amd-ruitang3 merged 2 commits into
ROCm:mainfrom
andrei-kochin:split/pa-ps-reduce-hip-varlen
Nov 23, 2026
Merged

amd-ruitang3 merged 2 commits into
ROCm:mainfrom
andrei-kochin:split/pa-ps-reduce-hip-varlen

Conversation

@andrei-kochin

@andrei-kochin andrei-kochin commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

Part 1 of 2 split out of #6099 (author: @sshlyapn), so each PR changes one backend.

pa_decode_gluon needs the same query_length for every sequence, so it can't take a decode batch with mixed lengths (e.g. speculative decodes next to plain decodes, as vLLM's ROCM_AITER_FA backend sends with shuffled KV). The follow-up Gluon PR adds ragged (varlen) input; this PR adds the matching support to the HIP PS reduce it dispatches to.

Changes

  • New optional query_start_loc ([num_seqs + 1], int32) for csrc/cpp_itfs/pa/pa_ps.py::launch_pa_decode_ps_reduce. With it, the output is packed per token as [1, num_tokens, num_kv_heads, group, head] (stride_output_bs unused), sequence b writes rows [query_start_loc[b], query_start_loc[b + 1]), and rows past a sequence's query length are not stored (the whole block exits together, since the check depends on blockIdx only).
  • The varlen code sits behind the IS_VARLEN template parameter, which is also part of the HIP JIT cache key.
  • _LAUNCHER_ABI_VERSION is bumped: the JIT build cache is keyed on the template kwargs, not the source, and the launcher's C signature gained a parameter.

Uniform path impact

query_start_loc_ptr is only read under if constexpr(IS_VARLEN). Uniform calls build the IS_VARLEN=false instance and pass nullptr, so uniform kernels never touch it. Existing callers don't pass query_start_loc, so behaviour on main is unchanged.

Related PRs

Tests

These three files are byte-identical to #6099. The varlen HIP reduce is exercised by op_tests/triton_tests/test_pa_decode_gluon_varlen.py in the stacked Gluon PR (split runs with 8 and 4 partitions forced onto the HIP reduce).

@andrei-kochin
andrei-kochin requested review from a team and a balanced review from Copilot October 12, 2026 16:50
@github-actions github-actions Bot added the HIP label Oct 12, 2026
@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 6444 --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.

🟡 Changes recommended

The signature change breaks an existing gfx950 caller, input layout validation is incomplete, and the new path lacks standalone coverage.

3 open findings
What changed in this PR

Adds ragged-query output support to the HIP paged-attention partition reducer.

Changes:

  • Adds optional query_start_loc dispatch and JIT specialization.
  • Packs variable-length sequence outputs by token.
  • Updates the launcher ABI and kernel signature.
File Description
csrc/​cpp_itfs/​pa/​pa_ps.py Exposes ragged reduction and updates JIT caching.
csrc/​cpp_itfs/​pa/​pa_ps.cuh Implements packed-row addressing.
csrc/​cpp_itfs/​pa/​pa_ps.cpp.jinja Threads the new pointer and template flag into HIP.

🧠 Review effort: Balanced


💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread csrc/cpp_itfs/pa/pa_ps.cuh Resolved
Comment thread csrc/cpp_itfs/pa/pa_ps.py Resolved
Comment thread csrc/cpp_itfs/pa/pa_ps.py Resolved
@zufayu
zufayu requested a review from shengnxu October 13, 2026 01:40
Copilot AI balanced review requested due to automatic review settings October 14, 2026 11:10
@sshlyapn
sshlyapn force-pushed the split/pa-ps-reduce-hip-varlen branch from e01d3e7 to 6562bac Compare October 14, 2026 11:10

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

The HIP kernel’s new ragged addressing path requires final human review without head-matched GPU validation in this PR.

3 open findings

🧠 Review effort: Balanced

@zufayu
zufayu requested review from amd-ruitang3 and removed request for shengnxu October 15, 2026 04:56
@zufayu zufayu assigned amd-ruitang3 and unassigned shengnxu Oct 15, 2026
Copilot AI balanced review requested due to automatic review settings October 15, 2026 10:55
@sshlyapn
sshlyapn force-pushed the split/pa-ps-reduce-hip-varlen branch from 6562bac to dd912eb Compare October 15, 2026 10:55

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

GPU addressing and launcher ABI changes need runtime validation and human review; no validation results were established here.

3 open findings

🧠 Review effort: Balanced

@sshlyapn

Copy link
Copy Markdown
Contributor

@zufayu @amd-ruitang3 could you please take a look at this PR?

sshlyapn and others added 2 commits October 28, 2026 12:01
…n) output

Optional query_start_loc ([num_seqs + 1], int32) for the HIP partitioned-
softmax reduce. With it, the output is packed per token as
[1, num_tokens, num_kv_heads, group, head] and sequence b writes rows
[query_start_loc[b], query_start_loc[b + 1]); rows past a sequence's query
length are not stored.

- The varlen code sits behind the IS_VARLEN template parameter, which is also
  part of the JIT cache key; uniform calls build IS_VARLEN=false and pass
  nullptr, so uniform kernels never touch the pointer.
- Bump the launcher ABI version: the JIT cache is keyed on the template
  kwargs, not the source, and the C signature gained a parameter.

Split out of ROCm#6099; the Gluon PA decode consumer and its tests follow in a
stacked PR.

Signed-off-by: Sergei Shliapnikov <[email protected]>
Signed-off-by: Andrei Kochin <[email protected]>
Co-authored-by: Cursor <[email protected]>
@sshlyapn
sshlyapn force-pushed the split/pa-ps-reduce-hip-varlen branch from dd912eb to 4b06630 Compare October 28, 2026 12:17
Copilot AI balanced review requested due to automatic review settings October 28, 2026 12:17

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

The HIP launcher ABI and device-side indexing changes still need exact-head GPU compilation and execution on supported AMD targets for uniform, ragged, and zero-length cases, which this review environment could not validate.

3 open issues

Review effort: Balanced

@github-actions

Copy link
Copy Markdown
Contributor

No activity for 15 days, so this is now labelled stale. A push or a comment clears it; keep-open exempts it. Nothing is closed automatically.

@github-actions github-actions Bot added the stale The PR hasn't been updated in 2 weeks label Nov 13, 2026
@amd-ruitang3

Copy link
Copy Markdown
Contributor

LGTM

@andrei-kochin andrei-kochin removed the stale The PR hasn't been updated in 2 weeks label Nov 16, 2026
@amd-ruitang3
amd-ruitang3 merged commit df741e9 into ROCm:main Nov 23, 2026
57 checks passed
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.

5 participants