Repository navigation
[HIP] Optimize wide-pool H64 fused attention decode with KV32 and tail splitting on MI355X - #8983
Conversation
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: Reviews: |
WAITING ON AUTHORPR Self-ReviewRevision 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
Edit the Missing or invalid answers
Shadow mode reports what would block but keeps the status successful. Set |
There was a problem hiding this comment.
🔵 Needs a closer look
The gfx950 assembly and manual pipeline changes require GPU-specialist review, and no head-matched validation report was supplied to substantiate MI355X correctness or performance.
No open issues 🎉
What changed in this PR
This PR optimizes AITER’s fused H64 MXFP8 attention decode on MI355X for large KV pools. It adds a direct KV32 path and explicit compact tail splitting while preserving existing automatic split selection and full-size workspaces.
Changes:
- Adds 32-row KV tiles, double-buffered shared memory, and query reordering for eligible direct calls.
- Adds compact tail-only splitting and reduction at supported query counts near the 256- and 512-query boundaries.
- Documents workspace requirements and extends tests for split thresholds, variable CSR lengths, wide KV addresses, and both position widths.
| File | Description |
|---|---|
op_tests/test_fused_norm_rope_attn_rope_cast.py |
Adds wide-pool direct and compact-tail correctness coverage. |
csrc/kernels/mla/fused_norm_rope_attn_rope_cast/fused_norm_rope_attn_rope_cast.cu |
Adds eligibility checks, workspace validation, and dispatch. |
csrc/kernels/mla/fused_norm_rope_attn_rope_cast/dispatch.hpp |
Defines compact-tail thresholds and launcher declarations. |
csrc/kernels/mla/fused_norm_rope_attn_rope_cast/attention_64rows_reduce.cu |
Adds tail reduction using existing reducers. |
csrc/kernels/mla/fused_norm_rope_attn_rope_cast/attention_32rows.cuh |
Adds direct-to-shared-memory KV loading and packed-scale handling. |
csrc/kernels/mla/fused_norm_rope_attn_rope_cast/attention_32rows.cu |
Implements query ordering, tail partitioning, and specialized launches. |
aiter/ops/fused_norm_rope_attn_rope_cast.py |
Documents compact workspace shapes and eligibility requirements. |
Review effort: Balanced
There was a problem hiding this comment.
🔵 Needs a closer look
The gfx950 LDS pipeline and compact softmax changes require human assessment of MI355X correctness and performance evidence, with head-matched validation unavailable and T=577–600 end-to-end testing still outstanding.
No open issues 🎉
Review effort: Balanced
There was a problem hiding this comment.
🔵 Needs a closer look
The gfx950 LDS pipeline and compact-tail softmax changes need MI355X expert review and runtime validation, with no independently verified head-matched report and outstanding end-to-end coverage for T=577–600.
No open issues 🎉
Review effort: Balanced
There was a problem hiding this comment.
🔵 Needs a closer look
The gfx950 assembly scheduling and compact-tail reductions lack independent, exact-head GPU correctness/performance validation and maintainer confirmation, while end-to-end validation of the 577–600-query extension remains outstanding.
No open issues 🎉
Review effort: Balanced
There was a problem hiding this comment.
🟡 Changes recommended
The compact launcher lacks regression coverage for graph replay with changing or empty tail CSR rows, leaving its partial-write and merge behavior unverified across supported 2/4/8 splits.
1 open issue
Review effort: Balanced
|
@aiter-bot review |
|
aiter-bot — queued behind 7 review(s); expect to start in about 73 min. The box reviews up to 4 PRs at a time. |
There was a problem hiding this comment.
🔵 Needs a closer look
The new gfx950 pipeline and compact-tail reductions require head-matched MI355X correctness, graph-replay, and latency checks unavailable here, with four-rank T=577–600 validation still outstanding.
No open issues 🎉
1 resolved since last review
Review effort: Balanced
@zufayu — please take a look. Re-comment |
…runcated watchdog read, size the agent timeouts for the 4-lane pool (#9201) * [CI] review-bot: read WORK out of a binary fetch log, retry a stalled watchdog read, size the agent timeouts for the 4-lane pool Three failure modes from the 2026-12-04 outage (6 failed runs, 01:24-03:02): - run_one.sh extracted WORK= from the tee'd fetch log with a bare grep, so a PR with binary artifacts (OPUS .co blobs put NULs in that log) made grep answer "binary file matches" instead of the match -- a fetch that SUCCEEDED was reported as "fetch produced no WORK dir" on every retry (#8283/#7979/#7983). grep -a reads the log as text. - watchdog.py caught only HTTPError, so a 30s socket timeout crashed the watchdog with a bare TimeoutError and failed a run whose review had already published a green card (#9178). A stalled GET is now retried (3 attempts, 5s backoff); a POST is never retried, because a retried comment can land twice, and a failed POST degrades to 0, which the caller already warns about. - AITER_AGENT_TIMEOUT=2400s was sized for one review at a time; the 4-lane pool serves four through the same GLM endpoint and workers measured 25-40+ min under that load, so 2400s timed out live while the backend answered normally (#8983/#8541). Defaults now 3300s/agent and 6900s/run (115 min, still under the job's timeout-minutes of 120; check_prompts.py asserts it). watchdog_test.py gains real-socket transport checks (the retry lives below the _get/_post seam its fakes replace) with a mutation guard; _fetchfail_test.sh gains the binary-log case. selftest: 156 green / 0 red. Co-Authored-By: Claude Code <[email protected]> * watchdog: retry a truncated response body, not just a stalled read A response that dies mid-body raises http.client.IncompleteRead -- an HTTPException, not an OSError -- so the OSError-only retry net added for the 2026-12-04 stall let it escape unretried and unnamed: the same bare-traceback crash one layer up, and _post's RuntimeError guard could not degrade it either. Name the family in the catch so a truncated GET is retried like a stalled one and a truncated POST degrades to 0. Co-Authored-By: Claude Code <[email protected]> --------- Co-authored-by: zufayu <[email protected]> Co-authored-by: Claude Code <[email protected]>

Summary
Optimize wide-pool H64 two-source MXFP8 decode on MI355X. The direct path uses a 32-row KV tile for eligible calls between 257 and 768 queries. Callers at the 256- and 512-query boundaries can explicitly split the KV work for the tail using a compact workspace.
Implementation
[T - bulk, parts, 64, 516]. The existing full-size split workspace has its own layout check. The op test covers compact workspaces, both RoPE position widths, variable CSR lengths and wide KV row addresses.MI355X results
Whole-call measurements on
65d8ba1The comparison base is
b495628a. On a single MI355X, we alternated base, previous PR head (cf37e238), and current head across three independent processes per revision and index pattern. Each process rotated six inputs, measured nine timed rounds after graph warmup, and reused its output buffers. Both KV sources have full lengths (512 + 128), H64/D512, with a 9M-row prefix pool. Random indices use int32 positions, and request-local indices use int64 positions. Times are medians in microseconds per complete fused call, including both launches for compact tails, with workspace allocation outside timing.We also replayed captured CSR indices and positions with seeded Q and KV, using three processes per route and input. T=582 is cropped from native T=768 recordings.
The wrapper commit limits default flag allocation to eligible full-workspace H64 two-way reductions. A direct or compact T=582 eager call on a fresh stream now allocates 0 bytes of default flags (previously 524,288 bytes). With a T=66 full-workspace split, capturing after a direct-only warmup takes the separate reduction. Warming the two-way reduction on the capture stream retains a single dispatch. In the T=66 request-local replay control, current-head latencies were 27.21 µs after direct-only warmup and 24.71 µs after two-way warmup.
The current and previous heads matched on all 198 full output-and-scale digest checks for the first input bank. The new allocation regression and 48 H64 pair-reduction cases passed. Four-rank serving results below are from earlier revisions; the current-head measurements above cover the operator and graph replay.
Earlier operator and model measurements
Each full query uses 512 prefix rows and 128 window rows, H64/D512, with a 9-million-row MXFP8 prefix pool and separate data and group32 scale planes. The table reports microseconds per complete fused call using request-local indices, int64 positions, four rotating inputs, warm HIP graph replay and the median of three independent processes. Both launches and the final quantized writeback are included in the compact results. Workspace allocation precedes capture.
The T=528 direct permutation assigns ten of its last sixteen CTAs to rows in the first 512 queries. The useful split therefore depends on the query lengths and on the direct workgroup order. Callers opt in explicitly.
For an independent reference, the existing OPUS attention with separate Q RoPE/quantization and inverse-RoPE/output quantization took 100.59 us at T=513 and 99.78 us at T=528 with full KV. These measurements start from raw BF16 Q and ready-to-read KV and end at the quantized output. Window updates and the output projection are outside the timing scope.
Extending the two-way split through 600 queries
On MI355X, a sweep of every T from 577 through 600 compared direct execution with opt-in two-way splitting. All 24 sizes improved in each of three independent processes on full-length request-local indices, full-length random indices, and two captured GSM8K CSR inputs. The sweep used an experimental upper limit of 640. By T=624, the random full-length and variable-length GSM8K inputs were roughly tied. The submitted upper limit is 600.
At T=582, paired graphs on the submitted build gave the following complete operator times in microseconds (one process per input, median of nine timing rounds). The model CSR inputs are the first 582 queries of T=768 recordings, with captured indices and positions and seeded Q/KV values.
The default path remains direct for this shape. To select the two launches at T=582, pass
num_splits=2and a contiguous FP32 workspace of shape[70, 2, 64, 516]. Choose the route using the actual workload.Direct KV32 path
In a separate same-card A/B against AITER
1c8b96fd, the wide-pool KV32 direct implementation reduced median latency at T=336 from 70.07 to 59.57 us, at T=448 from 73.14 to 61.84 us, and at T=768 from 113.20 to 98.04 us. These runs used random indices, int32 RoPE positions, six rotating input sets and automatic split selection. The compact-tail results above use request-local indices and int64 positions.Validation
ccc75a1378f82a566f465ed40b8388a8aa1b5a58, after merging main atb495628a41568ea3b0289c6c7076f59a6e4c8211, all seven HIP translation units were rebuilt. On MI355X (gfx950), the merged Python wrapper and rebuilt library passed 3,219 operator contract cases, including 26 wide-pool H64 cases and 48 H64 pair-reduction cases, followed by the public decode sweep at T=257, 513, 561 and 576. The wide-pool tests exercise compact tail workspaces with int32 and int64 positions. The pair-reduction tests compare full-workspace results with and without flags and exercise graph replay. The subsequent formatting commit changed only line wrapping in the op test, with identical Python AST. The rebuilt library SHA-256 is0f8d4a8ef8e588c06beb4a898cb0a60e55c5c5003c1c6e42accea8248623ecd4.db924ab5f67a3758e9f34597122b78ee426f4e6f363259645f89e255cf94d14f.The ATOM caller is tracked separately from this operator change. Its underlying fusion integration is ROCm/ATOM#2903.
Testing and documentation
Breaking changes
None. Existing callers can continue to use automatic split selection or a full-size workspace.
PR Self-Review
Reviewed revision
65d8ba1476e8c5f79d23659d3bf6a861cdcc15d6againstb495628a41568ea3b0289c6c7076f59a6e4c8211. The latest commit updates the Python wrapper and the allocation contract test.Behavior and intent
A full additional query at the CU boundary can put a long serial KV walk on the critical path. The compact launch distributes that tail query's KV tiles across workgroups and accounts for the sink once in the final reduction.
Validation and unverified scope
Before the merge, the gfx950 operator script completed 3,171 contract cases. That public-entry-point run included
python op_tests/test_fused_norm_rope_attn_rope_cast.py -b 513 528 576 -H 64 --topk 512 --window 128 --pool-rows 2048 --modes unprepared --stages decode --layout separate --splits 0. The wide-pool contract cases allocate their own buffers above the 4 GiB data-offset boundary. MI250X and MI300X were outside the hardware test scope.PR-specific question
Automatic dispatch selects the eligible direct kernel. Compact tail splitting requires explicit splits and a matching FP32 workspace. Empty and full tails have different cost crossovers, as shown in the paired results above.
Changed op tests
op_tests/test_fused_norm_rope_attn_rope_cast.pyadds H64 wide-pool decode coverage with variable CSR row counts, both RoPE position widths and compact split thresholds. It compares bulk output and scale bytes with the direct path and checks tail outputs against the reference.