llama.cpp fixes MoE model loading bug in v1.5
Critical fix resolves MoE model crashes in llama.cpp v1.5
The llama.cpp team has patched a critical bug in version 1.5 that prevented proper loading of Mixture-of-Experts (MoE) models after they were saved. The issue occurred when the model saver incorrectly handled expert shared feed-forward lengths in MoE architectures. Specifically, the `model-saver` component called `add_kv` twice with the same key (`LLM_KV_EXPERT_SHARED_FEED_FORWARD_LENGTH`), causing the second call to overwrite the first. This resulted in incorrect tensor shapes during model reloads, particularly affecting the shared expert layers.
The bug impacted major MoE models including Qwen2-MoE, Qwen3-Next, Granite-MoE, Hunyuan-MoE, Ernie 4.5, and others. When users attempted to save and reload these models, the architecture fallback incorrectly used the default feed-forward length rather than the expert-specific length. This caused tensor shape mismatches and complete model failure during reload. The fix ensures the correct key (`LLM_KV_EXPERT_CHUNK_FEED_FORWARD_LENGTH`) is used for the second call, preserving tensor shapes and enabling successful roundtrips for all affected architectures.
- Critical bug in llama.cpp v1.5 caused MoE models to fail after save/load cycles
- Affected 10+ major architectures including Qwen3-Next, Granite-MoE, and Hunyuan-MoE
- Fix prevents tensor shape mismatches in shared expert layers
Why It Matters
Ensures reliable deployment of Mixture-of-Experts models in production environments