Where Did the Compute Go? LLM Inference Bottlenecks and Governance
This article explains why LLM inference compute can disappear during model launches and traffic spikes. It covers four common causes—training and inference contention, long-context KV cache growth, exploratory user behavior, and peak-reserved capacity—and presents a practical model for memory, KV cache, throughput, and latency trade-offs. It then describes token-based quota and rate limiting, supply-side optimizations such as continuous batching, prefix reuse, quantization, disaggregated deployment, and speculative decoding, plus observability and organizational practices for aligning capacity, cost, and user experience.
1. Symptom: What a Rate-Limiting Notice Reveals About the Compute Ledger
A major model provider launched a new model version on the order of 3 trillion parameters. Within less than 12 hours after launch, quota consumption exceeded expectations, and strict rate limiting was triggered. Many paying members complained in community channels and through support tickets. Two days later, the provider issued an overnight apology, reset quotas for all subscribers, and added a 25% monthly quota credit.
If we translate this from a public-relations incident into an engineering incident, three signals become clear:
- The demand curve rises faster than the capacity curve. Traffic after a new model launch is not linear growth. Within hours, it can stack media testing, developer integration, and retry traffic from existing users.
- The cost per request is amplified. Parameter scale, context length, and reasoning-chain length together raise the compute cost per token. The same “monthly quota” corresponds to less physical compute under the new model.
- Rate limiting is the last gate, not the root fix. Rate limiting protected cluster availability, but it caused a sharp drop in user experience. The underlying issue was a mismatch between capacity planning and demand forecasting.
So the real question is not “Where did the compute go?” It is: “Who is consuming compute, at what rate, and how many useful tokens are we getting back?”
2. Four Real Paths Where Inference Compute “Disappears”
Path 1: Training and inference compete for the same accelerators. Large clusters often serve training, fine-tuning, and online inference workloads at the same time. Training jobs are long-running and consume accelerator capacity aggressively; once started, they are hard to preempt. Inference traffic, by contrast, is bursty. Without physical isolation or priority scheduling, starting a long-running training job can multiply queueing latency for online services.
Path 2: Long context amplifies memory usage multiplicatively. Model weights are a static memory cost, while the KV cache grows roughly linearly with concurrency multiplied by sequence length. When context length expands from a few thousand tokens to tens of thousands, the KV cache can overtake weights as the dominant memory item, directly reducing the available batch size.
Path 3: Exploratory calls in the early life of a new model. Users tend to write longer prompts, ask repeated follow-up questions, and retry immediately after failures. These behaviors are reasonable from a user-experience standpoint, but they significantly increase compute cost per useful output.
Path 4: Peak-to-average ratio and reserved headroom. To protect P99 latency, clusters must reserve capacity for peak load. From the daily average, these GPUs may look underutilized. From the peak second, they may already be saturated. Average utilization can hide how tight the system really is.
3. Making the Math Work: A Practical Quantified Model
First, set the right metrics. Do not measure cost only as “price per GPU per hour.” The core metrics should be cost per million tokens served and cost per unit of useful output.
An approximate relationship for memory usage is:
Memory usage ≈ model weights + KV cache × concurrent sequences + activations and temporary buffers + framework overhead
An illustrative estimate of KV cache size for a standard Transformer architecture:
def kv_cache_bytes(n_layers, n_kv_heads, head_dim, seq_len, batch=1, dtype_bytes=2):# K and V each take one copy, so multiply by 2return 2 * n_layers * n_kv_heads * head_dim * seq_len * batch * dtype_bytes
This function explains two common puzzles: why increasing the context window often reduces the maximum concurrency, and why architectural optimizations such as Grouped-Query Attention (GQA) can improve throughput significantly—GQA reduces the number of KV heads, which proportionally reduces cache usage.
The trade-off between throughput and latency also needs to be quantified:
Effective throughput ≈ batch size × output length / latency per batch
Batch size is constrained by memory, output length is constrained by business requirements, and per-batch latency is constrained by SLOs. These three form a triangle. Any request that says “we want long context, low latency, and high concurrency at the same time” must give up one side of that triangle.
4. Demand-Side Governance: Token-Based Quotas and Rate Limiting
Limiting by requests per minute is not enough, because one 20,000-token request may be more expensive than a thousand short requests. Quotas and rate limiting should be measured in tokens, and they should distinguish input tokens, output tokens, and cache-hit tokens.
Illustrative implementation (conceptual only, not tied to a specific framework):
import timeclass TokenBucket:def __init__(self, capacity, refill_rate):self.capacity = capacity # bucket capacity in tokensself.refill_rate = refill_rate # refill rate in tokens per secondself.tokens = capacityself.updated = time.monotonic()def _refill(self):now = time.monotonic()self.tokens = min(self.capacity,self.tokens + (now - self.updated) * self.refill_rate)self.updated = nowdef allow(self, est_tokens):self._refill()if self.tokens >= est_tokens:self.tokens -= est_tokensreturn Truereturn False
Four engineering practices should go with it:
- Estimate cost before admitting the request. Based on input length and historical output-length distribution, estimate token demand before the request enters. If the estimate is insufficient, fail fast instead of letting the request run halfway and then truncate it.
- Use tiers and priority queues. Interactive sessions should use a low-latency lane, while batch jobs should use a throughput lane. Paid tiers should be reflected in quotas and priorities, not in equal round-robin scheduling within the same queue.
- Support retries and idempotency. Rate-limit responses should include clear retry guidance and backoff recommendations. Clients should use exponential backoff with jitter. The same business request should carry an idempotency key so retries do not turn into a compute storm.
- Degrade gracefully instead of rejecting directly. First reduce context length, then switch to a smaller model, and only then queue or reject. A clear degradation path reduces the perceived impact on user experience.
5. Supply-Side Optimization: Extracting More Throughput per GPU
- Continuous batching. Dynamically insert and evict requests at iteration granularity instead of waiting for an entire batch to finish together. This can significantly improve accelerator utilization.
- Prefix and KV reuse. Shared prefixes such as system prompts, tool descriptions, and long documents should be computed only once. Cache-hit rate should be monitored as a first-class metric.
- Quantization and sparsification. Within an acceptable quality range, reducing weight precision or enabling mixture-of-experts routing can directly create more room for larger batches.
- Disaggregated deployment. Separate prefill, which is compute-intensive, from decode, which is memory-bandwidth-intensive, into different resource pools. Each pool can scale independently, avoiding resource mismatches caused by interference.
- Speculative decoding. A smaller model drafts tokens while the larger model verifies them, which can reduce the average number of decode steps in many scenarios.
- Autoscaling and warm-up. Scale-out should reserve time for replica warm-up. Scale-in should have a cooldown window to prevent flapping.
6. Observability: No Measurement, No Governance
At minimum, collect the following metrics and perform cost attribution:
- Latency side: time to first token (TTFT), time per output token (TPOT), and queueing time.
- Capacity side: KV-cache utilization, concurrency, batch-size distribution, and queue length.
- Cost side: input tokens, output tokens, cache-hit tokens, cost per million tokens, and cost per unit of useful output.
- Experience side: rate-limit rejection rate, degradation trigger rate, and retry rate.
Log records should include aggregatable fields so that cost and usage can be attributed by tenant and model:
{"tenant_id":"t-1024","model":"m-large","prompt_tokens":8192,"completion_tokens":512,"cache_hit_tokens":6144,"ttft_ms":420,"status":"rate_limited","retry_after_ms":1500}
7. Aligning Architecture, Organization, and Commercial Contracts
Capacity governance is not purely a technical issue. Quotas are service commitments to customers and must be aligned with pricing, SLAs, and capacity budgets. Practical steps include:
- Pushing compute budgets down to business teams and performing monthly attribution.
- Running load tests with real traffic distributions before launch, not only synthetic short requests.
- Adding “estimated token consumption” to the release-review checklist.
At the cloud-infrastructure layer, general-purpose capabilities can support this governance model: container platforms can handle elastic scaling and rolling releases; message queues can smooth traffic spikes and support task prioritization; object storage can hold long-context materials and knowledge-base assets; and logging, monitoring, and alerting services can collect metrics and link them to thresholds. Providers such as Baidu AI Cloud offer these general-purpose capability categories. However, specific product selection should be validated against your own workload characteristics rather than copied from someone else’s configuration.
8. Practical Checklist
- Use tokens, not request counts, as the unit for quotas and rate limiting.
- Before launch, quantify memory and throughput requirements, and make the “context length—concurrency—latency” trade-off explicit.
- Build tiered degradation paths, changing rate limiting from “reject” to “gradually downgrade.”
- Physically or priority-isolate training workloads from online inference.
- Enable continuous batching, prefix reuse, and autoscaling.
- Establish tenant-level cost attribution so quotas match actual bills.
- Prepare capacity plans and user-communication templates for every model upgrade.
Compute does not disappear into thin air. It is simply taken by longer contexts, higher concurrency, and steeper demand curves. Teams that can calculate capacity in advance, observe it in real time, and degrade in a tiered way are the ones most likely to turn a painful launch into a smooth upgrade.
