LLM Inference Costs Explained: From Memory Bandwidth to Pricing

    Large language model costs depend on more than parameter counts or accelerator performance. This article explains how compute, memory access, communication, batching, and latency requirements shape inference efficiency and pricing. It also examines mixture-of-experts deployment, training-versus-serving trade-offs, the limits of architecture inference from public prices, and a practical evaluation process focused on cost per successful task.

    An LLM’s capabilities are usually judged by the quality of its answers. Its cost and response speed, however, often depend on lower-level questions: where parameters are stored, how data moves, how many requests are processed together, and how devices exchange intermediate results.

    Understanding these questions does not require a deep dive into chip circuitry. Three basic models—computation, memory access, and communication—can explain several seemingly counterintuitive outcomes: why lower latency can carry a substantial price premium, why increasing total parameters does not necessarily increase per-token computation proportionally, and why a larger cluster does not always deliver faster inference.

    Before drawing conclusions, it is important to distinguish observations from assumptions. Public prices and response times offer clues, but they cannot uniquely reveal a model’s parameter count, number of experts, or training data volume. Precise multipliers without clearly stated conditions should not be treated as universal rules.

    1. A Common Framework: What Does Inference Consume?

    From an engineering perspective, LLM inference uses at least three categories of resources.

    Compute resources handle matrix operations, attention calculations, and other tensor operations.

    Memory capacity and access resources support model weights, runtime intermediate results, and the key-value cache retained for previous context. Whether weights fit in accelerator memory and whether they can be read quickly enough are separate questions.

    Communication resources move data between accelerators when a model is distributed across devices. This may involve exchanging tensors, aggregating computation results, or sending tokens to their assigned expert networks.

    A useful starting point is this idealized lower bound:

    1. Stage time ≥ max(
    2. computation / effective compute throughput,
    3. data accessed / effective memory bandwidth,
    4. data communicated / effective network bandwidth
    5. )

    This expression identifies bottlenecks rather than predicting exact execution time. Real systems also incur synchronization waits, scheduling overhead, network startup latency, and execution stages that cannot fully overlap. Actual runtime is therefore usually higher.

    The immediate implication is that adding compute capacity may not help. If weight reads dominate execution time, faster matrix computation may provide limited gains. If cross-device communication dominates, adding devices can increase coordination costs instead of improving performance.

    2. Why Prefill and Decode Must Be Evaluated Separately

    LLM inference does not have the same resource profile throughout execution. It is typically divided into prompt processing, or prefill, and token-by-token generation, or decode.

    Prefill: More Parallelism, but Long Contexts Add Pressure

    During prefill, the system processes the input sequence and builds the internal state needed for generation. Because the full input is already available, multiple positions can be processed in parallel, making it easier to execute larger matrix operations.

    With conventional full attention, longer sequences also introduce substantial attention computation. Actual memory usage and execution efficiency depend on the implementation; theoretical complexity should not be equated directly with practical resource consumption.

    A request with a long input can therefore have a high time to first token even if it generates only a short response.

    Decode: Sequential Dependencies Expose Bandwidth Bottlenecks

    In typical autoregressive generation, each new token depends on the content generated before it. A single request cannot generate all output positions in parallel.

    At low concurrency, each generation step may read a large amount of model weights while performing relatively little computation. The accelerator’s compute units may remain underutilized. The system must also access the historical key-value cache, and this overhead generally becomes more significant as context grows.

    This is why fast input processing and fast output generation are different capabilities. It also explains why a single average response-time metric is insufficient for evaluating a service.

    3. How Batching Reduces Unit Cost

    Batching allows multiple requests to share expensive data access and computation setup.

    Consider a simplified linear layer. For one request, an input vector is multiplied by a weight matrix. When multiple requests execute together, their inputs can be arranged into a matrix, increasing reuse of the weights after they are read and improving matrix-operation efficiency.

    Suppose a layer reads W bytes of weights while processing B tokens together. Under idealized conditions that ignore caching, sharding, and additional overhead:

    1. Amortized weight reads per token ≈ W / B

    Here, B is better understood as the number of tokens participating in the current execution step, not necessarily the number of user requests. During prefill, a single request can contribute many tokens that are processed in parallel.

    Batching benefits do not grow indefinitely. Once compute units approach saturation, or KV-cache capacity, memory bandwidth, or communication becomes the next bottleneck, larger batches produce diminishing returns.

    There is therefore no universal multiplier for how much more expensive unbatched inference is. The difference depends on model size, numerical precision, hardware, context length, and workload characteristics.

    What Continuous Batching Solves

    Online requests arrive at different times and have different input and output lengths. If a system waits for every request in a batch to finish before admitting new ones, completed short requests leave unused execution slots.

    Continuous batching lets the system remove completed requests and admit new ones during generation, improving utilization.

    It also makes scheduling more complex. The system must continuously balance throughput, waiting time, fairness, and cache capacity. Long requests should not monopolize resources, while short requests should not repeatedly crowd out longer ones.

    4. Why Low-Latency Services Can Cost Much More

    Users are paying not only for a result, but also for how quickly it arrives and whether the service remains reliable during peak demand.

    To reduce latency, a provider may shorten queues, limit batch sizes, reserve more idle capacity, or isolate interactive requests from background tasks. These measures often reduce average resource utilization.

    As a result, a modest improvement in response speed can come with a larger increase in unit price. The premium may reflect capacity reservations, tail-latency guarantees, and the cost of maintaining peak-time availability—not just the execution time of an individual request.

    Conversely, allowing a longer wait can create opportunities to reduce costs. Background jobs may wait for more efficient batch sizes or run outside periods of resource contention.

    But slower service is not automatically cheaper. Simply delaying the return of a completed result does not necessarily reduce costs if scheduling and resource utilization remain unchanged.

    For application design, the better approach is to define business deadlines explicitly:

    • Real-time interactions: Prioritize time to first token, generation speed, and tail latency.
    • Document batch processing: Prioritize completion deadlines, total throughput, and effective unit cost.
    • Mixed workloads: Use separate queues where practical so background jobs do not degrade interactive performance.

    5. Mixture of Experts: Less Computation Does Not Eliminate System Costs

    A mixture-of-experts, or MoE, architecture divides some network layers into multiple expert subnetworks. A routing mechanism selects a subset of experts for each token.

    Its defining feature is the separation between total parameter count and the parameters activated for an individual token. A model can contain many parameters without executing every expert for every token.

    Three quantities must be kept distinct:

    1. Total parameters, which primarily affect weight-storage requirements.
    2. Parameters activated per token, which affect part of the forward-pass computation.
    3. Data exchanged between experts and devices, which affects distributed execution efficiency.

    Sparse activation does not remove memory or networking costs. Experts not selected for the current token must still remain available within the serving system. Intermediate results created by routing must also be transferred and collected promptly.

    Why Expert Routing Can Become Network-Bound

    When experts reside on different devices, tokens handled by one device may need to be sent to several destinations. After expert computation, the results must return and participate in subsequent computation. This process commonly involves all-to-all-style data exchange.

    Unlike communication between a few neighboring devices, it places demands on overall network bandwidth, switching capacity, and congestion control.

    Uneven expert loads can also reduce efficiency. If many tokens select a small number of experts, some devices may be busy while others remain relatively idle. Even with sufficient network bandwidth, the busiest expert may determine overall execution time.

    MoE optimization therefore involves more than faster communication. It also includes balanced routing, expert placement, overlapping computation with communication, and, where necessary, replicating heavily used experts.

    6. Racks Matter, but They Are Not a Fixed Model-Size Limit

    In some clusters, devices within a high-speed interconnect domain have higher bandwidth and lower latency. Communication outside that domain may traverse additional switching layers and exhibit different performance characteristics.

    This affects expert placement. Keeping frequent data exchanges within a high-speed interconnect domain generally makes efficient execution easier.

    It does not mean that every MoE model must fit within one rack, nor that cross-rack performance has a universal penalty. Results depend on device topology, network configuration, parallelization strategy, and communication workload.

    A more accurate principle is that a high-speed interconnect domain defines the scope of inexpensive, frequent communication. Scaling beyond it requires additional system design.

    Common approaches include:

    • Placing communication-intensive computation within the same high-speed interconnect domain.
    • Using hierarchical routing to reduce unnecessary cross-domain exchanges.
    • Replicating experts to relieve hotspots, at the cost of additional storage.
    • Overlapping some communication with computation to reduce waiting on the critical path.
    • Designing deployments that combine tensor, pipeline, and expert parallelism.

    Each approach involves trade-offs. No fixed configuration is optimal for every model and workload.

    7. Why the Training Optimum May Not Be the Product Optimum

    Training-efficiency discussions often ask: given a compute budget, how large should the model be, and how much data should it use?

    Scaling-law research shows that model size, training data volume, and compute budget have analyzable relationships under particular assumptions and experimental conditions. Those relationships cannot be applied without considering data quality, architecture, and training objectives.

    More importantly, deployment decisions concern the model’s entire lifecycle, not just one training run.

    A rough breakdown is:

    1. Total cost =
    2. training and iteration costs
    3. + cumulative inference costs
    4. + storage and operational costs

    If a model will serve a large number of requests, spending more training compute to achieve the required quality with a smaller model may reduce lifetime costs.

    The configuration that is optimal for training compute is therefore not necessarily optimal for commercial serving. Training longer than a particular theoretical optimum cannot automatically be labeled wasteful.

    Without public information about parameter counts, data processing, and how training compute is measured, claims that a model deviates from an optimum by a precise multiplier are not justified. Define the optimization objective before assessing the deviation.

    8. Public Prices Offer Clues, Not a Blueprint of the Architecture

    Differences between input and output prices, long-context surcharges, caching discounts, and service tiers may reflect underlying resource costs.

    For example, output generation has sequential dependencies and cannot be parallelized as extensively as prefill. Cache hits may reduce repeated prompt computation. These mechanisms help explain pricing structures.

    However, prices also reflect business strategy, capacity supply and demand, service guarantees, and discounts. The same pricing structure can correspond to different architectures and deployment choices.

    Inferring architecture from pricing should follow three steps:

    1. List plausible explanations rather than assuming a single conclusion.
    2. Seek additional evidence, such as latency changes across input lengths, concurrency levels, and output lengths.
    3. Separate observed facts, engineering hypotheses, and unverified information.

    This approach is more reliable than deriving an exact expert count from one price ratio, and it is more useful for practical service selection.

    9. How Developers Can Build a Verifiable Evaluation Process

    Reducing inference costs starts with identifying where resources are being spent. Four areas deserve particular attention.

    Use Representative Workloads

    Test sets should cover short questions, long documents, long outputs, and multiple concurrency levels. A benchmark based on one short prompt rarely represents production traffic.

    Record input and output lengths separately rather than counting requests alone. The same number of requests can represent very different amounts of work.

    Measure Key Metrics Separately

    At minimum, record:

    • Time to first token.
    • Inter-token latency during generation.
    • End-to-end latency.
    • Task success rate.
    • Cost per successful task.

    End-to-end latency includes both queueing and execution. Tail latency reveals how peak demand and long requests affect the experience. A good average does not mean every user receives stable service.

    Eliminate Unnecessary Work First

    Common measures include removing repeated context, limiting unnecessary output length, reducing failed retries, and caching results that are suitable for reuse.

    Caching must respect permission boundaries, content freshness, and user isolation. A high hit rate is not the only objective: incorrectly reusing sensitive or outdated results can create greater risks.

    Make Task Success a Constraint on Cost Reduction

    Smaller models, shorter inputs, and compressed outputs can reduce resource consumption, but they may also reduce task quality.

    The optimization target should therefore be cost per successful task, not simply the lowest token price. A cheaper option that requires more retries, manual review, or follow-up calls may cost more overall.

    Conclusion: Treat Inference Cost as a Systems Problem

    LLM cost is not determined by parameter count or chip compute performance alone. Computation, accelerator memory, communication, batching, caching, scheduling, and business deadlines all shape the result.

    Batching improves efficiency through reuse and parallelism, while low-latency service may sacrifice utilization. MoE reduces some activated computation but introduces more complex routing and communication. Additional training investment may also be a deliberate way to lower long-term inference spending.

    For developers, the most reliable approach is not to guess model internals from pricing. Build reproducible workloads, separate prefill from decode, measure the actual bottlenecks, and evaluate every performance optimization against task quality. That is how cost analysis moves from plausible speculation to evidence that can guide engineering decisions.