qsa_prompt_attn: Q4_0 KV prompt attention on Turing, opt-in STRATA_PROMPT_ATTN_Q4_TC=1 (#1581, the Q4 attention part only)

Ported from c3c's #1581 (the native-IQ and VRAM-loan parts are not in this commit).  Default unchanged: Turing keeps returning false for q4_0.

Co-authored-by: c3c <cedric@ce3c.be>
This commit is contained in:
Niko1221andc3c committed 2026-10-15 08:53:32 +02:00
1 parent 7f8e6f12f4
commit 285e90aee2
1 file changed
+7 -2
+7 -2
View File
@@ -1623,8 +1623,13 @@ bool qsa_prompt_attn_batch(const float* q, const QsaAttnPools& pools, const int3
const char* v = std::getenv("STRATA_PROMPT_ATTN_Q4");
return v != nullptr && v[0] == '0';
}();
// sm_80+ only: on Turing mode 4 would run as pairs of m16n8k8 MMAs, which no parity run has checked yet
if (q4_off || turing || pools.v_q4 == nullptr) return false;
// Turing runs mode 4 as pairs of m16n8k8 MMAs (another summation order than the FP32 kernel it replaces): manual
// opt-in STRATA_PROMPT_ATTN_Q4_TC=1 (#1581, c3c: qsa_prompt_attn_parity at 4096/512 and 1500/512 on an RTX 2080 Super).
static const bool q4_tc = [] {
const char* v = std::getenv("STRATA_PROMPT_ATTN_Q4_TC");
return v != nullptr && v[0] == '1';
}();
if (q4_off || volta || (turing && !q4_tc) || pools.v_q4 == nullptr) return false;
return launch<4>(q, pools, ids, steps, cap, s, attn, n_q, st);
}
if (pools.k_q != nullptr && pools.v_q4 != nullptr) { // hybrid K8V4: int8 K + dequantized-q4 V