[PR #3073] [Engine] STRATA_SELECT_SIMT=2 takes the simt2 scorer on HIP too (it silently fell back to the warp kernel); 119K prompt -6.5% on gfx1030 #4435

Open
opened 2026-11-07 15:35:42 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/3073
Author: @Vop3p
Created: 10/18/2026
Status: 🔄 Open

Base: main ← Head: hip-simt2


📝 Commits (1)

  • 5dcc80c hip: STRATA_SELECT_SIMT=2 takes block_scores_simt2_kernel on HIP too (it was CUDA-only; =2 fell back to the warp kernel)

📊 Changes

1 file changed (+18 additions, -5 deletions)

View changed files

📝 src/kernels/cuda/qsa_select.cu (+18 -5)

📄 Description

Problem and result

qsa_block_scores_tc's HIP branch read only STRATA_SELECT_SIMT=1, so =2 (#2071's block_scores_simt2_kernel, 32 x 128 tiles with the next K chunk in registers) silently kept the warp scorer on AMD cards while CUDA ran it. With this change =2 launches block_scores_simt2_kernel<32, 128> (and the tail kernel) on HIP as the CUDA branch does; the confirmation line names it.

Result on 2x RX 6900 XT (below): prompt time -1.35% at 31K and -6.53% at 119K tokens, 10 of 10 interleaved cold-start pairs each; the selection scorer's share grows with the context. Without the variable the default path is byte-identical; with it, two runs are bit-identical to each other on this card.

Closed in the 0.2.0-beta tracker reset; this is the same change rebased on main and re-measured on 0.2.0-beta as asked. petski3 reported run-to-run differences with STRATA_SELECT_SIMT=1 on gfx906 in the earlier thread; item 3 below is the gfx1030 data point for that.

Approach

One file (src/kernels/cuda/qsa_select.cu, +18/-5): the HIP branch parses 0/1/2 like the CUDA branch; =2 takes the simt2 kernel with the same grid guard (grid.y > 65535 returns false, the caller keeps its path); =1 and unset are unchanged. Opt-in; CUDA unchanged.

Validation

Environment: 2x RX 6900 XT (gfx1030, 16 GB, PCIe 4.0 x8 each), Ryzen 5 5600X, 128 GB DDR4-3200, Ubuntu 26.04 (kernel 7.0.0), ROCm 10.0.0. Revision: main e88ee39d (v0.2.0-beta + 12 commits) and this branch on it; the branch merges cleanly with today's main 9ae93f7b (the 0.2.1 candidate), which was not re-measured. Built with setup.py's HIP options (-DSTRATA_PREFILL_MMQ=ON -DSTRATA_Q6K_EXPERTS=ON -DSTRATA_MMQ_KQUANTS=ON, gfx1030, the pinned ggml, Release). Model: Qwen3.8-Flash-Next GSQ-RCO IQ3_S, layer split over both cards, int8 KV.

Passed:

  1. ctest (STRATA_BUILD_TESTS=ON): 137 tests, 131 passed, including qsa_select_bench, qsa_select_bench_fp32_tiled and hip_native_qsa_score. The 6 failures are the same 6 on main built the same way: ple_parity (needs a Q2_0 GGUF this machine does not have), hip_prefill_mmq_parity (SEGFAULT on main too), native_hadamard_test, tq_cpu_parity, tq_cpu_parity_avx2 ("this ggml has no trellis types"), isa_guard_check (tq_rows_avx512 not listed).

  2. Default path byte-identical: deterministic config (parallel 1, no pipeline windows, --short-read 640 --adapt-every 100000, STRATA_PREFILL_CPU_SHARE=0, STRATA_LOGPOS top-256 log-probabilities), 8 chats of real text (first message 6K-105K tokens through the prompt path, ~580 continuation tokens scored), 4,067 positions: main and this branch without the variable cmp identical.

  3. Determinism with =2, same harness: two runs cmp identical (4,067 positions). So on gfx1030 the simt2 scorer itself does not make runs differ; in the serving configuration (CPU share, adaptive expert cache) outputs differ between starts with or without it.

  4. Quality, same harness: mean KL over the 8 chats to a local FP64-attention reference build (scores, softmax and sums of the QSA attention in double; not part of this PR): main 0.0334 (argmax agreement 94.81%), =2 0.0220 (95.75%); KL(main || =2) 0.0256. Not worse - the scorer only changes the summation order of the block scores.

  5. Speed: production-like config (parallel 2, --pipeline-windows 2 --batch-mtp, --kv-resident 32768, STRATA_PREFILL_CPU_SHARE=auto, STRATA_HC_PERSIST=1, STRATA_HIP_PROMPT_F16=1, STRATA_SH_STREAM=1, STRATA_PREFILL_STREAM_MIN=2048, a rocBLAS table via STRATA_ROCBLAS_TUNING), the same binary without and with STRATA_SELECT_SIMT=2, 20 cold starts alternating A B A B, each reading two real-text prompts with max_tokens 1, prompt_ms from /metrics, 0 tokens reused:

    prompt unset (median, range) =2 (median, range) per pair median faster
    31,039 tokens 19,117 ms (19,105-19,382) 18,867 ms (18,847-18,880) -1.18% to -2.71% -1.35% 10/10
    119,290 tokens 62,637 ms (62,583-62,882) 58,554 ms (58,511-58,653) -6.43% to -6.73% -6.53% 10/10

    The =2 arms all printed qsa select: FP32 tiled scorer (STRATA_SELECT_SIMT=2), tiles simt2 32x128 (#2071), the others no tiled-scorer line; 0 stalls.

  6. CUDA compile only (no NVIDIA GPU here): CUDA 13.2.2 (nvcc 13.2.86), GCC 15.2, -DSTRATA_ENABLE_CUDA=ON -DSTRATA_BUILD_TESTS=ON -DCMAKE_CUDA_ARCHITECTURES=86: the engine and the tests build (the file's CUDA branch is unchanged).

Failed: none observed.

Not run: gfx906 (petski3's card), gfx11 / gfx12 (=2 there still yields to the gfx12 WMMA scorer when that is on), other gfx103x cards, Windows; CUDA execution; SYCL and Metal (they do not compile this file).

Community measurements (not mine)

  • 2x Radeon Pro VII 16 GB (gfx906), HIP 7.14, v0.2.1 + this PR, IQ3_S, layer split 27, spec 4/0.5 - petski3, 2026-10-20 (comment below): =2 run vs repeat run 6 of 6 identical texts and draft counts (=1 and unset likewise); =2 equals =1 bit for bit; prompt 64K +2.5%, 128K +4.5% against unset, same as =1; decode within noise; 0 stalls. So =2 reaches block_scores_simt2_kernel on gfx906 and is deterministic there too.

Limits

  • Opt-in; only =2 on HIP changes.
  • Not bit-identical to the warp scorer (another summation order), so outputs differ from the default by FP32 rounding; quality item 4.

Developed with an AI coding assistant; every number above was measured on the machine described here.

🤖 Generated with Claude Code


🔄 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/3073 **Author:** [@Vop3p](https://github.com/Vop3p) **Created:** 10/18/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `hip-simt2` --- ### 📝 Commits (1) - [`5dcc80c`](https://github.com/Niko1221/Strata/commit/5dcc80c62010de592ea3a3c7418e2b82464ba5ec) hip: STRATA_SELECT_SIMT=2 takes block_scores_simt2_kernel on HIP too (it was CUDA-only; =2 fell back to the warp kernel) ### 📊 Changes **1 file changed** (+18 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `src/kernels/cuda/qsa_select.cu` (+18 -5) </details> ### 📄 Description ## Problem and result `qsa_block_scores_tc`'s HIP branch read only `STRATA_SELECT_SIMT=1`, so `=2` (#2071's `block_scores_simt2_kernel`, 32 x 128 tiles with the next K chunk in registers) silently kept the warp scorer on AMD cards while CUDA ran it. With this change `=2` launches `block_scores_simt2_kernel<32, 128>` (and the tail kernel) on HIP as the CUDA branch does; the confirmation line names it. Result on 2x RX 6900 XT (below): prompt time -1.35% at 31K and -6.53% at 119K tokens, 10 of 10 interleaved cold-start pairs each; the selection scorer's share grows with the context. Without the variable the default path is byte-identical; with it, two runs are bit-identical to each other on this card. ## Related discussion Closed in the 0.2.0-beta tracker reset; this is the same change rebased on main and re-measured on 0.2.0-beta as asked. petski3 reported run-to-run differences with `STRATA_SELECT_SIMT=1` on gfx906 in the earlier thread; item 3 below is the gfx1030 data point for that. ## Approach One file (`src/kernels/cuda/qsa_select.cu`, +18/-5): the HIP branch parses `0/1/2` like the CUDA branch; `=2` takes the simt2 kernel with the same grid guard (`grid.y > 65535` returns false, the caller keeps its path); `=1` and unset are unchanged. Opt-in; CUDA unchanged. ## Validation Environment: 2x RX 6900 XT (gfx1030, 16 GB, PCIe 4.0 x8 each), Ryzen 5 5600X, 128 GB DDR4-3200, Ubuntu 26.04 (kernel 7.0.0), ROCm 10.0.0. Revision: main e88ee39d (v0.2.0-beta + 12 commits) and this branch on it; the branch merges cleanly with today's main 9ae93f7b (the 0.2.1 candidate), which was not re-measured. Built with setup.py's HIP options (`-DSTRATA_PREFILL_MMQ=ON -DSTRATA_Q6K_EXPERTS=ON -DSTRATA_MMQ_KQUANTS=ON`, gfx1030, the pinned ggml, Release). Model: Qwen3.8-Flash-Next GSQ-RCO IQ3_S, layer split over both cards, int8 KV. **Passed:** 1. `ctest` (STRATA_BUILD_TESTS=ON): 137 tests, 131 passed, including `qsa_select_bench`, `qsa_select_bench_fp32_tiled` and `hip_native_qsa_score`. The 6 failures are the same 6 on main built the same way: `ple_parity` (needs a Q2_0 GGUF this machine does not have), `hip_prefill_mmq_parity` (SEGFAULT on main too), `native_hadamard_test`, `tq_cpu_parity`, `tq_cpu_parity_avx2` ("this ggml has no trellis types"), `isa_guard_check` (`tq_rows_avx512` not listed). 2. Default path byte-identical: deterministic config (`parallel` 1, no pipeline windows, `--short-read 640 --adapt-every 100000`, `STRATA_PREFILL_CPU_SHARE=0`, `STRATA_LOGPOS` top-256 log-probabilities), 8 chats of real text (first message 6K-105K tokens through the prompt path, ~580 continuation tokens scored), 4,067 positions: main and this branch without the variable `cmp` identical. 3. Determinism with `=2`, same harness: two runs `cmp` identical (4,067 positions). So on gfx1030 the simt2 scorer itself does not make runs differ; in the serving configuration (CPU share, adaptive expert cache) outputs differ between starts with or without it. 4. Quality, same harness: mean KL over the 8 chats to a local FP64-attention reference build (scores, softmax and sums of the QSA attention in double; not part of this PR): main 0.0334 (argmax agreement 94.81%), `=2` 0.0220 (95.75%); KL(main || `=2`) 0.0256. Not worse - the scorer only changes the summation order of the block scores. 5. Speed: production-like config (`parallel` 2, `--pipeline-windows 2 --batch-mtp`, `--kv-resident 32768`, `STRATA_PREFILL_CPU_SHARE=auto`, `STRATA_HC_PERSIST=1`, `STRATA_HIP_PROMPT_F16=1`, `STRATA_SH_STREAM=1`, `STRATA_PREFILL_STREAM_MIN=2048`, a rocBLAS table via `STRATA_ROCBLAS_TUNING`), the same binary without and with `STRATA_SELECT_SIMT=2`, 20 cold starts alternating A B A B, each reading two real-text prompts with max_tokens 1, `prompt_ms` from /metrics, 0 tokens reused: | prompt | unset (median, range) | `=2` (median, range) | per pair | median | faster | |---|---|---|---|---|---| | 31,039 tokens | 19,117 ms (19,105-19,382) | 18,867 ms (18,847-18,880) | -1.18% to -2.71% | -1.35% | 10/10 | | 119,290 tokens | 62,637 ms (62,583-62,882) | 58,554 ms (58,511-58,653) | -6.43% to -6.73% | -6.53% | 10/10 | The `=2` arms all printed `qsa select: FP32 tiled scorer (STRATA_SELECT_SIMT=2), tiles simt2 32x128 (#2071)`, the others no tiled-scorer line; 0 stalls. 6. CUDA compile only (no NVIDIA GPU here): CUDA 13.2.2 (nvcc 13.2.86), GCC 15.2, `-DSTRATA_ENABLE_CUDA=ON -DSTRATA_BUILD_TESTS=ON -DCMAKE_CUDA_ARCHITECTURES=86`: the engine and the tests build (the file's CUDA branch is unchanged). **Failed:** none observed. **Not run:** gfx906 (petski3's card), gfx11 / gfx12 (`=2` there still yields to the gfx12 WMMA scorer when that is on), other gfx103x cards, Windows; CUDA execution; SYCL and Metal (they do not compile this file). ## Community measurements (not mine) - **2x Radeon Pro VII 16 GB (gfx906), HIP 7.14, v0.2.1 + this PR, IQ3_S, layer split 27, spec 4/0.5** - petski3, 2026-10-20 (comment below): `=2` run vs repeat run 6 of 6 identical texts and draft counts (`=1` and unset likewise); `=2` equals `=1` bit for bit; prompt 64K +2.5%, 128K +4.5% against unset, same as `=1`; decode within noise; 0 stalls. So `=2` reaches `block_scores_simt2_kernel` on gfx906 and is deterministic there too. ## Limits - Opt-in; only `=2` on HIP changes. - Not bit-identical to the warp scorer (another summation order), so outputs differ from the default by FP32 rounding; quality item 4. Developed with an AI coding assistant; every number above was measured on the machine described here. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
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#4435
No description provided.