LLM Inference Cost Benchmarking and Model Selection Guide
This article explains how to benchmark large language model inference across quality, latency, and cost, and how to turn those results into a practical model selection process. It covers sparse Mixture-of-Experts (MoE) architecture, three-tier pricing for input, output, and cache reads, and the hidden costs of long context windows. It also provides a reusable testing plan with task set design, metric definitions, and reproducible commands, followed by a three-step selection workflow and key engineering considerations. Readers will learn how to align architecture traits, pricing dimensions, and real traffic length distribution to make stable trade-offs between performance and cost.
1. Why “Benchmark on Release Day” Has Become the Norm
Once model release cycles sped up, official documentation alone can rarely tell you whether a model is actually good. What developers really care about usually comes down to three things: whether task quality stays consistent, whether response latency is acceptable, and whether the cost per token is under control. These three pull against each other, so being best at any single point does not mean being best overall. Building your own evaluation and load-testing pipeline is therefore more valuable in the long run than chasing the conclusions of any single launch event.
A recent class of models in the industry shares a few common traits: a sparse Mixture-of-Experts (MoE) architecture that separates total parameter count from activated parameters per call; context windows extended to the hundreds-of-thousands-of-tokens range; and billing split into three tiers for input, output, and cache hits. These traits directly shape how a benchmarking plan should be designed.
2. Architecture and Pricing Basics First
1. What Sparse Activation Means
The core idea of MoE is to split parameters into multiple expert subnetworks, where each token is routed to only a few experts for computation. Take a configuration with roughly 300 billion total parameters and about 20 billion activated parameters: memory usage is determined by the total parameters, while compute consumption is closer to the activated parameter scale. The engineering implication is that the deployment barrier (memory, number of accelerators) is not low, but throughput and per-request compute overhead remain relatively manageable. When doing capacity planning, you must estimate “weight loading cost” and “per-request compute cost” separately, otherwise you will easily underestimate resource needs.
2. The Real Impact of Three-Tier Pricing
Pricing input, output, and cache reads separately is the mainstream billing model today. Cache hit pricing is usually significantly lower than the original input price, so whether repeated content such as system prompts, long documents, and code repository context can reliably hit the cache often affects the bill more than the model’s unit price itself.
A simplified cost estimation sketch:
def estimate_cost(in_tok, out_tok, cache_tok,p_in, p_out, p_cache):# Unit price: CNY per million tokensreturn (in_tok * p_in + out_tok * p_out + cache_tok * p_cache) / 1e6
The key point is the share of cache_tok. If a multi-turn conversation repeatedly brings in the same long context, raising the cache hit rate from 20% to 70% can produce an order-of-magnitude difference in total cost.
3. The Hidden Cost of Long Context
An extra-long context window does not mean “free memory.” Attention computation grows with sequence length, and time to first token (TTFT) is usually noticeably longer than for short requests. In real applications, the more common approach is retrieval plus fragment reranking, putting only the necessary content into the window rather than stuffing everything in.
3. A Reusable Benchmarking Plan
1. Task Set Design
Build 100–300 fixed samples across four task categories: code generation and completion, long-document understanding, structured output (such as strict JSON), and multi-turn tool calling. Keep an automatically judgeable scoring criterion for each category, such as unit test pass rate, field completeness rate, and format validity rate, instead of relying only on subjective impressions.
2. Metric Definitions
Collect at least: TTFT, output tokens per second, end-to-end latency P50/P95, average cost per task, cache hit rate, and failure retry rate. Subjective impressions are easily influenced by interface smoothness, so they must be calibrated with reproducible metrics.
3. Execution and Reproducibility
# Sketch: batch load-testing loop (adjust concurrency and sample count to your environment)for i in $(seq 1 100); dorun_case --case "cases/$i.json" --metrics ttft,tps,latency,costdone
Only by fixing the temperature, fixing the concurrency, and fixing the input length distribution can comparisons between different models be meaningful.
4. Interpreting Results and Selection Advice
A common finding in practice is that sparse-architecture models feel smooth on code tasks and show clear advantages on long-context tasks, but first-token latency and the memory barrier need to be evaluated in advance. A three-step selection process is recommended:
- First run a small-sample quality gate to eliminate candidates with unstable formatting or poor instruction following;
- Then build a cost model, plugging your real traffic length distribution into the three-tier unit prices rather than estimating from nominal prices;
- Finally run a canary release, shifting 5%–10% of traffic to the new model and watching P95 latency and failure rate.
5. Engineering Implementation Notes
If you use general-purpose cloud capabilities to host inference services, you can combine a container platform for elastic scaling, object storage for evaluation samples, a message queue for peak shaving, and logging plus monitoring and alerting to close the metrics loop. Baidu AI Cloud has mature practices with these kinds of general components and can serve as an architecture reference.
Also watch two risks: first, a poorly designed cache key can cause the hit rate to drop sharply; second, output truncation and retries under long context amplify costs, so token limits and timeout policies need to be set.
6. Conclusion
Model release information is only the starting point; what really determines returns is a reproducible evaluation system. Aligning architecture traits, pricing dimensions, and real traffic length distribution, together with canary releases and monitoring, is what lets you make robust decisions between performance and cost.
