LLM Inference Cost Reduction and Throughput Optimization: A Practical Guide
This article breaks down how to reduce costs and improve throughput in large language model inference systems by looking at throughput and per-GPU revenue together. It covers three main engineering tracks—multi-vendor chip compatibility, separating prefill and decode onto different hardware tiers, and retaining KVCache for 72 hours or more—plus the observability metrics and capacity planning needed to close the optimization loop. Readers will find reusable methods for capacity estimation, routing logic, cache eviction, and unit economics, illustrated with code snippets and formulas.
1. Why Throughput and Revenue per GPU Must Be Measured Together
A model’s capability ceiling is set by the model itself, but the price at which each token is ultimately delivered depends on the engineering quality of the inference system. Two sets of numbers commonly circulate in the industry: scale metrics, such as the total number of tokens a single cluster processes per day; and unit economics metrics, such as the revenue generated per accelerator card per hour. Looking at either set in isolation leads to misjudgment—focusing only on scale tends to hide marginal cost, while focusing only on unit price tends to hide how fixed costs are amortized.
Put both on the same table, and the real question the system must answer becomes: under the same GPU-hour budget, how do we serve more effective requests while minimizing redundant computation? This article takes as its background a scale publicly disclosed by a cloud vendor (roughly 155 trillion tokens per day per cluster, and about $38 per GPU-hour overall), and abstracts reusable engineering methods from it without binding to any specific product implementation.
It is worth aligning definitions first, otherwise later optimization work spins in place:
- Throughput definition: does it count input tokens, output tokens, or a weighted combination of both; does it include the portion served by cache hits.
- Revenue definition: is it list price, discounted price, or actual settled price; does it include the long-context premium.
- Cost definition: GPU-hours only, or also the hidden overhead of networking, storage, operations, and failed retries.
2. Track One: Multi-Vendor Chip Compatibility and Full Utilization
Heterogeneous compute is the norm. A single cluster may contain both general-purpose GPUs and domestic accelerators; if the upper-layer framework is tightly coupled to one hardware type, structural waste appears in the form of “not enough of the peak card type while other card types sit idle.”
Engineering practice usually decouples this in three layers:
- Operator layer: describe the computation graph with a unified tensor abstraction, provide operator implementations and automatic fallback paths for different backends, and fall back to a generic implementation when an operator is missing rather than failing outright.
- Communication layer: abstract the collective communication of tensor parallelism and pipeline parallelism into a unified interface, automatically selecting the communication backend and parallelism degree according to the topology.
- Scheduling layer: use the “card type—model—parallel strategy” triple as the schedulable unit, routing requests to the pool with the lowest cost that still satisfies the latency constraint.
Illustrative capability probing and routing logic:
def pick_pool(req, pools):# pools: [{'chip': 'A', 'free': 12, 'ttft_ms': 180, 'cost': 1.0}, ...]cands = [p for p in pools if p['free'] >= req.min_cards]cands = [p for p in cands if p['ttft_ms'] <= req.ttft_slo]return min(cands, key=lambda p: p['cost']) if cands else None
The key to “full utilization” is not peak capacity but steady-state utilization. Practical points include: continuous batching that mixes long and short requests to raise occupancy; a more aggressive batch-wait window for requests with short outputs; and memory defragmentation plus paged cache management to avoid the situation where “there are free cards but nothing fits.”
3. Track Two: Organize Hardware by Stage, Separating Prefill from Decode
Inference splits into two stages with completely different characteristics. Prefill processes the input: it is compute-intensive, highly parallel, and its time scales roughly linearly with input length. Decode generates tokens one by one: it is memory-access-intensive, has low parallelism, and is extremely sensitive to bandwidth and batch size. Co-locating them causes mutual interference—long inputs block the decode queue, making output rates jitter.
A layered approach is common practice: use smaller general-purpose instances (such as 8-card nodes) for prefill, and large-scale super nodes (64–128 cards with high-bandwidth inter-card interconnect) for decode, passing KVCache between them via a message queue or distributed cache.
The ratio can be estimated from workload characteristics:
prefill_cards ≈ (daily input tokens × average repetition factor) / (per-GPU prefill throughput × 86400)decode_cards ≈ daily output tokens / (per-GPU decode throughput × 86400 × target utilization)
Three tuning rules of thumb: first, bucket by input length and route extra-long requests separately so they do not slow down everything else; second, on the decode side prioritize larger batches and better bandwidth utilization, while on the prefill side prioritize higher parallelism and operator efficiency; third, enable elastic scaling that adds or removes replicas on both sides dynamically based on queue backlog and remaining SLO headroom.
4. Track Three: Retain KVCache for More Than 72 Hours
Repeated prefill is the most easily overlooked cost sink. System prompts, long documents, code repository context, and multi-turn conversation history all cause the same prefix to be recomputed over and over. Extending the cache window from minutes to more than 72 hours is essentially trading storage for compute.
Implementation points:
- Tiered storage: keep the hottest prefixes in GPU memory, the next tier in host memory, and let object storage or a distributed file system handle warm and cold data, migrating it back on demand after a hit.
- Prefix hash addressing: hash the token sequence in blocks and compare block by block, supporting partial hits rather than requiring a full match.
- Eviction policy: use “saved prefill compute − storage and migration overhead” as the value function instead of plain LRU.
def cache_value(block, now):saved = block.est_prefill_cost # compute savedcost = block.storage_cost * (now - block.last_hit) / 3600return saved / max(cost, 1e-6)
Request-side optimization makes this work better: placing stable content first and volatile content last significantly raises the prefix hit rate; for multi-turn conversations, keep the system segment fixed and avoid mid-session rewrites that invalidate the whole cache.
5. Closing the Loop: Observability and Capacity Planning
Without measurement there is no cost reduction. At minimum, four categories of metrics are needed: percentile values of TTFT and TPOT; cache hit rate and migration bandwidth; steady-state utilization of each card pool; and cost per token (GPU-hours per thousand tokens). A weekly capacity review is recommended, putting SLO headroom, hit rate, and unit price on the same dashboard, so as to avoid “sacrificing experience to cut cost” or “scaling without limit for the sake of experience.”
A simplified unit economics expression:
Revenue per GPU-hour = effective token throughput × unit price / number of GPUsEffective token throughput = raw throughput × (1 + cache-hit conversion gain) × steady-state utilization
The conclusion is straightforward: throughput determines scale, caching and staging determine cost, and heterogeneous compatibility keeps resources from sitting idle. Only when the three stack together can fixed costs be continuously amortized on the same set of cards, turning unit economics into a reusable engineering capability rather than a one-off tuning result.
