mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-05 07:48:45 +00:00
d877f150a06f4fdfd3a7e01acfe7be4dde844ca4
15
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
d1ec6f0397 |
prefill: the staged 40-79 SM class takes Flash-Next's K-quant experts on the fused kernels by default again (STRATA_PF_FUSED_SM40=0 and STRATA_PF_FUSED_KQ=0 give MMQ back)
This puts the 40-79 SM cards back into kq_takes for an unset switch, as the default commit had them: takes_by_default with its staged-launch clause (the K-quant gate/up is a weight-staging instance and its Q5_1 / Q8_0 down is one the staged kernels were measured with). The commit before this one took the class out because its one-layer table is below MMQ at 20,000 tokens; the rule for a default here is that our own kernels take over where quality is kept, also when they are a little slower at the largest size. The evidence for the class: - One layer of Flash-Next's shape on an RTX A4000 (sm_86, 48 SMs, CUDA 12.9, 128-row tile, one repetition), MMQ time / fused time at 300 / 1,000 / 2,048 / 4,096 / 8,192 / 20,000 tokens: 1.67 / 1.44 / 1.49 / 1.35 / 1.05 / 0.97 (Q4_K / Q5_1), 1.79 / 1.61 / 1.67 / 1.46 / 1.08 / 0.98 (Q4_K / Q8_0), 1.72 / 1.59 / 1.60 / 1.45 / 1.05 / 0.99 (Q5_K / Q8_0): ahead up to 8,192 tokens, 1 to 3% behind at 20,000. - The staged K-quant fused path runs end to end on that A4000 in the Qwen3.6 engine. - No end-to-end run of Flash-Next on a card of that size; the Qwen3.6 engine runs the same staged path there. The commit undoes the one before it (kq_takes takes its SM40 argument again, the grid test, the start-up-line test, the register note and the docs/QUANTS.md row name the RTX A4000 and RTX 5070 class again) and adds the numbers above to the comment of kq_takes. Host code only. |
||
|
|
df723eb5a1 |
prefill: the K-quant default stays on the cards with 80 or more SMs; the 40-79 SM cards keep MMQ unless STRATA_PF_FUSED_KQ=1
The previous commit let the 40-79 SM cards take the K-quant fused kernels with nothing set (through takes_by_default's staged-launch clause). The only measurement on such a card is one layer of Flash-Next's shape on an RTX A4000 (sm_86, 48 SMs, CUDA 12.9, one repetition, 128-row tile, which is what the rule picks there): MMQ time / fused time 1.67 / 1.44 / 1.49 / 1.35 / 1.05 / 0.97 (Q4_K / Q5_1), 1.79 / 1.61 / 1.67 / 1.46 / 1.08 / 0.98 (Q4_K / Q8_0) and 1.72 / 1.59 / 1.60 / 1.45 / 1.05 / 0.99 (Q5_K / Q8_0) at 300 / 1,000 / 2,048 / 4,096 / 8,192 / 20,000 tokens: below MMQ at 20,000 tokens, and no end-to-end run exists on a card of that size. A default goes only where it was measured, so kq_takes now answers "80 or more SMs on an sm_86-class or sm_120 card" for an unset switch and drops its SM40 argument; STRATA_PF_FUSED_KQ=1 still sets the kernels up on every sm_80+ card and =0 still turns them off. Host code, a comment, the rule's grid test (now 4,824 combinations of the switch, the card flags and 0-200 SMs against its oracle, none yes below 80 SMs), the start-up-line test, the register note and the docs/QUANTS.md row, which no longer names the RTX A4000 or RTX 5070 class. |
||
|
|
9e3a36714d |
prefill: Flash-Next's K-quant experts are read by the fused kernels by default on the NVIDIA cards the i-quant default takes (STRATA_PF_FUSED_KQ=0 turns it off)
The owner's standing word of 11-12: our own kernels become the default wherever quality is kept. Until now the fused K-quant path (Q4_K / Q5_K gate/up with a Q5_1 or Q8_0 down: UD-Q4_K_XL's 48 layers) was opt-in with STRATA_PF_FUSED_KQ=1 and every such layer went to llama.cpp's MMQ. With nothing set a CUDA build now sets the K-quant kernels up on the cards fused_tile::takes_by_default takes, the rule the i-quant default already uses: compute capability 8.0 / 8.6 / 8.9 (the sm_86 class) and 12.0 with 80 or more SMs, and the launches with a weight-staging gate/up on 40 to 79 SMs unless STRATA_PF_FUSED_SM40=0 (the K-quant gate/up is such an instance, and its Q5_1 / Q8_0 down is one the staged kernels were measured with). Under 40 SMs, sm_121 alone (the DGX Spark keeps its own defaults table), compute capabilities below 8, 8.7, 9.0, HIP and the other formats (Q6_K, Q8_0 gate/up, Q5_0 downs, trellis) are as before. The way back is STRATA_PF_FUSED_KQ=0 (a value that does not start with '1' counts as 0, the way STRATA_PF_FUSED is read); STRATA_PF_FUSED=0 and STRATA_PF_FUSED_SM86=0 turn the layers back to MMQ as for every fused layer; STRATA_PF_FUSED_KQ=1 keeps taking every sm_80+ card. The rule is one more pure function in fused_tile_rule.hpp, kq_takes(kq_env, card, sm40_env), which dev_info calls where it used to ask for the switch. The Qwen3.6 engine sets STRATA_PF_FUSED_KQ=1 itself and keeps its own rule (q36_takes), so its cards and bits are unchanged. Host code only: no kernel, tile or prompt-path file is touched. The tile for these launches is the previous commit's. tests/prefill/fused_tile_rule_test.cpp: 14,472 combinations of the switch (unset / 0 / 1), the SM40 switch, the three card flags and 0-200 SMs against an oracle written from the sentence above (0 wrong; 2,178 yes at 80+ SMs and 480 at 40-79 with the switch unset), the named cards (A6000, A40, A100, RTX 4090, PRO 5000, RTX 5090 on; A4000 and RTX 5070 on and off with the SM40 switch; GB10, 20 SMs, Turing, Hopper off), the compute capabilities, and the same answer as takes_by_default for a staged gate/up with a staged down. data/settings-register.json: the STRATA_PF_FUSED_KQ entry is a rollback switch now, with the new note. The log line of nv_defaults.cpp and the documentation rows that say the K-quant experts read their prompt on MMQ follow in a separate commit once their words are settled. |
||
|
|
2248e63619 |
prefill: Flash-Next's K-quant pairs take the 128-row tile on sm_86-class cards with 80 to 99 SMs, and the two Q8_0-down pairs on sm_120 cards with 100 to 149 SMs
The tile rule (fused_tile_rule.hpp, pick) gets a trailing argument kq: 0 for every pair as before, 1 for a Q4_K / Q5_K gate/up with a Q5_1 down, 2 with a Q8_0 down (kq_flash_kind; UD-Q4_K_XL: Q4_K / Q5_1 in 43 layers, Q4_K / Q8_0 in 4, Q5_K / Q8_0 in 1). The call site in moe_fused_iq.cu passes it; the Qwen3.6 copy of the kernels does not, so its rule (wide_pair, the 128-row tile above 112 rows an expert) is byte for byte as it was, and so is every other class: the 40-79 SM cards (the staged rule already takes 128 rows at every size), sm_121, the A100 and RTX 40 class (108 SMs and up, not measured), the other sm_120 cards, HIP. The tile only groups routed rows: the output bits hash is equal at 64, 128 and the default at every size measured. New lines of the rule, both from 5.8 rows an expert up (300 tokens x top 10 over 512 experts = 5.86; nothing smaller was measured): - sm_86-class card with 80 to 99 SMs, kq 1 or 2: 128 rows. - sm_120 card with 100 to 149 SMs, kq 2 only: 128 rows (the rule already gave 128 from 56 rows an expert there; this moves 5.8 to 56). Evidence, one layer of Flash-Next's shape (512 experts, top 10), MMQ ms / fused ms (above 1: fused faster), tests/cuda/prefill_fused_iq_test --no-ref with STRATA_PF_FUSED_TILE unset / 64 / 128: - RTX A6000 (sm_86, 84 SMs, CUDA 13.1), median of two repetitions, spread 0.01 or less, 300 / 1,000 / 2,048 / 4,096 / 8,192 / 20,000 / 32,768 tokens. Today's pick: Q4_K / Q5_1 1.28 1.26 1.28 1.29 0.88 0.79 0.73, Q4_K / Q8_0 1.25 1.30 1.32 1.40 0.83 0.72 0.67, Q5_K / Q8_0 1.10 1.15 1.10 1.31 0.67 0.58 0.53. Tile 128: 1.65 1.49 1.52 1.29 1.04 0.97 0.88, 1.83 1.73 1.72 1.40 1.07 0.98 0.91, 1.79 1.69 1.69 1.33 1.04 0.98 0.89. 128 is the best tile at every size, on all three pairs. - RTX PRO 5000 (sm_120, 110 SMs, CUDA 13.2), three repetitions, 300 / 1,000 / 2,048 tokens, today's pick against tile 128: Q4_K / Q8_0 1.18 1.43 1.47 against 1.52 1.51 1.56, Q5_K / Q8_0 0.94 1.20 1.35 against 1.46 1.44 1.49 (the ranges of the repetitions do not overlap). The Q5_1-down pair, 43 of 48 layers, is faster in the 64-row tile there below 56 rows an expert (1.64 1.71 1.67 against 1.50 1.52 1.58), so it keeps it. - RTX A4000 (48 SMs): the staged rule picks 128 rows at every size already; unchanged. Not measured: any sm_86-class card other than the A6000 (the A40 and RTX 3090 have the same SM range), end to end with the real set (the following commits' gates), launches under 300 tokens. tests/prefill/fused_tile_rule_test.cpp: kq_flash_kind over every pair of type ids; the whole grid of card flags x 0-200 SMs x launch sizes x staged x wide x kq against an oracle written from the sentence above (12,638,880 combinations, 0 wrong; 61,680 launches move to 128 rows on sm_86 and 16,800 on sm_120); named cards at the measured sizes, the card and size edges; the existing blocks (the Qwen3.6 wide class, the previous-rule comparisons) pass unchanged. Host code only: no kernel changes. |
||
|
|
9e491df8e7 |
prefill: the Qwen3.6 K-quant pairs take the 128-row tile from 112 rows an expert up on sm_86 cards with 80+ SMs
The tile rule picked 64 rows for the staged K-quant pairs of UD-Q4_K_XL (Q4_K / Q5_K gate/up with a Q5_K / Q6_K down) above 112 rows an expert on an sm_86 card with 80+ SMs, which is every prompt chunk of 4,096 tokens (the chunk the engine uses when the experts are resident: 32,768 routed rows over 256 experts). The staged 128-row kernels are faster there. One layer of Qwen3.6's shape (256 experts, top 8), MMQ ms / fused ms at 2,048 / 4,096 / 8,192 / 20,000 tokens, two repeats, the output bits hash equal at every tile: RTX A6000 (84 SMs), tile 64: Q4_K / Q5_K 0.91 0.85 0.71 0.65 Q4_K / Q6_K 0.82 0.73 0.61 0.53 Q5_K / Q6_K 0.71 0.63 0.52 0.46 RTX A6000 (84 SMs), tile 128: Q4_K / Q5_K 1.42 1.08 0.95 0.91 Q4_K / Q6_K 1.47 1.17 1.02 0.91 Q5_K / Q6_K 1.37 1.14 0.98 0.86 RTX PRO 5000 (110 SMs, sm_120), tile 64: 0.99 0.85 0.72 0.63 0.92 0.77 0.66 0.58 0.83 0.70 0.60 0.52 RTX PRO 5000 (110 SMs, sm_120), tile 128: 1.28 1.07 1.02 0.87 1.33 1.12 0.99 0.96 1.23 1.08 0.93 0.90 On the sm_120 card the rule already picks 128 there, so its default row equals the forced-128 row. At 2,048 tokens (64 rows an expert) both rules pick 128 already. fused_tile::wide_pair names the pairs of the existing wide class (a Q6_K or Q8_0 gate/up) and now also a Q4_K / Q5_K gate/up with a Q5_K / Q6_K down; experts_native_ext in the Qwen3.6 copy of the kernels passes it as the launch's wide argument. Flash-Next's K-quant gate/up (Q5_1 / Q8_0 down), the i-quant pairs, sm_120 cards, cards under 80 SMs (staged rule) and HIP are unchanged. The output bits are the same at either tile. No kernel changes; the unit test pins wide_pair over the type grid and the rule at the engine's chunk sizes on 84-, 108-, 128-SM sm_86 cards, the 48-SM staged card and the sm_120 cards, with a grid oracle for staged + wide on sm_86 cards. |
||
|
|
3860b43a4a |
prefill: the Qwen3.6 engine takes the fused prompt kernels by default on the cards the Flash-Next default rule takes
strata-q36 used the fused int8 prompt-expert kernels only with STRATA_PF_FUSED=1 and read the prompt's experts with MMQ otherwise. Now an unset STRATA_PF_FUSED takes them for every layer whose gate/up and down pair the kernels cover, on the cards fused_tile::takes_by_default takes (reused as it is, no second class test): sm_86-class (compute capability 8.0 / 8.6 / 8.9) and sm_120 cards with 80+ SMs, and on 40-79 SM cards the staged launches (a staged gate/up with a staged down) unless STRATA_PF_FUSED_SM40=0. STRATA_PF_FUSED=0 (or any value not starting with 1) keeps MMQ, STRATA_PF_FUSED=1 stays the opt-in on every card that covers the pair. HIP builds, cards under 40 SMs, sm_121 and compute capability below 8 are unchanged (MMQ). The rule is fused_tile::q36_takes, a pure function with a unit test over the whole grid (switch, SM40 switch, card flags, SM count, format flags) against an oracle; moe_fused_iq_q36.cu gets the host function native_layer_ext that feeds it the device's flags. No kernel changes. The engine's log line loses its draft mark: "strata-q36: prompt experts on the fused int8 kernels" (and the "(N of M layers), the rest on MMQ (int8)" form). Measured (UD-Q4_K_XL, RTX A6000 84 SMs, every expert in VRAM): prompt speed fused / MMQ 1.034 at 2K, 0.964 at 4K, 0.966 at 8K, 0.970 at 20K, decode equal; teacher-forced KL fused / MMQ over all positions 1.047 [0.924, 1.195] at 2K and 0.836 [0.727, 0.969] at 8K against the non-MMQ writer's logits, 1.060 [0.893, 1.240] and 0.941 [0.700, 1.199] against the FP32 reference engine; both arms repeat bit for bit. RTX A4000 (stream-bound, experts partly in RAM): speed equal, KL 0.880 [0.682, 1.098] at 2K and 0.704 [0.537, 0.904] at 8K. |
||
|
|
2fdee4aeb1 |
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. |
||
|
|
ef0fb17abf |
prefill: the staged fused path is the default on sm_86 / sm_120 cards with 40-79 SMs (STRATA_PF_FUSED_SM40=0 turns it off)
The owner said yes on 11-12 to the staged fused path as the default on 40-79 SM NVIDIA cards. Until now it was opt-in (STRATA_PF_FUSED_SM40=1, a research switch). It acts exactly where the opt-in acted: CUDA builds, a card with the sm_86 or sm_120 flag and 40 to 79 SMs, a gate/up kernel that is a weight-staging instance (IQ3_XXS / IQ3_S / IQ4_XS, sw_on) with an IQ4_NL or Q2_0 down. Everything else keeps today's behaviour: HIP builds (the branch is inside #if !defined(__HIPCC__)), cards under 40 SMs, cards with 80+ SMs (always on, as before), cards without either flag (sm_60, sm_80, sm_89, AMD), IQ2_XXS / IQ2_XS / IQ2_S gate/up below 80 SMs, a down outside IQ4_NL / Q2_0, and the K-quant / Qwen3.6 pairs (the K-quant fused path stays opt-in). STRATA_PF_FUSED=0 gives MMQ, =1 keeps its meaning. The staged-blob fallback is unchanged. The way back is STRATA_PF_FUSED_SM40=0 (a diagnostic like STRATA_PF_FUSED_SM86=0); unset and =1 both mean on. No new setting, no new log line. The rule is two more pure functions next to takes_by_default / default_takes in fused_tile_rule.hpp: sm40_on(env) and default_takes_env(env, card, sm40_env, gate_staged, down_ok, gu_type), which native_supported calls. Host code only: no kernel, tile pick or prompt-path change. tests/prefill/fused_tile_rule_test.cpp: 752,544 combinations of STRATA_PF_FUSED (unset / 0 / 1), the switch (unset / 0 / 1), the three card flags, 0-200 SMs, gate_staged, down_ok and 13 gate/up format ids against an oracle written from the decision (0 wrong; 2,880 yes below 80 SMs, 52,272 yes at 80+), and the named cards (RTX A4000, RTX 5070: on, off with the switch at 0; 39 SMs, a card without a flag, IQ2_XXS / IQ2_XS / IQ2_S, a non-staged down, Q4_K / Q5_K / Q6_K: off). The register note of STRATA_PF_FUSED_SM40 is rewritten as a diagnostic. Evidence (RTX A4000, sm_86, 48 SMs, IQ3_XXS set, the 19 staged-pair layers on the fused kernels and 29 on MMQ, experts streamed over PCIe at 11 GB/s, 5 interleaved rounds, fresh engine per arm): prompt time MMQ / fused 1.0004 / 1.0025 / 1.0278 / 1.0121 at 2K / 4K / 8K / 20K (fused faster in 5 of 5 rounds at 8K and 20K); teacher-forced per-position KL against the FP16 prompt path, fused / MMQ 0.930 [0.881, 0.988] at 2,048 ids and 0.973 [0.898, 1.057] at 8,192 ids (20 prompts x 256 positions; MMQ against itself 1.015 and 1.040). One layer, real routing, MMQ / fused 1.59 / 1.34 / 1.19 / 1.07 (IQ3_S / IQ4_NL) at 2K / 8K / 20K / 32K. The staged kernels give the same output bits as the unstaged ones. No end-to-end row exists below 48 SMs. |
||
|
|
df485b41c0 |
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
|
||
|
|
98e21c1713 |
prefill: a failed weight-staging check takes the unstaged kernel for that launch instead of ending the process
check_staged_blobs ended the process with std::exit(1) when an expert blob was not device / managed memory, or a row size or offset was odd. No default configuration reaches it (the prompt path passes expert-cache slots and stage-ring slots), but the engine must not exit there. The check is now staged_blobs_ok (bool) and launch_ww combines it with pick_ww: a launch that fails it gets ww = 4 (fused_tile::kUnstagedWw), the 64-row instances, which no weight-staging instance shares, also when STRATA_PF_FUSED_TILE=128 forces the 128-row tile. The output bits are the same (the identity tables of RESULTS-P4-SM.md: tile 64, 128 and the default hash equal). The first failing launch of a process logs one line to stderr. The check still runs on the first 256 launches only (a pointer query is a driver call); the decision is sticky: once one launch failed it, every later launch of the process takes the unstaged kernel without asking, because after the first launches nothing is checked any more and a call site that gave one bad blob will give more. The decision is a set of pure functions and a small state struct in fused_tile_rule.hpp (staged_geometry_ok, staged_blob_ok, StagedGuard), tested on the host in fused_tile_rule_test (blob memory kinds x addresses, the 16 odd / even geometries, the 256-launch budget, the sticky fallback, one log line). moe_fused_iq.hpp declares staged_blob_fallbacks(), the number of launches that took the fallback (0 in a HIP build). prefill_fused_iq_test takes --host-blobs=N (the first N experts' blobs in pinned host memory, timing part) with --expect-fallback / --expect-no-fallback; ctest entry prefill_fused_iq_test_hostblobs. moe_fused_iq.cu is also compiled a second time for the Qwen3.6 shape (moe_fused_iq_q36.cu includes it under a renamed namespace): the new names are inside the included source and carry no `fused` token outside namespaces, the state is per copy. A dispatch of that copy that launches staging instances itself (experts_native_ext) takes its ww from launch_ww(b, g, n, n_expert, staged, wide) instead of pick_ww. |
||
|
|
f689435345 |
prefill: weight staging for the Q8_0 gate/up and down, the Q6_K gate/up and the Q5_0 down kernels, and the 128-row tile for the Q6_K / Q8_0 gate/up class on sm_86 with 40+ SMs
The staging mechanism of the IQ3_S pack's kernels (cp.async copies of each row's slot into a two-slot shared-memory ring, the product's own loaders on the shared-memory address, three activation stages) now also covers, per instance at compile time (sw_on), 512-thread 128-row, non-F16, CUDA sm_80+: gate/up Q8_0 and Q6_K, down Q8_0 and Q5_0. - Q8_0 (gate/up and down) and Q5_0 (down): a slot is four 32-value blocks (two stages), 136 B / 88 B, 10 / 7 chunks of the aligned window; the decode is load_unit on the shared-memory address as for IQ4_NL. - Q6_K gate/up: a slot is half a super-block gathered from three windows (ql 64 B, qh 32 B, scales + d: 10 chunks, 160 B a row in the ring); the 14 words of kq_lean_load<T_Q6_K> are rebuilt from the windows at the same offsets, kq_lean_expand and the arithmetic are unchanged. Rings at 128 rows: Q8_0 and Q6_K 40,960 B, Q5_0 28,672 B; the largest instance is 96,768 B of shared memory against the 101,376 B a block can get (static_assert per staged instance). The kernels of the previous staging commit (IQ3_XXS / IQ3_S / IQ4_XS gate/up, IQ4_NL down) are byte-identical in device code. Unstaged: Q5_1 down and Q2_0 (staged they lose), Q4_K / Q5_K, IQ2_*, the trellis types, WW 4, NT 256, F16, HIP. Tile rule (fused_tile_rule.hpp): the staged rule (gate/up staged: 128 rows at every size on sm_86 / sm_120 cards under 80 SMs) now takes the Q8_0 / Q6_K launches too. The "wide" line stays, widened to sm_86 with 40+ SMs: a Q6_K or Q8_0 gate/up above 112 rows an expert takes 128 rows (Why::kS86Wide); below 80 SMs the staged rule already covers it, the line moves the 80+ SM cards. Evidence for the 80+ SM class, from lane P4-Q36 (RTX A6000, Qwen3.6 UD-Q6_K_XL, every expert in VRAM, end to end, ratio to MMQ at 2K / 8K / 20K): today's rule 0.95 / 0.90 / 0.92, tile 128 0.95 / 0.98 / 0.99; no staged-kernel row exists on an 80+ SM card. The i-quant pairs keep the rule gated by lane OWN-4X on that class. Unit cases at 84 SMs on both sides of 112 rows and a sweep of card flags x SM counts x staged x expert counts x rows (the unit test compares wide = false with the previous rule, 20,945,664 combinations, only the line's cells move, 64 -> 128). Gate, RTX A4000 (sm_86, 48 SMs), one layer, real routing (UD-Q4_K_XL / UD-IQ4_XS ids), ms, tile 128 staged against the same tile unstaged, MMQ beside it (base and head interleaved in one job): | pair | 2K | 8K | 20K | 32K | | Q8_0 / Q8_0, MMQ / head | 1.882 | 1.412 | 1.143 | 1.030 | | same, head against base at 128 rows | +26.0% | +22.2% | +19.4% | +20.2% | | Q6_K + Q8_0, MMQ / head | 1.499 | 1.188 | 0.998 | 0.918 | | same, head against base at 128 rows | +24.2% | +22.7% | +20.1% | +22.4% | | IQ3_S / Q8_0, MMQ / head | 1.708 | 1.379 | 1.211 | 1.060 | | same, head against base at 128 rows | +11.7% | +11.6% | +13.4% | +14.3% | | IQ4_XS / Q5_0 (no MMQ tile), head against base at 128 rows | +12.2% | +13.2% | +13.6% | +15.1% | The unstaged 64-row ratios MMQ / base 64 were Q8_0 / Q8_0 1.326 / 0.955 / 0.783 / 0.649 and Q6_K + Q8_0 1.059 / 0.787 / 0.638 / 0.547. Controls unchanged: IQ3_S / IQ4_NL +5.6 / +8.0 / +9.6 / +11.4% (its kernels are the previous commit's), IQ2_S / Q2_0 0.0 / 0.0 / -0.2 / +0.1%; head 64 against base 64 within 1.3% everywhere. Output bits: 84 of 84 hashes equal to the previous kernels (Q8_0 / Q8_0, Q6_K + Q8_0, IQ3_S / Q8_0, IQ4_XS / Q5_0, IQ3_S / IQ4_NL, IQ2_S / Q2_0; tile 64 / 128 / default; 2K / 8K / 20K real ids + 32K uniform; blob bases shifted by 2 and 14 bytes). Device code of moe_fused_iq.cu.o (sm_86, 70 functions): against the previous staging commit 4 functions differ (native_kernel<14,true>, <8,true>, <8,false>, <6,false> at 128 rows / 512 threads), against the unstaged base 8, base against base rebuilt 0. |
||
|
|
9f15c32d76 |
prefill: the 128-row tile on sm_86 cards with 40-79 SMs for the Q6_K / Q8_0 gate/up class above 112 rows an expert
pick() gets one more argument, wide (the launch's gate/up is Q6_K or Q8_0, set in experts_native), and one line: on an sm_86 card with 40-79 SMs a wide launch takes 128 rows above 112 rows an expert (Why::kS86Small). Every other pair keeps its rule: on the same card the 64-row tile is faster above 112 rows for the unstaged IQ2_S / Q2_0 pair at 8K (33.80 against 35.05 ms) and for Q2_0 / Q2_0 (26.52 against 28.56), so the line is not general. Evidence, RTX A4000 (sm_86, 48 SMs), one layer, tile 64 -> tile 128 with equal output bits: Qwen3.6's shape (256 experts, top 8, lane P4-Q36, job z440-20261111-2126-783b), Q6_K + Q8_0 at 4,096 / 8,192 / 20,000 tokens 17.65 -> 13.14, 31.91 -> 22.78, 73.46 -> 55.80 ms (MMQ 13.58 / 20.05 / 38.12); Qwen3.8-Flash-Next's shape (512 experts, top 10, real routing) at 8,192 / 20,000 / 32,768 tokens Q6_K + Q8_0 64.97 -> 52.56, 142.17 -> 110.45, 241.14 -> 173.50 and Q8_0 / Q8_0 50.64 -> 42.02, 109.88 -> 89.91, 186.36 -> 140.29. Only sm_86 is covered: the sm_120 cards under 80 SMs have rows for the staged pairs only. Unit cases for both sides of 112 rows (112.0 stays the old band, 112.002 takes the line), 39 / 40 / 79 / 80 SMs, sm_120 and sm_89 untouched, Qwen3.6's 256-expert counts, and a sweep of card flags x SM counts x staged x expert counts x rows against the previous rule (20,945,664 combinations: only the line's cells move, 64 -> 128). Host code only; the tile does not move output bits. The unit test also gets back a check on sm_89 / an unknown SM count that the previous commit's edit had dropped. This line is the interim: once the Q6_K / Q8_0 gate/up kernels are staged, the staged rule takes 128 rows at every size for them. |
||
|
|
f73297a96a |
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]). |
||
|
|
14ef1be891 |
prefill: weight staging for the IQ3_S pack's fused kernels (gate/up IQ3_XXS, IQ3_S, IQ4_XS; down IQ4_NL), and a 128-row tile rule for staged launches on sm_86 / sm_120 cards under 80 SMs
The 128-row, 512-thread instances of these formats copy each weight row's slot (a 256-value block for the gate/up i-quants, two stages of 32-value blocks for the IQ4_NL down) into shared memory with 16-byte cp.async over the aligned window that covers it (a ring of two slots, issued two slots ahead in the activation copy groups) instead of reading it from global memory in 2- and 4-byte loads. The decode runs the same load_unit on the shared-memory address, so the output bits are the same. It is chosen per instance at compile time (sw_on): every other instance keeps its device code, its shared memory and its four activation stages; a staged instance takes three. The ring is sized for the side the instance serves, with a static_assert against the 99 KB opt-in limit. Off in the HIP build, below sm_80, in the NT = 256 / F16 / WS kernels and in the 64-row (WW 4) instances. Tile rule (fused_tile_rule.hpp): a launch whose gate/up and down kernels are both staged takes 128 rows from every size on an sm_86 / sm_120 card with 1-79 SMs; every other launch keeps its rule (unit test: the old rule compared over the whole shape sweep, both sides of the new condition). No default change: below 80 SMs the fused kernels stay opt-in and MMQ stays the default. A debug check on the first staged launches of a process stops with a message when an expert blob is not device memory or a row / offset is not 2-byte aligned (the copy and decode assume both). Gate, RTX A4000 (sm_86, 48 SMs), one layer: 84 of 84 output hashes equal to the previous kernels (6 pairs, tile 64 / 128 / default, 2K / 8K / 20K real ids and 32K uniform, blob bases shifted by 2 and 14 bytes); device code of moe_fused_iq.cu.o: base against base rebuilt 0 differing, base against this commit 4 differing (the four staged instances). tests/cuda/prefill_fused_iq_test gets --blob-shift=N. |
||
|
|
5b6396fda7 |
prefill: 128-row fused tile from 119.9 rows an expert on sm_120 cards with 40 to 79 SMs; pick_ww's rule as a tested pure function (CUDA, same output bits)
On compute capability 12.0 cards with 40 to 79 SMs (the RTX 5070, 48 SMs; the 5070 Ti, 70, is inside the class; the 5060 Ti and smaller are not: nothing measured below 48 SMs), pick_ww takes the 128-routed-row
work item from 119.9 rows an expert on (a prompt of 6,144 tokens routes 6,143 positions = 119.98) and the 64-row item below it. The 56-112 band is dropped on this class.
Real routing, RTX 5070 (the routed expert ids of a UD-IQ4_XS prompt replayed through tests/cuda/prefill_fused_iq_test, one layer, 2 layers a point; 64-row time / 128-row time at 20 / 40 / 80 / 120 / 160 / 234 / 312 / 391
rows an expert): IQ3_S/IQ4_NL 0.877 / 0.927 / 1.020 / 1.073 / 1.106 / 1.154 / 1.194 / 1.207; IQ4_XS/IQ4_NL 0.841 / 0.884 / 0.967 / 1.017 / 1.067 / 1.095 / 1.131 / 1.148; the Q5_0 pairs (opt-in) 0.989 .. 1.227 at
4096 / 8192 / 20000 tokens. Crossovers about 70 rows (IQ3_S) and 106 (IQ4_XS); at 119.9 the worst measured pair is +1.7%. Fused / MMQ path on the 5070 at 8192 rows, IQ3_S/IQ4_NL: 1.19 with the 64-row tile, 1.31
with the 128-row tile; at 20000: 1.02 and 1.22. The tile only groups routed rows: the output bits are the same (hash equal at default / 64 / 128 in every file, and for the Q5_0 pairs in all 12 groups).
THIS IS ONE-LAYER EVIDENCE WITH REAL ROUTING. There is no end-to-end row on a 5070-class card yet, and the fused kernels are opt-in on this class today (MMQ is its default), so the change reaches only users who turn
them on until that decision is taken.
The rule moves from src/prefill/moe_fused_iq.cu into include/strata/prefill/fused_tile_rule.hpp, a pure function of the card class (cc 12.0, cc 12.1, SM count) and the launch's routed rows, so it can be tested without a GPU.
pick_ww calls it (same environment switch STRATA_PF_FUSED_TILE, same STRATA_PF_TILE_DEBUG lines, plus one for this class). tests/prefill/fused_tile_rule_test.cpp (ctest fused_tile_rule_test, no GPU) pins the result for
the RTX 5070 / 5070 Ti / 5060 Ti, RTX 5080 / 5090, PRO 5000 / PRO 6000, A6000 and A4000 (sm_86: the SM count does not matter), sm_121 and a HIP-style card at the two sides of every threshold (56.0 / 112.0 rows,
119.9, 159.9, 65,536 routed rows, 39 / 40 / 79 / 80 / 99 / 100 / 149 / 150 SMs), and compares the new function with the rule of commit
|