Half the Experts, All the Code: Memory-Efficient MoE Pruning for Agentic Coding Deployment
Abstract
Agentic coding assistants are almost always served from mixture-of-experts (MoE) architectures, but the memory a session must keep resident is set by the full expert pool, not the few experts any token uses, and most of that pool encodes abilities (multilingual chat, creative writing, factual recall) a dedicated coding agent never exercises. We ask how much can be removed before code-generation quality degrades, pruning two recent open-weight MoE models from different families (Qwen3.6-35B-A3B and Gemma-4-26B-A4B) under five expert selection strategies, calibrated on tool-calling and agent-trajectory data and judged functionally: whether the model still writes and executes correct code. Half the experts can be removed from either model with no statistically detectable loss on the primary code-generation benchmark, freeing exactly the memory an on-device agent needs for context and KV cache. But the selection strategy that achieves this reverses between the two models: the criterion that wins on one loses significantly on the other, so a pruning recipe validated on one family cannot be assumed to carry to the next. We further show that perplexity, the efficiency metric most compression work reports, can rate a broken model above an intact one; that a lightweight fine-tune recovers about half of what aggressive pruning loses; and that against simply quantizing the full model to the same memory budget, pruning wins only where quantization would have to drop below 3 bits per weight. Expert pruning is a real lever under a fixed memory envelope, but only with per-model validation, not a one-shot recipe borrowed from a paper on a different architecture.