Archived
libr4d: the gated prefill fold, the short-prompt split row, and the rows forms of rmsnorm and rope
Four rows of our own, each declared only by a model that asks for it, so every
other caller keeps the row and the bits it had:
gemm_nt_q_gated_wide gemm_nt_q_gated at every M: the narrow tile to 64 rows
and, past them, the gated prefill tile (128 gate and
128 up rows against 64 activation rows a block), whose
accumulators are the unfused prefill GEMM's. The
narrow row keeps its M <= 64 ceiling and kernel.
gemm_nt_q_short the narrow fp8 row with the short-prompt split rule:
N <= 512, K <= 5120 and 41..64 rows run unsplit, where
the split's per-slice floors dominate. Its scratch hook
makes the same choice, so the arena matches the launch.
rmsnorm_rows the same norm; at n <= 256 and 1024 or more rows a wave
a row, its sums in rmsnorm_kernel's wave order.
rope_rows the same rotation; at 64 or more rows and 4 or more
heads one angle a (token, pair), every head turned with
it, byte-identical to rope.
gate_quant_fp8 gains act none: the plain product (`mul` then the quantiser) in
one pass, rounded once as mul_bf16 rounds it. Its `mode` stays 1 by default, so
the sigmoid producer every other model issues is unchanged.
r4d_selftest: the act-none chain against mul + quant_act_fp8 at M 1, 8 and 65 with
strided sources and without out_bf16; gemm_nt_q_gated_wide against the tiled
GEMM + gated_quant_fp8 at 65 and 129 rows; and the RDNA4 device phase accepts
gfx1200 beside gfx1201, where the card this was measured on lives.
docs/OPS.md carries the four rows ops_doc checks.
Co-Authored-By: Pi <pi@localhost>
This commit is contained in:
1 parent
ed1e5caf9d
commit
b8cd1c950a
9 files changed
+750
-37
No files matched your search
+8
-1
@@ -757,6 +757,13 @@ int r4d_gemm_fp8a8_gated_nt_m16(long a, long ascale, long wq, long ws,
|
||||
int a_ld, int sa_ld, int w_ld, int sw_ld,
|
||||
int q_ld, int s_ld, int y_ld, long stream);
|
||||
int r4d_gemm_fp8a8_gated_nt_m16_max_m(void);
|
||||
// The same fold at any M (`gemm_nt_q_gated_wide`): past the narrow tile's 64 rows it takes the gated
|
||||
// prefill tile, whose accumulators are the unfused prefill GEMM's, so its bytes are the pair's.
|
||||
int r4d_gemm_fp8a8_gated_nt_wide(long a, long ascale, long wq, long ws,
|
||||
long q, long s, long y, int act,
|
||||
int M, int K, int nout,
|
||||
int a_ld, int sa_ld, int w_ld, int sw_ld,
|
||||
int q_ld, int s_ld, int y_ld, long stream);
|
||||
// The narrow GEMM with a bias: `bias` bf16 [N], added to each output column's f32 accumulator before
|
||||
// its one rounding, and C written at row pitch `c_ld` (0 = N), so C may be a column slice of a wider
|
||||
// buffer. Never split. M up to r4d_gemm_fp8a8_nt_m16_max_m(); K a multiple of 128, N of 16.
|
||||
@@ -811,7 +818,7 @@ int r4d_rmsnorm_had_quant_i8g(long x, long res, long w, long y, long q, long s,
|
||||
int r4d_gated_had_quant_i8g(long gu, long y, long q, long s, int M, int n, int mode,
|
||||
int gu_ld, int y_ld, int q_ld, int s_ld, long stream);
|
||||
// The activation is rounded to bf16 before the product, matching the unfused `sigmoid` then `mul`
|
||||
// pair with a bf16 buffer between them.
|
||||
// pair with a bf16 buffer between them; `mode` 2 is the plain product (`mul` + quantiser).
|
||||
// The same epilogue with the gate in a different buffer from what it scales, as in gated
|
||||
// attention: `x` is the attention output and the gate a column slice of the [q|gate] projection.
|
||||
// A row is then a (token, head) pair; both sources are a fixed stride apart and the scale plane
|
||||
|
||||
Reference in new issue
Block a user