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++

sm_60: stage the IQ3 tables by default on compute capability 6.0 only

ruibeikaaa87fb80e13b3
diff --git a/docs/OLDER_GPUS.md b/docs/OLDER_GPUS.md
index 42eb61567..c4cd2a73f 100644
--- a/docs/OLDER_GPUS.md
+++ b/docs/OLDER_GPUS.md
@@ -115,13 +115,19 @@ and i-quant blocks (Q6_K, IQ4_XS, Q4_K, IQ3_S, ...) one int at a time. Two chang
`--ple-gguf` at the new folder. Requantizing costs at most 0.4% of a tensor's |w|max (Q8_0 is finer than the
sources).
- IQ3_XXS's and IQ3_S's codebooks and sign-mask tables are staged in shared memory by the grouped expert kernels on
- compute capability 6.x (IQ3_XXS's ported from shinbunbun/llama-cpp-p100-patches 29 and 30, IQ3_S's the same for its
+ compute capability 6.0 (IQ3_XXS's ported from shinbunbun/llama-cpp-p100-patches 29 and 30, IQ3_S's the same for its
sign bytes; bitwise the same output; `STRATA_IQ_STAGE_TABLES=0|1` forces it off or on, on any card). IQ3_S was the
one gate/up format whose codebook those kernels still read from global memory: a verify window's layer of IQ3_S
experts (20 experts, 24 entries) takes 24% less on a GP100 die (517 -> 393 us with a Q2_0 down projection, 492 ->
369 us with IQ4_NL), and Swift 1.5 IQ3_XXS (13 of its 48 layers are IQ3_S) decodes 3.2% faster with the settings
below at 1M context (39.3 -> 40.5 tok/s, mean of the four prompts; the same drafts accepted). IQ3_XXS's tables
- alone were within noise (+0-4%).
+ alone were within noise (+0-4%). It is a trade that only pays where the decode is the limit: on an RTX 3090 Ti
+ (sm_86), forced on, the same IQ3_S layers took 3-13% longer (those kernels already read at 490-665 GB/s there), so
+ the default is 6.0 only.
+- Neither change is measured on compute capability 6.1 (P40, P4, GTX 10 series), which has `__dp4a`. Both build for
+ sm_61, and on a card with `__dp4a` the Q8_0 kernel's dot is the hardware instruction (`tools/q8_sm60_check.cu`
+ passes on an RTX 3090 Ti); numbers from a 6.1 card with `STRATA_Q8_SM60=1` or `STRATA_IQ_STAGE_TABLES=1` would
+ show whether either helps there.
Measured on a PH402 SKU 200 (two boards, four GP100 dies of 48 SMs and 32 GB HBM2), application clocks locked at
1050 MHz, Windows 11, driver 581.80 (TCC), CUDA 12.9, engine 0.1.40.2; Flash-Next IQ3_XXS, 32K, `--layer-split 12,24,36
diff --git a/src/kernels/cuda/iq_kernels.cu b/src/kernels/cuda/iq_kernels.cu
index a28c974be..923283514 100644
--- a/src/kernels/cuda/iq_kernels.cu
+++ b/src/kernels/cuda/iq_kernels.cu
@@ -2202,8 +2202,10 @@ bool g_stage_grid_mmvq = g_stage_grid && [] {
return v != nullptr && v[0] == '1';
}();
// IQ3_XXS's and IQ3_S's codebooks and sign-mask tables staged in shared memory by the grouped expert kernels (the
-// single-matrix mmvq does not): bitwise the same either way. Measured on Pascal GP100 only, so it is the default on
-// compute capability 6.x and off elsewhere; STRATA_IQ_STAGE_TABLES=1 / 0 forces it on / off on any card.
+// single-matrix mmvq does not): bitwise the same either way. The default on compute capability 6.0 (GP100: no
+// __dp4a, these kernels decode-bound at 70-140 GB/s) and off elsewhere: on an RTX 3090 Ti, where they run at
+// 490-665 GB/s, the staging made the IQ3_S layers 3-13% slower, and 6.1 cards (which have __dp4a) are unmeasured.
+// STRATA_IQ_STAGE_TABLES=1 / 0 forces it on / off on any card.
bool stage_tables_on() {
if (!g_stage_grid) return false;
static const int forced = [] {
@@ -2215,8 +2217,11 @@ bool stage_tables_on() {
int dev = 0;
if (cudaGetDevice(&dev) != cudaSuccess || dev < 0 || dev >= 64) return false;
if (by_device[dev] == 0) {
- int major = 0;
- by_device[dev] = (cudaDeviceGetAttribute(&major, cudaDevAttrComputeCapabilityMajor, dev) == cudaSuccess && major == 6) ? 1 : 2;
+ int major = 0, minor = 0;
+ const bool gp100 = cudaDeviceGetAttribute(&major, cudaDevAttrComputeCapabilityMajor, dev) == cudaSuccess &&
+ cudaDeviceGetAttribute(&minor, cudaDevAttrComputeCapabilityMinor, dev) == cudaSuccess &&
+ major == 6 && minor == 0;
+ by_device[dev] = gp100 ? 1 : 2;
}
return by_device[dev] == 1;
}