Reducing LLM Inference Costs: Practices in MoE Pruning and Speculative Decoding

    Trillion-parameter Mixture of Experts (MoE) models offer high training efficiency but present significant inference deployment challenges, including memory pressure, communication overhead, and hardware costs. This article explores how to reduce inference costs while maintaining model quality by combining expert pruning and speculative decoding. It covers the principles, implementation steps, hardware downgrade considerations, and practical deployment guidelines for optimizing MoE inference on fewer or lower-specification GPUs.

    I. Why Inference Costs Remain High

    Trillion-parameter Mixture of Experts (MoE) models are efficient during training but face three main issues during inference deployment.

    First is memory pressure. The size of the weights is determined by the total number of parameters. Even with low-precision quantization, many models still require hundreds of gigabytes of VRAM, which a single GPU cannot accommodate, necessitating multi-GPU parallelism.

    Second is multi-GPU communication overhead. Cross-GPU tensor parallelism or pipeline parallelism introduces inter-GPU communication. As the number of GPUs increases, the utilization per card may drop, raising the actual cost per token.

    Third is procurement and rental costs. Self-built clusters require an upfront hardware investment, while cloud deployments charge by the hour. Both approaches directly inflate the cost per token.

    Therefore, the real question enterprises care about is: Can we achieve near-original inference quality using fewer or lower-specification GPUs? The following technical categories address this problem.

    II. Expert Pruning: Identifying Low-Contribution Experts

    2.1 Applicability Boundaries

    Expert pruning is only applicable to MoE models. Dense models do not have expert modules that can be removed as a whole; they require structured or unstructured pruning and separate validation. Before pruning, the team must have routing logs and a representative set of calibration data.

    2.2 Pruning Process

    The pruning process roughly consists of three steps:

    1. Calculate the activation frequency of each expert on the calibration data and compute its importance score for downstream tasks.
    2. Remove low-contribution experts or merge experts with similar functions based on the business scenario.
    3. Recalibrate the routing after removal to ensure the overall output distribution remains stable.

    Example code (pseudo-code):

    1. expert_freq = defaultdict(int)
    2. for batch in calibration_data:
    3. routing = model.route(batch) # Record routing results for each token
    4. for expert_id in routing.experts:
    5. expert_freq[expert_id] += 1
    6. # Sort by activation frequency and task score, flag low-contribution experts
    7. low_value_experts = rank_by(expert_freq, task_score)[:k]
    8. pruned_model = model.remove_experts(low_value_experts)
    9. pruned_model.calibrate(calibration_data) # Recalibrate routing

    2.3 Effects and Trade-offs

    There is no universal optimal pruning ratio. For general tasks, the performance loss might be minimal. However, long-tail domain knowledge and high-difficulty reasoning are more susceptible to degradation. Therefore, the pruning ratio should be determined by the business scenario and backed by actual test results. This article does not provide a universal accuracy retention rate, as these figures are heavily dependent on the specific model, evaluation set, calibration data, and hardware conditions.

    2.4 Potential Benefits of Freed Memory

    Reducing the number of experts decreases the memory footprint of weights. Within the same memory budget, this leaves more space for the KV Cache, potentially supporting longer contexts, which is beneficial for long-document analysis and codebase understanding. The actual context length supported needs to be tested on the target model and hardware.

    III. Speculative Decoding: Accelerating Generation with a Draft Model

    3.1 Working Principle

    Speculative decoding executes in three steps:

    1. A small draft model quickly generates several candidate tokens.
    2. The main model verifies this batch of candidate tokens in parallel at once, accepting the correct ones and rejecting the incorrect ones.
    3. The main model regenerates tokens at rejected positions.

    The overhead of verifying multiple tokens is significantly lower than generating them one by one, thus increasing decoding speed. The memory freed by pruning can be used to keep the draft model resident, allowing both methods to work synergistically.

    3.2 Boundaries of Output Distribution

    Under standard speculative sampling and rejection rules, the target output distribution of the main model can theoretically be preserved. However, the engineering implementation requires verifying three aspects: whether the acceptance rate is stable, whether the fallback strategy is correct, and whether numerical errors are within an acceptable range. Skipping these validations may cause online outputs to diverge from expectations.

    3.3 Draft Model Selection

    Dimension Requirement Description
    Vocabulary Consistent with the main model Different vocabularies prevent direct token alignment
    Acceptance rate Tested on business data Determines the speedup ratio; must be measured per scenario
    Memory footprint Matches remaining memory after pruning Draft model shares memory budget with the main model
    Verification batch size Evaluated with concurrency Batch size variations impact speedup gains
    Latency benefit Compare TTFT and overall latency with/without draft model Looking only at throughput may mask latency degradation

    IV. Hardware Downgrade: From Flagship to Mid-Tier GPUs

    By combining pruning and speculative decoding, models that originally required multiple flagship GPUs to run can now potentially operate on fewer or lower-specification GPUs. This reduces procurement and rental costs, but the actual savings depend on multiple factors, so no uniform ratio is provided here.

    Enterprises can use the following table to calculate Total Cost of Ownership (TCO):

    Cost Item Calculation Focus
    GPU procurement or rental Calculated by model, cloud pricing, and commitment period
    Utilization rate Low utilization can offset the unit price advantage of mid-tier GPUs
    Network interconnect Fewer cards may reduce communication costs; calculate based on topology
    Storage Storage volume for model files, caches, and logs
    O&M labor Hours spent on deployment, monitoring, and debugging
    SLA breach risk Compensation or business losses due to latency exceeding standards

    V. Implementation Steps

    5.1 Establish a Baseline First

    Evaluate the original model using your own business dataset. Record accuracy, time to first token (TTFT), overall latency, memory usage, and cost per token. Without a baseline, it is impossible to determine if an optimization is effective.

    5.2 Create a Pruning Comparison Table

    Evaluate different pruning ratios and fill out the table below. The “To be tested” items need to be populated using your business data.

    Pruning Ratio Memory Usage General Task Accuracy Long-tail Domain Accuracy Complex Reasoning Accuracy TTFT
    0% (Original) Baseline Baseline Baseline Baseline Baseline
    To be tested To be tested To be tested To be tested To be tested To be tested

    5.3 Long-Tail Scenario Evaluation Checklist

    • Professional Q&A in niche domains (e.g., low-resource languages, industry jargon, historical materials).
    • Multi-step reasoning and math or code-related questions.
    • Information extraction and summarization under ultra-long inputs.
    • Refusal behaviors related to safety and compliance.

    Long-tail scenarios are prone to degradation after pruning. Set separate metrics for them and do not rely solely on average scores.

    5.4 Canary Release and Rollback

    First route a small amount of traffic to the optimized version, comparing quality metrics and latency in parallel with the original version. Once metrics stabilize, gradually increase traffic. Retain the original model and configuration at each step for quick rollback in case of quality drops.

    5.5 Risk Warnings

    Pruning and quantization may affect long-tail knowledge and complex reasoning. After deployment, continuously monitor online quality metrics such as user feedback rate, manual spot-check pass rate, and task success rate. If anomalies occur in these metrics, prioritize rolling back.

    VI. Conclusion

    Reducing inference costs requires the synergy of model structure optimization, decoding strategies, and hardware selection. Methods like pruning and speculative decoding must be validated on your own data and hardware to determine their benefits. By establishing a baseline first and proceeding step-by-step, enterprises can utilize existing GPU resources with greater confidence.