Cutting MoE Inference Costs by 20%: A Combined Optimization Path for Trillion-Parameter Models

    A practical guide to cutting inference costs for trillion-parameter Mixture-of-Experts (MoE) models by around 20% without retraining. Drawing on a public case that optimized a ~2.8-trillion-parameter open-weights MoE model, this article breaks down a three-layer strategy: expert-level pruning to slim the model, hardware downsizing to cheaper GPUs, and speculative decoding to turn freed VRAM into speed. It covers importance-based pruning, VRAM budgeting, parallelism recalibration, draft-model selection, acceptance-rate tuning, a reusable six-phase rollout, and common pitfalls to avoid.

    1. Background: As parameter counts approach the trillions, inference cost becomes a deployment barrier

    Over the past two years, open-weights large language models have kept scaling up, and the Mixture-of-Experts (MoE) architecture has gradually become the mainstream choice for this trend. Trillion-scale parameter counts are no longer rare among publicly downloadable models. The larger the model, the more GPU memory and compute are needed to generate an answer. As a result, inference cost has shifted from an “operational overhead” to a core barrier that determines whether enterprises can deploy LLM applications at scale.

    Cost pressure shows up in three main areas:

    • High upfront investment: Supporting a super-large model usually requires multi-GPU servers, with large one-time costs for hardware procurement and datacenter upgrades.
    • Linearly growing cloud spend: Under per-card-hour billing, model size directly determines the marginal cost of each request.
    • Poor scaling elasticity: LLM deployment has coarse granularity; a slightly higher business peak can force a full-machine scale-out, which easily drags down resource utilization.

    One often-overlooked fact: parameter count is the foundation of model capability, but it does not equal the lower bound of resource usage at inference time. An MoE model routes each token to only a few experts, so there is a lot of “fits-but-underutilized” resource redundancy. This is precisely the entry point for inference optimization.

    2. Core idea: Don’t change the weight source; do the subtraction in the inference pipeline

    A representative public optimization practice offers a reusable combined approach. An enterprise AI inference optimization team optimized an open-weights MoE model with a total of roughly 2.8 trillion parameters:

    • They switched the inference hardware to a relatively cheaper GPU model within the same generation;
    • After optimization, GPU procurement cost dropped by up to about 20%, and GPU rental cost in the cloud dropped by up to about 22%;
    • The team had previously compressed the higher-spec GPUs needed to run the previous generation of the same model series from 8 down to at most 4; this round further lowered the GPU spec tier required for later models.

    The key characteristics of this path can be summarized in three points:

    1. No change to the weight source: The model architecture, parameter weights, and tokenizer all stay the same. Optimization happens at the load and execution stages, with no need to re-pretrain.
    2. Three-layer coordination: The model layer does structural subtraction (expert pruning), the hardware layer does spec downsizing (cheaper GPUs with less VRAM), and the execution layer gains efficiency (draft model + speculative decoding).
    3. Reused savings immediately: The VRAM freed up by pruning is not left idle; it is allocated to the draft model and a larger context window.

    The sections below break down the technical principles, key parameters, and engineering caveats of each layer.

    3. Layer 1: Expert-level pruning — slimming down the MoE model

    3.1 Why start with the experts

    Common model-compression techniques each have a different focus:

    Technique Basic principle Typical benefit Main cost / risk
    Weight quantization (e.g., FP8, INT4) Represent weights with fewer bits VRAM usage drops roughly proportionally Precision loss; needs hardware and operator support
    Knowledge distillation Use a large model to guide the training of a smaller one Model size shrinks significantly Requires extra training; hard to cover all of the original model’s capabilities
    Structural pruning (layers / attention heads) Remove whole layers or heads Simple structure, hardware-friendly Breaks deep semantics; higher risk
    Expert-level pruning Remove low-contribution experts and re-map routing Significant drop in parameters and VRAM; relatively simple to implement Possible capability drift; needs dedicated evaluation
    Quantization + expert pruning combined Combine the two techniques Benefits stack Precision risks stack; needs strict validation

    For super-large MoE models, expert-level pruning has a distinct advantage. Experts are natural functional units, so removing a few of them does not break the connectivity within the rest of the network. The surviving experts continue to carry their original weights, and the router reassigns requests that would have gone to the removed experts, so precision declines in a “smooth decay” fashion rather than a structural break.

    The public practice provides two reference data points:

    • Even after removing up to 37% of the expert modules, the model still scores over 99% of the original on a high-level scientific-reasoning benchmark;
    • The 30%-reduced version can handle a 512K-token context, while the 37%-reduced version can handle 1M tokens.

    These numbers show that at the trillion-parameter scale, there is clear functional redundancy and load imbalance among experts. Pruning is not just about a “smaller size”; it is a fresh understanding of the model’s internal structure.

    3.2 Importance measurement: deciding “which experts can be removed”

    Pruning starts with quantifying each expert’s contribution. Common industry metrics fall into four categories:

    1. Routing frequency: On a calibration set that covers the real business distribution, count how often each expert is selected.
    2. Gating contribution: Look not only at whether an expert is selected, but also at the magnitude of its gate weight. Experts with weak gate signals usually have less influence on the output.
    3. Output sensitivity: Measure how much a layer’s output shifts when a given expert is removed, using approaches such as change in output norm or a first-order Taylor approximation.
    4. Task relevance: Run targeted statistics on the enterprise’s own corpus to avoid pruning based only on generic corpora.

    Real systems usually score experts with a combination of these metrics, then add protection rules based on business importance:

    1. # Illustrative pseudocode to express the pruning decision logic
    2. # 1) The calibration set should cover the real request distribution (domains, languages, context lengths)
    3. freq, gate_sum = {}, {}
    4. for batch in calibration_data:
    5. hidden = model.forward_to_router(batch)
    6. logits, probs = router(hidden) # gate scores and routing probabilities
    7. topk_idx = probs.topk(k).indices # experts actually selected per token
    8. for layer_id, idx in topk_idx:
    9. freq[layer_id] += count(idx)
    10. gate_sum[layer_id] += probs.gather(idx).sum()
    11. # 2) Scoring: routing frequency primary, gate strength secondary, weighted after normalization
    12. score[layer] = norm(freq[layer]) + alpha * norm(gate_sum[layer])
    13. # 3) Protection rules
    14. # - Shared experts (every token passes through them) are always kept
    15. # - High-contribution experts for critical business tasks (code, domain QA) can be flagged for protection
    16. # - Set a lower bound on the per-layer retention ratio to avoid routing degradation from too few experts
    17. keep_ratio = max(target_ratio, min_keep_per_layer[layer])
    18. keep_ids = topk(score[layer], round(num_experts * keep_ratio))
    19. # 4) Synchronous rewrite: experts compacted in retention order, gate output dimension trimmed accordingly
    20. pruned_experts = compact(model.experts[layer], keep_ids)
    21. new_router = remap_router(router[layer], keep_ids) # old index -> new index

    A few easily underestimated engineering details in the implementation:

    • Route remapping must be consistent: The indices of removed experts must be removed from the gate output at the same time. Otherwise the surviving experts get “mis-seated” because of index misalignment; the model still runs on the surface, but output quality has already collapsed.
    • Load-balancing constraints: MoE training relies on a load-balancing loss to keep the experts’ division of labor roughly even. If a layer keeps too few experts after pruning, the remaining experts become hotspots and hurt throughput stability.
    • Recovery training is an optional enhancement: For teams with budget and enough data, a short round of continued training after pruning can further narrow the precision gap.
    • Deliver by version rather than by the single optimum: The public practice provides two pruning tiers, 30% and 37%, corresponding to different context capabilities. This is a pragmatic trade-off: it leaves the “how much to prune” decision to the business side.

    3.3 Evaluation: how to interpret a 99% score

    The public practice uses a hard scientific-reasoning benchmark as its precision anchor. Such benchmarks cover graduate-level problems across physics, chemistry, biology, and other fields, and effectively test a model’s deep reasoning ability. Retaining over 99% of the score after pruning indicates the model’s core reasoning ability has not been structurally damaged. For engineering deployment, however, this is only a starting point. A complete evaluation should cover at least the following dimensions:

    Evaluation dimension Metrics of concern Suggested gate (example, adjustable)
    General capability Knowledge QA, math, code, instruction following Drop ≤ 1–2 percentage points vs. the original
    Specialized capability The enterprise’s own eval set (domain QA, summarization, etc.) Core tasks drop ≤ 1 percentage point
    Long context Multi-document retrieval, full-text summarization, cross-segment reasoning Key tasks don’t drop noticeably; run long-text stress tests
    Robustness Different languages, prompt templates, input distributions No single item collapses (e.g., one item drops more than 5 percentage points)
    Generation quality Preference comparison via human or model review Usability no lower than the original; no new systematic defects

    One caveat deserves special emphasis: 99% on a public benchmark is not the same as 99% in an enterprise’s business scenario. Different tasks depend on experts to different degrees. For example, highly predictable content such as structured text and code, along with knowledge-retrieval-augmented scenarios, tends to be less sensitive to expert routing. Open-ended writing, multi-step logical reasoning, and low-frequency specialized Q&A may rely more on the “long-tail experts” that get pruned. For this reason, the enterprise’s own eval set is an indispensable part of the process.

    4. Layer 2: Hardware spec downsizing — swapping the “expensive card” for the “right card”

    4.1 Why cost reduction is feasible

    The logic behind hardware downsizing is not “power through with a worse card,” but rests on a basic fact: VRAM capacity and spec do not always need to be maxed out.

    • VRAM capacity is determined by the model; performance headroom is the compressible part. Deploying a model at a given precision, the VRAM required for weight shards is relatively fixed. A flagship card’s large VRAM and ultra-high bandwidth are easily saturated on a super-large model, forcing you into the most expensive hardware tier.
    • The freed-up capacity changes the hardware-selection space. Expert pruning lowers weight usage, leaving enough headroom per card to accommodate the next tier down — a GPU with less VRAM.
    • Total cost of ownership (TCO) is about the whole chain. Cheaper GPUs cost less per unit and also have advantages in power, cooling, cards deployable per machine, datacenter space, and procurement lead time. TCO improvements are often more pronounced than the per-card price gap suggests.

    Here is a key detail: total VRAM demand only grows as the card count grows, but per-token memory-access demand stays roughly constant. In expert-parallel scenarios, the model’s VRAM can be split across cards, but the memory accessed to generate each token during decoding does not fall as the card count rises. So when going from a flagship card down to a next-tier card, lower per-card bandwidth does not necessarily slow generation directly. As long as the compute units are not fully utilized, a moderate drop in clock speed and bandwidth can be absorbed. This is also why hardware downsizing is often paired with speculative decoding: speculative decoding adds computation, while hardware downsizing gives up some compute headroom, so the two complement each other well.

    4.2 VRAM budgeting before downsizing

    Before downsizing hardware, you must run a complete VRAM budget to confirm the peak usage under the new spec leaves enough headroom (recommend ≥ 10%):

    1. # Illustrative budget formula; exact implementation depends on precision
    2. Weight shard VRAM ≈ total_params × bytes_per_param / parallelism
    3. KV cache VRAM ≈ 2 × num_layers × num_kv_heads × head_dim × context_length
    4. × num_concurrent_sequences × bytes_per_element / kv_parallelism
    5. Draft model VRAM ≈ draft_params × bytes_per_param
    6. + draft_model_kv_cache
    7. Available headroom = per_gpu_vram − weight_shard − peak_kv_cache − draft_model − framework_reserve

    Here the “2” accounts for the two caches, Key and Value. This formula shows that context length and concurrency are the two multipliers on the KV cache, and also the factors most likely to trigger an out-of-memory (OOM) error in long-context scenarios.

    4.3 Parallelism strategy needs recalibration

    After changing hardware, the existing parallelism configuration is not necessarily still optimal and needs recalibration:

    1. Tensor parallelism (TP): Generally should not cross a single-machine boundary, otherwise every token pays extra cross-machine communication overhead. More cards lower per-card weight usage, but more participants are involved in communication synchronization.
    2. Expert parallelism (EP): Distributes different experts across different cards; suits super-large MoEs with many experts where a single card can’t hold all of them. The cost is that tokens must be exchanged across cards according to routing results (All-to-All communication), which is sensitive to interconnect bandwidth. On a limited budget, prefer expert parallelism within a single machine.
    3. Pipeline parallelism (PP): Suits cross-machine deployment but introduces pipeline bubbles, so use it cautiously for latency-sensitive scenarios.
    4. KV cache quantization: For example, FP8 KV cache can roughly halve the KV portion of VRAM, making it a very cost-effective technique for long-context scenarios, though precision must be validated on the eval set.
    Parallelism Main partition target Advantage Cost Applicable scenario
    Tensor parallel (TP) A single matrix operation Lowers per-card weight and activation usage High-frequency communication; not suitable across machines Multi-GPU within one machine
    Expert parallel (EP) Different experts Fits the MoE structure; good scalability All-to-All communication overhead Many experts; limited single-machine VRAM
    Pipeline parallel (PP) Model layer segments Relatively small cross-machine traffic Pipeline bubbles; affects latency Cross-machine deployment of ultra-large models
    Context parallel Long-sequence dimension Relieves long-context KV pressure Complex to implement; needs extra communication Ultra-long-context scenarios

    5. Layer 3: Draft model + speculative decoding — turning freed VRAM into speed

    5.1 Principle: the small model “jumps the gun,” the big model “verifies in one pass”

    Standard autoregressive decoding runs the full large model to generate each token. As the context grows, every step must move all weights and the KV cache from VRAM to the compute units — a typically memory-access-bound process. The compute units sit largely idle, which is a real waste.

    Speculative decoding changes this rhythm:

    1. The draft model generates γ candidate tokens in a row;
    2. The main model verifies these γ positions in a single forward pass, in parallel;
    3. A specific accept/reject rule decides how many candidates to keep; rejected positions are resampled from the main model’s own distribution;
    4. Repeat until generation finishes.

    In a classic public experiment using a GPT-2-scale small model as the draft and GPT-2 XL as the target, generation speed reached up to 2–3× the original while keeping the output distribution exactly identical. The key to this result is “identical distribution”: the draft model only guesses, while the final answer is always gated by the main model.

    The acceptance rule differs by sampling mode:

    • Under random sampling (temperature > 0), standard speculative decoding uses a probabilistic acceptance rule of “min(1, p_target / p_draft)” and does residual-distribution sampling on rejected tokens, guaranteeing an output distribution exactly matching the target model.
    • Under greedy decoding (temperature = 0), a draft token is accepted as long as it matches the main model’s highest-probability token at that position, making the output exactly equivalent to token-by-token greedy decoding.

    In essence, speculative decoding is a form of “lossless acceleration,” which is what sets it apart from lossy optimizations like pruning and quantization.

    5.2 Four hard constraints for draft-model selection

    A poorly chosen draft model can make speculative decoding slow the system down. At minimum, consider:

    • VRAM budget: The draft model should usually be a fraction of the target — several tens of times smaller or less. The VRAM freed by the pruning described earlier is exactly what houses the draft model and its own KV cache.
    • Tokenizer consistency: The draft and target models should ideally share the same or highly compatible tokenizer. If you have to map the draft token sequence to the target’s token sequence, the mapping cost can cancel out the benefit.
    • Distribution alignment: The draft model is best drawn from the same model family, having learned similar data distributions and style, which yields a higher candidate hit rate.
    • Domain adaptation: A generic draft model may have a lower hit rate in a vertical domain. You can lightly fine-tune the draft model on business corpora, or pick a size variant from the same family that is closer to the business.

    5.3 Acceptance-rate tuning: not always faster under high concurrency

    The benefit of speculative decoding is closely tied to the acceptance rate α, the draft length γ, and the current batch size. Using token-by-token decoding of the original model as the baseline, the throughput improvement per unit time can be approximated as:

    1. Expected accepted tokens E = (1 − α^(γ+1)) / (1 − α)
    2. Ideal speedup ratio S_ideal = E / (γ + c)
    3. c : draft model overhead factor (draft cost / target cost)
    4. α : average draft token acceptance rate
    5. Optimal draft length γ* = argmax S_ideal

    A few conclusions you can use directly for decisions:

    • Higher acceptance rate, bigger benefit. At α = 0.8 and γ = 4, a single verification accepts about 2.95 tokens on average, giving an ideal speedup of about 1.56×; when α drops to 0.5, the speedup is only about 1.09×.
    • There is an optimal draft length. A longer draft yields more expected accepted tokens, but the per-round draft overhead and the waste from rejected candidates also grow.
    • Benefits shrink under high concurrency. With large batches, the target model shifts from memory-access-bound to compute-bound, and the extra verification computation competes for compute with other requests. So speculative decoding suits low-concurrency, low-latency interactive scenarios such as chat assistants and code completion. High-throughput offline batch jobs should prioritize throughput and toggle speculative decoding dynamically.
    • Adapt per request type. Acceptance rates for predictable content such as structured code and JSON are usually markedly higher than for open-ended writing. You can use a simple sliding window to track the actual acceptance rate over recent steps and dynamically adjust the draft length or even turn off speculative decoding automatically:
    1. # Illustrative pseudocode: dynamically adjust draft length by acceptance rate
    2. window, gamma, gamma_max = [], 4, 8
    3. for step in generation_stream:
    4. if speculative_enabled:
    5. draft = draft_model.propose(context, n=gamma) # draft model generation
    6. accepted = target_model.verify(draft) # target model verifies in one forward pass
    7. emitted += accepted
    8. window.append(len(accepted) / gamma)
    9. else:
    10. emitted += target_model.decode_one(context)
    11. if len(window) == WINDOW_SIZE:
    12. alpha = mean(window)
    13. gamma = clamp(round(alpha / (1 - alpha)), 1, gamma_max) # infer draft length from acceptance rate
    14. speculative_enabled = alpha >= MIN_ACCEPT_RATE # disable when acceptance is too low
    15. window.clear()

    5.4 Two direct benefits beyond generation speed

    • Time to first token (TTFT): Some inference frameworks let the draft model propose the first token first, and the main model returns it immediately after verification. TTFT therefore no longer depends entirely on the target model’s first full forward pass; it depends mainly on the draft model’s inference time.
    • Interaction experience: In streaming-output scenarios, users see content start scrolling sooner. This often has a bigger impact on the subjective sense of “fast” than pure throughput metrics.

    6. Balancing precision and resources: why expert pruning can make things “faster the more you cut”

    It’s worth noting that in the public practice, the pruning ratio is positively correlated with context capability: the more you prune, the longer the context you can actually handle. This is no coincidence, but an easily overlooked mechanism in MoE inference.

    In a standard MoE implementation, the forward pass has roughly three steps:

    1. The gate network selects the top-k experts for each token;
    2. It runs a forward pass over all experts, producing every expert’s output;
    3. It weights and sums the outputs of the selected experts by the gate weights.

    The compute in step 2 is proportional to the total number of experts, independent of top-k. The more experts there are, the more compute each token consumes, and the fewer concurrent sequences the system can serve, so the less VRAM can be allocated to the KV cache. Pruning more than 30% of the experts means each token’s base compute drops in the same proportion, while freeing both VRAM and compute:

    • The freed VRAM expands the KV cache, translating directly into a longer context window;
    • The extra compute can be used to verify, in parallel, the multiple candidate tokens produced by speculative decoding;
    • Stacked together, the system’s “concurrent requests × per-request length” capacity rises substantially.

    This also explains another seemingly contradictory phenomenon: pruning is a lossy optimization, yet a well-tuned system can actually be faster and support longer contexts in some scenarios. What’s lossy is the per-token generation quality, not the system’s overall processing capacity. The two need to be evaluated separately and shouldn’t be conflated.

    However, these conclusions depend on the specific implementation. Some inference engines use a sparse implementation that “computes only the selected experts,” in which case the compute savings from pruning are much smaller and the benefit is mainly at the VRAM level. In engineering, defer to the actual framework’s behavior and avoid copying the conclusion blindly.

    7. Cost-reduction logic from the case data

    Behind the cost-reduction numbers in the public practice, three points are worth noting:

    1. Rental savings exceed procurement savings. Procurement cost drops by up to about 20%, while cloud rental drops by up to about 22% — the rental-side reduction is slightly larger. This fits the general rule of cost structure: after hardware downsizing, the unit-price drop is linear, while the rental side is also affected by instance availability, regional supply and demand, and combinations of on-demand vs. reserved billing, so it has more room to fluctuate.
    2. “Spec downsizing + halving the count” can stack. The previous-generation model went from 8 higher-spec GPUs down to at most 4, and this round further lowers the GPU spec tier for later models. The two act on “quantity” and “unit price” respectively, so in theory they can be multiplied together. This also signals to enterprises: capacity planning should be based on the “target model” rather than the “current model” for long-term budgeting.
    3. The hidden benefit from a CAGR perspective. As the business grows, inference cost usually accumulates in a compounding way. A 20% drop in per-card cost is amplified continuously over a three-year horizon; combined with lower energy use per unit, the actual TCO improvement is often higher than the headline number.

    8. A reusable engineering practice: a six-phase rollout

    Regardless of which model and hardware combination you use, the following six-phase path applies:

    1. Baseline measurement: Record throughput (tokens/s), TTFT, P99 latency, VRAM usage, and quality metrics as the reference for all later comparisons.
    2. Precision-aware pruning: Compute expert importance based on a business calibration set, prune in tiers (e.g., 20%, 30%, 37%), and pass a quality gate at each tier.
    3. VRAM budgeting and hardware downsizing: Recompute the parallelism strategy and the KV cache ceiling, then choose the lowest GPU spec that meets the budget.
    4. Speculative decoding integration: Pick a same-family draft model, set up acceptance-rate monitoring and an adaptive policy, and re-run load tests on the target hardware.
    5. Long-context validation: Run stress tests at the target context length, watching for VRAM fragmentation, KV cache eviction, and interference from long requests on short ones.
    6. Canary rollout and continuous monitoring: Start with a small canary, then scale up gradually. Metrics to monitor should include cost per token, draft acceptance rate, GPU utilization, P99 latency, and sampled quality results.

    In a cloud-platform environment, combining these general capabilities works even better:

    • Use a container platform to host the inference service and scale elastically with business peaks and troughs;
    • Use a logging service to capture request-level metrics, and monitoring and alerting to catch VRAM overflow, latency degradation, and drops in acceptance rate in time;
    • Use object storage to manage model versions, supporting multi-version canary releases and fast rollback;
    • Sensibly combine reserved, on-demand, and spot instances to balance stability and cost.

    As one example, Baidu AI Cloud’s general-purpose GPU cloud servers, container service, monitoring and alerting, and log service can all be used to host the inference optimization approach described above.

    9. Common misconceptions

    • “Pruning necessarily hurts precision”: Pruning is indeed lossy, but the size of the loss depends on the quality of the importance measurement and the coverage of the evaluation. Tiered evaluation + a business eval set + recovery training can keep the loss within an acceptable range.
    • “A cheaper card means worse performance”: As long as the VRAM budget and parallelism strategy are sound, a moderate spec reduction often has limited impact in memory-access-bound scenarios, and combined with speculative decoding it may even net-improve the experience.
    • “Speculative decoding is always faster”: With a low acceptance rate or a large batch, speculative decoding can actually make things slower. You must benchmark it and monitor the acceptance rate.
    • “Cost reduction only means watching the GPU bill”: Network, storage, ops headcount, and failure rate all count toward TCO. The hidden cost of reduced stability is sometimes higher than the hardware savings.
    • “Pruning and quantization can be stacked freely”: Both are lossy, and their errors may amplify each other when combined. They need a unified evaluation rather than each passing on its own.

    10. Conclusion: from “model lightweighting” to “inference execution optimization”

    The core lesson of this kind of public practice is that cost reduction doesn’t rely only on “swapping in cheaper cards,” but on system-level, coordinated optimization of the model structure, hardware spec, and execution strategy.

    • Expert pruning solves the “does it fit” problem;
    • Hardware downsizing solves the “can we afford it” problem;
    • Speculative decoding solves the “is it fast” problem;
    • The long-context capability gain comes as a natural benefit of reallocating VRAM.

    This methodology is a useful reference for any open-weights model that uses an MoE architecture at a large parameter scale. It also echoes the view expressed by CEOs of inference-optimization companies: the focus is shifting from model lightweighting toward inference execution and serving optimization, helping enterprises make good use of their existing AI infrastructure at a reasonable cost.

    For enterprises, the more pragmatic approach is to internalize these capabilities as engineering standards:

    1. Build quality gates into the release process;
    2. Bring cost metrics into day-to-day monitoring;
    3. Upgrade capacity planning from “runs on the current model” to “runs on the target model.”

    Only then can large-model inference find a sustainable balance among performance, quality, and cost — truly moving from “affordable” to “well-used.”