prefill: the fused Gyro-S trellis kernels are the default on compute capability 8.6 cards with 80+ SMs (HELD for the owner's word, not merged)

Branch commit only, written ahead of the owner's answer on the A6000 Gyro-S table (RESULTS-OWN-4X.md, "GYRO-S ON THE RTX A6000").  Not for
any integration branch until he says yes; one confirming run is owed on this exact commit (unset against STRATA_PF_FUSED_TQ=1: same bits,
same speed row).

The rule (include/strata/prefill/fused_tq_default.hpp, a pure function, pinned by tests/prefill/fused_tq_default_test.cpp):
  STRATA_PF_FUSED_TQ unset  Gyro-S's TQK6 / TQK7 pair takes the fused kernels on a compute capability 8.6 card with 80+ SMs
                            (RTX A6000 / A40 84, RTX 3090 Ti 84, RTX 3090 82, RTX 3080 Ti 80); every other card stays on MMQ
  STRATA_PF_FUSED_TQ=1      as before: any sm_80+ card, and Gyro-M's TQ2_T / TQ2_T pair (no gate series, so never by default)
  STRATA_PF_FUSED_TQ=0      MMQ again (a diagnostic for bug reports)
STRATA_PF_FUSED_SM86=0 (DevInfo::s86 false) turns the trellis default off together with the i-quant default; STRATA_PF_FUSED=0 still turns
every fused kernel off.  Host code only: DevInfo::tq is set from fused_tq::on(env, s86, sms) in dev_info(), native_supported() asks
fused_tq::gyro_m_on() for the TQ2_T pair; the kernels, the tile pick and the prompt path (prefill.cpp) are unchanged, so the default path is
the STRATA_PF_FUSED_TQ=1 path the gates measured.

Gates (RTX A6000, 84 SMs, Boston GPU 0, Gyro-S, e86 = 454305361, MTP, frozen shipped expert profile; fused = STRATA_PF_FUSED_TQ=1 against
the MMQ default):
| gate | result |
|---|---|
| prompt speed, 5 interleaved pairs | fused / MMQ 1.203 / 1.166 / 1.116 at 4K / 8K / 20K, 5 of 5 each |
| first-token KL vs the FP16 prompt path, 2,048 x 48 | MMQ 0.00867 / again 0.01060, fused 0.00658 (below both); top-1 46 / 46 / 47 |
| same, 8,192 x 48 | 0.00335 / 0.00317, fused 0.00328 (between); top-1 48 / 48 / 47 |
| same, 20,000 x 96 | 0.00827 / 0.00666, fused 0.00952 (above the higher run, level by the paired interval 1.151 [0.799, 1.775] and within twice MMQ's own gap 0.00161); top-1 91 / 91 / 92 |
| forced tokens, 48 x 128, FP16-written text | MMQ 1.69 / 1.79 %, fused 1.56 / 1.64 %, fused minus MMQ -0.18 [-0.45, +0.08] and -0.10 [-0.35, +0.14] points, events 0 / 0, pass |
| forced tokens, MMQ-written text (llama.cpp cannot read the trellis types) | MMQ 1.14 / 1.04 %, fused 1.62 / 1.79 %, +0.53 and +0.70 points, inconclusive (biased toward MMQ) |
| small chunks, agent, first 8K read (12 engines per arm), backstop | all answered; first read median 3,425-3,429 ms MMQ vs 2,970-2,975 ms fused, 0 of 12 over 2x; designed clear error |
Not covered: any card other than the A6000, Gyro-M, Gyro-L, prompts below 1,024 tokens (both paths are MMQ), multi-GPU, Windows.

data/settings-register.json: the STRATA_PF_FUSED_TQ note ("research", a diagnostic switch for bug reports, not a user setting; goes with MMQ in
release C).  No user-visible text changes: no new line in the engine, setup, the Terminal or the docs.
This commit is contained in:
Niko1221 committed 2026-11-11 22:04:40 +01:00
1 parent 4543053612
commit 93834ddf89
5 files changed
+99 -12

No files matched your search

+6
View File
@@ -348,6 +348,12 @@ if(STRATA_BUILD_TESTS)
target_include_directories(fused_tile_rule_test PRIVATE include)
add_test(NAME fused_tile_rule_test COMMAND fused_tile_rule_test)
# whether the CUDA fused prompt kernels take the Gyro trellis experts by default (STRATA_PF_FUSED_TQ unset: the sm_86 cards with 80+ SMs; =1 any card; =0 off): the pure
# rule, pinned for every card class (header-only, no GPU)
add_executable(fused_tq_default_test tests/prefill/fused_tq_default_test.cpp)
target_include_directories(fused_tq_default_test PRIVATE include)
add_test(NAME fused_tq_default_test COMMAND fused_tq_default_test)
# STRATA_SELECT_TWO_PASS: the bound between the single-pass and 3xTF32 QSA block scores and the cut-off rule that
# keeps the selection (header-only, no GPU)
add_executable(qsa_two_pass_test tests/prefill/qsa_two_pass_test.cpp)
+1 -1
View File
@@ -25960,7 +25960,7 @@
"last_date": "",
"status": "research",
"owner": "prefill",
"note": "CUDA (phase 4, opt-in, default off): the Gyro trellis experts (TQK6 / TQK7, TQ2_T / TQ2_T) on the fused native kernels on any sm_80+ card instead of MMQ; Hadamard-folded layers are still declined by the prompt path.",
"note": "CUDA (phase 4): the Gyro trellis experts on the fused native kernels instead of MMQ (Hadamard rotations of the folded layers inside the fused path). Unset: Gyro-S (TQK6 / TQK7) on compute capability 8.6 cards with 80+ SMs (RTX A6000 class; include/strata/prefill/fused_tq_default.hpp, tests/prefill/fused_tq_default_test.cpp), a diagnostic switch for bug reports, not a user setting; =1: Gyro-S and Gyro-M (TQ2_T / TQ2_T, no gate series) on any sm_80+ card; =0: MMQ again. STRATA_PF_FUSED_SM86=0 turns the sm_86 default off too. Goes with MMQ in release C.",
"retire_after": "",
"retired_in": ""
},
@@ -0,0 +1,32 @@
// include/strata/prefill/fused_tq_default.hpp - whether the CUDA fused prompt kernels take the Gyro trellis experts (Gyro-S TQK6 / TQK7, Gyro-M TQ2_T / TQ2_T) for a
// card, as a pure function of STRATA_PF_FUSED_TQ and the card class (DevInfo in src/prefill/moe_fused_iq.cu), so the rule can be tested without a GPU.
//
// STRATA_PF_FUSED_TQ unset or empty: Gyro-S (TQK6 / TQK7) on for a compute capability 8.6 card with 80 or more SMs (RTX A6000 / A40 84, RTX 3090 Ti 84, RTX 3090 82,
// RTX 3080 Ti 80), the class of the A6000 gate series; off for every other card; Gyro-M (TQ2_T) always off (no gate series)
// STRATA_PF_FUSED_TQ=1 (first character '1'): on for any sm_80+ card whose trellis kernels set up, as the opt-in always did
// any other value (0, ...): off
// s86 is DevInfo::s86 (raw compute capability 8.6 and STRATA_PF_FUSED_SM86 not 0), so STRATA_PF_FUSED_SM86=0 puts the trellis experts back on MMQ together with the
// i-quant formats. STRATA_PF_FUSED=0 (every fused kernel off) is read by native_supported before this rule matters.
//
// Evidence for the default (RTX A6000, 84 SMs, Gyro-S, 11-11, lane OWN-4X, RESULTS-OWN-4X.md "Gyro-S"): prompt speed with the trellis path 1.203 / 1.166 / 1.116 times the MMQ
// path at 4K / 8K / 20K (5 of 5 pairs each); first-token KL against the FP16 prompt path at 2,048 x 48 below both MMQ runs (0.00658; 0.00867, 0.01060), at 8,192 x 48 between
// them (0.00328; 0.00335, 0.00317), at 20,000 x 96 above the higher MMQ run but inside its paired interval and twice its run-to-run gap (0.00952; 0.00827, 0.00666); forced
// tokens written by the FP16 path: tq 1.56 / 1.64 % against MMQ 1.69 / 1.79 % mismatches; first 8K read, small chunks, agent and
// backstop as MMQ. Not covered: any card other than the A6000, Gyro-M, Gyro-L, a Gyro file other than Gyro-S.
#pragma once
#include <cstdlib>
namespace strata::prefill::fused_tq {
// the value of STRATA_PF_FUSED_TQ: -1 unset or empty, 1 when it starts with '1', 0 otherwise
constexpr int parse_env(const char* v) { return v == nullptr || v[0] == '\0' ? -1 : (v[0] == '1' ? 1 : 0); }
constexpr bool on(int env, bool s86, int sms) { return env == 1 || (env < 0 && s86 && sms >= 80); }
// Gyro-M's TQ2_T / TQ2_T pair has no gate series: it is taken only when STRATA_PF_FUSED_TQ=1 asks for it, never by the default
constexpr bool gyro_m_on(int env) { return env == 1; }
inline int env_value() { return parse_env(std::getenv("STRATA_PF_FUSED_TQ")); }
} // namespace strata::prefill::fused_tq
+15 -11
View File
@@ -22,6 +22,7 @@
#include "strata/prefill/moe_fused_iq.hpp"
#include "strata/prefill/pf_fused_override.hpp"
#include "strata/prefill/fused_tile_rule.hpp"
#include "strata/prefill/fused_tq_default.hpp"
#include "strata/kernels/gfx_arch.hpp"
#include "strata/core/emulate.hpp"
#include "strata/core/sm120_series.hpp"
@@ -2003,7 +2004,7 @@ struct DevInfo {
int occ_q8gu = 1; // the Q8_0 gate/up kernels' blocks per multiprocessor (the down keeps occ_kq8)
bool q6k = false; // sm_80+ with STRATA_PF_FUSED_Q6K=1: the Q6_K gate/up kernels, and the Q8_0 down ones behind them (opt-in, phase 4)
int occ_q6k = 1; // the Q6_K gate/up kernels' blocks per multiprocessor (the down keeps occ_kq8)
bool tq = false; // sm_80+ with STRATA_PF_FUSED_TQ=1: the trellis kernels (TQK6 / TQ2_T gate/up, TQK7 / TQ2_T down) are set up (opt-in, phase 4)
bool tq = false; // the trellis kernels (TQK6 / TQ2_T gate/up, TQK7 / TQ2_T down) are set up: by default on sm_86 with 80+ SMs, STRATA_PF_FUSED_TQ=1 on any sm_80+ (fused_tq_default.hpp)
int occ_tq_gu = 1, occ_tq_d = 1; // their blocks per multiprocessor (their own)
#endif
};
@@ -2047,11 +2048,13 @@ bool q6k_cuda_requested() {
static const bool on = [] { const char* v = std::getenv("STRATA_PF_FUSED_Q6K"); return v != nullptr && v[0] == '1'; }();
return on;
}
// STRATA_PF_FUSED_TQ on CUDA: "1" sets the trellis kernels up (dev_info) and lets native_supported take Gyro-S's TQK6 / TQK7 and Gyro-M's TQ2_T /
// TQ2_T layers on any sm_80+ card (layers whose experts are Hadamard-folded are still declined by the prompt path); anything else: MMQ
bool tq_cuda_requested() {
static const bool on = [] { const char* v = std::getenv("STRATA_PF_FUSED_TQ"); return v != nullptr && v[0] == '1'; }();
return on;
// STRATA_PF_FUSED_TQ on CUDA (the rule is include/strata/prefill/fused_tq_default.hpp, pinned by tests/prefill/fused_tq_default_test.cpp): unset = the trellis kernels are
// set up (dev_info) and native_supported takes Gyro-S's TQK6 / TQK7 layers on a compute capability 8.6 card with 80+ SMs (RTX A6000 class; the A6000 gate series is
// Gyro-S); "1" takes them on any sm_80+ card, and Gyro-M's TQ2_T / TQ2_T layers too (no gate series: they are never taken by default); any other value ("0") and every other card: MMQ. The Hadamard rotations of a folded layer run inside
// experts_native (set_down_rotation), the gate/up input arrives rotated.
int tq_env() {
static const int v = strata::prefill::fused_tq::env_value();
return v;
}
bool kq_on(); // STRATA_PF_FUSED_KQ (below): on CUDA "1" sets the K-quant kernels up (dev_info)
template <int T, bool GU, int WW, int NT = THREADS, bool F16 = false> bool setup_ww(int& occ) {
@@ -2229,10 +2232,10 @@ const DevInfo& dev_info() {
d.occ_q6k = o9;
d.occ_kq8 = o10;
}
// STRATA_PF_FUSED_TQ=1 (opt-in on CUDA, off by default): the trellis experts (Gyro-S TQK6 gate/up + TQK7 down, Gyro-M TQ2_T both) on native_kernel:
// the trellis experts (Gyro-S TQK6 gate/up + TQK7 down, Gyro-M TQ2_T both) on native_kernel, by default on sm_86 with 80+ SMs, STRATA_PF_FUSED_TQ=1 on any sm_80+ card, =0 off:
// the decode is MMQ's (tq.cuh: 15-bit states, the int8 codebook tq_lut_i8, one scale d * TQ_LUT_I8_SCALE a 128-value block), the products the int8
// mma.sync path. All four instance pairs set up or none; their own occupancy.
if (int og = 1 << 20, od = 1 << 20; d.ok && tq_cuda_requested() && setup_one<T_TQK6, true>(og) && setup_one<T_TQ2_T, true>(og) &&
if (int og = 1 << 20, od = 1 << 20; d.ok && strata::prefill::fused_tq::on(tq_env(), d.s86, d.sms) && setup_one<T_TQK6, true>(og) && setup_one<T_TQ2_T, true>(og) &&
setup_one<T_TQK7, false>(od) && setup_one<T_TQ2_T, false>(od)) {
d.tq = true;
d.occ_tq_gu = og;
@@ -2293,7 +2296,7 @@ bool gu_covered(int t) {
|| ((t == T_Q4_K || t == T_Q5_K) && dev_info().kq) // STRATA_PF_FUSED_KQ=1 and its kernels set up
|| (t == T_Q8_0 && dev_info().q8gu) // STRATA_PF_FUSED_Q8GU=1 and its kernels set up
|| (t == T_Q6_K && dev_info().q6k) // STRATA_PF_FUSED_Q6K=1 and its kernels set up
|| ((t == T_TQK6 || t == T_TQ2_T) && dev_info().tq) // STRATA_PF_FUSED_TQ=1 and its kernels set up
|| ((t == T_TQK6 || t == T_TQ2_T) && dev_info().tq) // the trellis kernels set up (default on sm_86 with 80+ SMs, or STRATA_PF_FUSED_TQ=1)
#endif
#if defined(__HIPCC__)
|| (t == T_Q2_0 && dev_info().w12) // gfx12: the native Q2_0 pack's gate/up on native_w11_kernel (64-value blocks)
@@ -2469,7 +2472,7 @@ bool native_supported(int gu_type, int d_type) {
const DevInfo& d = dev_info();
return d_type == T_Q8_0 && d.ok && d.q6k && !d.t75 && d.occ_nt <= 0 && !d.ws;
}
// The trellis pairs (phase 4, opt-in STRATA_PF_FUSED_TQ=1): Gyro-S's TQK6 / TQK7 and Gyro-M's TQ2_T / TQ2_T only, same conditions. (A trellis
// The trellis pairs (phase 4; default on sm_86 with 80+ SMs, STRATA_PF_FUSED_TQ=1 on any sm_80+ card; d.tq): Gyro-S's TQK6 / TQK7 and Gyro-M's TQ2_T / TQ2_T only, same conditions. (A trellis
// down behind any other gate/up, or the reverse: MMQ.)
if (is_tq(gu_type) || is_tq(d_type)) {
// the compiled geometry must suit the trellis path: whole 128-value blocks along both K, and (a folded down) the FP32 H of a row,
@@ -2477,7 +2480,8 @@ bool native_supported(int gu_type, int d_type) {
// 1,100 and n_embd down to 1,024, so a geometry that breaks it declines the trellis fused path (MMQ) instead of overrunning the row
constexpr bool geo_ok = D_ROWS_K <= D_ROWS_N && D_ROWS_K % 128 == 0 && GU_ROWS_K % 128 == 0;
const DevInfo& d = dev_info();
const bool pair = (gu_type == T_TQK6 && d_type == T_TQK7) || (gu_type == T_TQ2_T && d_type == T_TQ2_T);
// Gyro-S's pair follows the default rule (d.tq); Gyro-M's TQ2_T / TQ2_T has no gate series yet: only with STRATA_PF_FUSED_TQ=1 (fused_tq::gyro_m_on)
const bool pair = (gu_type == T_TQK6 && d_type == T_TQK7) || (gu_type == T_TQ2_T && d_type == T_TQ2_T && strata::prefill::fused_tq::gyro_m_on(tq_env()));
return geo_ok && pair && d.ok && d.tq && !d.t75 && d.occ_nt <= 0 && !d.ws;
}
if (d_type == T_Q8_0 && gu_type != T_Q4_K && gu_type != T_Q5_K) {
+45
View File
@@ -0,0 +1,45 @@
// the default rule of the CUDA fused trellis (Gyro) prompt kernels (include/strata/prefill/fused_tq_default.hpp): unset = on for a compute capability 8.6 card with 80+ SMs,
// off for every other class; =1 forces on, any other value off. No GPU, no model.
#include <cstdio>
#include "strata/prefill/fused_tq_default.hpp"
using strata::prefill::fused_tq::gyro_m_on;
using strata::prefill::fused_tq::on;
using strata::prefill::fused_tq::parse_env;
static int failed = 0;
#define CHECK(x) do { if (!(x)) { std::fprintf(stderr, "FAIL %s:%d: %s\n", __FILE__, __LINE__, #x); ++failed; } } while (0)
int main() {
// the variable's three readings
CHECK(parse_env(nullptr) == -1 && parse_env("") == -1);
CHECK(parse_env("1") == 1 && parse_env("1x") == 1);
CHECK(parse_env("0") == 0 && parse_env("2") == 0 && parse_env("off") == 0);
// unset: the sm_86 cards with 80+ SMs take the trellis kernels (A6000 / A40 84, 3090 Ti 84, 3090 82, 3080 Ti 80) ...
const int unset = parse_env(nullptr);
CHECK(on(unset, true, 84) && on(unset, true, 82) && on(unset, true, 80));
// ... and nothing else does: RTX 3080 (68), A10 (72), A4000 (48) on sm_86 below 80 SMs; sm_120 cards (5070 48, 5080 84, PRO 5000 110, PRO 6000 188), GB10, sm_80 / 89 / 90
// (s86 false) whatever their SM count
CHECK(!on(unset, true, 79) && !on(unset, true, 72) && !on(unset, true, 68) && !on(unset, true, 48));
CHECK(!on(unset, false, 48) && !on(unset, false, 84) && !on(unset, false, 110) && !on(unset, false, 188) && !on(unset, false, 108) && !on(unset, false, 128));
// STRATA_PF_FUSED_SM86=0 makes DevInfo::s86 false: the A6000 class is back on MMQ
CHECK(!on(unset, false, 84));
// =1: the opt-in of before, on any card class (the kernels still have to set up on it)
CHECK(on(1, true, 84) && on(1, true, 48) && on(1, false, 48) && on(1, false, 110) && on(1, false, 188));
// =0 (or any other value): off, also on the A6000 class
CHECK(!on(0, true, 84) && !on(0, true, 80) && !on(0, false, 110));
CHECK(!on(parse_env("0"), true, 84) && !on(parse_env("false"), true, 84) && on(parse_env("1"), false, 48));
// Gyro-M (TQ2_T / TQ2_T) has no gate series: never by default, only with =1
CHECK(!gyro_m_on(parse_env(nullptr)) && !gyro_m_on(parse_env("")) && !gyro_m_on(parse_env("0")) && gyro_m_on(parse_env("1")));
if (failed) {
std::fprintf(stderr, "fused_tq_default_test: %d failed\n", failed);
return 1;
}
std::printf("fused_tq_default_test: all checks passed\n");
return 0;
}