[PR #3499] [Engine] hip: STRATA_SELECT_GRID=2 - the selection scorer's CTA order swaps for L2 (bitwise identical) #4655

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

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/3499
Author: @vlupilin
Created: 10/20/2026
Status: 🔄 Open

Base: main ← Head: pr-grid-swap


📝 Commits (1)

  • 939d56e hip: STRATA_SELECT_GRID=2 - the selection scorer's CTA order swaps for L2 (bitwise identical)

📊 Changes

1 file changed (+26 additions, -4 deletions)

View changed files

📝 src/kernels/cuda/qsa_select.cu (+26 -4)

📄 Description

Problem and result: The WMMA scorer's launch order put all the key tiles of query-tile 0 first: each of the 16 query-tiles re-read the pooled key array from DRAM because L2 (8 MiB) could not hold it between their turns. With STRATA_SELECT_GRID=2 the grid's dimensions swap so the CTAs that share a key tile run together and L2 holds it for all of them. The output is bitwise identical (only the scheduling order of independent CTAs moves).

Related discussion: #3164 (the original PR, closed in the 0.2.0 tracker reset; the check passed but GitHub would not reopen it). Independent of #1749 (wide top-k) and SPLIT2 (#3498) — they optimize different stages of the same pipeline.

Approach: Template parameter bool XQ mapping blockIdx to query/block tiles; opt-in env STRATA_SELECT_GRID=0|1|2 with adaptive threshold STRATA_SELECT_GRID_MIN (default 8192 blocks = 32K context). Default 0 = unchanged. One file changed: src/kernels/cuda/qsa_select.cu (+26/-4).

Validation:
Passed: Kernel benchmark (v0.2.1.3 @ c093ac26, gfx1151 Radeon 8060S Strix Halo, ROCm 10.1, Linux 7.0.0-38-generic): qsa_select_bench at 32768/262144/524288 context, 256 queries, 5 reps — scorer 0.818/8.429/13.316 ms (old order) vs 0.756/7.831/10.669 ms (swapped), 1.08x/1.08x/1.25x. Ids bitwise identical 256/256 at all depths (qsa_select_bench gate). Engine interleaved 2 rounds at 262144/524288: 1002.8/928.1 tok/s (mainline) vs 1014.1/944.1 tok/s (+grid), +1.1%/+1.7% at depth.
Failed: none.
Not run: CUDA backend (kernel is HIP-only); gfx12 hardware (maintainer's R9700 can verify); shallow-context regression below 8192 blocks (the adaptive threshold prevents the swap there by design).

Limits: HIP only; requires STRATA_SELECT_WMMA=1; the engine effect is depth-dependent (strongest at 512K+ where the selection cost is highest).


🔄 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/3499 **Author:** [@vlupilin](https://github.com/vlupilin) **Created:** 10/20/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `pr-grid-swap` --- ### 📝 Commits (1) - [`939d56e`](https://github.com/Niko1221/Strata/commit/939d56e1cc33722e0e56e3febe3f8c8a1f082fb4) hip: STRATA_SELECT_GRID=2 - the selection scorer's CTA order swaps for L2 (bitwise identical) ### 📊 Changes **1 file changed** (+26 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `src/kernels/cuda/qsa_select.cu` (+26 -4) </details> ### 📄 Description Problem and result: The WMMA scorer's launch order put all the key tiles of query-tile 0 first: each of the 16 query-tiles re-read the pooled key array from DRAM because L2 (8 MiB) could not hold it between their turns. With STRATA_SELECT_GRID=2 the grid's dimensions swap so the CTAs that share a key tile run together and L2 holds it for all of them. The output is bitwise identical (only the scheduling order of independent CTAs moves). Related discussion: #3164 (the original PR, closed in the 0.2.0 tracker reset; the check passed but GitHub would not reopen it). Independent of #1749 (wide top-k) and SPLIT2 (#3498) — they optimize different stages of the same pipeline. Approach: Template parameter bool XQ mapping blockIdx to query/block tiles; opt-in env STRATA_SELECT_GRID=0|1|2 with adaptive threshold STRATA_SELECT_GRID_MIN (default 8192 blocks = 32K context). Default 0 = unchanged. One file changed: src/kernels/cuda/qsa_select.cu (+26/-4). Validation: Passed: Kernel benchmark (v0.2.1.3 @ c093ac26, gfx1151 Radeon 8060S Strix Halo, ROCm 10.1, Linux 7.0.0-38-generic): qsa_select_bench at 32768/262144/524288 context, 256 queries, 5 reps — scorer 0.818/8.429/13.316 ms (old order) vs 0.756/7.831/10.669 ms (swapped), 1.08x/1.08x/1.25x. Ids bitwise identical 256/256 at all depths (qsa_select_bench gate). Engine interleaved 2 rounds at 262144/524288: 1002.8/928.1 tok/s (mainline) vs 1014.1/944.1 tok/s (+grid), +1.1%/+1.7% at depth. Failed: none. Not run: CUDA backend (kernel is HIP-only); gfx12 hardware (maintainer's R9700 can verify); shallow-context regression below 8192 blocks (the adaptive threshold prevents the swap there by design). Limits: HIP only; requires STRATA_SELECT_WMMA=1; the engine effect is depth-dependent (strongest at 512K+ where the selection cost is highest). --- <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#4655
No description provided.