Repository navigation
Add LLAMA_MOE_RANDOM_ROUTING=1 for benchmark-only random expert selection - #29539
Conversation
7e5ebb0 to
794253b
Compare
|
@ggerganov do you think it makes to add support for it in llama.cpp? This is mostly to enable benchmarking with synthetic inputs, similar goal as #27711. |
794253b to
d4ca78d
Compare
|
Wanted to call out one case that if we intend to run with LLAMA_MOE_RANDOM_ROUTING=1 while the MoE cache is on (--cpu-moe --moe-cache-mib N) to measure how well the cache performs, the numbers will mislead. |
The change should work fine with MoE cache too. Random experts obviously are not great for caching as effectiveness of caching depends on reuse of same experts across subsequent tokens. |
…tion (ggml-org#29539) * Add LLAMA_MOE_RANDOM_ROUTING=1 for benchmark-only random expert selection * Handle expert caching
…tion (ggml-org#29539) * Add LLAMA_MOE_RANDOM_ROUTING=1 for benchmark-only random expert selection * Handle expert caching
Upstream's newest tag, 191 commits past b12483, merged on pascal-p106-v5 af00bb1 (the 14 landed branches). 26 files conflicted. Each kept both sides' intent; the list with reasons is the public data folder docs/data/2026-11-24_c912_upstream_b12674/conflicts.tsv. The ones that change code: - ggml.h, ggml.c, ggml-rpc.h: upstream's GGML_OP_SLEEP and GGML_OP_SIGMOID_BACK go after the fork's three ops after GLU, so the fork's op numbers stay; GGML_OP_COUNT 105, RPC patch version 6 (fork 4 + upstream 2). - ggml-rpc.cpp: upstream's single validation step (ggml-org#32651) already rejects unknown ops, so the fork's own check goes; the client's FREE_BUFFER that forgets dropped graphs (C929) sends with upstream's typed call<>. - mmid.cu: upstream's helper with duplicate expert ids (ggml-org#32505) dumps its store in pieces; the legacy tile layout (GGML_CUDA_MMQ_MOE_LEGACY) reads the expert's column count from n_dumped. - mmq.cuh: the kernel takes kq_fp32 (C861) before upstream's force_tiling (GCN only); the force_tiling launch passes kq_fp32 through. - ggml-cuda.cu: ggml-org#32239 (no matrix-vector fusion on any Pascal card) merged without a conflict; the fork keeps the fusion on compute 6.1 as v5 measured it per file, and GGML_CUDA_MMID_GLU_UNFUSE=2 gives upstream's rule (C893). - llama-graph.cpp: upstream's automatic "<name>.scale" lookup (ggml-org#32669) replaces the explicit scale arguments, the cold tier's included (its scales carry their tensors' names); the down projection's rescale is upstream's use_amax rule (ggml-org#32677) and the fork's LLAMA_NO_MOE_DOWN_RESCALE condition; route-once's histogram before upstream's random routing (ggml-org#29539); the device-built KQ mask (LLAMA_GPU_KQ_MASK) moves into upstream's build_attn_iswa_impl (ggml-org#32429) and replaces only the default mask. - llama-memory-hybrid-idx.cpp: ggml-org#32519 scores only the ubatch's sequences' k-pools; with the k-pool tables on the devices (LLAMA_QSA_KPOOL_DEV) the list keeps every sequence's pools, as the tables hold them (get_n_kpool); the pads avoid every pool's rep in both layouts (LLAMA_QSA_PAD_LINEAR's bound kept). - llama-quant.cpp: N2P and N3P's fallbacks go into upstream's fallback_type_for (ggml-org#15550), with the row width; Q4_1_64 in upstream's moved llama_ftype_get_default_type. - glm5-next.cpp, qwen4exp.cpp: the fused lightning indexer is always on (ggml-org#32650): the in-place row variant (LLAMA_QSA_INDEXER_ROWS) without the removed switch. - flint.cpp, qwen4exp.cpp, gemma4.cpp, test-llama-archs.cpp, test-backend-ops.cpp, server-context.cpp: the fork's code with upstream's signature changes, model-name helper, decision groups and label outputs (ggml-org#32553), gemma4's multi-sequence prune (ggml-org#32342) without device-built masks. Carried upstream fixes now merged upstream: ggml-org#32434 (6026911: upstream's version taken, the fork's change kept is only --ctx-checkpoints-share's copy and get_reuse's two trim arguments) and ggml-org#31913 (2b2da8a: upstream's fill, the same change). Co-Authored-By: Claude Opus 5.5 <[email protected]>
…tion (ggml-org#29539) * Add LLAMA_MOE_RANDOM_ROUTING=1 for benchmark-only random expert selection * Handle expert caching (cherry picked from commit bba8408)
…tion (ggml-org#29539) * Add LLAMA_MOE_RANDOM_ROUTING=1 for benchmark-only random expert selection * Handle expert caching
Overview
This PR adds benchmark only env variable
LLAMA_MOE_RANDOM_ROUTING=1. This makes each MoE layer's expert matrix multiplies read random, distinct experts per token.The goal is reliable MoE performance numbers with synthetic inputs used during benchmarking. vLLM has something similar for MOE benchmarking:
VLLM_MOE_ROUTING_SIMULATION_STRATEGY=uniform_random.The router still runs normally, and only the expert ids used afterwards are replaced. So the fused router kernel and graph reuse behave exactly as in a normal run.
Requirements