[PR #2016] [CLOSED] qsa top-k: the register kernel's radix digit by a cooperative scan (same ids); gfx1151 takes it from 16K cells #3809

Closed
opened 2026-11-07 15:30:54 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/2016
Author: @libratechw
Created: 10/12/2026
Status: ❌ Closed

Base: main ← Head: pr/qsa-topk-scan


📝 Commits (2)

  • 5125ed0 qsa top-k: the register kernel's radix digit by a cooperative scan (same ids)
  • 11e3fc9 qsa top-k: the register kernel from 16K cells of context on gfx1151 (STRATA_TOPK_REG_MIN_BLOCKS, gfx1151's table sets 4096)

📊 Changes

4 files changed (+34 additions, -8 deletions)

View changed files

📝 CMakeLists.txt (+3 -0)
📝 docs/STRIX_HALO.md (+1 -0)
📝 src/core/arch_defaults.cpp (+1 -0)
📝 src/kernels/cuda/qsa_select.cu (+29 -8)

📄 Description

Title

Issue: none

Summary

block_topk_reg_kernel, the QSA block top-k on CUDA and HIP, picked each radix digit with thread 0 walking up to 255 bins
while the other threads waited. Threads 0-255 now prefix-sum the bins; the digit and the count above it are the same, so the
selected ids are the same. With the faster kernel, gfx1151 gains from it on shorter prompt batches too, so the HIP line below
which a batch takes the original kernel becomes STRATA_TOPK_REG_MIN_BLOCKS (default 7168, as before) and gfx1151's table
sets 4096.

What changed

  • src/kernels/cuda/qsa_select.cu: the cooperative digit scan (first commit, CUDA and HIP); the HIP dispatch reads
    STRATA_TOPK_REG_MIN_BLOCKS (second commit).
  • src/core/arch_defaults.cpp: gfx1151 sets STRATA_TOPK_REG_MIN_BLOCKS=4096. docs/STRIX_HALO.md: its row.
  • CMakeLists.txt: ctest qsa_topk_parity_reg_always, the self-test with the line at 0.

Ryzen AI Max+ 395 (gfx1151, ROCm 7.14.1), on 296b59d2, qsa_topk_parity <cells> 2048 10 131072 1 (a prompt batch), ms per
call, median of 3. The tool does not apply the architecture table, so the last column sets the variable:

cells 296b59d2 this branch this branch, STRATA_TOPK_REG_MIN_BLOCKS=4096
16K 1.30 1.28 0.86
24K 3.93 3.69 0.99
32K 2.19 1.11 1.11
64K 2.54 1.63 (the same kernel, not run)
131,000 4.89 3.97 (the same kernel, not run)

At 16K and 24K the first two columns are the original kernel, which this branch does not change. 4K and 8K stay at 0.37 and
0.41. The ids match the reference in every run (continuous, 64 levels, equal scores), with and without the variable.

Builds and tests on this branch:

  • HIP gfx1151: ctest, 113 tests: 105 pass (qsa_topk_parity_reg_always among them), 5 skip, and the same three fail as on
    296b59d2 (ple_parity, expert_parity, pool_test).
  • HIP: strata_kernels, strata_prefill and strata_mmq compile for gfx1012, gfx1030, gfx1100, gfx1103, gfx1150, gfx1151,
    gfx1200 and gfx1201.
  • CUDA 13.0, RTX 3060 (Windows): builds; ctest, 118 tests: 115 pass, 2 skip, and ple_parity fails as on 296b59d2.
    (pool_affinity_test, a CPU-only test, fails now and then on this machine: 1 of 10 runs alone here, 3 of 20 on 296b59d2.)
  • SYCL (oneAPI 2026.1 icpx): builds. The SYCL QSA top-k is its own copy and is not changed.

Not run: the kernel on other AMD cards (their line stays at 7,168 blocks), CUDA timings, and end to end.

🤖 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/2016 **Author:** [@libratechw](https://github.com/libratechw) **Created:** 10/12/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `pr/qsa-topk-scan` --- ### 📝 Commits (2) - [`5125ed0`](https://github.com/Niko1221/Strata/commit/5125ed0c8f1f01fa4c4d2f88f7c4b616af4ba36f) qsa top-k: the register kernel's radix digit by a cooperative scan (same ids) - [`11e3fc9`](https://github.com/Niko1221/Strata/commit/11e3fc90c2bb0915868af35cbfe54636883b3ce9) qsa top-k: the register kernel from 16K cells of context on gfx1151 (STRATA_TOPK_REG_MIN_BLOCKS, gfx1151's table sets 4096) ### 📊 Changes **4 files changed** (+34 additions, -8 deletions) <details> <summary>View changed files</summary> 📝 `CMakeLists.txt` (+3 -0) 📝 `docs/STRIX_HALO.md` (+1 -0) 📝 `src/core/arch_defaults.cpp` (+1 -0) 📝 `src/kernels/cuda/qsa_select.cu` (+29 -8) </details> ### 📄 Description ## Title Issue: none ## Summary `block_topk_reg_kernel`, the QSA block top-k on CUDA and HIP, picked each radix digit with thread 0 walking up to 255 bins while the other threads waited. Threads 0-255 now prefix-sum the bins; the digit and the count above it are the same, so the selected ids are the same. With the faster kernel, gfx1151 gains from it on shorter prompt batches too, so the HIP line below which a batch takes the original kernel becomes `STRATA_TOPK_REG_MIN_BLOCKS` (default 7168, as before) and gfx1151's table sets 4096. ## What changed - `src/kernels/cuda/qsa_select.cu`: the cooperative digit scan (first commit, CUDA and HIP); the HIP dispatch reads `STRATA_TOPK_REG_MIN_BLOCKS` (second commit). - `src/core/arch_defaults.cpp`: gfx1151 sets `STRATA_TOPK_REG_MIN_BLOCKS=4096`. `docs/STRIX_HALO.md`: its row. - `CMakeLists.txt`: ctest `qsa_topk_parity_reg_always`, the self-test with the line at 0. Ryzen AI Max+ 395 (gfx1151, ROCm 7.14.1), on 296b59d2, `qsa_topk_parity <cells> 2048 10 131072 1` (a prompt batch), ms per call, median of 3. The tool does not apply the architecture table, so the last column sets the variable: | cells | 296b59d2 | this branch | this branch, `STRATA_TOPK_REG_MIN_BLOCKS=4096` | |---:|---:|---:|---:| | 16K | 1.30 | 1.28 | 0.86 | | 24K | 3.93 | 3.69 | 0.99 | | 32K | 2.19 | 1.11 | 1.11 | | 64K | 2.54 | 1.63 | (the same kernel, not run) | | 131,000 | 4.89 | 3.97 | (the same kernel, not run) | At 16K and 24K the first two columns are the original kernel, which this branch does not change. 4K and 8K stay at 0.37 and 0.41. The ids match the reference in every run (continuous, 64 levels, equal scores), with and without the variable. Builds and tests on this branch: - HIP gfx1151: ctest, 113 tests: 105 pass (`qsa_topk_parity_reg_always` among them), 5 skip, and the same three fail as on 296b59d2 (`ple_parity`, `expert_parity`, `pool_test`). - HIP: `strata_kernels`, `strata_prefill` and `strata_mmq` compile for gfx1012, gfx1030, gfx1100, gfx1103, gfx1150, gfx1151, gfx1200 and gfx1201. - CUDA 13.0, RTX 3060 (Windows): builds; ctest, 118 tests: 115 pass, 2 skip, and `ple_parity` fails as on 296b59d2. (`pool_affinity_test`, a CPU-only test, fails now and then on this machine: 1 of 10 runs alone here, 3 of 20 on 296b59d2.) - SYCL (oneAPI 2026.1 icpx): builds. The SYCL QSA top-k is its own copy and is not changed. Not run: the kernel on other AMD cards (their line stays at 7,168 blocks), CUDA timings, and end to end. 🤖 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>
bsakaguchi 2026-11-07 15:30:54 +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#3809
No description provided.