gemma3: the gated gate_up fold up to 64 rows (RADIANCE_G3_FOLD_ROWS), and prefetch knobs

The gate_up GEMM + gelu_mul + quant_act_fp8 fold ran only up to 8 rows; at 2-8 concurrent translations with
speculation a step is 16-64 rows and the three kernels ran apart. gemm_mxfp4a8_gated_gemv_wide (9 <= M <= 64,
K >= 2688) is gemv_wide at two column tiles a block, the gate tile j and its up tile n/16 + j: each K-wave loads both
tiles' weights and reads the activation once; the wave partials are summed in gemv_wide's order and the narrow fold's
epilogue quantises, so codes and scales are byte-identical to the unfused path. No spill (96-196 VGPRs, RT 1-4).

RADIANCE_G3_FOLD_ROWS (0 = today's 8) sets the fold band; RADIANCE_G3_PF_ROWS / _PF_MIB / _PF_EARLY expose the
prefetch beside the all-reduces (measured: no gain, defaults unchanged). Unset knobs keep the pinned graph and steps.

Measured on 2x Radeon AI PRO R9700, TranslateGemma 27B (MXFP4 GPTQ, DFlash2 drafter, speculation 7), greedy held-out
translations, aggregate tok/s, 2 interleaved rounds:
| fold ceiling | x2 | x4 | x8 |
| 8 (today) | 289.9 | 521.2 | 686.3 |
| 16 | 298.6 (+3.0 %) | 521.0 (-0.0 %) | 686.9 (+0.1 %) |
| 32 | 296.9 (+2.4 %) | 541.6 (+3.9 %) | 682.7 (-0.5 %) |
| 64 | 297.8 (+2.7 %) | 549.0 (+5.3 %) | 700.0 (+2.0 %) |

Tests: r4d_selftest gated wide fold byte-for-byte against gemv_wide + gelu_mul + quant_act_fp8 (or gated_quant_fp8)
for TranslateGemma's 21504x5376 at M 9-64 and other shapes (156 ok, 0 FAIL on gfx1201); arch_test gemma3 16/16
(defaults keep the pinned graph and steps, knobs move only what they name).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
mici81andClaude Opus 5.5 committed 2026-10-26 10:08:01 +01:00
1 parent 96bc0465b3
commit b6ad757bfa
10 files changed
+645 -42

No files matched your search

+3 -1
View File
@@ -512,7 +512,9 @@ 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)
* (rows: gemm_mxfp4a8_gated_gemv, M <= 8, and gemm_mxfp4a8_gated_gemv_wide, 9..64; kernels:
* libr4d/r4d_gemm_mxfp4a8_gemv.hip, the gated forms. The chain's gemm_nt_q resolves to gemv and
* gemv_wide in those bands, the rows each form is byte-identical to.)
*
* Operands: [0] a [1] a_scale [2] b [3] b_scale [4] b_ref [5] q [6] scale [7] out_bf16
*