mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-05 07:48:45 +00:00
prefill: research switch STRATA_PF_FUSED_SM40=1 (off): sm_86 / sm_120 cards with 40-79 SMs take the fused kernels by default for the staged-gate pairs
native_supported()'s default rule took sm_86 / sm_120 cards with 80+ SMs only. It is now a pure function in fused_tile_rule.hpp, takes_by_default(card, sm40, gate_staged, down_ok), with a unit test; with STRATA_PF_FUSED_SM40=1 the cards with 40-79 SMs also take the launches whose gate/up kernel is a weight-staging instance (IQ3_XXS / IQ3_S / IQ4_XS) with an IQ4_NL or Q2_0 down. IQ2_S / Q2_0, IQ2_XXS / IQ2_XS and the other formats stay on MMQ; 39 SMs and below stay on MMQ; the switch is read once and is OFF unless set. Unset: the rule is exactly what it was (the unit test compares every card flag set, SM count 0-200 and launch kind with "sm_86 / sm_120, 80+ SMs"), and the change is host code only (the device code of the object does not change). Evidence for the later flip (not part of this commit): RTX A4000 (sm_86, 48 SMs), one layer, real routing, MMQ / fused with the staged 128-row tile at 2,048 / 8,192 / 20,000 / 32,768 tokens: IQ3_S / IQ4_NL 1.594 / 1.337 / 1.190 / 1.070, IQ3_XXS / IQ4_NL 1.645 / 1.373 / 1.223 / 1.097, IQ4_XS / IQ4_NL 1.621 / 1.326 / 1.176 / 1.055, IQ3_S / Q2_0 1.563 / 1.338 / 1.195 / 1.078. The output bits of these kernels are the same on every card (A4000, RTX PRO 5000, the previous kernels). No end-to-end row exists below 80 SMs; nothing below 48 SMs is measured. data/settings-register.json: the new entry (status research, note marked [DRAFT]).
This commit is contained in:
1 parent
d622bbb421
commit
f73297a96a
4 files changed
+81
-1
No files matched your search
@@ -25817,6 +25817,39 @@
|
||||
"retire_after": "",
|
||||
"retired_in": ""
|
||||
},
|
||||
{
|
||||
"name": "STRATA_PF_FUSED_SM40",
|
||||
"backends": [
|
||||
"cuda"
|
||||
],
|
||||
"reads": [
|
||||
{
|
||||
"file": "src/prefill/moe_fused_iq.cu",
|
||||
"line": 2614,
|
||||
"backend": "cuda",
|
||||
"fn": "getenv"
|
||||
}
|
||||
],
|
||||
"parse": "flag",
|
||||
"default_state": null,
|
||||
"code_default": null,
|
||||
"engine_sets": [],
|
||||
"engine_defaults": [],
|
||||
"launch_files": [],
|
||||
"launch_sets": [],
|
||||
"launch_reads": [],
|
||||
"doc_mentions": [],
|
||||
"first_commit": "",
|
||||
"first_date": "",
|
||||
"since": "",
|
||||
"last_commit": "",
|
||||
"last_date": "",
|
||||
"status": "research",
|
||||
"owner": "prefill",
|
||||
"note": "[DRAFT] CUDA research switch, off unless set, not a user setting: =1 lets compute capability 8.6 and 12.0 cards with 40-79 SMs take the fused prompt kernels by default for the IQ3_S pack's IQ3_XXS / IQ3_S / IQ4_XS gate/up layers with an IQ4_NL or Q2_0 down (those cards keep MMQ otherwise; one-layer rows on an RTX A4000). Goes away with MMQ (release C) or becomes the default.",
|
||||
"retire_after": "",
|
||||
"retired_in": ""
|
||||
},
|
||||
{
|
||||
"name": "STRATA_PF_FUSED_SM75",
|
||||
"backends": [
|
||||
|
||||
@@ -65,4 +65,16 @@ constexpr Pick pick(const Card& c, int64_t n, int n_expert, bool staged = false)
|
||||
return {avg > 56.0 && avg <= 112.0 ? 2 : 4, Why::kBand};
|
||||
}
|
||||
|
||||
// Whether native_supported's default rule (STRATA_PF_FUSED unset; the IQ3_S pack's gate/up IQ2_S / IQ3_XXS / IQ3_S / IQ4_XS with an IQ4_NL / Q2_0 down) takes a launch on this card, as a pure function so the
|
||||
// rule can be tested without a GPU. Today: sm_86 / sm_120 cards with 80+ SMs. sm40 (STRATA_PF_FUSED_SM40=1, a research switch, OFF unless set) adds the sm_86 / sm_120 cards with 40-79 SMs for the
|
||||
// launches whose gate/up kernel is a weight-staging instance (gate_staged: IQ3_XXS / IQ3_S / IQ4_XS, sw_on in src/prefill/moe_fused_iq.cu) with an IQ4_NL or Q2_0 down (down_ok). Evidence: RTX A4000
|
||||
// (sm_86, 48 SMs) one layer, real routing, staged 128-row tile against MMQ at 2,048 / 8,192 / 20,000 / 32,768 tokens: IQ3_S / IQ4_NL 1.594 / 1.337 / 1.190 / 1.070, IQ3_XXS / IQ4_NL 1.645 / 1.373 / 1.223 /
|
||||
// 1.097, IQ4_XS / IQ4_NL 1.621 / 1.326 / 1.176 / 1.055, IQ3_S / Q2_0 1.563 / 1.338 / 1.195 / 1.078 (RESULTS-P4-SM.md S1); the same kernels give the same output bits on every card. IQ2_S / Q2_0 is 0.95-0.97
|
||||
// of MMQ at 32K and stays out. No end-to-end row exists below 80 SMs, and nothing below 48 SMs is measured (the bound is 40).
|
||||
constexpr bool takes_by_default(const Card& c, bool sm40, bool gate_staged, bool down_ok) {
|
||||
if (!(c.s86 || c.s120)) return false;
|
||||
if (c.sms >= 80) return true;
|
||||
return sm40 && gate_staged && down_ok && c.sms >= 40;
|
||||
}
|
||||
|
||||
} // namespace strata::prefill::fused_tile
|
||||
@@ -2609,7 +2609,11 @@ bool native_supported(int gu_type, int d_type) {
|
||||
// 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),
|
||||
// and the RTX A4000 (sm_86, 48 SMs) has no real-model data - they keep MMQ unless STRATA_PF_FUSED=1
|
||||
return d.ok && (d.s120 || d.s86) && d.sms >= 80 && !d.t75 && d_covered_on(d_type, d);
|
||||
// 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 &&
|
||||
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
|
||||
#endif
|
||||
|
||||
@@ -99,6 +99,37 @@ int main() {
|
||||
CHECK(pick(a4000s, 81910, E, false).ww == 4 && pick(a4000s, 81910, E, true).ww == 2);
|
||||
CHECK(pick(a4000s, 40960, E, false).ww == 2 && pick(a4000s, 20000, E, false).ww == 4 && pick(a4000s, 20000, E, true).ww == 2); // band: 80 rows 128, 39 rows 64
|
||||
}
|
||||
// ---- the default rule (native_supported) with the research switch STRATA_PF_FUSED_SM40: takes_by_default(card, sm40, gate_staged, down_ok)
|
||||
{
|
||||
using strata::prefill::fused_tile::takes_by_default;
|
||||
const Card a4000s{false, false, 48, true}, s86at39{false, false, 39, true}, s86at40{false, false, 40, true}, s86at79{false, false, 79, true}, s86at80{false, false, 80, true},
|
||||
s120at48{true, false, 48, false}, s120at39{true, false, 39, false}, s89{false, false, 60, false}, gb10c{true, true, 48, false};
|
||||
// a staged-gate pair (IQ3_S / IQ4_NL, IQ3_XXS / Q2_0, ...) on 48 SMs: on with the switch, today's behaviour (off) without it
|
||||
CHECK(takes_by_default(a4000s, true, true, true) && !takes_by_default(a4000s, false, true, true));
|
||||
CHECK(takes_by_default(s120at48, true, true, true) && !takes_by_default(s120at48, false, true, true));
|
||||
// IQ2_S / Q2_0 (gate/up not staged) and a down outside IQ4_NL / Q2_0: off, switch or not
|
||||
CHECK(!takes_by_default(a4000s, true, false, true) && !takes_by_default(a4000s, true, true, false) && !takes_by_default(a4000s, true, false, false));
|
||||
// the bound: 39 SMs off, 40 and 79 on, 80 on without the switch
|
||||
CHECK(!takes_by_default(s86at39, true, true, true) && !takes_by_default(s120at39, true, true, true));
|
||||
CHECK(takes_by_default(s86at40, true, true, true) && takes_by_default(s86at79, true, true, true));
|
||||
CHECK(!takes_by_default(s86at79, false, true, true) && takes_by_default(s86at80, false, false, false));
|
||||
// other cards: sm_89 / sm_80 (neither flag) and an unknown SM count stay off with the switch; the s121 flag is not looked at by this rule (GB10 has its own tile rule only)
|
||||
CHECK(takes_by_default(gb10c, true, true, true) == takes_by_default(s120at48, true, true, true));
|
||||
// switch unset: exactly today's rule (sm_86 / sm_120 with 80+ SMs) for every card flag set, SM count and launch kind
|
||||
long long cmpd = 0, bad = 0;
|
||||
for (int s120 = 0; s120 < 2; ++s120)
|
||||
for (int s86 = 0; s86 < 2; ++s86)
|
||||
for (int sms = 0; sms <= 200; ++sms)
|
||||
for (int g = 0; g < 2; ++g)
|
||||
for (int d = 0; d < 2; ++d) {
|
||||
++cmpd;
|
||||
const Card c{s120 != 0, false, sms, s86 != 0};
|
||||
if (takes_by_default(c, false, g != 0, d != 0) != ((s120 || s86) && sms >= 80)) ++bad;
|
||||
if (sms >= 80 && takes_by_default(c, true, g != 0, d != 0) != takes_by_default(c, false, g != 0, d != 0)) ++bad; // the switch moves nothing at 80+ SMs
|
||||
}
|
||||
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);
|
||||
}
|
||||
// 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