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
+25
-1
@@ -413,6 +413,9 @@ extern "C" int r4d_fuse_router_sigmoid_topk_scatter(const RadParam* p, int n_p,
|
||||
* The gated attention's gate is a sigmoid, so nothing issues this row with silu and the shim's
|
||||
* `mode` defaults to 1.
|
||||
*
|
||||
* `act` none is the plain product: the chain is `mul` then `quant_act_fp8`, and the kernel rounds
|
||||
* the bf16 product once, exactly as mul_bf16 does. The product is TMP(0) or `out_bf16`.
|
||||
*
|
||||
* TMP(0) is act(gate), an [M, n] bf16 plane the fusion never writes. `out_bf16` is an operand: the
|
||||
* kernel stores the product there when asked and takes the codes over those bytes.
|
||||
*/
|
||||
@@ -423,7 +426,28 @@ extern "C" int r4d_fuse_gate_quant_fp8(const RadParam* p, int n_p, uint64_t pres
|
||||
const int64_t M = pi(p, n_p, "M"), n = pi(p, n_p, "n");
|
||||
if (!fp8_geometry_ok(p, n_p, M, n)) return RAD_E_UNSUPPORTED;
|
||||
/* The shim (r4d_fused_quant_fp8.hip) defaults this row's `mode` to 1 (sigmoid). */
|
||||
if (!act_is(p, n_p, "sigmoid", "sigmoid")) return RAD_E_UNSUPPORTED;
|
||||
const bool none = act_is(p, n_p, "sigmoid", "none");
|
||||
if (!none && !act_is(p, n_p, "sigmoid", "sigmoid")) return RAD_E_UNSUPPORTED;
|
||||
const int16_t mid = RAD_FUSE_HAS(present, 4) ? (int16_t)4 : RAD_FUSE_TMP(0);
|
||||
|
||||
if (none) {
|
||||
switch (step) {
|
||||
case 0: {
|
||||
/* gate * x, rounded to bf16 once: mul_bf16's store. */
|
||||
Step s(out, "mul");
|
||||
s.mirror(p, n_p, "M").mirror(p, n_p, "n").mirror(p, n_p, "dtype");
|
||||
return s.wire({ 0, 1, mid }); /* a, b, y */
|
||||
}
|
||||
case 1: {
|
||||
Step s(out, "quant_act_fp8");
|
||||
s.mirror(p, n_p, "M").mirror(p, n_p, "n").mirror(p, n_p, "group")
|
||||
.mirror(p, n_p, "dtype");
|
||||
return s.wire({ mid, 2, 3 }); /* x, q, scale */
|
||||
}
|
||||
default:
|
||||
return RAD_E_NOTFOUND;
|
||||
}
|
||||
}
|
||||
|
||||
switch (step) {
|
||||
case 0: {
|
||||
|
||||
Reference in new issue
Block a user