]> git.djapps.eu Git - pkg/ggml/sources/whisper.cpp/commit
opencl: ragged-tile MoE prefill FP16 GEMM optimization (skip padded expert tiles...
authorHongqiang Wang <redacted>
Wed, 8 Jul 2026 16:44:55 +0000 (09:44 -0700)
committerGeorgi Gerganov <redacted>
Fri, 10 Jul 2026 10:06:42 +0000 (13:06 +0300)
commit5f052fbfaf82d1e02670c0f974d673b22bde5ab4
treee3327c3588376de7dceda98c38b68cd33c62d91c
parent06492a14a33193d75538acf14e0be733d9dc48fb
opencl: ragged-tile MoE prefill FP16 GEMM optimization (skip padded expert tiles) (llama/25433)

* opencl: ragged-tile MoE prefill GEMM (skip padded expert tiles)

The MoE prefill GEMM groups tokens into TILESIZE_N=32 per-expert tiles; at low
tokens-per-expert most tiles are mostly padding. When a tile's upper 16 slots
are all padding (router index 0xFFFFFFFF), skip the second dotx16_reduce8 half.
Numerically identical (skipped lanes are padding). Applied to all eight *_f32_ns
MoE GEMMs; default on, opt out with GGML_OPENCL_MOE_RAGGED_FP16=0.

* opencl: quarter-granularity ragged MoE tile-skip (8-col skip-groups)

Replace the two half-tile dotx16_reduce8 calls in the 8 *_f32_ns MoE GEMMs with
four dotx8_reduce4 (8-column) calls, skipping each empty trailing skip-group
independently. Padding is always trailing, so the kernel rounds the valid count
up to the skip granularity and skips fully-padding groups. Byte-identical to the
non-skipped path. New env GGML_OPENCL_MOE_RAGGED_GRAN={8,16,32} (quarter/half/
off); default quarter.

* opencl: move ragged moe env var in cl_init

---------

Co-authored-by: Li He <redacted>
ggml/src/ggml-opencl/ggml-opencl.cpp
ggml/src/ggml-opencl/kernels/gemm_moe_mxfp4_f32_ns.cl
ggml/src/ggml-opencl/kernels/gemm_moe_q4_0_f32_ns.cl
ggml/src/ggml-opencl/kernels/gemm_moe_q4_1_f32_ns.cl
ggml/src/ggml-opencl/kernels/gemm_moe_q4_k_f32_ns.cl
ggml/src/ggml-opencl/kernels/gemm_moe_q5_0_f32_ns.cl
ggml/src/ggml-opencl/kernels/gemm_moe_q5_1_f32_ns.cl
ggml/src/ggml-opencl/kernels/gemm_moe_q5_k_f32_ns.cl
ggml/src/ggml-opencl/kernels/gemm_moe_q6_k_f32_ns.cl