LLM Inference Cost Analysis: A Guide to Calculating Tokens per kWh
This guide presents a three-layer framework for measuring the economics of large model compute, linking hardware power draw, inference throughput, and token pricing. It explains how to convert energy consumption into revenue per kWh, highlights six key variables that affect the results, and offers a practical tuning checklist. Readers will learn to replace single-point estimates with reproducible models, avoid common measurement mistakes, and turn capacity planning into a data-driven process.
1. Why “Tokens per kWh” Is Worth Calculating
As model capabilities converge and price competition continues, benchmark scores alone are no longer enough to support engineering decisions. What really determines business viability is how much usable output a unit of compute can produce. Putting electricity cost, GPU-hours, and token output into the same framework quickly answers three questions: whether the current inference cluster is fully utilized, whether pricing covers real costs, and whether the marginal return of scaling up is positive.
The goal of this kind of analysis is not to produce a single “standard answer,” but to build an explainable, reproducible model. Any single number (for example, “roughly four million tokens per kWh”) is only the result under specific assumptions. Change one parameter, and the conclusion may differ by an order of magnitude.
2. Core Framework: A Three-Layer Funnel
Break the calculation into three layers to progressively reduce uncertainty.
The first layer is hardware power consumption. For a single high-power accelerator card, full-load power draw is typically around 700W. Adding cooling, power delivery losses, networking, and control overhead, the facility’s overall power usage effectiveness (PUE) is generally taken as 1.2–1.4. After conversion, the “effective power” per card is about 800–1000W, meaning 800–1000 joules consumed per second.
The second layer is throughput. The output stage is autoregressive decoding, generating one token at a time; aggregated single-card output speed in batch inference scenarios is roughly 500–3000 tokens/second. The input stage (prefill) is a highly parallel matrix operation, with throughput typically one to two orders of magnitude higher, reaching tens of thousands of tokens per second.
The third layer is value. Multiply token count by price to get “revenue per kWh,” then add electricity cost, card depreciation, and operations labor to assess gross margin.
The relationship between the three layers can be expressed with a minimal function:
def tokens_per_kwh(power_w, tput_tps, pue=1.3):joules_per_token = (power_w * pue) / tput_tpsreturn 3_600_000 / joules_per_token # 1 kWh = 3.6e6 joules# Output side: 900W effective power, 1000 tokens/sprint(tokens_per_kwh(900, 1000)) # ≈ 4.0e6# Input side: same power, 10000 tokens/sprint(tokens_per_kwh(900, 10000)) # ≈ 4.0e7
3. Converting Energy Consumption into Revenue
Using the same assumptions: the output side yields about four million tokens per kWh. At an output price of $50 per million tokens, that is about $200 per kWh. The input side yields about forty million tokens per kWh; at $10 per million tokens, that is about $400 per kWh. If the input-to-output ratio in a workload is close to 3:1, the weighted result falls roughly in the range of $250–300 per kWh.
Because throughput parameters vary widely, a reasonable range should be widened to $100–800 per kWh. This span is a reminder that capacity planning cannot rest on a single-point estimate; it should provide upper and lower bounds and backfill them with load-testing data.
4. Six Key Variables That Affect the Conclusion
- Batch size. Too small a batch leaves compute idle; too large a batch increases queuing latency. You need to find the intersection of throughput and latency.
- Context length. Long contexts make attention computation and memory usage grow nonlinearly, significantly raising per-token energy consumption.
- Quantization and precision. Lower precision usually improves throughput and reduces memory bandwidth pressure, but may cause quality regression, so business-side evaluation is needed.
- Parallelism strategy. The combination of tensor parallelism, pipeline parallelism, and expert parallelism determines the share of communication overhead.
- Cache hit rate. Prefix reuse and result caching directly cut redundant computation and are among the most cost-effective optimizations.
- Facility efficiency. Every 0.1 drop in PUE reduces the overall electricity bill by roughly the same proportion.
5. An Actionable Tuning Checklist
- Establish a load-test baseline: fix the input/output length distribution, record P50/P95 latency and throughput, and build a reproducible capacity table.
- Tiered serving: route requests by latency sensitivity to resource pools of different specifications, preventing high-priority requests from being blocked by long-running tasks.
- Elastic scaling: combine message queues to smooth peaks, reclaim compute during off-peak hours, and use a container platform to handle burst traffic.
- Observability: use logging services and monitoring alerts to put token output, unit cost, and error rate on the same dashboard.
- Cost attribution: tag by business line, calculate the real cost per ten thousand tokens, and identify unprofitable callers.
6. Common Pitfalls
The first is treating peak throughput as normal throughput. The second is ignoring the cost-structure difference between the input side and the output side. The third is looking only at unit price while ignoring utilization, so “cheap resources” end up more expensive. The fourth is equating benchmark scores directly with a unit-cost advantage. Benchmarks reflect the upper limit of capability, while the bill is determined by utilization and architecture.
7. Conclusion
“Tokens produced per kWh” is essentially an engineering health-check metric. Mastering the three-layer conversion of power, throughput, and price, together with load testing and an observability system, turns the vague question of “whether compute is expensive” into optimizable numbers. With the general-purpose compute and containerization capabilities of platforms such as Baidu AI Cloud, teams can embed this model into their routine capacity review process so that every scaling decision is backed by data.
