When Compute Is Constrained: Why Memory Is the Critical Bottleneck in AI Infrastructure

    When compute supply is tight, memory—not accelerator peak FLOPS—is often what limits large-language-model serving. This article explains why. It first separates technical momentum from engineering delivery, then shows how compute supply is gated by four serial constraints (wafers, memory, power, and on-site labor). It explains why memory bandwidth dominates the decode phase using the Roofline model, why KV cache becomes the real cost center for long context, and how to size a per-GPU memory budget. It closes with six engineering techniques to relieve memory pressure, an observability checklist, scheduling and quota practices, and a general cloud deployment path.

    Shipping First Isn’t the Same as Delivering First

    Recently a leader at a top cloud provider made a thought-provoking point in a public interview: the technical direction of large models isn’t something any single team owns. “Getting there first” carries a large element of chance—everyone is exploring during the prototype phase. What actually opens up a gap is who first turns capability into a product form that is high-frequency, verifiable, and capable of closing a feedback loop, and who happens to catch the window for a distribution channel.

    This holds up from an engineering standpoint and can be distilled into three principles:

    1. The window is defined by “deliverable experience,” not by papers or internal demos. The distance between a model that “can answer questions correctly” and one that “can be used stably by millions” spans an entire pipeline: instruction alignment, long-context stability, reliable tool calling, rate limiting and graceful degradation, evaluation regression, and content safety. Whoever completes this pipeline first gets the real traffic and real feedback first.
    2. High-frequency, verifiable scenarios accelerate iteration. Coding assistance became an early breakthrough for structural reasons: code has clear correctness criteria (it compiles, unit tests pass), user feedback is immediate, context is naturally structured, and the cost of failure is controllable. These scenarios can accumulate enormous volumes of “input–expected output” pairs within weeks, which in turn feed alignment and evaluation systems.
    3. Distribution channels determine learning speed. Teams that already have touchpoints—developer communities, code-hosting platforms, office suites—naturally get usage data faster than teams with only a model API. Conversely, teams with capability but no channel have to make up the time gap through business development and ecosystem building.

    The takeaway: a first-mover advantage in model capability is easy to close, but the compounding returns of an “engineering delivery system + distribution channel + feedback loop” are hard to close. This also explains why, in the same period, the gap on public benchmarks narrows quickly while the gap in real-world stability persists.

    Compute Supply Is Not a Single Variable but Four Serial Constraints

    The same leader raised a very practical problem: compute supply is being constrained simultaneously by advanced-node wafer capacity, memory supply, power capacity, and on-site construction labor (including licensed electrical and HVAC staff). These four constraints are in series—total supply capacity is set by the shortest board, not by the theoretical peak of the accelerator itself.

    Broken down by delivery order, top to bottom:

    Layer Constraint Typical Delivery Cycle Can Software Help?
    Wafers and advanced packaging Advanced-node scheduling; 2.5D/3D advanced packaging and test capacity Long (quarters to a year) No
    Memory HBM and standard server DRAM share capacity; both capacity and bandwidth are tight at once Long (quarters) Partially (quantization, cache optimization)
    Power and cooling Rising rack power density; power distribution and grid interconnection lead times; liquid-cooling retrofits Medium to long term Partially (energy-efficient scheduling)
    On-site labor Licensed electricians, HVAC, low-voltage, and network construction and operations Medium to long term, and not compressible Partially (automation, prefabrication)

    The last row deserves emphasis. You can order equipment, and you can schedule chip production, but power-distribution retrofits, busbar installation, cold-aisle construction, and acceptance must have licensed personnel on site. This labor supply can’t be scaled up in the short term by throwing capital at it. That’s why more and more infrastructure teams manage “build time” as a harder bottleneck than “procurement time,” with supporting practices such as modular prefabricated data halls, remote operations, automated inspection, and standardizing delivery and acceptance workflows as much as possible.

    Why Memory Is the First Bottleneck in the Decode Phase

    Among all the constraints, memory is considered the most critical because of the computational characteristics of LLM inference. Autoregressive decoding has two phases, and their bottlenecks are completely different:

    • Prefill: processes the entire input in parallel; the matrix multiplications are large and it is usually compute-bound.
    • Decode: generates one token per step; the matrix multiplications degrade into “matrix–vector” operations and it is memory-bandwidth-bound.

    The Roofline model makes this quantifiable. For each token the decode phase advances, it has to move all the weights from memory to the compute units once, while the computation is roughly the number of parameters times 2. In other words, the arithmetic intensity (floating-point operations completed per byte read) is only about 2 FLOP/Byte at batch=1. The ratio of peak compute to memory bandwidth on modern accelerators is usually on the order of hundreds of FLOP/Byte—two orders of magnitude apart—which means the compute units spend most of their time waiting for data during decode.

    This yields a very useful upper-bound estimate of throughput:

    1. def decode_tokens_per_sec(batch, weights_gb, kv_gb, bw_tbs, num_params):
    2. """Upper bound on decode-phase throughput (ideal case, memory-bandwidth-bound only)"""
    3. bytes_per_step = (weights_gb + kv_gb) * 1024**3 # each step must read all weights + the full KV cache once
    4. steps_per_sec = (bw_tbs * 1e12) / bytes_per_step
    5. return steps_per_sec * batch, 2 * num_params * batch * steps_per_sec
    6. WEIGHTS_GB = 140 # example: quantized weights resident in memory
    7. KV_GB = 24 # example: total KV cache held by the current batch
    8. BW_TBS = 3.0 # example: memory bandwidth in TB/s
    9. for b in (1, 8, 32):
    10. tps, flops = decode_tokens_per_sec(b, WEIGHTS_GB, KV_GB, BW_TBS, 70e9)
    11. print(f"batch={b:>2} per-request {tps/b:5.1f} tok/s total {tps:6.0f} tok/s {flops/1e12:5.1f} TFLOPS")

    The output reveals a key pattern: before compute is saturated, increasing the batch size barely raises per-request latency but increases total throughput nearly linearly. This is the core economics of server-side inference—the GPU’s cost is amortized over tokens, not over requests. (Note: kv_gb should grow with the batch; as the batch keeps increasing and approaches peak compute, the linear relationship breaks and the system enters the compute-bound region.)

    KV Cache: The Real Cost Center for Long Context

    Weights aren’t the only thing occupying memory. The KV cache grows linearly with “layers × sequence length × concurrency,” and multi-turn conversations, long-document analysis, and long agent trajectories push sequence length to tens of thousands or even hundreds of thousands of characters, quickly making the KV cache the dominant term:

    1. def kv_cache_gib(n_layers, kv_heads, head_dim, seq_len, batch=1, dtype_bytes=2):
    2. # Each layer caches both K and V tensors, hence the factor of 2
    3. per_token = 2 * kv_heads * head_dim * dtype_bytes
    4. return n_layers * seq_len * batch * per_token / 1024**3
    5. # Example params: 80 layers, 8 KV heads (grouped-query attention), head_dim=128
    6. print(f"Single 128K context: {kv_cache_gib(80, 8, 128, 131072):.1f} GiB")
    7. # With multi-head attention (32 KV heads) instead, the same sequence would take 4x
    8. print(f"Same config with MHA: {kv_cache_gib(80, 32, 128, 131072):.1f} GiB")

    With these example parameters, a single 128K context consumes about 39 GiB of memory—and that doesn’t include the weights. This explains three things: why structures that reduce KV usage, such as grouped-query attention and sliding-window attention, are widely adopted; why “supporting long context” and “supporting high-concurrency long context” are two completely different service tiers; and why memory capacity often runs out before compute does.

    How to Size the Memory Budget

    For capacity planning, always reconcile against the identity below—overlooking any single term will show up during load testing as a mysterious OOM:

    1. Per-GPU memory budget = resident weights + KV cache (concurrency x sequence length) + activations and transient buffers
    2. + memory fragmentation and reserved headroom (10%~15% recommended)
    3. + parallel-communication buffers (NCCL-style buffers under tensor/pipeline parallelism)

    Six Engineering Techniques to Relieve Memory Pressure

    These are all standard industry practices that can be combined, and their benefits are largely additive:

    1. Quantization to cut resident usage. Dropping weights from FP16 to FP8/INT8 usually halves memory and bandwidth demand directly; weight-only INT4 schemes compress further but require assessing the precision loss from activation outliers. Run a before-and-after regression on your own business evaluation set rather than looking only at general leaderboards.
    2. Structural KV-cache optimization. Grouped-query/multi-query attention reduce the number of KV heads; sliding-window or layered attention limit how much history is retained; sparsify the KV of layers whose intermediate values can be discarded. Memory saved structurally is equivalent to free capacity expansion.
    3. Paged KV management to eliminate fragmentation. Slice the KV cache into fixed-size blocks (pages) and allocate and reclaim by block instead of reserving contiguous space sized to the maximum sequence length. This is the key to fixing “there’s plenty of memory free but a new request still won’t fit,” and it is the dividing line between high-concurrency serving and an experiment script.
    4. Continuous batching and dynamic scheduling. Traditional static batching has to wait for the longest request in the whole batch to finish before freeing resources, causing severe head-of-line blocking. Switching to iteration-level continuous batching—where requests exit as soon as they finish and new requests are inserted immediately—improves memory utilization and throughput at the same time. Combined with priority queues and preemption, you can set different SLOs for interactive online traffic and offline batch jobs.
    5. Prefix caching and reuse. System prompts, tool definitions, few-shot examples, and long documents are often identical across many requests. Caching and reusing the prefill results for this part reduces both time-to-first-token (TTFT) and prefill compute consumption; hit rates are usually much higher than expected.
    6. Tiered caching and speculative decoding. When the KV cache or session state exceeds memory capacity, you can tier offload in the order “memory → local fast disk → object storage,” swapping out cold sessions and migrating them back on a hit. Speculative decoding uses a small draft model to guess several tokens at once and then has the main model verify them, which can lower latency but consumes extra compute—so it is a trade-off between latency sensitivity and throughput priority.

    Observability: You Can’t Optimize What You Can’t Measure

    Optimizing a memory bottleneck has to be built on measurement. Collect at least the following metrics, and view them by P50/P95/P99 percentiles:

    • Service metrics: TTFT (time to first token), TPOT (time per output token), end-to-end latency, queueing time, timeout and degradation rates;
    • Capacity metrics: memory usage and peak, KV cache occupancy, paged-block fragmentation rate, prefix cache hit rate, current effective batch size and maximum concurrency;
    • Efficiency metrics: memory bandwidth utilization (to tell whether you’ve hit the Roofline ceiling), accelerator utilization, compute and power cost per million tokens, per-rack power consumption and PUE;
    • Business metrics: the traffic split across different model sizes, small-model interception rate, and the cost reduction from caching and batching.

    One practical load-testing methodology: test with a fixed distribution of input and output lengths rather than with average length. Tail requests determine peak memory and P99 latency, and averages systematically underestimate capacity needs. At the same time, use Little’s Law (concurrency ≈ throughput × average latency) to back out the required concurrency ceiling and cross-check it against the memory budget.

    Organization and Scheduling: Managing Scarce Resources Like an Investment Portfolio

    When supply is constrained, management actions matter as much as chip selection. Practical options include:

    • Centralized quota and priority governance: establish a single entry point for compute scheduling and allocate quotas by business value, so individual teams don’t privately hoard idle resources;
    • Preemptible mixed deployment: put interruptible training, fine-tuning, and batch-evaluation jobs in a low-priority queue so they yield quickly when online inference preempts them, which significantly improves overall utilization;
    • Utilization in the SLO: don’t measure only “did the job finish,” but also accelerator utilization and unit cost—otherwise scarce resources get tied up by inefficient experiments for a long time;
    • Demand-side governance: at the routing layer, direct requests of different complexity to different model sizes, set caps on context length and output length, and enable caching and batching—these often pay off faster than adding capacity.

    A General Path to Production on the Cloud

    For most enterprises, building a full stack in-house isn’t the optimal choice. More commonly, they hand elasticity off to general-purpose cloud capabilities and focus on the model and business logic. A typical path: run inference services on a container platform with autoscaling; decouple and smooth out batch and asynchronous jobs through a message queue; keep model weights, datasets, and cold-session state in object storage; and wire logs and metrics into unified logging and monitoring/alerting, forming a closed-loop “capacity–latency–cost” dashboard. Cloud platforms such as Baidu AI Cloud provide exactly this kind of general-purpose capability (containers, object storage, message queues, logging, monitoring and alerting, and model serving). When choosing, go back and validate against your own quantitative metrics rather than against general leaderboards.

    Conclusion

    The two remarks by that leader—that “open-source models perform well” and that “self-built accelerators require you to allocate them yourself”—actually point to the same thing: competition at the model layer is now highly public, and the real differentiation is sinking down into supply and engineering. Whoever can break the constraints of wafers, memory, power, and labor into measurable metrics, and whoever can combine techniques like quantization, paged KV, continuous batching, and prefix caching into a stable service capability, holds a moat that no single model iteration can erase. Being first only means catching a window; steadily optimizing memory utilization, cost per token, and P99 latency is the engineering capability that survives the cycles.