Reducing LLM Inference Costs: Expert Pruning and Speculative Decoding in Practice

    This article explains how to reduce the inference cost of large-scale LLMs through expert pruning, memory reclamation, and speculative decoding. It covers a four-step pruning workflow, KV cache and batching optimization, draft-model configuration, service-layer routing, and a staged rollout plan with risk controls. Public case studies cited show up to 37% fewer expert modules while retaining over 99% of benchmark scores, with hardware procurement costs reduced by about 20% and cloud rental costs by about 22%.

    1. Background: The Structural Cost Pressure of Large-Model Inference

    As open-weight models enter the multi-trillion-parameter era, inference cost is no longer just a matter of per-GPU performance. It is the combined result of memory capacity, memory bandwidth, interconnect bandwidth, batching efficiency, and cloud rental duration. Larger models occupy more memory for weights. Although Mixture-of-Experts (MoE) architectures activate only a subset of experts per forward pass, the full set of weights must still reside in memory or be swapped in and out efficiently, keeping the number and class of accelerators required stubbornly high.

    From a cost-model perspective, total inference cost can be roughly decomposed as: accelerator purchase or rental cost × number of cards × runtime, plus electricity, operations, networking, and retry overhead. If an enterprise serves all traffic on the full model with the highest-spec hardware, a common contradiction emerges: peak capacity is provisioned at the highest spec while everyday utilization stays low. Therefore, the core of cost reduction is not simply switching to cheaper hardware, but progressively breaking down the constraint that “high-spec hardware is mandatory” through model structure optimization, inference execution optimization, and serving-layer scheduling.

    One public optimization practice shows that by selectively removing some expert modules and running an auxiliary draft model in the freed memory, teams can lower the required accelerator class while preserving core reasoning quality—reducing procurement costs by up to about 20% and cloud rental costs by up to about 22%. This approach is valuable for both self-built clusters and cloud deployments.

    2. Expert Pruning: From Removing Modules to Preserving Quality

    An MoE model typically consists of a routing network and multiple expert modules. Experts differ in activation frequency and contribution across tasks, languages, and context types. The key to pruning is not blindly deleting parameters, but identifying experts that are low-contribution, low-activation, and replaceable—then recalibrating and running regression evaluations after removal.

    The engineering workflow has four steps:

    1. Routing statistics analysis: On representative traffic, measure expert activation frequency, routing entropy, task distribution, and long-tail request coverage. Avoid pruning based solely on average activation rates.
    2. Sensitivity evaluation: Run grouped sensitivity tests on candidate experts, observing quality changes in core reasoning, long-context, multilingual, and tool-calling tasks to establish a quality floor.
    3. Grouped pruning and recalibration: Prune progressively by layer and by expert group, preserving critical routing paths. Perform lightweight recalibration afterward to repair routing drift and output distribution shifts.
    4. Quality gates and canary rollout: Gate releases with core benchmarks, business regression suites, and manual spot checks. Start with a small traffic share and expand gradually.

    In public cases, expert module count was reduced by up to 37% while the model still retained over 99% of the original score on a high-level scientific reasoning benchmark. The version with 30% fewer modules can serve contexts of about 512K tokens, and the version with 37% fewer modules can serve contexts of about 1M tokens. The key insight: memory freed by pruning should not only be used to “buy fewer cards”—it can also be converted into longer context, higher concurrency, or more stable batching capacity.

    Pruning carries risks, however. Over-pruning can cause uneven expert loads, router collapse, long-tail task degradation, and the problem of “average metrics look fine while specific tasks regress noticeably.” A rollback version must always be retained, and a layered evaluation matrix should be built for core business scenarios.

    3. Memory Reclamation: Where the Space for Long Context and Batching Comes From

    LLM inference memory usage comes not only from weights, but also from the KV cache, activations, temporary buffers, and batching queues. In long-context scenarios, the KV cache grows rapidly with sequence length and becomes a major constraint on concurrency and context length. After pruning reduces the number of expert modules, the freed memory can be used to expand KV cache capacity, increase batch size, or support longer context windows.

    Common supporting techniques include paged KV cache management, KV cache quantization and eviction policies, prefix cache reuse, continuous batching, and request orchestration. Engineering teams should closely monitor time to first token, per-token latency, memory fragmentation rate, OOM retry rate, and batching utilization. The cost of long-context serving often does not grow linearly—without cache reuse and request merging, simply expanding the context window will quickly consume the gains from pruning.

    Therefore, capacity planning after pruning must answer three questions: Should the freed memory prioritize long context or higher concurrency? What is the proportion and SLA of long-context requests? Under peak traffic, should requests be routed to different model variants based on difficulty? Only by combining memory reclamation with serving strategy can you form a sustainable cost-reduction loop.

    4. Draft Models and Speculative Decoding: Trading Idle Memory for Throughput

    The memory freed by pruning can also host a smaller draft model. The draft model first proposes the next several tokens; the main model verifies them in parallel in a single forward pass. Accepted proposals reduce the number of main-model decoding steps, improving generation speed. This is speculative decoding, and its benefit depends on draft acceptance rate, draft model overhead, main-model batching efficiency, and request length distribution.

    Engineering considerations include:

    • The draft model and main model should share the same tokenizer and have closely aligned output distributions to keep the verification failure rate low;
    • Draft length should be adjusted dynamically, with different strategies for short and long requests;
    • The rejection fallback path must be stable—verification failures should not cause tail-latency jitter;
    • When combined with continuous batching and priority queues, the draft model must not preempt the main model’s memory.

    An illustrative configuration:

    1. inference_policy:
    2. model_variant: pruned_expert
    3. expert_keep_ratio: 0.63
    4. draft_model:
    5. enabled: true
    6. max_draft_tokens: 6
    7. accept_strategy: adaptive
    8. context:
    9. max_tokens: 512000
    10. kv_cache_policy: paged
    11. fallback:
    12. quality_gate: true
    13. route_to_full_model: true

    Public cases show that even on 8 high-spec accelerators, responses are generated faster; earlier optimizations had compressed the required high-spec accelerators from 8 to at most 4, and this round further lowered the required accelerator class. The essence is rebalancing the triangle of “model quality—memory footprint—decoding speed,” rather than simply maximizing the parameter pruning ratio.

    5. Serving-Layer Synergy: Turning Point Optimizations into Systemic Savings

    Model pruning and speculative decoding are point optimizations; real cost reduction comes from serving-layer synergy. It is recommended to build difficulty-tiered inference routing: hard requests go to the full or lightly-pruned variant, ordinary requests go to the pruned variant; long-context requests use cache reuse and paged management; low-latency requests use small batches with draft-model acceleration. Combined with elastic scheduling, co-location, and hot/cold tiering, accelerator utilization can be further improved.

    Cost accounting should cover TCO: procurement or rental fees, electricity, networking, operations, retry overhead, and capacity redundancy. The cases showing roughly 20% lower procurement costs and 22% lower cloud rental costs demonstrate that dropping hardware specs produces cascading benefits—but only if quality gates and capacity planning are in place. When deploying on Baidu AI Cloud, you can combine general-purpose container platforms with monitoring, alerting, and logging services to build an observability loop, continuously tracking throughput, latency, memory, acceptance rate, and quality regression metrics.

    6. Rollout Plan and Risk Control

    A “baseline → offline optimization → canary validation → scaled rollout” path is recommended: first, select representative traffic to establish quality and cost baselines; then complete expert analysis, pruning, and recalibration offline; next, validate with quality gates and small-traffic canaries; finally, scale up progressively according to business SLAs. For risk control, retain a rollback path to the full model, set thresholds for quality degradation, OOM, and tail latency, and run dedicated evaluations for long-tail tasks, multilingual scenarios, tool calling, and safety cases.

    7. Conclusion

    Reducing inference costs for large-parameter models is a systems engineering effort: expert pruning removes redundant modules, memory reclamation supports longer context and draft models, speculative decoding improves decoding efficiency, and serving-layer routing and scheduling amplify point gains into overall cost savings. Enterprises should take a defined quality floor as the prerequisite, observable metrics as the basis for decisions, and canary rollout with rollback as the safeguard—only then can they make full use of existing AI infrastructure at a reasonable cost.