Archived
decode launches: gate_up + gated_quant_fp8 folded for MXFP4 (gemm_nt_q_gated_mx)
A decode step on Qwen3.8-27B at TP2 issues 631 kernels a card, and a dependent kernel costs the card 3.5-6.4 us in a replayed graph on gfx1201 however little it does, so launches are about 13 % of a step. - gemm_nt_q_gated_mx: gemm_nt_q_gated over an OCP-MXFP4 weight (b_ref after b_scale; a new op, not an optional operand on the old one). Row gemm_mxfp4a8_gated_gemv: M <= 8, a block per 128-column group of the gated output, a wave per gate or up tile running all of the gemv WMMA form's partials in its order, then gated_quant_fp8's epilogue -- byte-identical to gemv + gated_quant_fp8 (selftest, M = 1..8, Qwen's and TranslateGemma's gate_up). The MLP block declares it for a plain MXFP4 gate_up when a loaded library declares the op (libref does not), so a CPU-only engine takes the pair. Layout hooks map its b_ref (operand 4) to gemm_nt_q's index, so the weight is stored once. The fold: 82.5 us against 81 + 4.6 for the pair at Qwen's gate_up, 98.8 against 104 + 4.7 at TranslateGemma's. - --perfmxd times gated_quant_fp8 and the fold beside the gemv row at a gate_up shape. Greedy texts of four prompts, speculation 0 and 3, identical to the production build. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
486c933161
commit
f16854499c
9 files changed
+497
-7
No files matched your search
@@ -510,6 +510,45 @@ extern "C" int r4d_fuse_gemm_nt_q_gated(const RadParam* p, int n_p, uint64_t pre
|
||||
}
|
||||
}
|
||||
|
||||
/* ==========================================================================================
|
||||
* gemm_nt_q_gated_mx -- the same fold over an OCP-MXFP4 weight.
|
||||
* (row: gemm_mxfp4a8_gated_gemv; kernel: libr4d/r4d_gemm_mxfp4a8_gemv.hip, the gated form)
|
||||
*
|
||||
* Operands: [0] a [1] a_scale [2] b [3] b_scale [4] b_ref [5] q [6] scale [7] out_bf16
|
||||
*
|
||||
* The GEMM step is gemm_nt_q at dtype mxfp4a8 with `b_ref` in its last operand. `group` is the
|
||||
* weight's 32 on the GEMM and the activation's 128 on the quantiser, so the quantiser's is set, not
|
||||
* mirrored.
|
||||
*/
|
||||
extern "C" int r4d_fuse_gemm_nt_q_gated_mx(const RadParam* p, int n_p, uint64_t present, int step,
|
||||
RadFuseStep* out) {
|
||||
if (!out) return RAD_E_INVAL;
|
||||
const int64_t M = pi(p, n_p, "M"), N = pi(p, n_p, "N"), K = pi(p, n_p, "K");
|
||||
const char* dt = r4d_pgets(p, n_p, "dtype");
|
||||
if (M <= 0 || N <= 0 || K <= 0 || N % 2) return RAD_E_UNSUPPORTED;
|
||||
if (pi(p, n_p, "group", 32) != 32) return RAD_E_UNSUPPORTED;
|
||||
if (!dt || std::strcmp(dt, "mxfp4a8")) return RAD_E_UNSUPPORTED;
|
||||
if (!act_is(p, n_p, "silu", "silu")) return RAD_E_UNSUPPORTED;
|
||||
|
||||
switch (step) {
|
||||
case 0: {
|
||||
Step s(out, "gemm_nt_q");
|
||||
s.mirror(p, n_p, "M").mirror(p, n_p, "N").mirror(p, n_p, "K")
|
||||
.mirror(p, n_p, "group").mirror(p, n_p, "dtype");
|
||||
/* a, a_scale, b, b_scale, y, a_sum, b_ref */
|
||||
return s.wire({ 0, 1, 2, 3, RAD_FUSE_TMP(0), RAD_FUSE_NONE, 4 });
|
||||
}
|
||||
case 1: {
|
||||
Step s(out, "gated_quant_fp8");
|
||||
s.mirror(p, n_p, "M").pint("n", (long long)(N / 2)).pint("group", 128)
|
||||
.pstr("dtype", "bf16").mirror(p, n_p, "act");
|
||||
return s.wire({ RAD_FUSE_TMP(0), 5, 6, 7 }); /* gate_up, q, scale, out_bf16 */
|
||||
}
|
||||
default:
|
||||
return RAD_E_NOTFOUND;
|
||||
}
|
||||
}
|
||||
|
||||
/* ==========================================================================================
|
||||
* gdn_conv_recurrent_update -- the decode convolution folded into the recurrent update's prologue.
|
||||
* (row: gdn_conv_recurrent_update_k128_v128_bf16; kernel: libr4d/
|
||||
|
||||
Reference in new issue
Block a user