Skip to content

Qwen3.8-Flash-Next on any consumer hardware: one-click install for Windows / Linux. Strata inference engine, OpenAI/Anthropic API on localhost, optional image input.

C++

qsa top-k: Turing prefill above ~90K cells takes the wide kernel (from #743; STRATA_TOPK_STREAM=0 restores)

konijiwa1101bb5c72484eb
diff --git a/src/kernels/cuda/qsa_select.cu b/src/kernels/cuda/qsa_select.cu
index 638f27e49..bddd8476c 100644
--- a/src/kernels/cuda/qsa_select.cu
+++ b/src/kernels/cuda/qsa_select.cu
@@ -1245,7 +1245,14 @@ void qsa_block_topk(const float* scores, const int32_t* steps, int64_t nq, int64
std::exit(1);
}
#if !defined(__HIPCC__)
- if (reach > fit) // past the register kernel's reach
+ // Turing prefill (the `counted` bound) above ~90K cells (22,528 blocks): the wide kernel, which reads the keys
+ // coalesced, instead of the register kernel's uncoalesced per-thread runs (PR #743: 131K, 1.03 -> 0.75 ms); the
+ // same ids. STRATA_TOPK_STREAM=0 restores the register kernel there.
+ static const bool turing_wide = [] {
+ const char* v = std::getenv("STRATA_TOPK_STREAM");
+ return v == nullptr || v[0] != '0';
+ }();
+ if (reach > fit || (turing_wide && counted && reach > 22528)) // past the register kernel's reach, or Turing's band
block_topk_wide_kernel<<<(unsigned) nq, TK_T, 0, (cudaStream_t) stream>>>(scores, steps, max_blocks, cap, ids);
else
#endif
diff --git a/src/kernels/qsa_topk_active_parity.cpp b/src/kernels/qsa_topk_active_parity.cpp
index 031c0d70e..a46a64d6a 100644
--- a/src/kernels/qsa_topk_active_parity.cpp
+++ b/src/kernels/qsa_topk_active_parity.cpp
@@ -88,8 +88,10 @@ int main() {
{131075, 255, 0}, {135164, 256, 0}, {135168, 256, 0}, {250022, 256, 0},
{262144, 256, 0}, {131072, 1, 0}, {131072, 8, 0}, {131072, 257, 0},
{131072, 256, 1}, {131072, 256, 2}, {131072, 256, 3}, {131072, 256, 4},
+ // either side of the Turing wide-kernel bound (22,528 blocks), and ties above the register limit
+ {90108, 256, 0}, {90112, 256, 0}, {200000, 256, 2}, {262144, 256, 1},
};
for (const auto c : cases) if (!check(c)) return 1;
- std::puts("PASS: 16 top-k active-bound cases, selected IDs bitwise identical");
+ std::puts("PASS: 20 top-k active-bound cases, selected IDs bitwise identical");
return 0;
}