[PR #512] [CLOSED] prefill: use active QSA top-k bounds on Turing with large KV capacity #2670

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

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/512
Author: @imanu86
Created: 10/2/2026
Status: ❌ Closed

Base: main ← Head: prefill-topk-active-bound


📝 Commits (2)

  • 8e8ab11 GPT6-QSA-Limita il top-k prefill ai blocchi attivi su Turing
  • 42131ca GPT6-QSA-Riallinea la PR ai kernel upstream 0.1.36

📊 Changes

4 files changed (+124 additions, -5 deletions)

View changed files

📝 CMakeLists.txt (+7 -0)
📝 include/strata/kernels/qsa_select.hpp (+3 -1)
📝 src/kernels/cuda/qsa_select.cu (+25 -4)
➕ src/kernels/qsa_topk_active_parity.cpp (+89 -0)

📄 Description

With --max-context 262144, QSA score rows have a stride of 65538 blocks. A prefill batch at 131K actual context fits the register top-k kernel's 33792-block limit, but CUDA dispatch currently tests the allocated capacity and selects the reference kernel.

This enables the already supplied active_blocks bound only on sm_75. It keeps the score-row stride, selection arithmetic and kernel bodies unchanged. Other CUDA architectures retain the capacity rule, including the RTX 5070 case documented in the current source as a 1–3% regression. HIP retains its existing policy. Decode omits the bound, so captured graphs keep the capacity rule as their context grows. Invalid bounds and contexts beyond the register limit fall back to the existing dispatch. Presence of STRATA_TOPK_CAPACITY_GUARD restores the CUDA capacity rule for A/B runs.

The change reuses upstream's existing API and prefill caller rather than importing the separate API from our 0.1.31 fork. A CUDA parity target covers 16 cases with stride 65538: partial tails, zero/tied scores, batch sizes 1/8/255/256/257, invalid bounds, and both sides of the 33792-block limit.

Retained measurements on our previous daily

Modified RTX 2080 Ti 22 GB, Ryzen 7 5800X, 96 GB RAM, Windows, CUDA 12.6, IQ3_XXS, KV262144/int8/resident32768, automatic elastic expert cache and MTP. Same-executable capacity/active/capacity A/B/A, two 1024-token outputs per arm; fresh prompt131248, second prompt131239 with131072 reused.

Dispatch Fresh prefill tok/s TTFT seconds Aggregate decode tok/s
Capacity A1 831.20 158.509 38.251
Active B 886.38 148.664 39.272
Capacity A2 828.26 159.092 39.293

Prefill +6.83% relative to the mean reference; reference spread0.35%. TTFT saves10.14s. No decode gain attributed to this change. The kernel fixture passed16 bitwise selected-ID cases. At8192 context the register kernel was slower in the microbenchmark; no universal short-prompt improvement is claimed. Elastic slots and MTP output varied, and whole-model logits were not bitwise even between the reference arms.

Full measurement record, fixture cases and limitations.

Validation status of this upstream port

Updated against upstream 36fa455e579b23a9c909c2c6fe1bddd9e51cb8ca (0.1.36), preserving the new sm_90+ cluster dispatch. The branch contains a merge of upstream main without rewriting its published history. The CUDA port and harness compile with CUDA 12.6 for sm_75, and all 16 selected-ID parity cases pass bitwise on the modified RTX 2080 Ti. The full SM75 fork engine build and its CMake-built top-k harness now pass; the fork contains additional changes and its model timings are not attributed to this narrow PR. The harness also passes MSVC C++17 syntax-only compilation; the existing-file diffs pass the whitespace check. The measurements above belong to the separately validated 0.1.31 daily, not this rebased tree. Keep this PR draft until an isolated full-engine model A/B/A has been repeated on this upstream base. No installer, workflow, elastic-cache patch or other fork optimization is included.


🔄 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/512 **Author:** [@imanu86](https://github.com/imanu86) **Created:** 10/2/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `prefill-topk-active-bound` --- ### 📝 Commits (2) - [`8e8ab11`](https://github.com/Niko1221/Strata/commit/8e8ab11c1ac19ea7fee668c68fc43b23550aa7cc) GPT6-QSA-Limita il top-k prefill ai blocchi attivi su Turing - [`42131ca`](https://github.com/Niko1221/Strata/commit/42131caf08c5f45329a97341590655e01664790a) GPT6-QSA-Riallinea la PR ai kernel upstream 0.1.36 ### 📊 Changes **4 files changed** (+124 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `CMakeLists.txt` (+7 -0) 📝 `include/strata/kernels/qsa_select.hpp` (+3 -1) 📝 `src/kernels/cuda/qsa_select.cu` (+25 -4) ➕ `src/kernels/qsa_topk_active_parity.cpp` (+89 -0) </details> ### 📄 Description With `--max-context 262144`, QSA score rows have a stride of 65538 blocks. A prefill batch at 131K actual context fits the register top-k kernel's 33792-block limit, but CUDA dispatch currently tests the allocated capacity and selects the reference kernel. This enables the already supplied `active_blocks` bound **only on sm_75**. It keeps the score-row stride, selection arithmetic and kernel bodies unchanged. Other CUDA architectures retain the capacity rule, including the RTX 5070 case documented in the current source as a 1–3% regression. HIP retains its existing policy. Decode omits the bound, so captured graphs keep the capacity rule as their context grows. Invalid bounds and contexts beyond the register limit fall back to the existing dispatch. Presence of `STRATA_TOPK_CAPACITY_GUARD` restores the CUDA capacity rule for A/B runs. The change reuses upstream's existing API and prefill caller rather than importing the separate API from our 0.1.31 fork. A CUDA parity target covers 16 cases with stride 65538: partial tails, zero/tied scores, batch sizes 1/8/255/256/257, invalid bounds, and both sides of the 33792-block limit. ### Retained measurements on our previous daily Modified RTX 2080 Ti 22 GB, Ryzen 7 5800X, 96 GB RAM, Windows, CUDA 12.6, IQ3_XXS, KV262144/int8/resident32768, automatic elastic expert cache and MTP. Same-executable capacity/active/capacity A/B/A, two 1024-token outputs per arm; fresh prompt131248, second prompt131239 with131072 reused. | Dispatch | Fresh prefill tok/s | TTFT seconds | Aggregate decode tok/s | |---|---:|---:|---:| | Capacity A1 | 831.20 | 158.509 | 38.251 | | Active B | 886.38 | 148.664 | 39.272 | | Capacity A2 | 828.26 | 159.092 | 39.293 | Prefill **+6.83%** relative to the mean reference; reference spread0.35%. TTFT saves10.14s. **No decode gain attributed to this change.** The kernel fixture passed16 bitwise selected-ID cases. At8192 context the register kernel was slower in the microbenchmark; no universal short-prompt improvement is claimed. Elastic slots and MTP output varied, and whole-model logits were not bitwise even between the reference arms. [Full measurement record, fixture cases and limitations](https://github.com/imanu86/moe-aggressive-commit/blob/research/ds4-iq1-subbit-tier-planner/docs/porto/strata_adattivo/RISULTATI_TOPK_2_OTTOBRE.md). ### Validation status of this upstream port Updated against upstream `36fa455e579b23a9c909c2c6fe1bddd9e51cb8ca` (0.1.36), preserving the new sm_90+ cluster dispatch. The branch contains a merge of upstream main without rewriting its published history. The CUDA port and harness compile with CUDA 12.6 for sm_75, and all 16 selected-ID parity cases pass bitwise on the modified RTX 2080 Ti. The full SM75 fork engine build and its CMake-built top-k harness now pass; the fork contains additional changes and its model timings are not attributed to this narrow PR. The harness also passes MSVC C++17 syntax-only compilation; the existing-file diffs pass the whitespace check. The measurements above belong to the separately validated 0.1.31 daily, not this rebased tree. Keep this PR draft until an isolated full-engine model A/B/A has been repeated on this upstream base. No installer, workflow, elastic-cache patch or other fork optimization is included. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-04 02:02:16 +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#2670
No description provided.