mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-04 15:28:40 +00:00
On a Tesla V100 every routed expert of a prompt runs on the int8 dp4a kernels (Volta has no int8 matrix cores). From about 8K tokens up they lost to MMQ per layer (0.82-0.83 of its speed at 26,000 tokens with the two-block tile), and with every expert resident (#6053's 6x V100) that loss is most of the prompt gap. Change: src/kernels/cuda/i8h_volta.cuh, i8h_kernel (tile code 5, compiled for sm_70 only; a trap elsewhere): 64 weight rows x 64 entries a block, K in stages of 128, the decoded int8 codes of the weights and activations stored as FP16 (integers -128..127: exact), mma.m8n8k4 with FP32 accumulators, a fresh accumulator per 32-value sub-block (per 16 values for the two-scale formats). Every partial sum is an integer below 2^24, so it is exact in any order; the epilogue then does the dp4a kernels' arithmetic on the same integers in the same order (t = s1 m1 + s0 m0, acc = fmaf(t, base * d_x, acc), sub-block after sub-block). The output is bit-identical to the dp4a tiles'. The fragment layout was checked on the V100 (phaseA-tests/tune0216/probe_m884.cu: every (quad pair, row, column) once). Formats: every one without a per-32 minimum (the IQ3_S / IQ3_XXS / IQ2_XXS sets, Coder, IQ4_NL / Q2_0 / Q8_0 downs, Q6_K); Q4_K / Q5_K / Q5_1 keep the dp4a tiles. 44 KB shared memory: two blocks per SM. The pick is automatic: i8_expert_rule.hpp i8_tile_volta takes tile 5 from kI8hMinAvg = 160 entries an expert on average (about 8K-token chunks) on a compute capability 7.0 card, the two-block tile below; STRATA_I8_SM70=0 turns the Volta rule off, STRATA_I8_TM forces a tile (research). No other card class launches it. Tesla V100-SXM2 32 GB, one layer of Flash-Next's shape (bench, uniform routing), MMQ time / time, tile 3 -> this kernel: 4,096 tokens 1.06 -> 0.88 (the rule keeps tile 3 there), 8,192 0.947 -> 0.954 (IQ3_S), 0.906 -> 0.945 (IQ2_S / Q2_0), 12,288 0.906 -> 0.946, 16,384 0.858 -> 0.888, 26,000 0.820 -> 0.859 (IQ3_S), 0.823 -> 0.889 (IQ2_S / Q2_0); output hashes equal in every cell. End to end, 5 interleaved rounds, one V100, prompt ms (the previous commits = t3, this = t6, released 0.1.58): every expert resident (Coder IQ1_M, 12,288 slots): t3 / t6 / 0.1.58 256 393 / 392 / 532 2,048 1,519 / 1,540 / 1,687 8,192 4,876 / 4,789 / 4,739 26,000 15,251 / 14,794 / 14,992 IQ3_S, experts streamed (13,513 of 24,576 slots): 256 710 / 715 / 740 2,048 2,266 / 2,262 / 2,293 8,192 5,133 / 5,087 / 5,239 26,000 15,409 / 15,068 / 17,464 (the repeat of t3 within 0.6 %) Identity against 0.1.60 (gate21, first-token logit dumps and generated tokens, the reference's repeat as control): IQ3_S streamed 10 of 10 dumps and 10 of 10 token sequences equal; Coder all resident 10 of 10 / 10 of 10. Unit test: i8_expert_rule_test (the tile-5 threshold and format gate).