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
@@ -1692,6 +1692,28 @@ inline rad_op decl_gated_fold(RadBuilder* b, int64_t rows, int64_t N, int64_t K,
|
||||
return op;
|
||||
}
|
||||
|
||||
/* The same fold over an OCP-MXFP4 [2n, K] gate_up weight (`gemm_nt_q_gated_mx`: codes, the E8M0
|
||||
* plane and that plane again as the per-row reference), declared for M up to min(rows, 8), the band
|
||||
* of libr4d's one-to-eight-row GEMM it is built on. Optional like decl_gated_fold, and asked for
|
||||
* only when a loaded library declares the op: libref does not, so a CPU-only engine takes the pair
|
||||
* without ever naming it. */
|
||||
inline rad_op decl_gated_fold_mx(RadBuilder* b, int64_t rows, int64_t N, int64_t K, rad_weight w,
|
||||
rad_weight ws, rad_weight wref,
|
||||
std::initializer_list<rad_buf> reads,
|
||||
std::initializer_list<rad_buf> writes, int64_t* gated_rows) {
|
||||
const int64_t hi = rows < 8 ? rows : 8;
|
||||
if (hi <= 0 || N % 256 || K % RAD_FP8_BLOCK) return 0;
|
||||
if (!rad_op_declared(b, "gemm_nt_q_gated_mx")) return 0;
|
||||
const rad_op op = rw(b, RAD_OP(b, "gemm_nt_q_gated_mx",
|
||||
RAD_PARAMS(RAD_RANGE("M", 1, hi), RAD_INT("N", N), RAD_INT("K", K),
|
||||
RAD_INT("group", RAD_MX_GROUP), RAD_STR("dtype", "mxfp4a8"),
|
||||
RAD_STR("act", "silu")),
|
||||
RAD_WEIGHTS(w, ws, wref)),
|
||||
reads, writes);
|
||||
if (op) *gated_rows = hi;
|
||||
return op;
|
||||
}
|
||||
|
||||
} /* namespace arch */
|
||||
} /* namespace rad */
|
||||
|
||||
|
||||
Reference in new issue
Block a user