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:
Code000andPi authored and StillDeadcode committed 2026-10-29 16:23:28 +01:00
1 parent ed1e5caf9d
commit b8cd1c950a
9 files changed
+750 -37

No files matched your search

+8
View File
@@ -575,6 +575,10 @@ int r4d_rad_rope_table (const RadArgs*, RadStream);
int r4d_rad_gemm_fp8a16_m1 (const RadArgs*, RadStream);
int r4d_rad_gemm_fp8a8_m16 (const RadArgs*, RadStream);
int r4d_rad_gemm_fp8a8_gated_m16(const RadArgs*, RadStream);
int r4d_rad_gemm_fp8a8_gated_wide(const RadArgs*, RadStream);
/* `gemm_nt_q_short`: the narrow row with the short-prompt split rule (narrow_ksplit). */
int r4d_rad_gemm_fp8a8_m16_short(const RadArgs*, RadStream);
int64_t r4d_rad_gemm_fp8a8_m16_short_scratch(const RadArgs*);
int r4d_rad_gemm_fp8a8_bias_m16(const RadArgs*, RadStream);
int64_t r4d_rad_gemm_fp8a8_m16_scratch(const RadArgs*);
int r4d_rad_gemm_fp8a8_tiled(const RadArgs*, RadStream);
@@ -740,6 +744,8 @@ int r4d_rad_gather_rows_u8 (const RadArgs*, RadStream);
int r4d_rad_scatter_rows_u8 (const RadArgs*, RadStream);
int r4d_rad_scatter_rows_bf16(const RadArgs*, RadStream);
int r4d_rad_rmsnorm (const RadArgs*, RadStream);
/* The same row choosing the short-row form when it serves (`rmsnorm_rows`, rmsnorm_short_kernel). */
int r4d_rad_rmsnorm_rows (const RadArgs*, RadStream);
int r4d_rad_rmsnorm_p (const RadArgs*, RadStream);
int r4d_rad_add (const RadArgs*, RadStream);
int r4d_rad_mul (const RadArgs*, RadStream);
@@ -798,6 +804,8 @@ int r4d_shape_moe_gather_inv(const RadParam*, int, int, RadOpdDesc*);
int r4d_shape_router_sigmoid_topk_scatter(const RadParam*, int, int, RadOpdDesc*);
int r4d_rad_gelu_mul (const RadArgs*, RadStream);
int r4d_rad_rope (const RadArgs*, RadStream);
/* The same row choosing the per-(token, pair) angles form when it serves (`rope_rows`). */
int r4d_rad_rope_rows (const RadArgs*, RadStream);
/* -- the vision tower's ops (r4d_vit_bf16.hip) -- */
int r4d_rad_layernorm (const RadArgs*, RadStream);
int r4d_rad_grid_embed (const RadArgs*, RadStream);