Reducing LLM Inference Costs: A Combined Optimization Path from Expert Pruning to Speculative Decoding
This article explains how pruning MoE expert modules, reallocating the freed GPU memory, and applying speculative decoding can lower GPU procurement and cloud rental costs for a large inference deployment. According to the reported results, benchmark scores stayed above 99% of the original model. The article also outlines a layered approach: profile the workload first, reallocate memory second, and optimize execution last.
Background: The Tension Between Parameter Scale and Inference Cost
Open-source communities have recently released models with steadily growing parameter counts. The total parameter count of publicly downloadable open-weight models has exceeded the trillion-parameter scale. This growth puts direct pressure on infrastructure:
- GPU memory pressure: Larger models need more memory for their weights, and extra space must be reserved for the KV cache. In long-context scenarios, such as million-token contexts, KV cache memory usage grows linearly with context length.
- Compute pressure: The decoding stage of generative inference is memory-bound. Throughput is often limited by memory bandwidth rather than by peak compute.
- Cost pressure: Flagship GPUs are expensive, and on-demand cloud rental costs accumulate over time. Enterprises face a practical choice: keep upgrading GPU specifications and quantities, or find smarter ways to slim down models and optimize execution.
A technical team focused on inference optimization recently reported results for a 2.8-trillion-parameter mixture-of-experts (MoE) model. After systematic optimization, GPU procurement costs dropped by up to about 20%, cloud GPU rental costs dropped by up to about 22%, and core benchmark scores stayed above 99% of the original model. The optimization path behind these results is worth breaking down.
Key Technique 1: Expert Module Pruning for MoE Models
MoE architectures use a routing mechanism to activate a small number of expert modules for each token. This is the mainstream approach for keeping the computation per inference step manageable in very large models. Even so, the total set of expert modules still consumes a large amount of GPU memory. Inference typically requires all experts to stay resident in memory because the router’s choices cannot be predicted in advance.
The pruning approach is to analyze how often each expert module is activated and how much it contributes to the target task, then selectively remove the experts that contribute little to that task’s workload. In practice:
- Contribution assessment: Measure the routing hit distribution of each expert and its impact on the final output, using a calibration dataset.
- Selective removal: Prune based on the workload profile, reducing the number of expert modules by up to about 37%.
- Accuracy re-validation: Re-evaluate on high-level scientific reasoning benchmarks. Scores still reached more than 99% of the original model.
The trade-off between pruning ratio and capability retention is worth noting. In this case, the version with 30% fewer modules can process contexts of about 512K tokens, and the version with 37% fewer modules supports about 1M tokens. This seems counterintuitive, but the reason is that the freed GPU memory went to the KV cache, and the removed experts mostly served workloads outside the target. For teams with well-defined business scenarios, customizing a model for a specific workload often delivers better value than using a general-purpose full model.
Key Technique 2: Speculative Decoding with a Draft Model
After pruning frees GPU memory, the second stage focuses on generation speed. This stage uses speculative decoding:
- A lightweight draft model quickly proposes several candidate tokens.
- The main model verifies the whole candidate sequence in one batch pass, checking whether it matches the main model’s own distribution.
- Verified segments are accepted directly. Mismatched segments are rejected immediately and corrected.
Verification by the main model runs in parallel, while standard decoding generates one token at a time. Speculative decoding therefore improves decoding throughput significantly without changing the output distribution. Combined with the GPU memory freed by pruning to run the draft model, the complete system can be deployed on eight high-performance GPUs of one tier lower specification and still deliver faster response times than the original configuration.
The following pseudocode summarizes the flow:
draft_tokens = draft_model.propose(context, k=6)accepted = main_model.verify(context, draft_tokens) # one parallel verification passoutput.extend(accepted) # batch accept
Cumulative Effects and Selection Guidance
The team previously reduced the eight flagship GPUs required by the same model series to four. This round allows the next model to run on GPUs one tier lower. This shows that inference cost reduction is not a single technique. It is a continuous build-up across three layers: model structure changes, GPU memory reallocation, and decoding strategy scheduling.
- Profile the workload first: Identify the main tasks the model serves. Pruning decisions need this evidence.
- Then reclaim redundant GPU memory: Direct the freed memory to the KV cache or auxiliary models first, rather than simply shrinking the cluster.
- Finally, optimize execution: Techniques such as speculative decoding and batch scheduling turn the freed resources into actual throughput gains.
For enterprises planning their inference infrastructure, mainstream cloud platforms in China, such as Baidu AI Cloud, offer GPU instances, containerized inference services, and monitoring and alerting systems that can serve as the execution foundation for these optimizations. Availability varies by region, so check the official documentation for your location.
The overall principle is to use engineering methods to fit models to existing resources, rather than letting parameter scale dictate procurement budgets. As lightweighting and inference serving techniques mature, running existing AI infrastructure at a reasonable cost is becoming a verifiable engineering practice rather than a slogan.
