LLM Inference Costs Explained: Batching and Expert Parallelism
Large language model inference costs depend on more than parameter count. This article explains how batching, mixture-of-experts architectures, memory bandwidth, interconnects, and request scheduling shape latency, throughput, and cost. It also examines what service pricing can reveal and outlines a practical approach to evaluating performance with real workloads and quality requirements.
1. Understanding LLM Costs Starts with Resource Usage
Why can the same model be offered at different speeds and prices? Why does a larger parameter count not always produce a proportional increase in inference costs? And why can a model perform well on a single machine but encounter significant bottlenecks when deployed across a cluster?
Parameter count alone cannot answer these questions. Actual efficiency depends on how compute capacity, accelerator memory capacity, memory bandwidth, inter-device communication, and request scheduling work together.
Think of the system as a pipeline. Once a request arrives, the system must load or read model weights, perform matrix operations, access cached context, and exchange data across devices when necessary. If one stage cannot keep up, other resources may sit idle.
At a minimum, an analysis of LLM costs should distinguish three metrics:
- Per-request latency: How long a user waits for a result.
- Overall throughput: How many requests or tokens the system processes per unit of time.
- Cost per successful task: The resources or money required to complete a task that meets the expected quality standard.
These metrics cannot always be optimized simultaneously. Lower latency may require smaller batches and more reserved capacity. Higher throughput may require some waiting time to gather more requests into a batch.
2. Training and Inference: Similar Computation, Different Bottlenecks
Training prioritizes sustained compute utilization
Training involves forward passes, backpropagation, and parameter updates. Large batches of samples help matrix operations make effective use of accelerators.
However, training efficiency is not simply a matter of adding compute. Parameters, gradients, optimizer states, and intermediate activations all require storage. Distributing a model across devices also introduces gradient synchronization and transfers of intermediate results. If communication cannot overlap effectively with computation, the gains from adding devices diminish.
Training efficiency therefore depends on how much runtime is spent doing useful computation, not on the sum of the devices’ theoretical computing power.
Inference has two distinct workloads
Generative model inference generally consists of two stages.
The prefill stage processes the input sequence, computes representations across model layers, and builds the cache needed for subsequent generation. Because multiple input positions can be processed together, this stage typically offers substantial computational parallelism.
The decode stage generates the next token based on the existing context. For an individual request, each generation step depends on the previous step’s result, so the process cannot be fully parallelized in the same way as training.
At small batch sizes, decoding often requires repeatedly reading large amounts of model weights while performing relatively little computation per step. It is therefore more likely to be limited by memory bandwidth. As batch size grows, compute utilization improves, and the bottleneck may shift to compute capacity, cache access, or inter-device communication.
This explains why the same hardware can perform very differently on long-input analysis, short question-answering tasks, and long-form text generation.
3. Why Batching Can Significantly Reduce Inference Costs
The key is reusing weight reads
Suppose a computation step requires reading an amount of weight data, W, and the effective available memory bandwidth is B. Considering data reads alone, a rough lower bound on the time required is:
T_memory ≈ W / B
If that weight read serves only one request, the request bears the entire cost. If multiple requests in a batch can share the read, the cost allocated to each request can decrease.
More generally, execution time for one step can be approximated as:
T_step ≳ max(computation / effective compute capacity,memory traffic / effective memory bandwidth)
Communication, scheduling, and synchronization overhead must also be considered. Batching increases the useful computation performed per weight read, moving the device from waiting for data toward fuller compute utilization.
The benefits are not unlimited. Larger batches also increase intermediate activations and context-cache usage. Once compute capacity or memory capacity becomes the bottleneck, further increases in batch size deliver diminishing returns.
Large cost differences are not universal rules
Under specific hardware, model, and workload conditions, the efficiency gap between single-request execution and well-batched execution can be substantial. However, any claimed multiplier needs clearly defined test conditions, including:
- Model architecture and numerical precision.
- Input and output lengths and their distributions.
- Batch size and actual concurrency.
- Cache usage and hit rates.
- Acceptable waiting time.
- Hardware utilization and billing model.
Without this context, claiming that inference without batching costs a fixed number of times more can confuse theoretical utilization, actual operating cost, and service pricing.
Online services need dynamic batching
Real requests do not arrive or finish together. Some generate short outputs, others continue for much longer, and new requests arrive throughout execution. If a system must wait for an entire batch to finish before accepting more work, positions freed by completed requests remain idle.
Dynamic batching allows the system to release positions as requests finish and admit new requests. The scheduler must still balance fairness, memory budgets, and tail latency. Otherwise, long requests may block short ones, or queues may keep growing under heavy load.
4. Mixture of Experts: Less Computation, More Communication
Total parameters are not the same as active parameters
Mixture-of-experts (MoE) models place multiple expert subnetworks in certain layers. A routing mechanism selects a subset of those experts for each token.
This makes it important to distinguish:
- Total parameters: All parameters across experts and shared modules.
- Active parameters: The parameters that participate in processing a particular token.
MoE architectures can increase total model capacity while limiting computation per token. However, experts that are not selected for the current token still need to be stored. Total memory requirements therefore do not fall in proportion to the fraction of active parameters.
Expert counts, routing strategies, and shared-module designs vary considerably across models. No single configuration should be treated as the standard for all MoE architectures.
Expert parallelism requires token-data exchange
When experts are distributed across devices, a token’s intermediate representation must be sent to the device hosting the selected expert. After computation, the results must be returned and combined. This typically involves all-to-all communication.
Performance depends primarily on three factors:
- Data volume. This depends on the number of tokens, hidden dimension, number of experts selected per token, and numerical precision.
- Effective network performance. Link bandwidth is only one factor. End-to-end performance also depends on topology, congestion, communication scheduling, and synchronization.
- Routing balance. If many tokens are routed to a small number of experts, overloaded devices can slow down the entire layer even when the network is not fully saturated.
The computational savings from MoE must therefore be evaluated alongside the additional communication, storage, and scheduling costs.
5. How High-Speed Interconnect Domains Affect Deployment
Clusters typically contain multiple levels of connectivity. Some groups of devices have faster, tighter connections, while communication conditions change when traffic crosses between those groups.
Keeping an expert-parallel group within a high-speed interconnect domain generally makes it easier to achieve stable bandwidth and low latency. When deployment spans multiple domains, large amounts of token traffic over slower links can put communication on the critical path.
This does not mean that MoE models must fit within a single rack, nor is there a universal limit on the number of devices they can use. Deployment boundaries depend on network topology, expert size, routing distribution, and the software’s ability to overlap communication with computation.
Possible optimization approaches include:
- Topology-aware placement: Place experts according to actual communication patterns to reduce frequent cross-domain transfers.
- Replication of heavily used experts: Use additional memory to distribute load, while accounting for the resource cost of replication.
- Hierarchical communication scheduling: Separate intra-domain and cross-domain transfers to improve data grouping and transmission order.
- Communication–computation overlap: Transfer some data while computation is in progress to reduce time spent waiting.
- Controlled parallel-group size: Keep each expert-parallel group within an appropriate scope while using other forms of parallelism to scale the system.
Load-balancing mechanisms used during model training also matter. However, they involve training objectives and model quality, so they should not be treated as risk-free switches that can simply be enabled after deployment.
6. Why Faster Service Can Cost More Without Being Proportionally Faster
Service pricing is not the direct inverse of execution time.
To reduce waiting, a low-latency service may use smaller batches, reserve more idle capacity, or route requests to less congested resource pools. Individual requests become faster, but the hardware can serve fewer requests overall.
Generation also has sequential dependencies that cannot be fully eliminated. Adding resources does not necessarily reduce execution time by the same proportion. Pricing may additionally cover capacity guarantees, peak-demand reserves, and operating costs. A price increase that exceeds the speed improvement is therefore not inherently contradictory.
Conversely, accepting longer waits does not automatically produce a lower price. The system must be able to use those waiting windows to build batches and fill idle capacity, and its billing model must pass on the resulting savings.
Asynchronous tasks, such as batch classification, offline summarization, and document organization, are better suited to this flexibility. Interactive question answering requires clear limits on acceptable time to first token and total response time.
7. What Public Pricing Can Reveal—and What It Cannot Prove
Input, output, and cache-related prices can provide clues about a service’s resource requirements, but they cannot uniquely identify the underlying model architecture.
For example, higher output-token prices may reflect the bandwidth demands, execution time, and resource occupancy of sequential decoding. Lower prices after a cache hit may reflect reduced repeated computation. The same pricing patterns, however, can also result from commercial strategy, service tiers, utilization, or temporary pricing adjustments.
A more reliable approach is to treat pricing as one observation and cross-check it against latency, throughput, performance as context length changes, and publicly available technical information.
Likewise, a claim that training data volume exceeds a “theoretical optimum” must specify the optimization objective. Compute-optimal training under a fixed training budget is not necessarily optimal for total lifecycle cost. If a model will serve a large volume of future requests, investing more in training to obtain a smaller model or better quality may be economically reasonable.
Without information about the training budget, data quality, and deployment needs, a single multiplier cannot establish whether a training strategy is good or bad.
8. A Practical Evaluation Framework for Developers
Define the business workload before benchmarking
Do not record only average input length. Measure input and output length distributions, changes in concurrency, the share of repeated context, and the duration of peak demand.
The real workload determines whether batching, caching, and capacity planning will be effective.
Measure latency, throughput, and quality together
At a minimum, track:
- Time to first token.
- Token generation rate.
- Total response time.
- Throughput.
- High-percentile tail latency.
Performance comparisons should use similar quality requirements and the same workload conditions. Otherwise, a supposedly faster system may simply produce shorter outputs or complete tasks less thoroughly.
Prioritize cost optimizations by benefit and risk
A practical starting point is to remove unnecessary context and duplicate calls. Next, evaluate reusable prefix caching, batching for asynchronous tasks, and assigning models of different sizes according to task difficulty.
Then adjust concurrency and batch size rather than investing prematurely in complex cluster-level optimization.
Shorter outputs can also reduce costs, but output limits should reflect business needs. Necessary information should not be cut off solely to save money.
Monitor metrics that identify the bottleneck
For self-hosted inference, examine compute utilization, accelerator memory usage, memory bandwidth, communication wait time, and expert-load distribution together.
For external API services, focus on queueing time, rate limiting, failed requests and retries, and task success rate.
Price per token captures only part of the cost. The more meaningful business metric is the actual cost of completing a task that meets the required quality standard.
Conclusion
LLM economics emerge from the interaction of model design, hardware, and service scheduling. Batching improves resource reuse. MoE changes the balance between computation and communication. High-speed interconnects influence parallel deployment efficiency, while low-latency service requires additional capacity.
For developers and businesses, the priority is not to infer hidden architectures from parameter counts or public prices. It is to build a verifiable performance model using real workloads. Finding the right balance among quality, latency, throughput, and cost is the foundation of sustainable LLM optimization.
