LLM Inference Cost: Why the Bill Per Task Matters More Than the Price Per Token

    This article explains why a lower price per million tokens does not always mean a lower bill. It breaks the issue into three layers: sparse architecture sets the theoretical lower bound, linear attention changes what gets bottlenecked, and the runtime often doubles or halves the actual cost for the same weights. It also gives a reproducible evaluation method based on cost per effective task, so you can compare setups using your own fixed task set instead of a price sheet.

    1. Where the Conflict Comes From: Two Price Tags, Two Different Baselines

    In November 2026, one model service cut its lightweight tier to 1 RMB per million input tokens and 3 RMB per million output tokens. Around the same time, another vendor’s lightweight tier was priced at 2 RMB for input and 8 RMB for output during peak hours. Looking at that single line, the first option is roughly two-thirds cheaper, and most developers would open its documentation first.

    But another set of numbers grows from a completely different direction: with the same model and the same weights, simply swapping the runtime (often referred to as a harness or execution framework) reduced the total cost of a 60-task real-world suite from USD 12 to USD 6. End-to-end latency increased by only 4.2%, while the unit-cost score rose from 218 points per dollar to 450 points per dollar. Not a single parameter changed, yet the bill was cut in half.

    Put the two sets of numbers side by side, and you get the conflict this article unpacks: the cheap baseline is not the same. One price tag is settled per token; the other is settled per task. Anyone who uses the former to directly infer the latter will get the conclusion wrong. Each layer below provides a reproducible basis, not just theory.

    2. Layer One: The Low Unit Price Is Built into the Architecture

    The extremely low unit price of a lightweight tier usually comes from a sparse design. Take a sparse Mixture-of-Experts (MoE) model as an example: about 125B total parameters, with only about 6B activated per token, plus roughly 51B of N-gram Embedding attached for high-frequency fragment memory; native context of 262,144 tokens, extended to the million-token range via a position interpolation scheme (such as YaRN); and training cost reduced by nearly 90% compared with the previous generation.

    The key abstraction here is: the parameter pool determines “how much can be remembered,” while the activation volume determines “how much is computed per inference.” Sparse activation decouples the two, so “large parameters” no longer equal “high unit price.” But note that architecture only provides a theoretical lower bound; real money has to be realized on the hardware.

    3. Layer Two: Linear Attention Compresses O(L²) into O(L)

    A reproducible example: in a 27B dense model with 64 layers, 48 layers use gated linear attention (such as GDN), with a state of about 3.21 MB per sequence per layer; the remaining 16 layers retain exact attention to handle the parts that require precise retrieval.

    Linear attention reduces standard attention from O(L²) to O(L). What is saved is not GPU memory, but the attention computation per token; the state size is fixed, so long sequences do not inflate the state. Therefore, what it caps is the number of concurrent sequences, not the context length—a point that is extremely easy to misjudge in capacity planning.

    On the engineering side, this is usually paired with a hand-written operator library (written in a DSL such as TileLang/Triton), which splits prefill into two fused kernels with a context-parallel preprocessing step in between; inside each kernel, one producer warpgroup moves data, while three consumer warpgroups compute V′, S, and O respectively; when shared memory is saturated, two consumers share the swap surface, using an mbarrier with count=4 to pass the “previous round has been fully read” synchronization signal. On cards such as Hopper/Blackwell, this kind of implementation often achieves 2–3x forward and about 2x backward speedup relative to a generic Triton approach.

    Illustration (pseudocode, only expressing the pipeline structure):

    1. # prefill: two fused kernels + intermediate CP preprocessing
    2. state = init_state(batch, heads, dim) # fixed size, does not grow with L
    3. for chunk in split_by_cp(seq, cp_rank): # context-parallel split
    4. q, k, v = load_chunk(chunk) # producer warpgroup moves data
    5. v_prime, s = kernel_A(q, k, v, state) # consumer 0/1
    6. o = kernel_B(q, v_prime, s, state) # consumer 2, mbarrier(count=4) sync
    7. state = update_state(s) # state is fixed, does not inflate on long sequences

    4. Layer Three: The Runtime Is the Amplifier of the Bill

    The same weights, with the runtime swapped, halve the cost—which shows that the main variable in the bill is not the unit price, but “how many tokens and how much wall-clock time it takes to complete a task.” The runtime usually amplifies or compresses cost from four places:

    • Batching and scheduling: continuous batching, chunked prefill, and priority preemption determine the GPU idle ratio.
    • Cache reuse: prefix cache hits directly eliminate repeated prefill; every 10% increase in hit rate brings an approximately linear drop in the bill for long-system-prompt scenarios.
    • Parallelism strategy: how context parallelism and pipeline parallelism are split determines the marginal cost of long sequences.
    • Decoding strategy: speculative decoding, quantization, and operator fusion reduce per-token latency.

    5. A Reproducible Evaluation Method (Readers Can Use Directly)

    Do not compare unit prices; compare “cost per effective task.” Suggested basis:

    1. cost per task = (input tokens × input price + output tokens × output price) / cache hit rate correction
    2. unit-cost score = task quality score / cost per task

    Four steps to put it into practice:

    1. Build a fixed set from your own 30–60 real tasks, recording input/output tokens and latency;
    2. Run three rounds each under the “default runtime” and the “optimized runtime,” and take the median;
    3. Also record cache hit rate, P95 latency, and the number of failed retries (retries are a hidden bill);
    4. Compute the score with the formula above, rather than ranking by the price sheet.

    6. Conclusion

    A low unit price does not mean a low bill. Sparse architecture and linear attention determine the theoretical lower bound; the runtime determines the actual realization rate. When choosing, replace “price per million tokens” with “cost per completed task,” and recompute with a fixed task set, so you avoid being misled by a single price tag. If you need to run the same kind of stress test on Baidu AI Cloud, you can combine the container platform, object storage, log service, and monitoring alerts to build a reproducible evaluation pipeline, making every cost conclusion traceable and reproducible.