[PR #849] [CLOSED] HIP gfx103x: PR #540's attention kernel with 8 cells per step and DPP lane exchanges (bit-exact, prompt +6-12% on RX 6900 XT) #2869

Closed
opened 2026-11-04 02:03:44 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/849
Author: @Vop3p
Created: 10/4/2026
Status: ❌ Closed

Base: main ← Head: hip-gfx103x-qsa-attn


📝 Commits (10+)

  • 749d957 setup (--backend hip): a system ROCm without the HIP development files falls back to the wheels (#446)
  • 5a30024 calibrate: the engine's arguments come from the server's engine_args; a failed tuning says why (#447)
  • 9f60d13 serve, setup: name the small split card that caps the prompt chunk; setup recommends the big card alone (#448)
  • eb8da1d /metrics: each request's speculative draft counts, and their sums in the totals (#457)
  • 6a09387 setup (--gguf-dir): GGUFs Strata cannot run are named as such, with the --family/--model to use (#444)
  • d6a91e2 docs: the Coder is weaker outside code, Chinese/CJK text included; the unpruned sizes for that (#438)
  • d8d4ad3 Merge branch 'f-135-eng' into rel-0.1.35
  • 7b600d5 Merge branch 'f-135-small' into rel-0.1.35
  • d9ab843 Engine 0.1.35: Windows AMD uses its bundled HIP runtime (#468 #461), the low-RAM resident mode on Windows 32 GB PCs (#467), fixes #460 #459 #446 #447 #457 #448 #444; setup requires it
  • 57bd713 sycl: pipeline the expert cache's profile fill (model load 3-4x faster)

📊 Changes

3 files changed (+159 additions, -2 deletions)

View changed files

➕ bench/results/2026-10-04-rdna2-pre75-attention/README.md (+116 -0)
➕ bench/results/2026-10-04-rdna2-pre75-attention/strata-1gpu.json (+40 -0)
📝 docs/OLDER_GPUS.md (+3 -2)

📄 Description

Summary

attn_chunk_kernel_pre75 (PR #540, bit for bit the default attention kernel) is built only into the experimental CUDA
build and run below sm_75. On HIP the default kernel runs, whose score loop is bound by the LDS pipe on gfx1030: its
12 heads × 5 __shfl_xor_sync per cell all compile to ds_bpermute_b32 (ROCm 10.0's hipcc emits no DPP for them), sharing the LDS
pipe with the shared-memory q reads.

This builds the pre75 kernel for HIP wave32 (not the gfx906 wave64 backend) and runs it on gfx103x by default, with two
template parameters whose defaults keep CUDA exactly as it is:

  • NC_ (cells per step): CUDA 2 as before; HIP 8. On gfx1030 every step up in NC was faster although occupancy went
    down from NC 1 (NC = 1 / 2 / 4 / 8: 101 / 142 / 149 / 144 VGPRs; 9 / 7 / 6 / 7 waves/SIMD), so the q reads, not
    occupancy, bound it there - the opposite of the V100, where 4 was slower than 2.
  • DPP_: the butterfly's lane exchanges (in reduce12 and the softmax's max / sum) in registers - DPP row_xmask
    within a 16-lane row, v_permlanex16 across the two rows - instead of ds_bpermute. The same values move in the same
    pairing order, so every sum is unchanged bit for bit. CUDA keeps __shfl_xor_sync.

pre75_attn() on HIP: on for gfx103x (per device), STRATA_ATTN_PRE75=0 off (as before), =1 also on another wave32
card. The CUDA branch of pre75_attn() and the non-experimental CUDA build are unchanged.

Measurements (one RX 6900 XT, ROCm 10.0, Qwen3.8-Flash-Next GSQ-RCO IQ3_S, KV int8)

Prompt tok/s, cold server per run, same binary with STRATA_ATTN_PRE75=0 vs default:

9.4K 34.7K 105.8K
default kernel 441 467 460
this change 459 (+4.2%) 494 (+5.7%) 488 (+6.1%)

With #835 (FP16 GEMMs) also applied, attention is a larger share of the prompt and the gain grows:
746 / 917 / 928 -> 801 / 1,022 / 1,041 (+7.4 / +11.4 / +12.2%). On that base, step by step (same three prompts):

pre75 variant 9.4K 34.7K 105.8K
NC 1 763 950 960
NC 2 779 982 997
NC 4 787 997 1,008
NC 8 792 1,006 1,025
NC 8 + DPP 801 1,022 1,041

Decode: measured unchanged within 1.3%, slightly faster (the A/B in "Validation and docs" below).

#835 runs the prompt path's 16-bit GEMMs FP16 in and out on gfx103x. The two changes are independent (different files,
either applies alone) and compound: with both, a prompt reads at 1.82x / 2.19x / 2.26x today's main on this card
(439 / 466 / 461 -> 801 / 1,022 / 1,041 tok/s at 9.4K / 34.7K / 105.8K). This one is bit-exact; #835 is not (its
distribution check is in its README).

Exactness

Teacher-forced log-probabilities (STRATA_LOGPOS, top 256, 3 chats of 9.4K / 34.7K / 105.8K tokens read by the batched
prompt path, 1,578 scored positions): this change against the default kernel - KL 0, argmax and top-10 agreement 100%,
at every NC above and with DPP. ISA check (-Rpass-analysis=kernel-resource-usage, -S): the DPP variant has 0
ds_bpermute (154 without) and 103 LDS instructions (257).

Not tested

CUDA builds (no CUDA on this machine; the CUDA path is unchanged by construction: template defaults equal the old
constants and shfl_x<false> is __shfl_xor_sync). Other wave32 AMD architectures (opt-in with STRATA_ATTN_PRE75=1).

Validation and docs

  • ctest (-DSTRATA_BUILD_TESTS=ON, the same options as the engine build, gfx1030, ROCm 10.0): 60 of 65 pass, the same 60 as 6f32ec0 without this change. Skipped: hip_prompt_attn_wmma (no matrix cores on gfx1030), hip_prefill_hipblaslt_gemm (no hipBLASLt table). Failed for reasons outside the engine, identically with and without the change: ple_parity (a Q2_0 PLE file that is not on this machine), expert_multi_test (this Zen 3 CPU has no AVX-512), platform_memory_test (mlock at the shell's default ulimit -l).
  • Decode A/B (one card, greedy, 256-token answers to three ~4K prompts, STRATA_DECODE_TIMING=1, two rounds alternating): the window is 0.3-0.6 ms shorter with this change (56.0 -> 55.7, 42.2 -> 41.9, 42.5 -> 42.0, 44.2 -> 43.6 ms per window; the two rounds of one arm differ by at most 0.2 ms), decode 43-53 -> 43-56 tok/s. Details in the README below.
  • Docs: docs/OLDER_GPUS.md's AMD table row for RX 6800 / 6900 (the kernel is the default on gfx1030, the switch, the gain) and its A/B-switches line; the measurements, compiler output and exactness check are in bench/results/2026-10-04-rdna2-pre75-attention/README.md with the configuration used.

Developed with an AI coding assistant; every number above was measured on one RX 6900 XT (gfx1030) / Ryzen 5 5600X, ROCm 10.0.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/849 **Author:** [@Vop3p](https://github.com/Vop3p) **Created:** 10/4/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `hip-gfx103x-qsa-attn` --- ### 📝 Commits (10+) - [`749d957`](https://github.com/Niko1221/Strata/commit/749d957a1790b1a171dd4a01ab3e31b3882c9892) setup (--backend hip): a system ROCm without the HIP development files falls back to the wheels (#446) - [`5a30024`](https://github.com/Niko1221/Strata/commit/5a3002446dbb9dfcabb7d0bd9f113da90cc2f3c0) calibrate: the engine's arguments come from the server's engine_args; a failed tuning says why (#447) - [`9f60d13`](https://github.com/Niko1221/Strata/commit/9f60d13246e46b02b1dd0841980b4d18b0faaea7) serve, setup: name the small split card that caps the prompt chunk; setup recommends the big card alone (#448) - [`eb8da1d`](https://github.com/Niko1221/Strata/commit/eb8da1d8c26ec41e6ffb084fdf579dba7cad10bd) /metrics: each request's speculative draft counts, and their sums in the totals (#457) - [`6a09387`](https://github.com/Niko1221/Strata/commit/6a093874fe037020f49bd5cf053879ff6a133c21) setup (--gguf-dir): GGUFs Strata cannot run are named as such, with the --family/--model to use (#444) - [`d6a91e2`](https://github.com/Niko1221/Strata/commit/d6a91e2d1770d0f469d6ec15890acc7ee93e764c) docs: the Coder is weaker outside code, Chinese/CJK text included; the unpruned sizes for that (#438) - [`d8d4ad3`](https://github.com/Niko1221/Strata/commit/d8d4ad337d3c98ba21d3bd0af1a16e9177e112b6) Merge branch 'f-135-eng' into rel-0.1.35 - [`7b600d5`](https://github.com/Niko1221/Strata/commit/7b600d55ff801caaaa11542af1523050992e049b) Merge branch 'f-135-small' into rel-0.1.35 - [`d9ab843`](https://github.com/Niko1221/Strata/commit/d9ab8435f654c368c586340d490915f6addf56a3) Engine 0.1.35: Windows AMD uses its bundled HIP runtime (#468 #461), the low-RAM resident mode on Windows 32 GB PCs (#467), fixes #460 #459 #446 #447 #457 #448 #444; setup requires it - [`57bd713`](https://github.com/Niko1221/Strata/commit/57bd713454ddb4b965f994e95d95cacd68c93fb1) sycl: pipeline the expert cache's profile fill (model load 3-4x faster) ### 📊 Changes **3 files changed** (+159 additions, -2 deletions) <details> <summary>View changed files</summary> ➕ `bench/results/2026-10-04-rdna2-pre75-attention/README.md` (+116 -0) ➕ `bench/results/2026-10-04-rdna2-pre75-attention/strata-1gpu.json` (+40 -0) 📝 `docs/OLDER_GPUS.md` (+3 -2) </details> ### 📄 Description ## Summary `attn_chunk_kernel_pre75` (PR #540, bit for bit the default attention kernel) is built only into the experimental CUDA build and run below sm_75. On HIP the default kernel runs, whose score loop is bound by the LDS pipe on gfx1030: its 12 heads × 5 `__shfl_xor_sync` per cell all compile to `ds_bpermute_b32` (ROCm 10.0's hipcc emits no DPP for them), sharing the LDS pipe with the shared-memory q reads. This builds the pre75 kernel for HIP wave32 (not the gfx906 wave64 backend) and runs it on gfx103x by default, with two template parameters whose defaults keep CUDA exactly as it is: - `NC_` (cells per step): CUDA 2 as before; HIP 8. On gfx1030 every step up in NC was faster although occupancy went down from NC 1 (NC = 1 / 2 / 4 / 8: 101 / 142 / 149 / 144 VGPRs; 9 / 7 / 6 / 7 waves/SIMD), so the q reads, not occupancy, bound it there - the opposite of the V100, where 4 was slower than 2. - `DPP_`: the butterfly's lane exchanges (in `reduce12` and the softmax's max / sum) in registers - DPP `row_xmask` within a 16-lane row, `v_permlanex16` across the two rows - instead of `ds_bpermute`. The same values move in the same pairing order, so every sum is unchanged bit for bit. CUDA keeps `__shfl_xor_sync`. `pre75_attn()` on HIP: on for gfx103x (per device), `STRATA_ATTN_PRE75=0` off (as before), `=1` also on another wave32 card. The CUDA branch of `pre75_attn()` and the non-experimental CUDA build are unchanged. ## Measurements (one RX 6900 XT, ROCm 10.0, Qwen3.8-Flash-Next GSQ-RCO IQ3_S, KV int8) Prompt tok/s, cold server per run, same binary with `STRATA_ATTN_PRE75=0` vs default: | | 9.4K | 34.7K | 105.8K | | --- | ---: | ---: | ---: | | default kernel | 441 | 467 | 460 | | this change | 459 (+4.2%) | 494 (+5.7%) | 488 (+6.1%) | With #835 (FP16 GEMMs) also applied, attention is a larger share of the prompt and the gain grows: 746 / 917 / 928 -> 801 / 1,022 / 1,041 (+7.4 / +11.4 / +12.2%). On that base, step by step (same three prompts): | pre75 variant | 9.4K | 34.7K | 105.8K | | --- | ---: | ---: | ---: | | NC 1 | 763 | 950 | 960 | | NC 2 | 779 | 982 | 997 | | NC 4 | 787 | 997 | 1,008 | | NC 8 | 792 | 1,006 | 1,025 | | NC 8 + DPP | 801 | 1,022 | 1,041 | Decode: measured unchanged within 1.3%, slightly faster (the A/B in "Validation and docs" below). ## Related: #835 #835 runs the prompt path's 16-bit GEMMs FP16 in and out on gfx103x. The two changes are independent (different files, either applies alone) and compound: with both, a prompt reads at 1.82x / 2.19x / 2.26x today's main on this card (439 / 466 / 461 -> 801 / 1,022 / 1,041 tok/s at 9.4K / 34.7K / 105.8K). This one is bit-exact; #835 is not (its distribution check is in its README). ## Exactness Teacher-forced log-probabilities (`STRATA_LOGPOS`, top 256, 3 chats of 9.4K / 34.7K / 105.8K tokens read by the batched prompt path, 1,578 scored positions): this change against the default kernel - KL 0, argmax and top-10 agreement 100%, at every NC above and with DPP. ISA check (`-Rpass-analysis=kernel-resource-usage`, `-S`): the DPP variant has 0 `ds_bpermute` (154 without) and 103 LDS instructions (257). ## Not tested CUDA builds (no CUDA on this machine; the CUDA path is unchanged by construction: template defaults equal the old constants and `shfl_x<false>` is `__shfl_xor_sync`). Other wave32 AMD architectures (opt-in with `STRATA_ATTN_PRE75=1`). ## Validation and docs - **ctest** (`-DSTRATA_BUILD_TESTS=ON`, the same options as the engine build, gfx1030, ROCm 10.0): 60 of 65 pass, the same 60 as `6f32ec0` without this change. Skipped: `hip_prompt_attn_wmma` (no matrix cores on gfx1030), `hip_prefill_hipblaslt_gemm` (no hipBLASLt table). Failed for reasons outside the engine, identically with and without the change: `ple_parity` (a Q2_0 PLE file that is not on this machine), `expert_multi_test` (this Zen 3 CPU has no AVX-512), `platform_memory_test` (`mlock` at the shell's default `ulimit -l`). - **Decode A/B** (one card, greedy, 256-token answers to three ~4K prompts, `STRATA_DECODE_TIMING=1`, two rounds alternating): the window is 0.3-0.6 ms shorter with this change (56.0 -> 55.7, 42.2 -> 41.9, 42.5 -> 42.0, 44.2 -> 43.6 ms per window; the two rounds of one arm differ by at most 0.2 ms), decode 43-53 -> 43-56 tok/s. Details in the README below. - **Docs:** `docs/OLDER_GPUS.md`'s AMD table row for RX 6800 / 6900 (the kernel is the default on gfx1030, the switch, the gain) and its A/B-switches line; the measurements, compiler output and exactness check are in `bench/results/2026-10-04-rdna2-pre75-attention/README.md` with the configuration used. Developed with an AI coding assistant; every number above was measured on one RX 6900 XT (gfx1030) / Ryzen 5 5600X, ROCm 10.0. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-04 02:03:44 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#2869
No description provided.