How to Cut Inference Costs by About 20% for Trillion-Parameter MoE Models
Mixture-of-Experts (MoE) models reduce compute per token through sparse activation, but all expert weights must still reside in GPU memory. This article examines how one inference-optimization team lowered the hardware requirements for a 2.8-trillion-parameter open-source MoE model, reducing self-hosted GPU procurement costs by up to about 20% and cloud on-demand GPU costs by up to about 22%. The key techniques are structured expert pruning, speculative decoding, and using freed memory to expand context length. It also covers routing rebalancing, acceptance-rate limits, KV cache cost, and a practical deployment checklist.
1. Executive Summary: When Parameter Scale Becomes a Hardware Threshold
Mixture-of-Experts (MoE) architectures decouple total parameter count from compute per token through sparse activation. Mainstream designs usually route each token to only a small number of experts, for example selecting 2 out of 8. This lets models increase capacity while controlling inference compute. However, the tradeoff is direct: all expert weights must remain resident in GPU memory, and total weight size is determined by total parameter count. Once the memory requirement of an ultra-large model exceeds what a given generation of accelerators can provide, deployers have only two options: buy higher-end accelerators or rent more GPUs.
A Korean AI inference-optimization company has demonstrated a third approach. It recently announced that it completed inference optimization for an open-source MoE model with 2.8 trillion total parameters, enabling the model to run on lower-tier, more affordable accelerators. Compared with running the original version, self-hosted GPU procurement costs were reduced by up to about 20%, while cloud on-demand GPU costs were reduced by up to about 22%.
This was not the company’s first effort to lower deployment thresholds. Previously, it reduced the number of accelerators required to run the previous-generation model from eight to fewer than four. The core of this optimization is moving the requirement from “requiring the latest accelerator generation” to “being able to step back to the previous hardware tier.”
The case can be abstracted into three general technical paths: structured expert pruning, speculative decoding, and memory reallocation for longer context or higher concurrency. Each path has different benefits, boundaries, and engineering requirements. Together, they form a reusable methodology for architects trying to control large-model inference costs.
2. Case Breakdown: Three Ways to Lower the Hardware Tier
The team applied three categories of optimization to this trillion-parameter-class model, targeting GPU memory, inference speed, and context capacity.
1. Expert Module Pruning: Removing Low-Value Parameters
In an MoE model, each expert is essentially an independent parameter subnetwork, and a router selects experts dynamically per token. The team selectively removed experts that were least frequently invoked in the target scenarios, reducing the number of modules by up to 37%.
A common misconception needs correction: MoE experts are not fixed to a specific task. The same expert can be shared by tokens from different domains, and expert-task relationships are formed dynamically during training. Therefore, pruning criteria are usually not manually assigned functions, but quantitative metrics such as routing frequency and parameter importance measured on calibration data.
In terms of results, the most compressed version still retained more than 99% of the original model’s score on GPQA Diamond, a challenging scientific reasoning benchmark.
2. Speculative Decoding: Turning Freed Memory into Speed
The memory freed by pruning was not left idle. It was used to load a small draft model. The draft model proposes several subsequent tokens, and the main model verifies them in parallel in a single forward pass. With eight accelerators, the model generated responses faster than the original setup.
3. Context Capacity Expansion: Compounding the Memory Savings
The same memory savings were also invested in long-context capability:
- A version with about 30% fewer modules can handle a context length of 512,000 tokens.
- A version with about 37% fewer modules can support a context length of 1 million tokens.
The team lead said the technical direction will be extended from model lightweighting to inference execution and service optimization, helping enterprises use existing AI infrastructure at more reasonable cost.
These techniques are not isolated tricks. They share the same main line: reducing the hardware requirement per request.
3. Path 1: Expert Module Pruning — Recalculating the Weight Budget
3.1 Why MoE Pruning Is More Effective Than Dense-Model Pruning
Dense-model pruning often operates at the level of individual weights, creating unstructured sparsity. On mainstream hardware, this kind of sparsity is difficult to translate into lower memory traffic and compute unless the inference engine has specialized sparse-compute support.
MoE pruning, by contrast, is naturally structured. An expert is a relatively independent subnetwork with clear boundaries. Removing the entire expert causes:
- The weight matrices to become smaller.
- The router’s candidate set to shrink at the same time.
The reductions in memory and compute are therefore real. This is why ultra-large MoE models are ideal targets for structured compression.
3.2 Three Criteria for Identifying Redundant Experts
- Routing frequency: On a calibration set that reflects the real business distribution, count how often each expert is selected.
- Output sensitivity: Mask each expert individually and observe changes in output distributions or task metrics. Smaller changes indicate greater redundancy.
- Vector similarity: Compare expert parameters or representations. Experts that are highly similar or functionally overlapping can be grouped, and only a representative kept.
In practice, these criteria are often combined: frequency and similarity identify candidates, while sensitivity ranks the final list.
from collections import Counterdef select_experts_to_prune(model, calib_loader, top_k=2, keep_ratio=0.7):"""Select experts to prune based on routing frequency on a calibration set.Illustrative code, not tied to a specific framework API."""freq = Counter()for batch in calib_loader:logits = model.router(batch.hidden_states) # router scoresfor token_scores in logits:for expert_id, _ in token_scores.topk(top_k).items():freq[expert_id] += 1# Sort by invocation frequency in ascending order and keep the top keep_ratio fractionranked = sorted(freq, key=freq.get)keep_count = int(len(ranked) * keep_ratio)return set(ranked[keep_count:]) # set of experts to prunedef apply_pruning(model, drop_ids):for layer in model.layers:# Remove entire expert subnetworks and update router weights accordingly,# achieving structured compressionlayer.drop_experts(drop_ids)layer.renormalize_router()
3.3 Deleting Experts Is Not Enough: Routing Rebalancing and Lightweight Recovery Matter
Naive deletion creates two side effects:
- Wasted probability mass: The router may still assign probability to deleted experts. These weights become wasted capacity.
- Load drift: Traffic shifts to the remaining experts, potentially unbalancing the previously stable routing distribution. A few experts may become overloaded, reducing overall quality.
Engineering practice usually adjusts the routing logic at the same time:
- Renormalize the weights of the remaining experts.
- Use a bias-correction approach similar to expert-parallel load balancing, adding a dynamic bias term to router scores so tokens are pulled back toward a balanced distribution.
After that, a lightweight fine-tuning or distillation step with a small batch of data can recover the accuracy lost to pruning. The cost of routing rebalancing and fine-tuning is much lower than retraining, but it can significantly improve real-world performance after compression.
3.4 What “99% Score” Means and Does Not Mean
The statement that GPQA Diamond retains more than 99% of the score shows at least two things:
- Pruning did not destroy the model’s core reasoning ability.
- Standard public benchmarks may not expose subtle regressions caused by compression.
However, passing benchmarks does not mean the business is lossless, for three reasons:
- Benchmark distributions are relatively concentrated, while real enterprise traffic may be any mix of code, long documents, and multi-turn dialogue.
- A small average metric drop may be concentrated on a few difficult samples.
- Evaluations often use fixed decoding parameters, while production batching, context length, and other conditions may differ.
Recommendation: Build a small regression set from business samples, run it before and after pruning, and pay attention to percentile metrics such as P95 and P99 accuracy, not just average scores.
3.5 Benefit Boundaries of Pruning
MoE pruning essentially pushes the tradeoff of “capacity for capability” to a more aggressive extreme. Each additional pruned expert reduces weight memory roughly in proportion, but also loses the knowledge and expressiveness carried by the removed experts.
Therefore, compression levels around 33% to 37% are a tradeoff:
- They enable a full downgrade in hardware tier and a substantial expansion of context length.
- They assume the original model has relatively sufficient capacity and that the target scenario is not sensitive to extreme capability.
If a business depends on the strongest capabilities in the open-source weights, lossless or near-lossless techniques such as quantization plus speculative decoding should be prioritized.
4. Path 2: Speculative Decoding — Producing Multiple Tokens from One Weight Read
4.1 Principle: A Small Model Drafts, a Large Model Verifies
The standard speculative decoding process is:
- A draft model starts from the original prompt and generates γ candidate tokens continuously.
- The prompt and candidate tokens are concatenated and passed through the main model in a single forward pass, producing next-token probability distributions at each position in parallel.
- Verification proceeds left to right. If a draft token matches the main model’s distribution, it is accepted. At the first mismatch, the main model’s sampled token at that position replaces the draft token, and all subsequent draft candidates are discarded.
Thus, one main-model forward pass can produce up to γ+1 tokens.
The key property is losslessness. Under greedy decoding, if every accepted position matches what the main model would decode independently, the final output is identical. Under stochastic sampling, after acceptance-rejection with residual resampling correction, the output distribution is strictly identical to independent decoding by the main model. The speedup comes from running fewer main-model forward passes, not from reducing output quality.
def speculative_decode(draft, target, prompt, gamma=4):"""Draft proposal plus parallel verification by the target model.Illustrative greedy-decoding code."""prefix = list(prompt)for _ in range(gamma):prefix.append(draft.greedy_next(prefix)) # draft model proposes tokens# One forward pass over the target model gives next-token distributions in parallellogits = target.forward(prefix)[:-1]new_tokens, accepted = [], 0for i in range(gamma):pos = len(prompt) + itoken = logits[pos].argmax()new_tokens.append(token)if token != prefix[pos]: # first mismatchbreak # correct and discard the remaining draft tokensaccepted += 1if accepted == gamma: # all accepted: target model produces one extra tokennew_tokens.append(logits[-1].argmax())return new_tokens, accepted + 1
4.2 Memory Economics: Why Pruning and Speculative Decoding Work Well Together
Leaving the memory freed by pruning for a draft model is an efficient tradeoff:
- Pruning reduces resident weights.
- The draft model adds extra benefit but does not consume the main model’s compute budget.
- Draft models usually have only a small fraction of the main model’s parameters, often between one-twentieth and one-hundredth, so the memory overhead is controllable.
Conversely, if memory is already tight, there is no place for a draft model. Pruning and speculative decoding therefore have a clear synergy: free up space first, then convert it into speed.
4.3 Benefit Boundaries: When It Speeds Things Up and When It Slows Things Down
Autoregressive LLM decoding is memory-traffic-intensive. At low concurrency, generating each token requires reading all weights from memory, leaving much GPU compute idle. Speculative decoding improves effective arithmetic intensity by amortizing one weight read over multiple tokens.
But the benefit is not unconditional:
- Diminishing returns at higher concurrency: As request batch size increases, the main model shifts from memory-bound to compute-bound. Verifying extra γ candidates may increase wasted computation.
- Acceptance rate sets the ceiling: Acceptance rate equals the frequency with which draft and main model match token by token. If the draft is too weak, it is often rejected. If the draft is too strong, its own overhead consumes the benefit.
- Long context raises costs: Long prefixes force the draft model to process more history each time, increasing drafting cost.
Practical engineering approaches include:
- Using mainstream inference engines’ speculative decoding and continuous batching capabilities to mix draft tokens with regular requests, utilizing idle compute during verification.
- Applying adaptive policies, such as enabling or disabling drafting dynamically based on concurrency or draft hit rate.
4.4 How to Choose a Draft Model
- Same-family small version: If the open-source weight family includes a lightweight version, it is the easiest draft source.
- Self-distilled small model: Distill a small model from data generated by the main model so that the draft distribution is closer to the main model, often improving acceptance rate.
- Draft-free schemes: Add a small number of prediction heads to the same model for self-drafting, avoiding extra memory and deployment cost.
- Tree-based candidates: Propose multiple branches at once, increasing the chance of a correct guess in exchange for a small amount of additional compute.
Regardless of the approach, compare options using a unified metric: the average number of effective tokens produced per main-model forward pass.
5. Path 3: Context Expansion — Compounding the Memory Savings
5.1 The Memory Cost of Long Context
Longer context means a larger KV cache. It grows linearly with sequence length and can be estimated as:
KV memory (bytes) ≈ 2 × layers × KV heads × head dimension × sequence length × batch size × bytes per element
For example, with 80 layers, 8 KV heads, head dimension 128, and FP16 storage, each token requires about 320 KB of KV cache:
- 500,000 tokens require about 150 GB.
- 1,000,000 tokens require about 300 GB.
Adding activation overhead during prefill, a single million-token context can saturate the memory of a high-end accelerator. The two case versions extended context to 512,000 and 1,000,000 tokens by using memory freed through pruning.
5.2 The “Attention Dilution Effect”
Long context is also a challenge for the model. Research in the industry commonly finds that as context grows longer, models become less effective at using information in the middle, a phenomenon often described as “lost in the middle.” Capacity reduction from pruning may amplify this effect.
Therefore, before deploying long-context configurations, two capabilities should be validated:
- Needle in a haystack: Embed key information in a long text and test whether it can be retrieved accurately.
- Multi-hop reasoning: Test whether the model can synthesize information scattered across different parts of the input.
Ultra-long context should be positioned as a specialized capability for a small number of high-value requests, not as the default configuration for all requests.
5.3 Three Possible Uses of the Memory Budget
| Option | Main benefit | Suitable scenarios |
|---|---|---|
| Expand context | Accept longer input per request | Long-document analysis, cross-file code understanding |
| Load draft model | Reduce decoding latency | Interactive Q&A, code completion |
| Increase concurrent batch size | Improve overall throughput and amortize unit cost | Offline batch processing, large-scale content generation |
These options compete for the same memory. Allocate them according to business SLAs. For example, online interaction should prioritize latency, while offline batch processing should prioritize throughput.
6. Cost Accounting: About 20% Lower Procurement and About 22% Lower Rental
6.1 Self-Hosting: From Accelerator Procurement to Total Cost of Ownership
The most direct interpretation is that after model requirements fall, the required accelerator tier and count both decrease, reducing procurement cost. A more accurate measure is whether the amortized cost per million tokens declines over the hardware lifecycle.
- If the lower-tier hardware changes the compute time per token little, the reduction will be close to the reduction in hardware unit price.
- If compute time also falls, the reduction can be larger.
Do not forget racks, power, networking, and operations. These costs change roughly in proportion to the number of GPUs, so the procurement-level benefit may be greater than the roughly 20% GPU unit-price reduction alone.
| Cost item | Change when moving to a lower tier | Notes |
|---|---|---|
| Accelerator procurement | Decreases | Lower unit price and fewer cards |
| Supporting servers and networking | Decreases roughly proportionally | Usually provisioned per GPU |
| Racks, power, and cooling | Decreases roughly proportionally | Related to equipment scale |
| Data center and operations fixed costs | Basically unchanged | Amortized over a longer period |
| Software adaptation and evaluation effort | One-time increase | Includes pruning, fine-tuning, and regression testing |
6.2 Cloud: Changes in Instance Configuration Can Produce a Larger Reduction
Cloud instances are usually billed as a bundle of GPU type × GPU count × duration. When requirements fall:
- The price discount from moving to a lower GPU tier may be greater than the linear reduction from fewer GPUs.
- High-end GPUs are often in tight supply, and on-demand prices may carry a premium. Moving down a tier can also avoid supply constraints.
In addition, when the required GPU count crosses a key threshold, a machine type with a smaller interconnect scale can be used. Tensor parallelism, expert parallelism, and other cross-GPU communication are important components of inference latency. If the optimized deployment still meets the SLO, reducing the parallel domain and cross-GPU synchronization moderately can lower both cost and latency.
This helps explain why the rental-side reduction can be slightly higher than the procurement-side reduction. However, the reported figures of “20%” and “22%” are case-specific results and vary with model version, GPU combinations, and pricing levels. They must be validated against actual business workloads.
6.3 Self-Hosting or Renting: Do Not Compare Unit Prices Only
Lower requirements also change the balance point between self-hosting and renting:
- Self-hosting: Lower depreciation cost when demand is stable and utilization is high.
- Renting: More flexible when traffic is volatile or new models need to be tested quickly.
When deployment scale falls back to a few GPUs on a single machine, the self-hosting threshold becomes significantly lower. However, self-hosting still requires considering utilization, operations staffing, and depreciation period. Make the decision after comprehensive calculation.
7. Deployment Guide: From Buying More Expensive GPUs to Using Existing GPUs Better
Step 1: Establish Cost and Performance Baselines
| Metric | Meaning | Focus |
|---|---|---|
| TTFT | Time to first token | Interactive experience, mainly determined by prefill |
| TPOT | Time per output token | Generation smoothness, determined by decoding |
| Throughput | Output tokens per unit time | Determines unit cost |
| Effective acceptance rate | Fraction of draft tokens accepted | Source of speculative decoding benefit |
| Cost per million tokens | Token-level unit cost | Common basis for comparing self-hosted and cloud |
Step 2: Identify Bottlenecks and Apply Techniques in Priority Order
| Bottleneck | Preferred techniques |
|---|---|
| Insufficient memory, forcing more GPUs | Quantization → expert pruning → offloading/layered caching |
| Long-context memory pressure | KV quantization/sparsification, paged management, on-demand eviction, prefix reuse |
| High interactive latency, large TPOT | Speculative decoding |
| Low throughput and high cost | Continuous batching, PagedAttention-style memory management, chunked prefill |
| Spare memory | Increase batch size |
Overall, follow “lossless first, then lossy”: quantization, KV cache management, and speculative decoding generally do not affect output quality and should be prioritized. Pruning and distillation are lossy techniques and should be used after building a business regression set.
Step 3: Make Optimization Measurable and Rollbackable
- Canary and A/B testing: Run old and new versions on part of the traffic, comparing real metrics and user feedback.
- Versioning: Record pruning ratio, calibration set, and draft model version to ensure reproducibility.
- Switches and degradation: Use configuration switches for hot toggling, so anomalies can be rolled back quickly.
- Cost dashboard: Aggregate token consumption by business and model to identify major cost drivers.
Step 4: Use General Cloud Capabilities Well
When a self-hosted cluster falls from “starting at eight GPUs” to “fewer than four,” the elasticity advantage of the cloud becomes more visible: release resources during low-traffic periods and scale temporarily during peaks. Model preparation and inference serving can combine several general cloud capabilities:
- Object storage: Store weights, calibration data, and evaluation sets.
- Container services: Host inference services with automatic elastic scaling.
- Logging and monitoring alerts: Track metrics such as TTFT and TPOT.
- Model-as-a-service platforms: Host models and provide unified APIs.
Baidu AI Cloud’s model-as-a-service platform covers model hosting and inference serving and can be one reference environment when evaluating this architecture.
Step 5: Establish a Long-Term Evaluation Process
Optimization is not a one-time project. After the base model is updated, pruning ratios, draft models, and context strategies need to be re-evaluated. It is recommended to institutionalize the evaluation set and cost/performance dashboards as a fixed process, making each hardware-tier reduction a sustainable operational capability.
8. Risks and Misconceptions
- Treating “passing benchmarks” as “lossless for business”: Public benchmarks differ from real traffic distributions, so business regression sets must be authoritative.
- Ignoring routing rebalancing: Deleting experts without adjusting routing can waste effective capacity and cause load imbalance.
- Blindly enabling speculative decoding at high concurrency: Draft overhead may exceed the benefit, so it should be toggled dynamically based on load.
- Assuming larger context is always better: Long context brings memory and latency costs, as well as the risk of losing information in the middle.
- Treating a hardware downgrade as a free lunch: Lower-tier hardware may have different memory, interconnect bandwidth, and compute characteristics that become new bottlenecks. Load-test before migration.
9. Conclusion
The key lesson from this case is: in the era of ultra-large models, the main way to reduce inference cost is no longer simply buying cheaper GPUs, but making models fit cheaper GPUs.
Toward that goal, the article outlines a progressive path:
- Structured pruning: Reduce weight memory requirements to fit within the capacity of lower-tier hardware.
- Speculative decoding: Convert freed memory into decoding speed.
- Memory reallocation: Trade off between context expansion and higher concurrency.
- General cloud capabilities: Elastic scaling, observability, and unified service entry points.
When deployment scale falls back to a few GPUs, enterprises can rent on demand more calmly, experiment quickly, and concentrate funds on scenarios that create real business value. Further, optimization can move from model lightweighting to inference execution and service-layer optimization, such as continuous batching, KV cache reuse, and request priority scheduling. This is the key step from “being able to afford a model” to “using a model well.”
