mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-05 07:48:45 +00:00
fused prompt kernels: the sm_86 rule class takes compute capability 8.0 and 8.9 as well
The CUDA fused prompt kernels' default rules were keyed on one flag that was true only for compute capability 8.6 (and 12.0 for the sm_120 part): the 80+ SM default for the i-quant formats (IQ2_XXS, IQ2_XS, IQ2_S, IQ3_XXS, IQ3_S, IQ4_XS), the staged default of the 40-79 SM cards, the staged and wide tile lines of pick(), and the Gyro-S default. A100-class (8.0) and RTX 40-class (8.9) cards run the same source as the 8.6 and 12.0 cards those rules were gated on, and took MMQ instead. s86_class(major, minor, off) in fused_tile_rule.hpp is true for 8.0, 8.6 and 8.9 (false for everything else, 8.7 and 9.0 included; false for all when STRATA_PF_FUSED_SM86=0), and DevInfo::s86 in moe_fused_iq.cu comes from it. Nothing else moves: the 40-79 SM rule and its STRATA_PF_FUSED_SM40=0 way back, cards under 40 SMs and the small-card rule (MMQ as before), K-quant / Q6_K / Q8_0 / Q5_0 / Qwen3.6 fused (opt-in on every class), HIP builds, sm_60 / 6.1 / 7.0 / 7.5. No kernel, tile table, log line or setting changes; the device code is the same. No card of compute capability 8.0 or 8.9 has run these kernels here. The evidence is the 8.6 and 12.0 gates plus the same source compiled for sm_80 and sm_89 (the release packages carry sm_89 in both CUDA variants and sm_80 in the CUDA 12 variant). The unit test fused_tile_rule_test gets the compute capability as an input: 12 capabilities x STRATA_PF_FUSED x STRATA_PF_FUSED_SM40 x STRATA_PF_FUSED_SM86 x STRATA_SM120_PERF x 0-200 SMs x staged x down x 13 formats against an oracle written from the decision, the tile rule and the Gyro-S default over the same capabilities, and the old rule against the new one for every capability but 8.0 and 8.9. Register notes of STRATA_PF_FUSED_SM40, STRATA_PF_FUSED_SM86 and STRATA_PF_FUSED_TQ name the new class.
This commit is contained in:
1 parent
a269d4c82b
commit
2fdee4aeb1
6 files changed
+142
-21
No files matched your search
@@ -24476,7 +24476,7 @@
|
||||
"last_date": "",
|
||||
"status": "research",
|
||||
"owner": "prefill",
|
||||
"note": "CUDA diagnostic for bug reports, not a user setting: =0 puts compute capability 8.6 and 12.0 cards with 40-79 SMs back on MMQ for the IQ3_XXS / IQ3_S / IQ4_XS gate/up layers with an IQ4_NL or Q2_0 down (the fused prompt kernels are the default on those cards since 11-12; unset or =1 is the default; RTX A4000 end to end: prompt time MMQ / fused 1.000 / 1.003 / 1.028 / 1.012 at 2K / 4K / 8K / 20K). Goes away with MMQ (release C).",
|
||||
"note": "CUDA diagnostic for bug reports, not a user setting: =0 puts compute capability 8.0, 8.6, 8.9 and 12.0 cards with 40-79 SMs back on MMQ for the IQ3_XXS / IQ3_S / IQ4_XS gate/up layers with an IQ4_NL or Q2_0 down (the fused prompt kernels are the default on those cards since 11-12, on 8.0 and 8.9 by the same code with no card of those two run; unset or =1 is the default; RTX A4000 end to end: prompt time MMQ / fused 1.000 / 1.003 / 1.028 / 1.012 at 2K / 4K / 8K / 20K). Goes away with MMQ (release C).",
|
||||
"retire_after": "",
|
||||
"retired_in": ""
|
||||
},
|
||||
@@ -24550,7 +24550,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 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).",
|
||||
"note": "CUDA diagnostic for bug reports, not a user setting: =0 puts compute capability 8.0, 8.6 and 8.9 cards (the sm_86 class) 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 on 8.6 cards with 80+ SMs since 11-11, IQ2_XXS / IQ2_XS since 11-12, and on 8.0 and 8.9 cards since 11-12 by the same code with no card of those two run). Goes away with MMQ (release C).",
|
||||
"retire_after": "",
|
||||
"retired_in": ""
|
||||
},
|
||||
@@ -24630,7 +24630,7 @@
|
||||
"last_date": "",
|
||||
"status": "research",
|
||||
"owner": "prefill",
|
||||
"note": "[DRAFT] CUDA and HIP gfx12 (phase 4): the Gyro trellis experts (TQK6 / TQK7, TQ2_T / TQ2_T), Hadamard-folded layers included, on the fused native kernels instead of MMQ. CUDA, 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 and, on HIP, on gfx1200 / gfx1201 (HIP stays opt-in, default off); =0: MMQ again. STRATA_PF_FUSED_SM86=0 turns the sm_86 default off too. Goes with MMQ in release C.",
|
||||
"note": "[DRAFT] CUDA and HIP gfx12 (phase 4): the Gyro trellis experts (TQK6 / TQK7, TQ2_T / TQ2_T), Hadamard-folded layers included, on the fused native kernels instead of MMQ. CUDA, unset: Gyro-S (TQK6 / TQK7) on compute capability 8.0, 8.6 and 8.9 cards with 80+ SMs (RTX A6000 class, gated on the 8.6 A6000 only; 8.0 and 8.9 by the same code since 11-12, no card of those two run; 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 and, on HIP, on gfx1200 / gfx1201 (HIP stays opt-in, default off); =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": ""
|
||||
},
|
||||
|
||||
@@ -23,9 +23,15 @@ struct Card {
|
||||
bool s120 = false; // compute capability 12.0 (sm120_series.hpp: STRATA_SM120_PERF not 0)
|
||||
bool s121 = false; // GB10 (DGX Spark)
|
||||
int sms = 0;
|
||||
bool s86 = false; // compute capability 8.6 (appended last: the aggregate initializers {s120, s121, sms} of the callers and the test stay valid)
|
||||
bool s86 = false; // the sm_86 rule class, s86_class below: compute capability 8.0, 8.6 or 8.9 (appended last: the aggregate initializers {s120, s121, sms} of the callers and the test stay valid)
|
||||
};
|
||||
|
||||
// The compute capabilities that take the sm_86 rules (the 80+ SM default, the staged default of the 40-79 SM cards, the staged / wide tile lines, the Gyro-S default of fused_tq_default.hpp). 8.6 is the class
|
||||
// the rules were gated on (RTX A4000 and RTX A6000); 8.0 (A100 class) and 8.9 (RTX 40 / Ada class) joined on the owner's word of 11-12 ("1 Yes" to: may RTX 40 / A100 take the defaults of the cards we
|
||||
// tested, since they run the same code?). No card of those two capabilities has run these kernels here: the evidence is the 8.6 and 12.0 rows below, and the same source compiled for sm_80 / sm_89.
|
||||
// 8.7 (Jetson Orin), 9.0, 10.x, 12.0 / 12.1 and everything below 8.0 are not in the class. `off` is STRATA_PF_FUSED_SM86=0 (a diagnostic: the class is empty then, whatever the card).
|
||||
constexpr bool s86_class(int major, int minor, bool off = false) { return !off && major == 8 && (minor == 0 || minor == 6 || minor == 9); }
|
||||
|
||||
enum class Why { kBand, kS121, kS120Large, kS120Mid, kS120Small, kStaged, kS86Wide };
|
||||
|
||||
struct Pick {
|
||||
@@ -48,8 +54,8 @@ constexpr Pick pick(const Card& c, int64_t n, int n_expert, bool staged = false,
|
||||
// Staged launches (weight staging: a gate/up kernel of IQ3_XXS / IQ3_S / IQ4_XS / Q8_0 / Q6_K) on an sm_86 or sm_120 card under 80 SMs: 128 rows from every size. The 128-row staged kernels
|
||||
// against the 64-row unstaged ones (RTX A4000, sm_86, 48 SMs, one layer, REAL routing, ms, 2,048 / 8,192 / 20,000 tokens): IQ3_S / IQ4_NL 12.37 / 31.46 / 67.33 against 13.18 / 36.71 / 81.65,
|
||||
// IQ3_XXS / IQ4_NL 11.72 / 30.04 / 64.44 against 12.07 / 33.97 / 76.16, IQ4_XS / IQ4_NL 11.97 / 30.60 / 65.33 against 13.10 / 36.17 / 80.54, IQ3_S / Q2_0 (the Q2_0 down is not staged)
|
||||
// 11.89 / 30.48 / 65.19 against 12.27 / 34.35 / 76.42 (RESULTS-P4-SM.md S1). Nothing below 48 SMs is measured, and no sm_120 card under 80 SMs with staging. sm_89 / sm_80 are not in
|
||||
// the class (no DevInfo flag, not measured); launches without a staged gate/up and every other class keep the rules below. With Q8_0 / Q6_K staged (RTX A4000, one layer, real routing, MMQ / head 128 at 2K / 8K / 20K / 32K):
|
||||
// 11.89 / 30.48 / 65.19 against 12.27 / 34.35 / 76.42 (RESULTS-P4-SM.md S1). Nothing below 48 SMs is measured, and no sm_120 card under 80 SMs with staging. sm_80 / sm_89 are in
|
||||
// the class since 11-12 (s86_class: the same source, no card of those two capabilities run here); launches without a staged gate/up and every other class keep the rules below. With Q8_0 / Q6_K staged (RTX A4000, one layer, real routing, MMQ / head 128 at 2K / 8K / 20K / 32K):
|
||||
// Q8_0 / Q8_0 1.882 / 1.412 / 1.143 / 1.030 (64-row unstaged 1.326 / 0.955 / 0.783 / 0.649), Q6_K + Q8_0 1.499 / 1.188 / 0.998 / 0.918 (1.059 / 0.787 / 0.638 / 0.547), IQ3_S / Q8_0 1.708 / 1.379 / 1.211 / 1.060 (1.407 / 1.076 / 0.912 / 0.768).
|
||||
if (staged && (c.s86 || c.s120) && c.sms > 0 && c.sms < 80) return {2, Why::kStaged};
|
||||
// sm_120 with 80 SMs and up (the cards that take these kernels by default: RTX 5080 / 5090, PRO 5000 / 6000): 128 rows from 159.9 rows an expert on, the first
|
||||
@@ -64,7 +70,7 @@ constexpr Pick pick(const Card& c, int64_t n, int n_expert, bool staged = false,
|
||||
// everything else (sm_80 / 86 / 89, sm_120 outside the classes above, HIP builds): 128 rows when an expert has about one such tile (56 to 112 rows on average), else 64.
|
||||
// Measured on the RTX 5070 with uniform routing (tests/cuda/prefill_fused_iq_test, a layer of 2048 / 3584 / 8192 tokens, ms, 64 -> 128): IQ2_S 5.2 -> 6.7, 9.5 -> 9.3, 17.5 -> 19.5;
|
||||
// IQ2_XXS 4.2 -> 5.8, 7.4 -> 7.6, 13.6 -> 16.5; IQ3_S 5.6 -> 6.6, 10.2 -> 8.8, 18.4 -> 19.0; IQ3_XXS 5.1 -> 6.3, 9.1 -> 8.3, 16.5 -> 17.5 (256 rows was slower still).
|
||||
// sm_86 with 40 SMs and up (the 40-79 SM cards and the 80+ SM ones), a Q6_K or Q8_0 gate/up (Q6_K + Q8_0, Q8_0 / Q8_0; CUDA opt-ins), above 112 rows an expert: 128 rows (below 80 SMs the staged rule above already
|
||||
// sm_86-class cards (s86_class: 8.0, 8.6, 8.9) with 40 SMs and up (the 40-79 SM cards and the 80+ SM ones), a Q6_K or Q8_0 gate/up (Q6_K + Q8_0, Q8_0 / Q8_0; CUDA opt-ins), above 112 rows an expert: 128 rows (below 80 SMs the staged rule above already
|
||||
// takes 128 at every size once these formats are staged; this line is the one that moves the 80+ SM cards). Measured on the RTX A4000 (sm_86, 48 SMs, one layer, ms, tile 64 -> tile 128, output bits
|
||||
// equal): Qwen3.6's shape (256 experts, top 8; lane P4-Q36, z440-20261111-2126-783b) Q6_K + Q8_0 4,096 / 8,192 / 20,000 tokens 17.65 -> 13.14, 31.91 -> 22.78, 73.46 -> 55.80 (MMQ 13.58 / 20.05 / 38.12);
|
||||
// Qwen3.8-Flash-Next's shape (512 experts, top 10, real routing, RESULTS-P4-SM.md S0) at 8,192 / 20,000 / 32,768 tokens: Q6_K + Q8_0 64.97 -> 52.56, 142.17 -> 110.45, 241.14 -> 173.50; Q8_0 / Q8_0
|
||||
@@ -76,7 +82,7 @@ constexpr Pick pick(const Card& c, int64_t n, int n_expert, bool staged = false,
|
||||
}
|
||||
|
||||
// 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. sm_86 / sm_120 cards with 80+ SMs: always. sm40 (the 40-79 SM rule; ON by default since the owner's word of 11-12, STRATA_PF_FUSED_SM40=0 turns it off, see sm40_on
|
||||
// rule can be tested without a GPU. sm_86-class (s86_class: 8.0, 8.6, 8.9) and sm_120 cards with 80+ SMs: always. sm40 (the 40-79 SM rule; ON by default since the owner's word of 11-12, STRATA_PF_FUSED_SM40=0 turns it off, see sm40_on
|
||||
// below; it was a research switch, off unless set, before) 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,18 +1,19 @@
|
||||
// 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 unset or empty: Gyro-S (TQK6 / TQK7) on for a card of the sm_86 class (fused_tile_rule.hpp s86_class: compute capability 8.6, and since 11-12 8.0 and 8.9) with 80 or more
|
||||
// SMs (RTX A6000 / A40 84, RTX 3090 Ti 84, RTX 3090 82, RTX 3080 Ti 80; A100 108, RTX 4090 128, RTX 6000 Ada 142), 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
|
||||
// s86 is DevInfo::s86 (raw compute capability 8.0 / 8.6 / 8.9 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.
|
||||
// backstop as MMQ. Not covered: any card other than the A6000 (the 8.0 and 8.9 cards run the same source and were not run), Gyro-M, Gyro-L, a Gyro file other than Gyro-S.
|
||||
#pragma once
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
@@ -2150,7 +2150,7 @@ struct DevInfo {
|
||||
bool q2n = false; // sm_80+ with STRATA_PF_FUSED_Q2N=1: the native Q2_0 pack's Q2_0 gate/up is set up as well (opt-in)
|
||||
bool s120 = false; // compute capability 12.0 (sm120_series.hpp): the default for the formats measured there
|
||||
bool s121 = false; // GB10 (sm_121, DGX Spark): 128-row tiles win from 65,536 routed rows a launch up (pick_ww)
|
||||
bool s86 = false; // compute capability 8.6 (RTX A6000 / A40 / RTX 3090 class): the same default as s120 with 80+ SMs (STRATA_PF_FUSED_SM86=0 off)
|
||||
bool s86 = false; // the sm_86 rule class, compute capability 8.0 / 8.6 / 8.9 (RTX A6000 / A40 / RTX 3090 class; A100 and RTX 40 since 11-12): the same default as s120 with 80+ SMs (STRATA_PF_FUSED_SM86=0 off)
|
||||
int sms = 0, occ = 1;
|
||||
int occ_nt = 0; // blocks per multiprocessor of the NT = 256 kernels (0: not set up)
|
||||
bool ws = false; // STRATA_PF_FUSED_WS: the warp-specialized kernels are set up
|
||||
@@ -2211,7 +2211,7 @@ bool q6k_cuda_requested() {
|
||||
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
|
||||
// set up (dev_info) and native_supported takes Gyro-S's TQK6 / TQK7 layers on a card of the sm_86 class (compute capability 8.6, and 8.0 / 8.9 since 11-12; fused_tile::s86_class) 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() {
|
||||
@@ -2336,9 +2336,9 @@ const DevInfo& dev_info() {
|
||||
cudaDeviceGetAttribute(&minor, cudaDevAttrComputeCapabilityMinor, dev);
|
||||
d.s120 = strata::sm120_default(major, minor); // (takes the raw attributes, as is_sm120 does)
|
||||
d.s121 = major == 12 && minor == 1; // GB10 (DGX Spark): its own tile threshold, see pick_ww
|
||||
// sm_86 (raw attributes, as s120): STRATA_PF_FUSED_SM86=0 is a diagnostic for bug reports (MMQ on these cards again); it goes with MMQ
|
||||
// the sm_86 rule class (raw attributes, as s120; fused_tile::s86_class: compute capability 8.6, and since 11-12 8.0 and 8.9): STRATA_PF_FUSED_SM86=0 is a diagnostic for bug reports (MMQ on these cards again); it goes with MMQ
|
||||
static const bool sm86_off = [] { const char* v = std::getenv("STRATA_PF_FUSED_SM86"); return v != nullptr && v[0] == '0'; }();
|
||||
d.s86 = major == 8 && minor == 6 && !sm86_off;
|
||||
d.s86 = strata::prefill::fused_tile::s86_class(major, minor, sm86_off);
|
||||
major = strata::cc_major_of(major); // STRATA_EMULATE_CC counts (tests)
|
||||
minor = strata::cc_minor_of(minor);
|
||||
cudaDeviceGetAttribute(&d.sms, cudaDevAttrMultiProcessorCount, dev);
|
||||
@@ -2809,7 +2809,7 @@ bool native_supported(int gu_type, int d_type) {
|
||||
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 (!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 (RTX PRO 5000 / 6000, RTX 5080 / 5090; RTX A6000 / A40, RTX 3090 / 3090 Ti / 3080 Ti) take every format of the default list;
|
||||
// 12.0 and 8.6 cards with 80+ SMs (RTX PRO 5000 / 6000, RTX 5080 / 5090; RTX A6000 / A40, RTX 3090 / 3090 Ti / 3080 Ti), and since 11-12 8.0 and 8.9 cards (A100; RTX 4090 / 4080 Super, RTX 6000 Ada: the same code, no card run) take every format of the default list;
|
||||
// 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), so the 40-79 SM cards take only the staged launches below
|
||||
// (the unstaged formats keep MMQ there unless STRATA_PF_FUSED=1)
|
||||
// The sm_86 / sm_120 cards with 40-79 SMs (RTX A4000, RTX 5070 class) also take the launches with a staged gate/up kernel (IQ3_XXS / IQ3_S / IQ4_XS) and an IQ4_NL / Q2_0 down, by default since
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <initializer_list>
|
||||
|
||||
#include "strata/prefill/fused_tile_rule.hpp"
|
||||
#include "strata/prefill/fused_tq_default.hpp"
|
||||
|
||||
using strata::prefill::fused_tile::Card;
|
||||
using strata::prefill::fused_tile::pick;
|
||||
@@ -256,6 +257,119 @@ int main() {
|
||||
CHECK(!default_takes_env(-1, a4000c, -1, true, true, 12) && !default_takes_env(-1, a4000c, -1, true, true, 13) && !default_takes_env(-1, a4000c, -1, true, true, 14)); // Q4_K / Q5_K / Q6_K: opt-in as before
|
||||
CHECK(default_takes_env(-1, gb10c, -1, true, true, 21) == default_takes_env(-1, r5070, -1, true, true, 21)); // the s121 flag is not looked at by this rule
|
||||
}
|
||||
// ---- the sibling classes (owner 11-12, "1 Yes"): compute capability 8.0 (A100 class) and 8.9 (RTX 40 / Ada class) take the rules of the cards we tested (8.6; 12.0). The grid below starts from the compute
|
||||
// capability, builds the card the way dev_info() in src/prefill/moe_fused_iq.cu does (s120 = 12.0 and STRATA_SM120_PERF not 0, s121 = 12.1, s86 = s86_class(cc, STRATA_PF_FUSED_SM86=0)) and checks the
|
||||
// default of native_supported (default_takes_env), the Gyro-S default (fused_tq::on) and the tile rule (pick) against oracles written from the sentence of the decision, not from the code
|
||||
{
|
||||
using namespace strata::prefill::fused_tile;
|
||||
namespace tq = strata::prefill::fused_tq;
|
||||
struct Cc { int major, minor; };
|
||||
// every capability a CUDA card the engine sees can report, 8.7 (Jetson Orin) and 9.0 (Hopper) included: the class is 8.0, 8.6 and 8.9 only
|
||||
const Cc kCc[] = {{6, 0}, {6, 1}, {7, 0}, {7, 5}, {8, 0}, {8, 6}, {8, 7}, {8, 9}, {9, 0}, {10, 0}, {12, 0}, {12, 1}};
|
||||
const auto flagged = [](const Cc& c, bool off, bool perf120) { // the oracle: which cards the rules call tested-class
|
||||
const bool a = !off && c.major == 8 && (c.minor == 0 || c.minor == 6 || c.minor == 9);
|
||||
const bool b = c.major == 12 && c.minor == 0 && perf120;
|
||||
return a || b;
|
||||
};
|
||||
const auto card_for = [](const Cc& c, int sms, bool off, bool perf120) { // dev_info()
|
||||
return Card{c.major == 12 && c.minor == 0 && perf120, c.major == 12 && c.minor == 1, sms, s86_class(c.major, c.minor, off)};
|
||||
};
|
||||
// the class function itself over a wider range: 0.0 .. 15.9, only 8.0 / 8.6 / 8.9 are in; the old rule (8.6 only) differs from it at exactly 8.0 and 8.9
|
||||
long long cls = 0, cls_bad = 0, cls_moved = 0;
|
||||
for (int major = 0; major < 16; ++major)
|
||||
for (int minor = 0; minor < 10; ++minor) {
|
||||
++cls;
|
||||
if (s86_class(major, minor) != (major == 8 && (minor == 0 || minor == 6 || minor == 9))) ++cls_bad;
|
||||
if (s86_class(major, minor, true)) ++cls_bad; // STRATA_PF_FUSED_SM86=0: nothing is in the class
|
||||
if (s86_class(major, minor) != (major == 8 && minor == 6)) ++cls_moved;
|
||||
}
|
||||
CHECK(cls_bad == 0 && cls_moved == 2);
|
||||
// the default of native_supported: STRATA_PF_FUSED (unset / 0 / 1) x SM40 switch (unset / 0 / 1) x STRATA_PF_FUSED_SM86=0 x STRATA_SM120_PERF=0 x 12 capabilities x 0-200 SMs x gate_staged x down_ok x 13 formats
|
||||
const int kTypes[] = {8, 12, 13, 14, 16, 17, 18, 19, 20, 21, 22, 23, 29};
|
||||
long long cmp = 0, bad = 0, yes_hi = 0, yes_mid = 0, yes_new = 0;
|
||||
for (const Cc& cc : kCc)
|
||||
for (int off = 0; off < 2; ++off)
|
||||
for (int perf = 0; perf < 2; ++perf)
|
||||
for (int env = -1; env <= 1; ++env)
|
||||
for (int sm40e = -1; sm40e <= 1; ++sm40e)
|
||||
for (int sms = 0; sms <= 200; ++sms)
|
||||
for (int g = 0; g < 2; ++g)
|
||||
for (int d = 0; d < 2; ++d)
|
||||
for (int gu : kTypes) {
|
||||
++cmp;
|
||||
const bool inlist = gu == 16 || gu == 17 || gu == 18 || gu == 21 || gu == 22 || gu == 23; // IQ2_XXS, IQ2_XS, IQ3_XXS, IQ3_S, IQ2_S, IQ4_XS
|
||||
const bool want = env == -1 && inlist && flagged(cc, off != 0, perf != 0) && (sms >= 80 || (sms >= 40 && sm40e != 0 && g != 0 && d != 0));
|
||||
const bool got = default_takes_env(env, card_for(cc, sms, off != 0, perf != 0), sm40e, g != 0, d != 0, gu);
|
||||
if (got != want) ++bad;
|
||||
if (want && (cc.minor == 0 || cc.minor == 9) && cc.major == 8) { if (sms >= 80) ++yes_hi; else ++yes_mid; ++yes_new; }
|
||||
}
|
||||
CHECK(bad == 0);
|
||||
CHECK(yes_hi > 0 && yes_mid > 0 && yes_new == yes_hi + yes_mid);
|
||||
std::printf("fused_tile_rule_test: sibling classes, default rule: %lld capability / switch / SM count / launch / format combinations (%lld wrong; the new 8.0 / 8.9 cards: %lld yes at 80+ SMs, %lld yes at 40-79); class function: %lld capabilities (%lld wrong, %lld moved from the old rule)\n",
|
||||
cmp, bad, yes_hi, yes_mid, cls, cls_bad, cls_moved);
|
||||
// what must NOT move: for every capability but 8.0 / 8.9 the card, and with it every answer, is the one the old flag (8.6 only) gave
|
||||
long long same = 0, moved_card = 0;
|
||||
for (const Cc& cc : kCc)
|
||||
for (int off = 0; off < 2; ++off)
|
||||
for (int sms : {0, 1, 39, 40, 48, 79, 80, 84, 108, 128, 200}) {
|
||||
const Card now = card_for(cc, sms, off != 0, true);
|
||||
const Card old{cc.major == 12 && cc.minor == 0, cc.major == 12 && cc.minor == 1, sms, cc.major == 8 && cc.minor == 6 && off == 0};
|
||||
++same;
|
||||
if (now.s120 != old.s120 || now.s121 != old.s121 || now.sms != old.sms || now.s86 != old.s86) {
|
||||
++moved_card;
|
||||
CHECK(cc.major == 8 && (cc.minor == 0 || cc.minor == 9) && off == 0); // only the two new capabilities, and not under STRATA_PF_FUSED_SM86=0
|
||||
}
|
||||
}
|
||||
CHECK(moved_card == 2 * 11); // 8.0 and 8.9, SM86 switch not 0, 11 SM counts
|
||||
std::printf("fused_tile_rule_test: sibling classes: %lld capability / SM count / switch cards built, %lld differ from the old flag (8.0 and 8.9 without STRATA_PF_FUSED_SM86=0 only)\n", same, moved_card);
|
||||
// Gyro-S default (fused_tq_default.hpp): STRATA_PF_FUSED_TQ unset / 0 / 1 (the parsed value) x capability x SM86 switch x SM count: on for env 1, else only the class with 80+ SMs
|
||||
long long cmpq = 0, badq = 0;
|
||||
for (const Cc& cc : kCc)
|
||||
for (int off = 0; off < 2; ++off)
|
||||
for (int tqe = -1; tqe <= 1; ++tqe)
|
||||
for (int sms = 0; sms <= 200; ++sms) {
|
||||
++cmpq;
|
||||
const bool want = tqe == 1 || (tqe == -1 && flagged(cc, off != 0, false) && sms >= 80); // (perf120 false: the 12.0 card is not in the Gyro rule, whatever STRATA_SM120_PERF says)
|
||||
if (tq::on(tqe, card_for(cc, sms, off != 0, true).s86, sms) != want) ++badq;
|
||||
}
|
||||
CHECK(badq == 0);
|
||||
CHECK(tq::on(-1, card_for({8, 0}, 108, false, true).s86, 108) && tq::on(-1, card_for({8, 9}, 128, false, true).s86, 128) && !tq::on(-1, card_for({8, 9}, 60, false, true).s86, 60) &&
|
||||
!tq::on(-1, card_for({12, 0}, 110, false, true).s86, 110) && !tq::on(-1, card_for({8, 0}, 108, true, true).s86, 108) && !tq::on(-1, card_for({8, 7}, 128, false, true).s86, 128));
|
||||
std::printf("fused_tile_rule_test: sibling classes, Gyro-S default: %lld capability / switch / SM count combinations (%lld wrong)\n", cmpq, badq);
|
||||
// the tile rule: an 8.0 or 8.9 card of N SMs picks, for every launch kind and size, what an 8.6 card of N SMs picks (the same class); 8.7 / 9.0 / 7.5 / 6.x pick what a card with no flag picks
|
||||
long long cmpt = 0, badt = 0;
|
||||
for (int sms : {0, 1, 39, 40, 48, 56, 60, 76, 79, 80, 84, 108, 128, 142, 200})
|
||||
for (int staged = 0; staged < 2; ++staged)
|
||||
for (int wide = 0; wide < 2; ++wide)
|
||||
for (int ne : {1, 256, 512})
|
||||
for (int64_t n = 0; n <= 400000; n += 53) {
|
||||
const Pick ref = pick(card_for({8, 6}, sms, false, true), n, ne, staged != 0, wide != 0);
|
||||
const Pick none = pick(Card{false, false, sms, false}, n, ne, staged != 0, wide != 0);
|
||||
for (const Cc& cc : kCc) {
|
||||
if (cc.major == 12) continue;
|
||||
const Pick p = pick(card_for(cc, sms, false, true), n, ne, staged != 0, wide != 0);
|
||||
const bool in_class = cc.major == 8 && (cc.minor == 0 || cc.minor == 6 || cc.minor == 9);
|
||||
const Pick& want = in_class ? ref : none;
|
||||
++cmpt;
|
||||
if (p.ww != want.ww || p.why != want.why) ++badt;
|
||||
}
|
||||
}
|
||||
CHECK(badt == 0);
|
||||
std::printf("fused_tile_rule_test: sibling classes, tile rule: %lld capability / SM count / launch combinations (%lld wrong)\n", cmpt, badt);
|
||||
// named cards, switches unset: A100 (8.0, 108 SMs) and RTX 4090 (8.9, 128): every format of the default list; A30 (8.0, 56) and RTX 4070 Ti (8.9, 60): the staged launches only; RTX 4060 Ti (8.9, 34): nothing
|
||||
for (int gu : {16, 17, 18, 21, 22, 23}) {
|
||||
CHECK(default_takes_env(-1, card_for({8, 0}, 108, false, true), -1, false, true, gu) && default_takes_env(-1, card_for({8, 9}, 128, false, true), -1, false, true, gu));
|
||||
CHECK(!default_takes_env(-1, card_for({8, 9}, 34, false, true), -1, true, true, gu) && !default_takes_env(-1, card_for({8, 0}, 56, false, true), 0, true, true, gu));
|
||||
}
|
||||
for (int gu : {18, 21, 23}) CHECK(default_takes_env(-1, card_for({8, 0}, 56, false, true), -1, true, true, gu) && default_takes_env(-1, card_for({8, 9}, 60, false, true), -1, true, true, gu));
|
||||
CHECK(!default_takes_env(-1, card_for({8, 9}, 60, false, true), -1, false, true, 22) && !default_takes_env(-1, card_for({8, 0}, 56, false, true), -1, false, true, 16)); // IQ2_S / IQ2_XXS: unstaged, MMQ below 80 SMs
|
||||
CHECK(!default_takes_env(-1, card_for({8, 9}, 128, false, true), -1, true, true, 12) && !default_takes_env(-1, card_for({8, 0}, 108, false, true), -1, true, true, 14) &&
|
||||
!default_takes_env(-1, card_for({8, 9}, 128, false, true), -1, true, true, 8)); // Q4_K / Q6_K / Q8_0: opt-in on every class
|
||||
CHECK(!default_takes_env(0, card_for({8, 0}, 108, false, true), -1, true, true, 21) && !default_takes_env(1, card_for({8, 9}, 128, false, true), -1, true, true, 21)); // STRATA_PF_FUSED=0 is MMQ, =1 the opt-in decided elsewhere
|
||||
CHECK(!default_takes_env(-1, card_for({8, 0}, 108, true, true), -1, true, true, 21) && !default_takes_env(-1, card_for({8, 9}, 128, true, true), -1, true, true, 21)); // STRATA_PF_FUSED_SM86=0: MMQ again
|
||||
CHECK(!default_takes_env(-1, card_for({8, 7}, 128, false, true), -1, true, true, 21) && !default_takes_env(-1, card_for({9, 0}, 132, false, true), -1, true, true, 21) &&
|
||||
!default_takes_env(-1, card_for({7, 5}, 72, false, true), -1, true, true, 21) && !default_takes_env(-1, card_for({6, 0}, 56, false, true), -1, true, true, 21)); // Orin, Hopper, Turing, Pascal: untouched
|
||||
}
|
||||
// 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;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// 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.
|
||||
// the default rule of the CUDA fused trellis (Gyro) prompt kernels (include/strata/prefill/fused_tq_default.hpp): unset = on for a card of the sm_86 class (compute capability 8.6, and
|
||||
// 8.0 / 8.9 since 11-12: fused_tile_rule.hpp s86_class, tested with the capability in fused_tile_rule_test) 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"
|
||||
@@ -20,8 +20,8 @@ int main() {
|
||||
// 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
|
||||
// ... 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_90 / 8.7
|
||||
// (s86 false: outside the sm_86 class) 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
|
||||
|
||||
Reference in new issue
Block a user