]> git.djapps.eu Git - pkg/ggml/sources/llama.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)
committerGitHub <redacted>
Wed, 8 Jul 2026 16:44:55 +0000 (09:44 -0700)
commit167d057604d97e1f8ebd7d3e9bd4cc500bc9e9be
treef5673776fe4f4571880185a1c908f4767ab6cba9
parent1ee093937fb4e0ff58f4b3e03188f5e133e7e62b
opencl: ragged-tile MoE prefill FP16 GEMM optimization (skip padded expert tiles) (#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