router_gemm_topk_scatter: the router GEMM, its selection and its sort in one launch (R4D_ROUTER_FUSE

At decode every MoE layer launches the router GEMM, router_topk_scatter
after it, and the shared expert's gate. With R4D_ROUTER_FUSED=1 the last
workgroup of the router's skinny bf16 GEMM, named by a self-resetting
arrival counter, runs router_topk_scatter's body, and one more workgroup
computes the shared gate; =2 keeps the gate separate. Each logit is the
same split-K chain at the split the unfused GEMM's law picks, so the
outputs are byte-identical. Decode band only (M <= 64); unset, nothing new
is declared. Single stream: -0.8 % a step.
This commit is contained in:
keptn42 committed 2026-10-06 09:13:58 +02:00
1 parent d0f639bd06
commit 0eeee5bb3a
7 files changed
+719 -4

No files matched your search

+6
View File
@@ -226,6 +226,11 @@ int r4d_rad_router_topk (const RadArgs*, RadStream);
int r4d_rad_moe_scatter (const RadArgs*, RadStream);
int r4d_rad_router_topk_scatter(const RadArgs*, RadStream);
int r4d_rad_router_topk_scatter_describe(const RadArgs*, RadStream, RadLaunchDesc*, int, int*);
/* The router GEMM, the selection and the sort in one launch, the shared gate optionally beside
* them (R4D_ROUTER_FUSED in rad_block_moe_fp8.h). */
int r4d_rad_router_gemm_topk_scatter(const RadArgs*, RadStream);
int r4d_rad_router_gemm_topk_scatter_describe(const RadArgs*, RadStream, RadLaunchDesc*, int,
int*);
int64_t r4d_rad_moe_scatter_scratch(const RadArgs*);
int r4d_rad_moe_gemm_q (const RadArgs*, RadStream);
/* Scratch for the run map the prefill form is aligned by. Zero in the decode band and zero for a
@@ -487,6 +492,7 @@ int r4d_shape_dequant_w4 (const RadParam*, int, int operand, RadOpdDesc*);
int r4d_shape_row_topk (const RadParam*, int, int operand, RadOpdDesc*);
int r4d_shape_router_topk (const RadParam*, int, int operand, RadOpdDesc*);
int r4d_shape_router_topk_scatter(const RadParam*, int, int, RadOpdDesc*);
int r4d_shape_router_gemm_topk_scatter(const RadParam*, int, int, RadOpdDesc*);
int r4d_shape_moe_scatter (const RadParam*, int, int operand, RadOpdDesc*);
int r4d_shape_moe_gemm_q (const RadParam*, int, int operand, RadOpdDesc*);
int r4d_shape_moe_gemm_q_mod4(const RadParam*, int, int operand, RadOpdDesc*);