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_topk_active_parity checks the active-bound dispatch on any CUDA card (#512 follow-up)

Niko1221f2c220f560fc
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5d1cd4281..074a1cde7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -274,9 +274,8 @@ if(STRATA_ENABLE_CUDA OR STRATA_ENABLE_HIP)
target_include_directories(qsa_prompt_attn_parity PRIVATE ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES})
target_link_libraries(qsa_prompt_attn_parity PRIVATE strata_kernels CUDA::cudart)
endif()
- # the QSA selection (block scores on the warp kernel and the tensor-core one, top-k): a GPU bench with a
- # scorer-vs-scorer comparison and an FP64 accuracy gate (synthetic, no model); the ctest runs a 32K context under a
- # 262144-cell capacity (the top-k dispatch follows the capacity) and exits non-zero on a failed gate
+ # #512: the top-k's active-block bound (Turing's dispatch, forced on any card by STRATA_TOPK_ACTIVE_ANY) against
+ # the capacity rule, selected ids bitwise
if(STRATA_BUILD_TESTS AND STRATA_ENABLE_CUDA)
add_executable(qsa_topk_active_parity src/kernels/qsa_topk_active_parity.cpp)
target_include_directories(qsa_topk_active_parity PRIVATE ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES})
@@ -284,6 +283,9 @@ if(STRATA_ENABLE_CUDA OR STRATA_ENABLE_HIP)
add_test(NAME qsa_topk_active_parity COMMAND qsa_topk_active_parity)
set_tests_properties(qsa_topk_active_parity PROPERTIES SKIP_RETURN_CODE 77)
endif()
+ # the QSA selection (block scores on the warp kernel and the tensor-core one, top-k): a GPU bench with a
+ # scorer-vs-scorer comparison and an FP64 accuracy gate (synthetic, no model); the ctest runs a 32K context under a
+ # 262144-cell capacity (the top-k dispatch follows the capacity) and exits non-zero on a failed gate
if((STRATA_BUILD_TESTS OR STRATA_PARITY_PROMPT_ATTN) AND STRATA_ENABLE_HIP)
add_executable(qsa_select_bench src/kernels/qsa_select_bench.cpp)
set_source_files_properties(src/kernels/qsa_select_bench.cpp PROPERTIES LANGUAGE HIP)
diff --git a/src/kernels/cuda/qsa_select.cu b/src/kernels/cuda/qsa_select.cu
index 76bc9fd98..ad705b1df 100644
--- a/src/kernels/cuda/qsa_select.cu
+++ b/src/kernels/cuda/qsa_select.cu
@@ -1078,8 +1078,11 @@ void qsa_block_topk(const float* scores, const int32_t* steps, int64_t nq, int64
// Other CUDA devices keep 0.1.32's capacity rule: #337 was measured on RDNA4, and RTX 5070 64K prompts were
// 1-3% slower. Decode/captured graphs omit the bound and never query the device here.
static const bool capacity_guard = std::getenv("STRATA_TOPK_CAPACITY_GUARD") != nullptr;
+ // STRATA_TOPK_ACTIVE_ANY=1 (tests): the Turing dispatch on any CUDA card, so qsa_topk_active_parity checks it
+ // on whatever card runs the tests (the kernels are the same on every architecture)
+ static const bool any_card = [] { const char* v = std::getenv("STRATA_TOPK_ACTIVE_ANY"); return v && v[0] == '1'; }();
const bool counted = !capacity_guard && active_blocks > 0 && active_blocks <= max_blocks &&
- topk_active_turing_device();
+ (any_card || topk_active_turing_device());
#endif
const int64_t reach = counted && active_blocks < max_blocks ? active_blocks : max_blocks;
const int64_t fit = (int64_t) TK_T * (counted ? TK_PER_MAX : TK_PER);
diff --git a/src/kernels/qsa_topk_active_parity.cpp b/src/kernels/qsa_topk_active_parity.cpp
index 6d128c4dd..031c0d70e 100644
--- a/src/kernels/qsa_topk_active_parity.cpp
+++ b/src/kernels/qsa_topk_active_parity.cpp
@@ -77,6 +77,12 @@ int main() {
std::puts("SKIP: no CUDA device");
return 77;
}
+ // the active-bound dispatch is Turing's in the engine; forced here so every CUDA card checks it
+#if defined(_WIN32)
+ _putenv_s("STRATA_TOPK_ACTIVE_ANY", "1");
+#else
+ setenv("STRATA_TOPK_ACTIVE_ANY", "1", 1);
+#endif
const Case cases[] = {
{1111, 256, 0}, {8192, 256, 0}, {32768, 256, 0}, {131072, 256, 0},
{131075, 255, 0}, {135164, 256, 0}, {135168, 256, 0}, {250022, 256, 0},