LLM Training and Inference: How Architecture, Bandwidth, and Cost Interact
Understand the system-level factors behind large language model performance and pricing, from training and inference bottlenecks to mixture-of-experts architectures, batching, and KV cache capacity. This article explains how to identify deployment bottlenecks and evaluate quality, latency, throughput, and lifecycle cost together.
1. Understanding LLMs Requires a Systems View
Why can a model with more parameters cost less per API call? Why do low-latency services often cost more, and why does adding hardware not necessarily increase throughput proportionally?
“More advanced models” alone cannot explain these differences. An LLM service is an execution pipeline that combines computation, memory, communication, and scheduling. Model architecture determines which operations must run, hardware determines how quickly they can execute, and serving policies determine how effectively resources are used.
The relationship can be summarized as follows:
Model capability depends on training investment and data quality. Inference efficiency depends on execution paths and system utilization. Service pricing also reflects operational and commercial factors.
Public pricing therefore provides only indirect clues about system design. It cannot reliably reveal parameter counts, expert counts, or deployment topology. Similar prices may come from very different combinations of models, hardware, and scheduling policies.
2. Training and Inference Have Different Bottlenecks
Training Includes Forward Passes, Backpropagation, and Parameter Updates
LLM pretraining typically learns statistical relationships among language, knowledge, and patterns by predicting subsequent text units. These units are called tokens, and their boundaries do not necessarily align with complete words or characters.
A training iteration has three main stages:
- Forward pass: Compute predictions and loss from the input.
- Backward pass: Calculate gradients of the loss with respect to model parameters.
- Parameter update: Use those gradients to adjust the weights.
Training must store not only weights but also gradients, optimizer states, and intermediate activations needed for backpropagation. Its accelerator memory requirements are therefore usually much higher than the memory needed simply to load the same model for inference.
For common dense autoregressive models, training compute can be approximated as:
Training compute ≈ k × Parameter count × Training token count
The coefficient k depends on the architecture, how computation is counted, and the implementation. This relationship is useful for order-of-magnitude estimates, not detailed performance analysis. Long-sequence attention, activation recomputation, and communication overhead can all affect actual resource requirements.
Inference Has Two Distinct Phases: Prefill and Decode
Inference does not generate the entire output in a single operation. It has two phases with different performance characteristics.
Prefill processes the input context. Multiple input positions can be processed in parallel within a forward pass, making it easier to execute large matrix operations. Longer contexts, however, generally increase attention computation and cache-writing overhead.
Decode generates subsequent tokens step by step. For an individual request, each generation step depends on previously generated content, so the output sequence cannot be fully parallelized across time. With small batches, hardware may spend much of its time reading weights and cached state rather than performing arithmetic.
Inference optimization must therefore address these phases separately. Improving input-processing throughput does not necessarily reduce per-token latency during generation.
3. Beyond Parameter Count: How Much Computation Is Activated?
Dense Models and Mixture-of-Experts Models
A dense model generally uses the same main computational modules for every token. A mixture-of-experts (MoE) architecture places multiple expert subnetworks in selected layers, with a router choosing a small subset of experts for each token.
Three concepts must be kept separate:
- Total parameters: All parameters in the model.
- Active parameters: The parameters used to process a particular token.
- Actual computation: The operations required to execute those paths, including attention, routing, and other shared modules.
MoE architectures can increase total parameter capacity without increasing per-token computation by the same proportion. But fewer active parameters do not guarantee lower system costs. All expert weights still need to be stored, routing adds communication, and workloads may be unevenly distributed.
Evaluating an MoE model therefore requires more than checking total or active parameter counts. Expert placement, communication overhead, and actual batch size also matter.
Why Expert Parallelism Depends on Fast Networks
When experts reside on different accelerators, tokens received by one device may need to be sent to experts on other devices. After expert computation, the results must return and be combined.
This exchange pattern is commonly called all-to-all communication.
Its performance depends on more than peak network bandwidth. Relevant factors include:
- Which devices receive the tokens.
- Message sizes and how effectively messages can be combined.
- Network congestion and competition from other workloads.
- Whether popular experts are concentrated on a few devices.
- Whether communication can overlap with computation.
If some experts receive substantially more traffic, a small number of devices can become stragglers. Devices that finish earlier may still have to wait for the slowest participant.
Rack Boundaries Matter, but They Are Not Universal Limits
Accelerator clusters typically have several communication tiers: within a device, between devices, between servers, and across the wider network. These tiers differ in bandwidth, latency, and resource sharing.
Performance may drop significantly when expert exchanges move from a fast local interconnect to a slower inter-server network. However, the device count of one hardware configuration should not be treated as a universal size limit for MoE models. Nor should cross-boundary communication be assumed to incur a fixed slowdown.
Communication overlap, routing locality, expert replication, and combinations of parallelism strategies can help mitigate these constraints. They also add memory requirements, scheduling complexity, or implementation complexity.
The more useful conclusion is that the size and quality of the high-speed interconnect domain affect the economic viability of MoE architectures—not just whether a model can run.
4. How Batching Reduces Inference Cost
Batching Improves Weight Reuse and Compute Utilization
Suppose a decode step needs to read W bytes of weight data, and effective accelerator memory bandwidth is BW. Weight-reading time can be roughly expressed as:
Weight-reading time ≈ W / BW
For a single request, reading those weights may support relatively little computation. Combining multiple requests into a batch allows matrix operations to reuse the same weight data, spreading the read overhead across more tokens.
For a batch size of B, a simplified relationship is:
Weight data read amortized per token ≈ W / B
This approximation explains the mechanism, not an exact scaling law. Real systems have multiple cache levels, sharding, repeated accesses, and different compute kernels. Costs are not guaranteed to fall linearly with batch size.
Batching Benefits Have Limits
As batches grow, a system may move from being bandwidth-bound to being compute-bound. Meanwhile, every active request requires its own context cache, increasing memory consumption.
A larger batch does not necessarily make each request faster. Excessive batching can cause:
- Longer waits before execution begins.
- Longer execution time for each decode step.
- Cache usage that exhausts available memory.
- Long requests slowing down short requests.
- Worse tail latency.
Claims that serving without batching increases costs by an enormous factor apply only under specific model, hardware, and utilization conditions. They are not universal rules. Organizations should measure batching benefits through load testing rather than assume a fixed multiplier.
Continuous Batching Fits Online Serving Better Than Fixed Batches
Requests typically have different input and output lengths. If a system waits for an entire batch to finish, requests that complete early leave resources idle.
Continuous batching allows completed requests to leave and new requests to join subsequent execution steps, improving utilization. The scheduler must still account for request priority, context length, cache capacity, and latency targets.
Continuous batching optimizes service-wide throughput and resource use. It should not be interpreted as making every individual request faster.
5. Why Faster Services Can Cost More
Low-latency services often need more spare capacity, smaller batches, higher scheduling priority, or additional replicas to reduce queueing.
These choices can reduce the useful work completed per unit of hardware time. As a result, latency improvements and price increases do not necessarily scale proportionally.
Whether a slower service can be cheaper depends on the workload:
- Document archiving and offline summarization: Asynchronous queues and larger batches can improve utilization.
- Real-time interaction: Users cannot wait indefinitely, so the available batching window is short.
- Cache- or communication-bound workloads: Simply allowing more queueing time may not materially reduce costs.
Batching also requires enough concurrent demand. If requests arrive infrequently, extending the waiting window may still fail to produce an effective batch.
6. Why Training Data May Exceed a Simple Compute-Optimal Estimate
Training-scale discussions often consider the compute-optimal balance between parameter count and training token count. But “optimal” must be defined against a specific objective.
If the goal is to minimize loss within a fixed training budget, there is a balance between model size and data volume. If the trained model will serve a large number of requests, the objective changes:
Total lifecycle cost = Training cost + Cumulative inference cost + Operational cost
Under this objective, a relatively smaller model trained on more data may be more economical than a larger deployed model. Additional training investment may reduce long-term inference costs.
This does not mean that adding data indefinitely is beneficial. Repetition, low-quality data, biased knowledge distributions, and contamination of training or evaluation data can reduce the value of additional training.
Without reliable disclosures, it is not possible to establish that a particular frontier model used a specific multiple of a theoretical optimum. Different theoretical assumptions, data distributions, and optimization objectives also produce different definitions of “optimal.”
7. KV Cache Is a Critical Capacity-Planning Variable
Autoregressive inference typically stores attention keys and values for previous positions so that it does not have to recompute all historical information for every new token. This state is called the key-value cache, or KV cache.
Cache size depends on the number of model layers, sequence length, number of KV heads, head dimension, storage precision, and concurrent requests.
A rough estimate for a single sequence is:
KV cache size ≈ 2 × Number of layers × Sequence length × Number of KV heads × Head dimension × Bytes per element
The factor of 2 accounts for keys and values. This expression estimates an unsharded, uncompressed single-sequence cache. Architecture and implementation details affect actual memory usage.
This explains why fitting model weights into accelerator memory does not guarantee support for high concurrency. Long-context serving may be limited primarily by cache capacity rather than weight storage.
Common optimizations include sharing caches for identical prefixes, reducing memory fragmentation, and using lower-precision storage after validating quality. Cache sharing requires strict cache-hit validation and tenant isolation: efficiency must not introduce data leakage risks.
8. How to Identify Your Inference Bottlenecks
Track Metrics by Stage
At a minimum, record the following separately:
- Time to first token: Time from request arrival until output begins.
- Inter-token latency: Time between consecutive output tokens during generation.
- Total completion time: How long the user waits for the complete result.
- System throughput: Requests or tokens processed per unit of time.
- Tail latency: Response performance at high percentiles.
- Cost per successful task: Resource cost required to complete a useful business task.
Average response time alone can hide problems caused by long contexts, traffic bursts, and long-tail tasks.
Load-Test with Representative Workloads
Tests should reflect the real distribution of input lengths, output lengths, concurrency, and task types. Fixed short inputs and outputs often fail to represent production behavior.
A useful testing sequence is:
- Test a single request to establish baseline execution latency.
- Increase concurrency gradually and observe throughput growth and latency inflection points.
- Increase context length to assess cache pressure and input-processing overhead.
- Introduce request bursts to evaluate queueing and rate-limiting policies.
- Inspect communication time and load balance in multi-device deployments.
Once throughput reaches its peak, adding concurrency usually lengthens queues rather than increasing output proportionally.
Choose Optimizations Based on the Bottleneck
For a memory-bandwidth bottleneck, examine effective batch size, weight data volume, and memory-access efficiency.
For a compute bottleneck, focus on operator implementations, parallelism strategies, and the model size needed to meet quality requirements.
For a communication bottleneck, inspect sharding strategies, expert routing distributions, and network topology.
For a queueing bottleneck, adjust capacity reservations, request prioritization, and admission control rather than only changing model computation.
Every optimization should be evaluated for quality, cost, and latency together. Lower answer quality should not be mistaken for a genuine performance improvement.
9. Turning Technical Metrics into Business Decisions
LLM deployment is not a matter of choosing the largest model and adding the most hardware. A better approach is to establish the task-quality threshold first, define latency and concurrency targets next, and then select an architecture and resource configuration that meet those constraints.
Real-time question answering prioritizes time to first token and a smooth generation experience. Offline processing emphasizes throughput and cost. Complex analytical tasks may tolerate longer processing times in exchange for better results.
Model architecture determines execution paths. Training strategy shapes capability. Cache capacity constrains concurrency. Networks determine parallel efficiency. Batching determines resource utilization.
Evaluating these factors within a shared cost-and-performance framework makes LLM service behavior easier to explain—and supports deployment plans that are measurable, optimizable, and sustainable.
