Commit cf34d3113 for llama.cpp
commit cf34d311332e362198f0a410c466d1e940287d02
Author: Alexey Kopytko <alexey@kopytko.com>
Date: Sun Nov 8 22:29:11 2026 +0900
moe-cache : ensure CPU part does not wait for the cached experts (#31888)
diff --git a/src/llama-graph.cpp b/src/llama-graph.cpp
index b5d4642a2..b38daca76 100644
--- a/src/llama-graph.cpp
+++ b/src/llama-graph.cpp
@@ -2414,6 +2414,9 @@ ggml_tensor * llm_graph_context::build_moe_ffn(
//call early so that topk-moe can be used
ggml_build_forward_expand(gf, weights);
+ // compute the expert input before the slot lookup, so that the scheduler prefetches it for the CPU part (the router can read a different tensor)
+ ggml_build_forward_expand(gf, cur);
+
// the experts of host-resident layers may be read from the MoE cache, and part of the misses computed from the host experts
// the CPU part does not support weights before the FFN, LoRAs or rotated experts
const std::array<ggml_tensor *, 4> exps = { up_exps, gate_exps, down_exps, gate_up_exps };