llama.cpp/ggml/src/ggml-cpu
shaobo.xie 4367734ac3 ggml: add moe_sum operator for Mixture of Experts aggregation
Add a new operator GGML_OP_MOE_SUM that efficiently aggregates outputs
from multiple experts in MoE models by summing along the expert dimension.

Input format: [hidden_dim, n_expert_used, n_tokens]
Output format: [hidden_dim, n_tokens]

CPU implementation:
- Optimized cache-friendly loop order (expert -> token -> hidden_dim)
- Multi-threaded parallelization across tokens
- Specialized F32 implementation for better performance
- 1.28x faster than naive add_loop approach

CUDA implementation:
- Warp-per-token kernels for large token counts
- Specialized F16 vectorized kernel for large batches
- Small-token kernels for edge cases
- 1.50x faster than naive add_loop approach

Tests:
- 96 test cases covering F32/F16, various expert counts (2,4,8),
  hidden dimensions (64-4096), and token counts (16-256)
- Relaxed error threshold for F16 (1e-6 vs 1e-7 for F32) due to
  limited precision when summing multiple expert outputs
2026-02-05 15:34:24 +08:00
..
amx ggml : fix unaligned access in AMX code (#16315) 2025-10-06 16:05:27 +03:00
arch ggml-cpu: use LUT for converting e8->f32 scales on x86 (#19288) 2026-02-04 09:43:29 +08:00
cmake ggml : build backends as libraries (#10256) 2024-11-14 18:04:35 +01:00
kleidiai kleidiai: add and integrate SVE 256-bit vector-length kernel (#18458) 2025-12-30 14:04:53 +02:00
llamafile ggml-cpu: Enable FP16 MMA kernels on PPC (#19060) 2026-01-27 11:52:34 +08:00
spacemit ggml : fix SpaceMit IME array out-of-bounds in task assignment (#16629) 2025-10-17 13:01:23 +03:00
CMakeLists.txt kleidiai: add and integrate SVE 256-bit vector-length kernel (#18458) 2025-12-30 14:04:53 +02:00
arch-fallback.h ggml-cpu: aarm64: q6_K repack gemm and gemv (and generic) implementations (i8mm) #18860 (#18888) 2026-01-27 11:08:10 +02:00
binary-ops.cpp cpu: de-duplicate some of the operators and refactor (ggml/1144) 2025-03-30 08:33:31 +03:00
binary-ops.h cpu: de-duplicate some of the operators and refactor (ggml/1144) 2025-03-30 08:33:31 +03:00
common.h ggml-cpu: Use tiled FA for prompt-processing (#19012) 2026-01-25 23:25:58 +08:00
ggml-cpu-impl.h ggml-cpu: FA split across kv for faster TG (#19209) 2026-02-03 01:19:55 +08:00
ggml-cpu.c ggml: add moe_sum operator for Mixture of Experts aggregation 2026-02-05 15:34:24 +08:00
ggml-cpu.cpp ggml-cpu: FA split across kv for faster TG (#19209) 2026-02-03 01:19:55 +08:00
hbm.cpp ggml-cpu : split arch-specific implementations (#13892) 2025-06-09 16:47:13 +02:00
hbm.h ggml-cpu : split arch-specific implementations (#13892) 2025-06-09 16:47:13 +02:00
ops.cpp ggml: add moe_sum operator for Mixture of Experts aggregation 2026-02-05 15:34:24 +08:00
ops.h ggml: add moe_sum operator for Mixture of Experts aggregation 2026-02-05 15:34:24 +08:00
quants.c llama : add gpt-oss (#15091) 2025-08-05 22:10:36 +03:00
quants.h llama : add gpt-oss (#15091) 2025-08-05 22:10:36 +03:00
repack.cpp ggml-cpu: aarm64: q6_K repack gemm and gemv (and generic) implementations (i8mm) #18860 (#18888) 2026-01-27 11:08:10 +02:00
repack.h ggml-cpu: aarm64: q6_K repack gemm and gemv (and generic) implementations (i8mm) #18860 (#18888) 2026-01-27 11:08:10 +02:00
simd-mappings.h ggml-cpu: use LUT for converting e8->f32 scales on x86 (#19288) 2026-02-04 09:43:29 +08:00
traits.cpp ggml : fix fallback to CPU for ununsupported ops (#15118) 2025-08-06 14:37:35 +02:00
traits.h ggml : fix fallback to CPU for ununsupported ops (#15118) 2025-08-06 14:37:35 +02:00
unary-ops.cpp ggml : add ops SOFTPLUS, EXPM1, TRI, SOLVE_TRI, CUMSUM (#17063) 2025-11-13 20:54:47 +02:00
unary-ops.h ggml : add ops SOFTPLUS, EXPM1, TRI, SOLVE_TRI, CUMSUM (#17063) 2025-11-13 20:54:47 +02:00
vec.cpp ggml-cpu: optimize ggml_vec_dot_bf16 for Power9 (#18837) 2026-01-15 17:31:18 +08:00
vec.h ggml-cpu: extend support for RVV floating-point kernels (#17318) 2025-12-18 16:02:09 +02:00