mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-05 07:48:45 +00:00
prefill: the fused kernels are the default for IQ2_XXS / IQ2_XS gate/up on sm_86 / sm_120 cards with 80+ SMs
The owner said yes on 11-12 ("2-bit fused kernels as the default on 80+ SM NVIDIA cards"), on the decision table of lane OWN-4X
(RESULTS-OWN-4X.md, "IQ3_XXS 2-bit cell on 80+ SM cards"). Until now native_supported's default branch (CUDA, STRATA_PF_FUSED unset) took only
IQ2_S / IQ3_XXS / IQ3_S / IQ4_XS gate/up and kept MMQ for IQ2_XXS / IQ2_XS ("until measured"); the IQ3_XXS set has 19 such layers (9 IQ2_XXS,
10 IQ2_XS) of 48, and the IQ2_XS sets have their own. They join the list; the card rule is the one the i-quant default already uses
(fused_tile::takes_by_default: sm_86 / sm_120 with 80+ SMs; STRATA_PF_FUSED_SM86=0 turns the sm_86 default off), nothing changes below 80 SMs
(the sm40 research switch only takes the weight-staging gate/up instances, sw_on, which IQ2_XXS / IQ2_XS are not), nothing for AMD (its own rule
in native_supported, the HIP branch), no new setting. STRATA_PF_FUSED=0 gives MMQ again, =1 keeps its meaning.
The rule is now a pure function (include/strata/prefill/fused_tile_rule.hpp): default_gate_format(ggml type id) and
default_takes(env, card, sm40, gate_staged, down_ok, gu_type); moe_fused_iq.cu static_asserts that the ids are GGML_TYPE_*. Host code only:
the kernels, the tile pick and the prompt path (prefill.cpp) are untouched. tests/prefill/fused_tile_rule_test.cpp: IQ2_XXS / IQ2_XS over
both card flags x sm_121 x 0-200 SMs x the sm40 switch x down kinds (12,864 combinations): yes exactly for sm_86 / sm_120 with 80+ SMs (80 yes,
79 no, 48 no, AMD and sm_89 without a flag no), STRATA_PF_FUSED=0 off, =1 not by default; the formats already in the list keep their rule.
Evidence (RTX A6000, sm_86, 84 SMs, Boston GPU 0, IQ3_XXS set, frozen shipped expert profile, MTP on; fused = STRATA_PF_FUSED=1 = what this
commit makes the default, against nothing set before):
- prompt speed, 5 interleaved rounds, fresh engine per arm: tok/s fused / default 1.030 / 1.040 / 1.035 at 4K / 8K / 20K, 5 of 5 each (e93);
on the integration head 9f81b8b67, prompt ms fused / default 0.874 to 0.976 from 300 to 8,193 tokens, fused slower in 0 of 5 rounds at every
length (below 1,024 tokens the head runs the staged fused groups; on e93 800-1,024 tokens were 1.03x slower, not on the head)
- teacher-forced per-position KL against the FP16 prompt path, 48 prompts x 256 positions, paired bootstrap over prompts, fused / default
[95 %]: 512 ids 0.965 [0.912, 1.021], 1,000 ids 1.062 [0.995, 1.137], 2,048 ids 1.072 [1.020, 1.123], 8,192 ids 1.008 [0.939, 1.101]; the
floor (default again) 0.974 / 1.012 / 1.006 / 1.003
- one layer against FP32 (19 layers, real blobs, real routing): fused and MMQ equally far (ratio 1.0001 at 2K, 0.9998 at 8K)
- robustness: small chunks, agent run, first 8K read (24 engines, 0 of 24 over 2x), forced-slow-layer backstop with its designed error, no hang
Not covered: any card other than the A6000 (sm_120 with 80+ SMs follows by the class rule, not measured on a 2-bit set), the IQ2_XS sets end
to end, multi-GPU, Windows, tool-call agent runs.
data/settings-register.json: the STRATA_PF_FUSED_SM86 note names the default list. No user-visible text changes.
This commit is contained in:
1 parent
15dfa33240
commit
df485b41c0
4 files changed
+64
-5
No files matched your search
@@ -24456,7 +24456,7 @@
|
||||
"last_date": "",
|
||||
"status": "research",
|
||||
"owner": "prefill",
|
||||
"note": "CUDA diagnostic for bug reports, not a user setting: =0 puts compute capability 8.6 cards with 80+ SMs back on MMQ for the IQ3_S pack's formats (the fused prompt kernels are the default there since 11-11). Goes away with MMQ (release C).",
|
||||
"note": "CUDA diagnostic for bug reports, not a user setting: =0 puts compute capability 8.6 cards with 80+ SMs back on MMQ for the default list's gate/up formats (IQ2_XXS, IQ2_XS, IQ2_S, IQ3_XXS, IQ3_S, IQ4_XS; the fused prompt kernels are the default there since 11-11, IQ2_XXS / IQ2_XS since 11-12). Goes away with MMQ (release C).",
|
||||
"retire_after": "",
|
||||
"retired_in": ""
|
||||
},
|
||||
|
||||
@@ -87,6 +87,23 @@ constexpr bool takes_by_default(const Card& c, bool sm40, bool gate_staged, bool
|
||||
return sm40 && gate_staged && down_ok && c.sms >= 40;
|
||||
}
|
||||
|
||||
// The gate/up formats native_supported's default rule (CUDA, STRATA_PF_FUSED unset) takes at all: IQ2_XXS, IQ2_XS, IQ2_S, IQ3_XXS, IQ3_S, IQ4_XS, as ggml type ids (moe_fused_iq.cu static_asserts
|
||||
// that they are GGML_TYPE_*). IQ2_XXS / IQ2_XS joined on the owner's word of 11-12 ("2-bit fused kernels as the default on 80+ SM NVIDIA cards"): the IQ3_XXS set's 19 gate/up layers (9 IQ2_XXS,
|
||||
// 10 IQ2_XS) on an RTX A6000 (sm_86, 84 SMs): prompt time fused / default 0.874-0.976 from 300 to 8,193 tokens on the integration head, teacher-forced KL against the FP16 prompt path 0.965 [0.912,
|
||||
// 1.021] at 512, 1.062 [0.995, 1.137] at 1,000, 1.072 [1.020, 1.123] at 2,048 and 1.008 [0.939, 1.101] at 8,192 ids (RESULTS-OWN-4X.md). The card rule is takes_by_default above and did not
|
||||
// change: sm_86 / sm_120 with 80+ SMs; below 80 SMs the sm40 research switch only takes the weight-staging gate/up instances (IQ3_XXS / IQ3_S / IQ4_XS: sw_on), never IQ2_XXS / IQ2_XS.
|
||||
// AMD (HIP) has its own rule in native_supported and is not touched.
|
||||
constexpr int kTypeIq2Xxs = 16, kTypeIq2Xs = 17, kTypeIq3Xxs = 18, kTypeIq3S = 21, kTypeIq2S = 22, kTypeIq4Xs = 23;
|
||||
constexpr bool default_gate_format(int t) {
|
||||
return t == kTypeIq2Xxs || t == kTypeIq2Xs || t == kTypeIq2S || t == kTypeIq3Xxs || t == kTypeIq3S || t == kTypeIq4Xs;
|
||||
}
|
||||
|
||||
// native_supported's CUDA default decision for a gate/up format on a card: `env` is STRATA_PF_FUSED as native_supported reads it (-1 unset, 0 = "0", 1 = other: the opt-in, decided
|
||||
// elsewhere, never "by default"), so only an unset variable can take a layer here, and STRATA_PF_FUSED=0 turns the default off again.
|
||||
constexpr bool default_takes(int env, const Card& c, bool sm40, bool gate_staged, bool down_ok, int gu_type) {
|
||||
return env < 0 && default_gate_format(gu_type) && takes_by_default(c, sm40, gate_staged, down_ok);
|
||||
}
|
||||
|
||||
// ---- the weight-staging guard (check_staged_blobs's decision in src/prefill/moe_fused_iq.cu), as pure functions so the decision can be tested without a GPU.
|
||||
// The staging kernels (sw_on instances) copy the expert blobs into shared memory with cp.async and read 16-bit words at the rows' offsets: they need blobs in device (or managed)
|
||||
// memory at 2-byte aligned addresses and 2-byte aligned rows and offsets. A launch that fails the check does NOT end the process: it takes the unstaged 64-row kernel of the same
|
||||
|
||||
@@ -88,6 +88,10 @@ constexpr int H_ROW_BYTES = D_ROWS_K / 64 * AB; // bytes of a row of H in the
|
||||
static_assert(GU_ROWS_K % 256 == 0 && D_ROWS_K % 64 == 0, "the native expert kernels: K of gate/up is whole 256-value super-blocks, K of down whole 64-value stages");
|
||||
|
||||
// the formats (ggml type ids)
|
||||
static_assert(GGML_TYPE_IQ2_XXS == strata::prefill::fused_tile::kTypeIq2Xxs && GGML_TYPE_IQ2_XS == strata::prefill::fused_tile::kTypeIq2Xs &&
|
||||
GGML_TYPE_IQ2_S == strata::prefill::fused_tile::kTypeIq2S && GGML_TYPE_IQ3_XXS == strata::prefill::fused_tile::kTypeIq3Xxs &&
|
||||
GGML_TYPE_IQ3_S == strata::prefill::fused_tile::kTypeIq3S && GGML_TYPE_IQ4_XS == strata::prefill::fused_tile::kTypeIq4Xs,
|
||||
"fused_tile_rule.hpp's default_gate_format uses ggml's type ids");
|
||||
constexpr int T_IQ2_XXS = GGML_TYPE_IQ2_XXS, T_IQ2_XS = GGML_TYPE_IQ2_XS, T_IQ2_S = GGML_TYPE_IQ2_S,
|
||||
T_IQ3_XXS = GGML_TYPE_IQ3_XXS, T_IQ3_S = GGML_TYPE_IQ3_S, T_IQ4_XS = GGML_TYPE_IQ4_XS,
|
||||
T_IQ4_NL = GGML_TYPE_IQ4_NL, T_Q2_0 = GGML_TYPE_Q2_0,
|
||||
@@ -2792,15 +2796,16 @@ bool native_supported(int gu_type, int d_type) {
|
||||
// formats measured there - the IQ3_S pack's IQ2_S, IQ3_XXS, IQ3_S and IQ4_XS layers with IQ4_NL / Q2_0 down (RTX PRO 5000:
|
||||
// prompt +7.0% 4K, +5.2% 20K, +3.4% 98K; teacher-forced KL against MMQ 0.0002 over 5998 positions, 0.0010 over 1760 long
|
||||
// ones; first-token KL against the FP16 prompt path 0.01181 vs MMQ's 0.01236 over 48 prompts; HumanEval, reasoning,
|
||||
// agent, needles, CJK and tool calls the same). IQ2_XXS / IQ2_XS gate/up (the IQ3_XXS and IQ2_XS packs) keep MMQ until
|
||||
// measured. The same on a compute capability 8.6 card with 80+ SMs (RTX A6000, 84 SMs, IQ3_S pack, 11-11: prompt +6.7% 4K, +3.6% 8K,
|
||||
// agent, needles, CJK and tool calls the same). The same on a compute capability 8.6 card with 80+ SMs (RTX A6000, 84 SMs, IQ3_S pack, 11-11: prompt +6.7% 4K, +3.6% 8K,
|
||||
// +1.0% 20K, 5/5 each; first-token KL against the FP16 prompt path at or below MMQ's at 2,048 / 4K / 8K / 20K; neutral-writer
|
||||
// forced-token gate PASS over 48 prompts; small chunks, agent, first 8K read, backstop as MMQ; STRATA_PF_FUSED_SM86=0 off).
|
||||
// IQ2_XXS / IQ2_XS gate/up (the IQ3_XXS and IQ2_XS packs) joined on 11-12 on the owner's word (RTX A6000, IQ3_XXS pack: prompt time fused / MMQ-mixed 0.874-0.976 from 300 to 8,193
|
||||
// tokens on the integration head, 5 rounds; teacher-forced KL vs the FP16 prompt path 0.965 / 1.062 / 1.072 / 1.008 at 512 / 1,000 / 2,048 / 8,192 ids; the rule: fused_tile_rule.hpp).
|
||||
// Every other CUDA card: opt-in as before.
|
||||
if (env < 0) {
|
||||
// the native Q2_0 pack's Q2_0 / Q2_0 layers: only with STRATA_PF_FUSED_Q2N=1 (d.q2n), on any sm_80+ card
|
||||
if (gu_type == T_Q2_0) { const DevInfo& d = dev_info(); return d.ok && d.q2n && d_type == T_Q2_0 && d_covered_on(d_type, d); }
|
||||
if (gu_type != T_IQ2_S && gu_type != T_IQ3_XXS && gu_type != T_IQ3_S && gu_type != T_IQ4_XS) return false;
|
||||
if (!strata::prefill::fused_tile::default_gate_format(gu_type)) return false; // IQ2_XXS / IQ2_XS joined 11-12 (owner), see fused_tile_rule.hpp
|
||||
const DevInfo& d = dev_info();
|
||||
// 12.0 and 8.6 cards with 80+ SMs only (RTX PRO 5000 / 6000, RTX 5080 / 5090; RTX A6000 / A40, RTX 3090 / 3090 Ti / 3080 Ti):
|
||||
// on an RTX 5070 (48 SMs, IQ2_XS pack, experts partly in RAM) the fused kernels were 4.7% slower on 20K prompts (0/6 pairs),
|
||||
@@ -2808,7 +2813,7 @@ bool native_supported(int gu_type, int d_type) {
|
||||
// STRATA_PF_FUSED_SM40=1 (research, off unless set): the sm_86 / sm_120 cards with 40-79 SMs also take the launches with a staged gate/up kernel (IQ3_XXS / IQ3_S / IQ4_XS) and an IQ4_NL / Q2_0
|
||||
// down; the rule itself is fused_tile::takes_by_default (unit-tested)
|
||||
static const bool sm40 = [] { const char* v = std::getenv("STRATA_PF_FUSED_SM40"); return v != nullptr && v[0] == '1'; }();
|
||||
return d.ok && strata::prefill::fused_tile::takes_by_default({d.s120, d.s121, d.sms, d.s86}, sm40, sw_on(gu_type, true), d_type == T_IQ4_NL || d_type == T_Q2_0) && !d.t75 &&
|
||||
return d.ok && strata::prefill::fused_tile::default_takes(env, {d.s120, d.s121, d.sms, d.s86}, sm40, sw_on(gu_type, true), d_type == T_IQ4_NL || d_type == T_Q2_0, gu_type) && !d.t75 &&
|
||||
d_covered_on(d_type, d);
|
||||
}
|
||||
if (gu_type == T_Q2_0 && d_type != T_Q2_0) return false; // the opt-in (STRATA_PF_FUSED=1 as well) takes the Q2_0 / Q2_0 pair only
|
||||
|
||||
@@ -173,6 +173,43 @@ int main() {
|
||||
CHECK(bad == 0);
|
||||
std::printf("fused_tile_rule_test: default rule with the switch unset: %lld card / launch combinations compared with 'sm_86 / sm_120, 80+ SMs' (%lld differing)\n", cmpd, bad);
|
||||
}
|
||||
// ---- the 2-bit gate/up formats in the default (owner 11-12): default_gate_format / default_takes(env, card, sm40, gate_staged, down_ok, gu_type)
|
||||
{
|
||||
using namespace strata::prefill::fused_tile;
|
||||
// the ids are ggml's (GGML_TYPE_*, asserted in moe_fused_iq.cu): IQ2_XXS 16, IQ2_XS 17, IQ3_XXS 18, IQ1_S 19, IQ4_NL 20, IQ3_S 21, IQ2_S 22, IQ4_XS 23
|
||||
CHECK(default_gate_format(16) && default_gate_format(17)); // IQ2_XXS, IQ2_XS: new
|
||||
CHECK(default_gate_format(18) && default_gate_format(21) && default_gate_format(22) && default_gate_format(23)); // IQ3_XXS, IQ3_S, IQ2_S, IQ4_XS: as before
|
||||
CHECK(!default_gate_format(19) && !default_gate_format(20) && !default_gate_format(29) && !default_gate_format(12) && !default_gate_format(0)); // IQ1_S, IQ4_NL, IQ1_M, Q4_K, F32
|
||||
const int kIq2[2] = {16, 17};
|
||||
long long cmp2 = 0, bad2 = 0;
|
||||
for (int gu : kIq2)
|
||||
for (int s120 = 0; s120 < 2; ++s120)
|
||||
for (int s86 = 0; s86 < 2; ++s86)
|
||||
for (int s121 = 0; s121 < 2; ++s121)
|
||||
for (int sms = 0; sms <= 200; ++sms)
|
||||
for (int sm40 = 0; sm40 < 2; ++sm40)
|
||||
for (int d = 0; d < 2; ++d) {
|
||||
++cmp2;
|
||||
const Card c{s120 != 0, s121 != 0, sms, s86 != 0};
|
||||
const bool want = (s120 || s86) && sms >= 80; // sm_86 / sm_120, 80+ SMs; gate_staged is false for IQ2_XXS / IQ2_XS (sw_on), so sm40 adds nothing
|
||||
if (default_takes(-1, c, sm40 != 0, false, d != 0, gu) != want) ++bad2;
|
||||
if (default_takes(0, c, sm40 != 0, false, d != 0, gu)) ++bad2; // STRATA_PF_FUSED=0: the default is off again
|
||||
if (default_takes(1, c, sm40 != 0, false, d != 0, gu)) ++bad2; // STRATA_PF_FUSED=1 is the opt-in, decided elsewhere
|
||||
}
|
||||
CHECK(bad2 == 0);
|
||||
std::printf("fused_tile_rule_test: IQ2_XXS / IQ2_XS default: %lld card / switch combinations (%lld wrong)\n", cmp2, bad2);
|
||||
// named cards: 80 SMs yes, 79 no, 48 no, AMD (no s86 / s120 flag) no at any SM count, sm_89 / sm_80 (no flag) no
|
||||
CHECK(default_takes(-1, Card{false, false, 84, true}, false, false, true, 16) && default_takes(-1, Card{false, false, 80, true}, false, false, true, 17)); // A6000, 3080 Ti
|
||||
CHECK(!default_takes(-1, Card{false, false, 79, true}, false, false, true, 16) && !default_takes(-1, Card{false, false, 79, true}, true, false, true, 17)); // 79 SMs: no, switch or not
|
||||
CHECK(!default_takes(-1, Card{false, false, 48, true}, true, false, true, 16) && !default_takes(-1, Card{true, false, 48, false}, true, false, true, 17)); // A4000, 5070
|
||||
CHECK(default_takes(-1, Card{true, false, 100, false}, false, false, true, 16)); // PRO 5000 (sm_120)
|
||||
CHECK(!default_takes(-1, Card{false, false, 304, false}, true, false, true, 16) && !default_takes(-1, Card{false, false, 128, false}, false, false, true, 17)); // AMD / sm_89: no
|
||||
// the formats already in the list keep their rule: IQ3_XXS on 80+ SMs yes, with the sm40 switch and a staged gate also 40-79
|
||||
CHECK(default_takes(-1, Card{false, false, 84, true}, false, true, true, 18) && !default_takes(-1, Card{false, false, 60, true}, false, true, true, 18) &&
|
||||
default_takes(-1, Card{false, false, 60, true}, true, true, true, 18));
|
||||
// a format outside the list never takes the default
|
||||
CHECK(!default_takes(-1, Card{false, false, 84, true}, true, true, true, 19) && !default_takes(-1, Card{false, false, 84, true}, true, true, true, 20));
|
||||
}
|
||||
// every class, every launch size: staged = false gives the rule of commit 083b1ac82 exactly as before the argument existed, for the sm_86 cards too (the new flag does not move them)
|
||||
{
|
||||
long long cmp = 0, diff = 0;
|
||||
|
||||
Reference in new issue
Block a user