Skip to content

Record why ragged prefill is ungated, and what would have to be measured to gate it - #372

Merged
demandal25 merged 1 commit into
amd-integrationfrom
rocm-ragged-gate-evidence
Sep 14, 2026
Merged

Record why ragged prefill is ungated, and what would have to be measured to gate it#372
demandal25 merged 1 commit into
amd-integrationfrom
rocm-ragged-gate-evidence

Conversation

@demandal25

@demandal25 demandal25 commented Sep 14, 2026

Copy link
Copy Markdown
Collaborator

Summary

The short-query section explains why ragged prefill is not gated with an argument — it runs on already-contiguous KV, so there is no gather to amortise — which reads as "no penalty". The measurement does not say that, and the sweep that sited the paged gate covers ragged too. The real reason is narrower and more useful: gfx942 could be gated at ≤16 and is not, while gfx950 cannot be gated at all, because one shape favours AITER from the shortest query measured onward.

Follow-up to #366 and #362, and the only thing worth keeping from #367, now closed as superseded.

What changed

  • docs/rocm/backends.md — six lines in the "deliberately not gated" paragraph: what the sweep shows per architecture, and which of the two gates is merely unclaimed rather than unsafe.

Benchmark results

Re-measured on merged main (fa37f6408) through BatchPrefillWithRaggedKVCacheWrapper, 9 query lengths × 5 shapes × 2 architectures, --refcheck clean, auto resolved to aiter in all 90 rows. Ratio is aiter / fa2 median time back-to-back in one process, so >1 means AITER is slower.

gfx942 — loses in every shape at 16, first wins at 24

bs / kv q16 q24 q32 q48 q64 q96 q128 q192 q256
bs1 / kv1024 1.18 1.24 1.24 1.16 1.08 1.07 1.01 0.80 0.69
bs1 / kv8192 4.74 2.88 2.88 2.33 1.81 1.50 1.09 0.81 0.58
bs8 / kv1024 1.28 0.99 0.97 0.82 0.65 0.43 0.43 0.33 0.31
bs8 / kv8192 1.24 0.63 0.61 0.48 0.33 0.25 0.23 0.20 0.19
bs32 / kv2048 1.22 0.65 0.65 0.39 0.38 0.29 0.23 0.27 0.22

gfx950 — bs32/kv2048 favours AITER at every query length

bs / kv q16 q24 q32 q48 q64 q96 q128 q192 q256
bs1 / kv1024 1.29 1.47 1.26 1.14 1.05 1.02 0.90 0.60 0.63
bs1 / kv8192 5.29 4.28 3.30 2.02 1.59 1.17 0.91 0.55 0.45
bs8 / kv1024 1.11 0.81 0.71 0.43 0.38 0.28 0.25 0.29 0.15
bs8 / kv8192 1.35 0.71 0.54 0.31 0.26 0.18 0.12 0.24 0.12
bs32 / kv2048 0.58 0.34 0.34 0.37 0.21 0.22 0.17 0.22 0.16

A gfx942-only gate at ≤16 would gain 1.18–4.74×. It is not claimed here — this PR documents the state; taking the win is a separate change with its own test surface.

Test plan

  • Both sweeps re-run on merged main rather than quoted from the earlier branch, and the CSVs kept outside any worktree
  • pre-commit run -a
  • gh api /markdown render check on the edited paragraph
  • /code-review medium — the level review-level.sh --explain computes for a docs-only changelist

No test changes: this documents a decision already implemented and covered by test_batch_prefill_kernels.py's short-query tests.

Note on two earlier drafts

Worth recording, since the diff is small and the reasoning changed twice. The first draft quoted only the one cell where the sign flips and argued "a shared threshold would regress CDNA4" — which the per-arch table one screen above disproves. The second claimed ragged was ungated "for want of a crossover sweep", which Copilot correctly caught as contradicting this PR's own description: the sweep exists. Both are replaced by what the data actually shows.

Copilot AI balanced review requested due to automatic review settings September 14, 2026 02:06

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Reconcile the benchmark-scope claims before approval.

Pull request overview

This documentation-only PR explains why ragged prefill remains ungated and records its measured performance across architectures.

Changes:

  • Documents AITER performance results and the gfx950 exception.
  • Clarifies that a dedicated crossover sweep is needed to establish a threshold.
File summaries
File Summary
docs/rocm/backends.md Documents ragged-prefill performance and gating rationale; benchmark-scope claims still need reconciliation.
Review details

Suppressed comments (1)

docs/rocm/backends.md:514

  • The PR description says BatchPrefillWithRaggedKVCacheWrapper was measured at 9 query lengths × 5 shapes × 2 architectures (and #367's test plan likewise says both routes were swept at 9 query lengths), but this text says the crossover sweep is missing and presents q=16 as the available evidence. Please reconcile these claims: if the 9-point ragged data exists, explain why it is insufficient to site a per-architecture threshold; otherwise correct the benchmark description to say only q=16 was measured.
It is ungated for want of a crossover sweep, not for want of a penalty: at 16
query tokens AITER is slower in every measured shape on gfx942 (1.07–4.42×)
and in four of five on gfx950 (1.10–5.09×), but wins 1.7× at bs 32 / kv 2048
there. Siting a threshold needs its own per-arch sweep, as the paged one did.
  • Files reviewed: 1/1 changed files
  • Comments generated: 0
  • Review effort level: Lite (auto)

Note

Copilot is running an experiment and ran this review at Lite.


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@demandal25
demandal25 force-pushed the rocm-ragged-gate-evidence branch from 4dec408 to 0323b31 Compare September 14, 2026 02:24
Copilot AI review requested due to automatic review settings September 14, 2026 02:24
@demandal25

Copy link
Copy Markdown
Collaborator Author

Suppressed comment on docs/rocm/backends.md:514: correct, and the contradiction was mine — the 9-point ragged sweep does exist, so "for want of a crossover sweep" was false. Re-measured both routes on merged main rather than quoting the old branch, and the real reason is narrower: gfx942 loses in all five shapes at 16 and first wins at 24, so a gfx942 gate is supportable and simply unclaimed; gfx950 cannot be gated because bs32/kv2048 favours AITER at every query length measured. Rewritten in 0323b31, full tables in the PR body.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Qualify the “lose” wording to accurately reflect shape-dependent crossovers.

Get a fresh assessment by requesting another Copilot review.

Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 1
  • Review effort level: Lite (auto)

Note

Copilot is running an experiment and ran this review at Lite.

Comment thread docs/rocm/backends.md Outdated
@demandal25
demandal25 force-pushed the rocm-ragged-gate-evidence branch from 0323b31 to dc91aec Compare September 14, 2026 02:29
Copilot AI review requested due to automatic review settings September 14, 2026 02:29

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Correct the documented crossover range to match the benchmark sweep.

Get a fresh assessment by requesting another Copilot review.

Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 1
  • Review effort level: Lite (auto)

Note

Copilot is running an experiment and ran this review at Lite.

Comment thread docs/rocm/backends.md Outdated
Copilot AI review requested due to automatic review settings September 14, 2026 02:34
@demandal25
demandal25 force-pushed the rocm-ragged-gate-evidence branch from dc91aec to d1ca157 Compare September 14, 2026 02:34

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

The gfx942 crossover description must match the benchmark data by shape.

Get a fresh assessment by requesting another Copilot review.

Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 1
  • Review effort level: Lite (auto)

Note

Copilot is running an experiment and ran this review at Lite.

Comment thread docs/rocm/backends.md Outdated
…vers it

The short-query section gave an argument -- ragged runs on already-contiguous
KV, so there is no gather to amortise -- which reads as "no penalty". The
measurement does not say that, and the sweep that sited the paged gate covers
ragged as well. Re-measured on merged main, 9 query lengths x 5 shapes x 2
architectures, refcheck clean, `auto` resolved to aiter in all 90 rows:

    gfx942            q16    q24    q32    q48    q64    q96   q128   q192   q256
    bs1/kv1024       1.18   1.24   1.24   1.16   1.08   1.07   1.01   0.80   0.69
    bs1/kv8192       4.74   2.88   2.88   2.33   1.81   1.50   1.09   0.81   0.58
    bs8/kv1024       1.28   0.99   0.97   0.82   0.65   0.43   0.43   0.33   0.31
    bs8/kv8192       1.24   0.63   0.61   0.48   0.33   0.25   0.23   0.20   0.19
    bs32/kv2048      1.22   0.65   0.65   0.39   0.38   0.29   0.23   0.27   0.22

    gfx950            q16    q24    q32    q48    q64    q96   q128   q192   q256
    bs1/kv1024       1.29   1.47   1.26   1.14   1.05   1.02   0.90   0.60   0.63
    bs1/kv8192       5.29   4.28   3.30   2.02   1.59   1.17   0.91   0.55   0.45
    bs8/kv1024       1.11   0.81   0.71   0.43   0.38   0.28   0.25   0.29   0.15
    bs8/kv8192       1.35   0.71   0.54   0.31   0.26   0.18   0.12   0.24   0.12
    bs32/kv2048      0.58   0.34   0.34   0.37   0.21   0.22   0.17   0.22   0.16

Ratio is aiter/fa2 median time in one process, so >1 means AITER is slower.
First query length at which each shape favours AITER, in the row order above:

    gfx942   192, 192, 24, 24, 24
    gfx950   128, 128, 24, 24, 16

gfx950's bs32/kv2048 wins at every length measured, so no threshold serves
that shape and ragged cannot be gated there. gfx942 has no such shape -- all
five lose at 16 -- so a gfx942-only gate is supportable and simply unclaimed.
That, not "ragged is cheap", is the reason, and it is worth recording because
the argument is what invites the change.

The doc carries the two conclusions; these tables are the evidence behind them,
which is why the paragraph points here rather than growing a third table.

Co-Authored-By: Claude <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings September 14, 2026 02:41
@demandal25
demandal25 force-pushed the rocm-ragged-gate-evidence branch from d1ca157 to 625c868 Compare September 14, 2026 02:41

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

Focused, benchmark-backed documentation update with no unresolved issues.

Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 0 new
  • Review effort level: Lite (auto)

Note

Copilot is running an experiment and ran this review at Lite.

@demandal25
demandal25 merged commit 4d322ab into amd-integration Sep 14, 2026
3 checks passed
@demandal25
demandal25 deleted the rocm-ragged-gate-evidence branch September 14, 2026 02:52
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