mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-06 08:18:54 +00:00
prefill: Q6_K gate/up with Q6_K down (UD-Q6_K_XL, UD-Q6_K, UD-Q5_K_XL) on the fused tensor-core kernels (STRATA_PF_FUSED_KQD, q4_lite)
Qwen4's UD-Q6_K_XL is Q6_K gate/up with Q6_K down in all 40 layers (UD-Q6_K: Q5_K / Q6_K then Q6_K / Q6_K; UD-Q5_K_XL: Q5_K / Q6_K then Q6_K / Q6_K). H11 covered a Q6_K gate/up only with a Q8_0 down, so these layers ran on the int8 dp4a kernels. Under the same switch as the K-quant pairs (kKqDownGeo, the q4_lite shape, per-architecture default of the previous commit): - dev_info sets the Q6_K gate/up instance up with the K-quant set (d.q6k, which a no-MMQ build already did through STRATA_PF_FUSED_Q6K=1) and the Q8_0 / Q8_0 pair (d.q8gu, likewise STRATA_PF_FUSED_Q8GU=1); - native_supported takes a Q6_K gate/up with a Q6_K down (d.kqd: the Q6_K down instance of the K-quant set); experts_native launches it on that instance and occupancy. Q6_K has no minimum, so no code sums are read. Measured (RTX PRO 6000, CUDA 13.0, UD-Q6_K_XL, every expert in VRAM, ABBA, medians of 6 requests, tokens / s dp4a -> fused): 2K 6,483 -> 7,453, 4K 8,049 -> 9,048, 8K 8,806 -> 10,003, 16K 9,670 -> 11,079, 32K 9,906 -> 11,488 (+15 / +12 / +14 / +15 / +16 %). With 4,000 of 10,240 expert slots in VRAM (the rest streamed): 4K 7,691 -> 8,177 (+6 %), 16K 9,439 -> 10,729 (+14 %). Golden (36 probes): dp4a top-1 0.97986 / KL 0.011778, fused 0.97917 / 0.012338 (+4.8 % KL, 0 flips of 4,659; the PRO 6000 run is deterministic, the difference is the rounding of the two kernels). Bit identity: switch off = H11 (last-prompt-position logits and greedy ids, 4,096 tokens and a real 6,144-token prompt); tile 64 / 128 / default give the same bits. The Q8_0 / Q8_0 pair (Q8_0, UD-Q8_K_XL) needs nothing: a no-MMQ build already takes it on the fused kernels, and fused and dp4a give the same logits hash and the same golden (0.98021 / 0.011456) with the same speed (0.995-1.000 at 4K-32K, 0.92 at 2K).
This commit is contained in:
1 parent
0f53345767
commit
b1808a0f48
2 files changed
+17
-8
No files matched your search
@@ -3018,6 +3018,13 @@ const DevInfo& dev_info() {
|
||||
static const int kq_env = strata::prefill::fused_tile::pf_env(std::getenv("STRATA_PF_FUSED_KQ"));
|
||||
static const int kq_sm40_env = strata::prefill::fused_tile::sm40_env_of(std::getenv("STRATA_PF_FUSED_SM40"));
|
||||
const bool kq_want = strata::prefill::fused_tile::kq_takes(kq_env, {d.s120, d.s121, d.sms, d.s86}, kq_sm40_env);
|
||||
// STRATA_PF_FUSED_KQD (kKqDownGeo, the q4_lite shape): Qwen4's K-quant, Q6_K and Q8_0 expert pairs on these kernels instead of the int8 dp4a ones. Unset: on for compute capability 12.0 (RTX 5090 / PRO 6000 / 5070),
|
||||
// 8.9 (RTX 4090) and 8.6 (RTX 3090), measured; else off (8.0 / A100: not measured); 1 on any sm_80+ card that sets up the K-quant kernels, 0 off.
|
||||
bool kqd_on = false;
|
||||
if constexpr (kKqDownGeo) {
|
||||
const char* kqd_v = std::getenv("STRATA_PF_FUSED_KQD");
|
||||
kqd_on = kqd_v == nullptr || kqd_v[0] == '\0' ? (kKqDownDefault || d.s120 || (major == 8 && (minor == 6 || minor == 9))) : kqd_v[0] != '0';
|
||||
}
|
||||
if (int o4 = 1 << 20; d.ok && kq_want && setup_one<T_Q4_K, true>(o4) && setup_one<T_Q5_K, true>(o4) && setup_one<T_Q5_1, false>(o4)) {
|
||||
d.kq = true;
|
||||
d.occ_kq = o4;
|
||||
@@ -3025,10 +3032,8 @@ const DevInfo& dev_info() {
|
||||
// its own occupancy, and a failed setup leaves those layers on MMQ
|
||||
if (int o5 = 1 << 20; setup_one<T_Q8_0, false>(o5)) { d.kq8 = true; d.occ_kq8 = o5; }
|
||||
// the Q5_K / Q6_K downs (kKqDownGeo: n_ff a whole number of 256-value super-blocks): the same instances the Qwen3.6 copy sets up for its UD-Q4_K_XL (kqdown_info); their own occupancies.
|
||||
// STRATA_PF_FUSED_KQD=0 leaves them off (those layers stay on the int8 dp4a kernels), =1 sets them up, unset = kKqDownDefault.
|
||||
// STRATA_PF_FUSED_KQD=0 leaves them off (those layers stay on the int8 dp4a kernels), =1 sets them up, unset = the per-card default above.
|
||||
if constexpr (kKqDownGeo) {
|
||||
const char* kqd_v = std::getenv("STRATA_PF_FUSED_KQD");
|
||||
const bool kqd_on = kqd_v == nullptr || kqd_v[0] == '\0' ? (kKqDownDefault || d.s120 || (major == 8 && (minor == 6 || minor == 9))) : kqd_v[0] != '0'; // unset: on for compute capability 12.0 (RTX 5090 / PRO 6000 / 5070), 8.9 (RTX 4090) and 8.6 (RTX 3090), measured; else off (8.0 / A100: not measured)
|
||||
if (int o5 = 1 << 20, o6 = 1 << 20; kqd_on && setup_one<T_Q5_K, false>(o5) && setup_one<T_Q6_K, false>(o6)) { d.kqd = true; d.occ_kqd5 = o5; d.occ_kqd6 = o6; }
|
||||
}
|
||||
}
|
||||
@@ -3038,14 +3043,14 @@ const DevInfo& dev_info() {
|
||||
if (int o6 = 1 << 20; d.ok && q8d_cuda_requested() && setup_one<T_Q8_0, false>(o6)) { d.q8d = true; d.occ_kq8 = o6; }
|
||||
// STRATA_PF_FUSED_Q8GU=1 (opt-in on CUDA, off by default): a Q8_0 gate/up (int8 codes, one scale per 32 values: two blocks a 64-value
|
||||
// stage, as the Q8_0 down reads them) with a Q8_0 down on A2's down instances. Both set up or neither; the gate/up's occupancy is its own.
|
||||
if (int o7 = 1 << 20, o8 = 1 << 20; d.ok && q8gu_cuda_requested() && setup_one<T_Q8_0, true>(o7) && setup_one<T_Q8_0, false>(o8)) {
|
||||
if (int o7 = 1 << 20, o8 = 1 << 20; d.ok && (q8gu_cuda_requested() || (kKqDownGeo && kqd_on && d.kq)) && setup_one<T_Q8_0, true>(o7) && setup_one<T_Q8_0, false>(o8)) { // (kKqDownGeo: the Q8_0 / Q8_0 pair of Qwen4 Q8_0 / UD-Q8_K_XL with STRATA_PF_FUSED_KQD)
|
||||
d.q8gu = true;
|
||||
d.occ_q8gu = o7;
|
||||
d.occ_kq8 = o8;
|
||||
}
|
||||
// STRATA_PF_FUSED_Q6K=1 (opt-in on CUDA, off by default): a Q6_K gate/up (int8 codes q - 32, an int8 scale times d per 16 values: the
|
||||
// per-16-value scale path of IQ2_XS / IQ2_S) with a Q8_0 down on A2's down instances. Both set up or neither; its own occupancy.
|
||||
if (int o9 = 1 << 20, o10 = 1 << 20; d.ok && q6k_cuda_requested() && setup_one<T_Q6_K, true>(o9) && setup_one<T_Q8_0, false>(o10)) {
|
||||
if (int o9 = 1 << 20, o10 = 1 << 20; d.ok && (q6k_cuda_requested() || (kKqDownGeo && kqd_on && d.kq)) && setup_one<T_Q6_K, true>(o9) && setup_one<T_Q8_0, false>(o10)) { // (kKqDownGeo: the Q6_K gate/up of UD-Q6_K / UD-Q6_K_XL with STRATA_PF_FUSED_KQD)
|
||||
d.q6k = true;
|
||||
d.occ_q6k = o9;
|
||||
d.occ_kq8 = o10;
|
||||
@@ -3510,7 +3515,8 @@ bool native_supported(int gu_type, int d_type) {
|
||||
// A Q6_K gate/up (phase 4, opt-in STRATA_PF_FUSED_Q6K=1; gu_covered checked q6k above): with a Q8_0 down only, same conditions.
|
||||
if (gu_type == T_Q6_K) {
|
||||
const DevInfo& d = dev_info();
|
||||
return d_type == T_Q8_0 && d.ok && d.q6k && d.occ_nt <= 0 && !d.ws;
|
||||
// (kKqDownGeo: UD-Q6_K_XL / UD-Q6_K, a Q6_K gate/up with a Q6_K down, on the Q6_K down instance of the K-quant set (d.kqd); no minimum, so no code sums are read)
|
||||
return (d_type == T_Q8_0 || (kKqDownGeo && d_type == T_Q6_K && d.kqd)) && d.ok && d.q6k && d.occ_nt <= 0 && !d.ws;
|
||||
}
|
||||
// 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.)
|
||||
@@ -3765,7 +3771,7 @@ void experts_native(const Batch& b, const NativeGeom& g, int n_expert, int64_t n
|
||||
#endif
|
||||
#if !defined(__HIPCC__)
|
||||
// (d_covered_on says nothing for a K-quant down by itself: behind an i-quant gate/up it has no code sums to read, native_supported only takes it behind Q4_K / Q5_K)
|
||||
const bool kqd_pair = kKqDownGeo && d.kqd && (g.gu_type == T_Q4_K || g.gu_type == T_Q5_K) && (g.d_type == T_Q5_K || g.d_type == T_Q6_K);
|
||||
const bool kqd_pair = kKqDownGeo && d.kqd && ((g.gu_type == T_Q4_K || g.gu_type == T_Q5_K) && (g.d_type == T_Q5_K || g.d_type == T_Q6_K) || (g.gu_type == T_Q6_K && g.d_type == T_Q6_K && d.q6k));
|
||||
#else
|
||||
constexpr bool kqd_pair = false;
|
||||
#endif
|
||||
@@ -4042,6 +4048,9 @@ void experts_native(const Batch& b, const NativeGeom& g, int n_expert, int64_t n
|
||||
} else if (g.d_type == T_Q8_0) { // STRATA_PF_FUSED_Q8D=1 (d_covered_on checked d.q8d above); A2's instances and occupancy
|
||||
const unsigned g8 = (unsigned) std::min<int64_t>(tiles * (D_ROWS_N / weight_rows(ww)), (int64_t) d.sms * d.occ_kq8);
|
||||
launch<T_Q8_0, false>(ww, g8, b, g, tb, ha, src, nullptr, dm, s);
|
||||
} else if (kKqDownGeo && g.d_type == T_Q6_K) { // a Q6_K gate/up (UD-Q6_K_XL) with a Q6_K down (kqd_pair checked d.kqd above): the K-quant set's Q6_K down instance and occupancy
|
||||
const unsigned g6 = (unsigned) std::min<int64_t>(tiles * (D_ROWS_N / weight_rows(ww)), (int64_t) d.sms * d.occ_kqd6);
|
||||
launch<T_Q6_K, false>(ww, g6, b, g, tb, ha, src, nullptr, dm, s);
|
||||
} else if (g.d_type == T_TQK7 || g.d_type == T_TQ2_T) { // STRATA_PF_FUSED_TQ=1 (d_covered_on checked d.tq above); their own occupancy
|
||||
if (g_rot_on) { // a folded down (set_down_rotation): the FP32 H rows of this call's experts (in dm), rotated and quantized into ha
|
||||
const int64_t nw = n * (D_ROWS_K / 128);
|
||||
|
||||
@@ -47687,7 +47687,7 @@
|
||||
"last_date": null,
|
||||
"status": "rollback",
|
||||
"owner": "q4lite",
|
||||
"note": "In a q4_lite CUDA build (Qwen4-35B-A3B on the `strata` GGUF engine) the prompt experts of UD-Q4_K_XL (a Q4_K / Q5_K gate/up with a Q5_K / Q6_K down) run on the fused tensor-core kernels of moe_fused_iq.cu instead of the int8 dp4a kernels: on by default on compute capability 12.0 (RTX 5090 / RTX PRO 6000 / RTX 5070), 8.9 (RTX 4090) and 8.6 (RTX 3090), off elsewhere (8.0 / A100 not measured); 1 turns it on for any sm_80+ card that sets up the K-quant kernels, 0 turns it off (the dp4a kernels again). The output differs from the dp4a kernels' at rounding level (golden KL 0.0149 against 0.0164). Not compiled into any other shape.",
|
||||
"note": "In a q4_lite CUDA build (Qwen4-35B-A3B on the `strata` GGUF engine) the prompt experts of UD-Q4_K_XL (a Q4_K / Q5_K gate/up with a Q5_K / Q6_K down) and of UD-Q6_K_XL / UD-Q6_K / UD-Q5_K_XL (Q6_K gate/up with a Q6_K down) run on the fused tensor-core kernels of moe_fused_iq.cu instead of the int8 dp4a kernels: on by default on compute capability 12.0 (RTX 5090 / RTX PRO 6000 / RTX 5070), 8.9 (RTX 4090) and 8.6 (RTX 3090), off elsewhere (8.0 / A100 not measured); 1 turns it on for any sm_80+ card that sets up the K-quant kernels, 0 turns it off (the dp4a kernels again). The output differs from the dp4a kernels' at rounding level (golden KL 0.0149 against 0.0164). Not compiled into any other shape.",
|
||||
"retire_after": "",
|
||||
"retired_in": ""
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user