AI Compute Demand Is Being Reshaped: From Inference to Agents
This article explains why AI is rewriting the compute stack rather than simply running on top of it, and why demand is growing by orders of magnitude as workloads shift from single-pass generation to multi-step agentic execution. It covers the structural constraints on compute supply, practical engineering optimizations for agent scenarios such as context governance, model routing, caching, tool-call governance and observability, a general cloud deployment approach, and common capacity-planning mistakes to avoid.
1. Introduction: AI Is a Rewrite of the Compute Stack, Not an App Layered on Top
Over the past two years, the industry’s view of AI has shifted noticeably. It was first treated as “just another application,” and later recognized as something closer to a rewrite of the entire computing stack. Traditional applications are deterministic: input determines output, and CPU-to-memory ratios, database read amplification, and cache hit rates can all be modeled with reasonable precision. AI applications, by contrast, have a probabilistic mapping between input and output. The same request can consume vastly different amounts of compute depending on context, which breaks the existing capacity-planning paradigm outright.
Against this backdrop, compute supply has become the focus of industry competition, and the reason is not mysterious. The core output of large-model serving is tokens, and token production depends heavily on accelerated compute, so the gross-margin structure per unit of output differs sharply from that of traditional software. When call volume on the demand side grows quickly, capacity ramp-up on the supply side is constrained by chip delivery, data center power, network interconnect, and cluster bring-up cycles. “Securing capacity” therefore becomes an inevitable outcome.
The more consequential change is in task shape. Early generative tasks were mostly single-turn text production, with compute concentrated in one forward pass. When a model has to understand, reason, plan, and call tools to take real action, the chain stretches into several or even dozens of alternating rounds, and the required compute jumps by orders of magnitude. It is widely held in the industry that tool-using tasks consume roughly three orders of magnitude more compute than purely generative ones. This article attempts to break that phenomenon down into an engineering problem that can be analyzed and optimized.
2. Why Compute Demand Grows by Orders of Magnitude
2.1 From a Single Forward Pass to Multi-Round Alternation
Single-turn generation has relatively simple compute characteristics: a prefill stage processes the input context, and a decode stage produces tokens one by one. In planning tasks, the model must first decompose the goal, then decide which tool to call, wait for the external result, and fold that result back into the context to continue reasoning. Every tool call means a full context rebuild and attention recomputation; the longer the context, the larger the repeated-compute overhead.
The execution loop can be understood schematically as follows:
# Pseudocode: plan-act-observe loopcontext = [system_prompt, user_goal]for step in range(max_steps):decision = model.generate(context) # reasoning and planningif decision.type == "final":return decision.answerobservation = tool_registry.call( # tool calldecision.tool, decision.args)context.append(decision) # context keeps growingcontext.append(observation)
This loop reveals where the cost comes from: number of rounds multiplied by context length per round, multiplied by decode steps per round. If the average number of rounds is ten and context grows linearly with each round, actual compute far exceeds the intuitive estimate for a single-turn scenario.
2.2 Attention Overhead from Long Contexts
Attention complexity grows superlinearly with sequence length. Long contexts not only increase memory footprint but also amplify capacity pressure on the key-value cache. Under concurrency, the KV cache often becomes the memory bottleneck, directly limiting how many concurrent requests a single card can carry and thereby pushing up the cost per token.
2.3 Concurrency Shift: From Throughput-Friendly to Latency-Sensitive
Generative tasks are often batch workloads that tolerate latency, while an agent’s multi-round chain is sensitive to both time-to-first-token and inter-round latency. The batching window is compressed, so the scheduler must rebalance throughput against latency, and resource utilization drops as a result.
3. Structural Constraints on Compute Supply
Capacity is not determined by accelerator count alone. Delivering one usable inference service requires all of the following to be satisfied at once:
- Accelerated compute: training and inference use different card types, and inference cares more about memory capacity and bandwidth;
- High-speed interconnect: in multi-node, multi-card parallelism, communication overhead can directly determine scaling efficiency;
- Power and cooling: power density per rack is rising, and data center retrofit costs are often underestimated;
- Storage and data paths: model weight loading and session-state persistence depend on high-throughput storage;
- Operations: monitoring and alerting, logging, canary release, and self-healing set the floor for availability.
A shortfall in any one link turns into lost effective capacity. Capacity planning should therefore shift from “card count” to two business metrics: servable concurrency and cost per token.
4. Engineering Optimization Paths for Agent Scenarios
4.1 Context Governance
Manage context in layers: place the stable parts (system instructions, tool descriptions) up front and reuse their cache; summarize and compress the volatile parts (historical observations); and set length limits plus structured trimming on tool returns so irrelevant fields never enter the context.
4.2 Layered Inference Routing
Route tasks by complexity: send simple requests to smaller models or rule-based handling, and escalate only complex planning to larger models. In most businesses this layering lowers average cost significantly while preserving quality on the critical path.
4.3 Cache Reuse and Batching Strategy
Enable prefix-cache reuse for requests sharing the same prefix; use continuous batching for offline tasks that tolerate latency in order to raise throughput; and use small-batch, low-latency configurations for interactive chains. Deploy the three traffic classes in isolation so they do not interfere with each other.
4.4 Tool-Call Governance
A growing tool set raises both prompt length and the mis-call rate. It is advisable to establish a tool registry with tiered permissions, add confirmation and idempotency design for write-type tools, and validate call results before feeding them back into the context.
{"tool": "query_order_status","risk_level": "read_only","timeout_ms": 800,"max_result_tokens": 512,"idempotent": true}
4.5 Observability and Cost Attribution
Instrument by request chain, recording round count, context length, cache hit rate, tool latency, and retry count, and build a per-task cost dashboard. Without fine-grained attribution, optimization can only rely on guesswork.
5. A General Approach to Running This on the Cloud
Building this kind of service in a cloud environment typically combines a set of general-purpose capabilities: a container platform to host inference services and elastic scaling; object storage for model weights and datasets; a message queue to smooth peaks and decouple long-running tasks; logging plus monitoring and alerting for end-to-end observability; and key and configuration management to keep credentials secure. Baidu AI Cloud offers standardized combinations of such general capabilities, which enterprises can compose freely according to their own traffic characteristics rather than being locked into a specific architecture.
The point to stress is that architecture choices should be driven by business metrics: if tasks are mainly short interactions, prioritize latency and cache hit rate; if they are mainly batch processing, prioritize throughput and resource utilization.
6. Common Pitfalls
- Planning inference capacity with a training mindset, ignoring memory and bandwidth bottlenecks;
- Counting only call volume without attributing cost per task, which sends optimization in the wrong direction;
- Expanding the tool set without limit, which actually lowers task completion rates;
- Ignoring retries and failure compensation, turning occasional jitter into a cost black hole;
- Co-locating all traffic, so interactive and offline tasks compete for the same resources.
7. Conclusion
AI’s reshaping of the computing industry is essentially the introduction of uncertainty into capacity planning and cost models. A chain made up of understanding, reasoning, planning, and tool calls amplifies compute demand by orders of magnitude, and amplifies the room for engineering optimization just as much. For developers, real competitiveness lies not in piling up resources but in organizing context, model layering, caching, scheduling, and observability into a technical system that can keep evolving.
