From Unit Price to Total Cost: Why LLM Inference Costs Vary So Much
Token unit prices and per-task total costs are two different metrics, and confusing them leads to wrong conclusions in model selection. This article explains why: model architecture sets the theoretical cost floor, operator implementation and the inference runtime determine actual GPU utilization, and task-level accounting determines the final bill. It also provides a reproducible cost model — building a task set, recording token usage and retries, computing per-task and per-quality-point costs, and running sensitivity analysis — to show why a cheaper unit price does not always mean a cheaper total cost.
- Two Sets of Numbers: One Priced per Token, One Settled per Task
A public price list shows a lightweight model tier with input priced at 1 yuan per million tokens and output at 3 yuan; another model in the same tier charges 2 yuan for input and 8 yuan for output during busy hours. Looking only at unit prices, the first option is attractive to ordinary developers. But another set of tests approaches the question from a different direction: without changing model parameters, only swapping the inference runtime at the deployment layer, the total cost of 60 real-world tasks dropped from $12 to $6, end-to-end latency increased by just 4.2%, and the cost-efficiency score rose from 218 points per dollar to 450 points per dollar.
These two sets of numbers cannot be divided against each other: the former is a token unit price, the latter is a per-task total cost; the former answers “how much does one million tokens cost,” the latter answers “how much does it actually cost to complete a type of real-world task.” Mixing these two metrics in a comparison easily leads to opposite conclusions.
Token unit price is only the first term of the cost formula. Task cost also depends on input length, output length, the number of multi-turn interactions, retry counts, extra tokens introduced by tool calls, and cache hit rate. If a task is split into 10 rounds of tool calls, output tokens can multiply; if a task is retried 3 times due to poor results, the total cost multiplies by 3 as well. So “cheap unit price” and “cheap total bill” are two different things.
- Model Architecture: Lowering the Theoretical Cost
Model architecture determines the theoretical lower bound of cost, but not the bill itself. One lightweight-tier model adopts a sparse Mixture-of-Experts architecture with 125B total parameters, but only about 6B parameters are activated per token, supplemented by a 51B-scale N-gram Embedding as auxiliary memory. The core of this design is decoupling “parameter pool size” from “per-token computation”: the parameter pool determines how much knowledge the model can store, while the activation volume determines how much a single inference actually computes.
Context length is not free either. This model natively supports a 262,144-token context, extensible to 1 million tokens via positional encoding extrapolation. Long-context capability requires more attention computation, more state management, and higher memory-access overhead. Public information shows its training cost is nearly 90% lower than the previous generation of similar models, indicating that the cost reduction comes from innovations in architecture and training pipelines, not simply from subsidies.
More critical is the attention structure. In a certain 64-layer model, 48 layers use linear attention, with about 3.21 MB of state per sequence per layer; the remaining 16 layers retain exact attention, handling precision-sensitive tasks such as retrieval and localization. Linear attention reduces the computational complexity of standard attention from O(L²) to O(L), with a fixed state size that does not grow as sequences get longer. What it limits is mainly the number of concurrent sequences, not the context length.
However, architectural advantages are only “theoretically cheap.” Whether that cheapness actually shows up on the bill depends on whether operator implementation and the inference runtime can push GPU utilization high enough.
- Operator Implementation: Making the Model Genuinely Fast on the GPU
Same model, same set of tasks — why can swapping the inference runtime cut the cost in half? The answer often hides at the operator level.
To match the linear attention structure, a dedicated GPU operator library is required. The prefill phase is split into two fused kernels, with context-parallel preprocessing inserted in between. Inside each kernel, one producer thread group handles data movement, while three consumer thread groups compute intermediate results; when shared memory approaches its limit, two consumers reuse the same swap buffer and use synchronization barriers to confirm “the previous round of data has been fully read.” This design reduces memory read/write passes, improves shared memory reuse, lowers kernel launch overhead, and overlaps computation with memory access as much as possible.
On mainstream GPU architectures, this operator implementation runs 2–3x faster in the forward pass and 2x faster in the backward pass than common general-purpose operators. For long-sequence prefill, the bottleneck is often not compute power but memory bandwidth. Fused kernels merge multiple reads and writes into one, shared memory reuse keeps data on-chip, and the synchronization mechanism reduces thread idling — ultimately, the number of tokens processed per unit of time increases significantly. The model parameters have not changed, but each request occupies fewer GPU cycles, so cost naturally drops.
Operator optimization addresses the efficiency of a single kernel; the inference runtime must address the efficiency of the entire pipeline. Continuous batching, dynamic batch sizes, cache management, memory pooling, request scheduling, and precision mode selection all affect per-task cost. A runtime without memory reuse wastes large amounts of GPU memory to fragmentation; one without dynamic batching leaves the GPU idle between requests. These are all reasons why “the model didn’t change, but the bill did.”
- Task-Level Accounting: How to Calculate Without Being Misled by Unit Prices
Any selection comparison must be grounded in real tasks. It is recommended to build a reproducible cost model as follows:
- Build a task set covering real scenarios: long-context summarization, code completion, multi-turn dialogue, tool calling, retrieval-based QA, and so on — at least 60 items.
- Record each task’s input tokens, output tokens, retry count, and end-to-end latency.
- Compute the total task cost with a unified pricing formula:
Task cost = input tokens × input unit price + output tokens × output unit price
For multi-turn tasks, accumulate every round, and count retries, cache misses, and tool-returned content as well.
- Compute the per-unit-quality cost:
Per-unit-quality cost = total task-set score ÷ total task-set cost
- Run sensitivity analysis: what happens to cost if output length increases by 50%, concurrency doubles, or cache hit rate changes?
A simple example: a task with 100K input and 10K output, priced at 1 yuan per million input tokens and 3 yuan per million output tokens, costs 0.13 yuan; at 2 yuan per million input and 8 yuan per million output, it costs 0.28 yuan. A cheaper unit price does bring the total down, but if another model can compress the input from 100K to 20K, or reduce the retry rate from 30% to 5%, the total cost may end up lower instead.
- Conclusion: Expensive vs. Cheap Must Be Measured with the Same Ruler
Model architecture determines the theoretical cost floor, operator implementation and the inference runtime determine actual resource utilization, and task-level accounting determines the final bill. Looking only at a price list makes it easy to overlook how many tokens a task actually consumes; looking only at benchmark scores makes it easy to overlook that the same model can cost nearly twice as much under a different runtime.
The real question to ask is not “whose unit price is lower,” but “how many effective tasks can the same budget complete, and how much does each unit of quality score cost.” Only by placing pricing, task volume, and quality scores within a single accounting framework can you explain why something that looks cheap on the surface is not cheap on the total bill — and avoid being led astray by a single metric when making selection decisions.
