From Rack Topology to Batching: Breaking Down LLM Inference Costs

    A system-level look at the engineering constraints behind large language model training and inference costs. This article explains how rack-scale interconnect topology limits MoE model design, why training and inference follow different cost curves, how batch size drives pricing tiers across fast and standard service modes, and why pretraining token counts may far exceed theoretical optima. It closes with a practical engineering checklist covering topology, model, inference, and operations layers.

    From Rack Topology to Batching: Breaking Down LLM Inference Costs

    Training and serving frontier large language models is not purely an algorithmic problem. How large a model can scale, how cheap inference gets, and why different service tiers are priced so differently are often determined by a set of very “hard” engineering constraints: the reach of high-speed interconnects between accelerators, the communication patterns of Mixture-of-Experts (MoE) models, batch sizes, memory capacity and bandwidth, and the ratio between training data and compute. Placing these variables in a single system diagram makes many counterintuitive phenomena explainable.

    This article does not rehash the specifics of any single model. Instead, it starts from general engineering logic, breaks down the underlying mechanics of LLM training and inference, and offers actionable guidance for deployment and capacity planning.

    1. Rack Topology: The First Physical Boundary on Model Scale

    Modern LLMs are typically deployed on clusters of large numbers of accelerators. To reduce communication latency, a common industry practice is to pack dozens of accelerators into a single high-density rack, forming a large “scale-up domain” through intra-rack high-speed interconnect. Within this domain, any two cards can communicate over few switch hops with high bandwidth and low latency. Once traffic leaves the rack and enters the inter-rack network, bandwidth may drop several-fold and latency rises significantly.

    This gap directly determines the applicability of parallelism strategies. Common training approaches—data parallelism, tensor parallelism, pipeline parallelism, and expert parallelism—have different communication requirements. Tensor parallelism and expert parallelism typically require frequent global communication, while data and pipeline parallelism can hide some communication behind larger batches or finer pipeline splits. Regardless of strategy, communication across high-speed domains becomes the bottleneck.

    A simplified cost model helps:

    1. Step time ≈ compute time + intra-domain comm time + cross-domain comm time
    2. The higher the cross-domain share, the lower the scaling efficiency

    Therefore, “how many cards fit in one rack” is not merely a procurement question—it is one of the upper bounds on model architecture design. The larger the intra-rack high-speed domain, the better it can host highly sparse, communication-heavy model structures. Smaller domains force more conservative designs, or require cross-domain traffic reduction through expert replication, topology-aware scheduling, or communication-computation overlap.

    2. Mixture-of-Experts: All-to-All Communication and Expert Parallelism

    The core idea of MoE models is to use a large number of experts to increase model capacity while activating only a small subset per inference, trading off parameter count against compute. Typical configurations discussed publicly involve “hundreds of experts, with only dozens activated per token,” though the exact ratio depends on the task, training stability, and deployment cost.

    The most natural deployment is expert parallelism: different experts are placed on different accelerators, and tokens are routed to the card hosting the chosen expert. This is a classic all-to-all communication pattern: any card may send tokens to, and receive results from, any other card. All-to-all communication aligns naturally with intra-rack high-speed interconnect topologies, so it can be quite efficient within a single high-speed domain.

    The problem arises across domains. Once experts span two or more racks, some tokens must traverse the much slower inter-rack network. The sparser the routing and the more experts there are, the harder cross-domain traffic is to predict, and the more pronounced tail latency becomes. This leads to a key conclusion: the size of a high-speed interconnect domain limits the deployable scale and sparsity of expert layers.

    Common engineering mitigations include:

    • Expert replication: duplicate hot experts across multiple racks to reduce cross-domain routing
    • Capacity factor control: cap the number of tokens each expert receives, preventing overload of a few experts
    • Topology-aware routing: prefer routing tokens to experts in the same domain
    • Communication-computation overlap: keep processing other batches while waiting for expert results
    • Load-balancing constraints: introduce auxiliary losses or routing constraints during training to reduce skew at inference time

    These techniques cannot eliminate cross-domain communication entirely, but they turn the bottleneck from “unusable” into “plannable.”

    3. Training and Inference Follow Different Cost Curves

    Training focuses on throughput, stability, and global synchronization efficiency. Large-model training typically combines multiple parallelism strategies: data parallelism replicates model copies, tensor parallelism splits individual layer matrices, pipeline parallelism splits network layers, and expert parallelism splits experts. Each training step involves forward computation, backpropagation, and gradient synchronization—heavy communication and large optimizer states make training very sensitive to high-speed interconnect and memory capacity.

    Inference, by contrast, consists of two fundamentally different phases:

    1. Prefill: processes the input context in one pass; compute-intensive and well suited to larger batches
    2. Decode: generates tokens one at a time; typically memory-bandwidth-bound, repeatedly reading model weights and the KV cache

    The key tension in the decode phase: generating each token requires reading large amounts of weights and cache, while the actual compute per token is limited. If only one request is served at a time, weight-reading cost cannot be amortized, and per-request inference cost becomes very high. A commonly cited rule of thumb in public technical discussions: without batching, single-request inference cost can be an order of magnitude higher or more, reaching three orders of magnitude in extreme cases.

    Batching merges the decode steps of multiple requests so that one weight read serves many tokens. The larger the batch, the lower the amortized weight-read cost per token and the higher the throughput. But bigger is not always better: larger batches increase memory usage, lengthen queueing, affect tail latency, and demand more from KV cache management.

    4. Batch Size: The Core Variable Behind Pricing Differences

    The price differences among many service tiers may look like “fast versus slow,” but underneath they are a trade-off between batch size and service-level agreements.

    High-priority fast modes typically use smaller batching windows, stricter scheduling priority, and lower queueing latency, so each request absorbs more fixed cost and is priced higher. Standard or slower modes can use larger batches, longer queueing windows, and even off-peak batch scheduling, lowering per-unit cost.

    A typical observation from public discussions: some fast modes cost several times more while improving latency by only about 2.5x. This is not contradictory. The price covers not just compute but also priority scheduling, capacity reservation, tail latency control, and idle resource guarantees. Conversely, trading latency for lower prices via “slow modes” is engineering-feasible, provided that:

    • Requests can tolerate longer queueing times
    • The workload allows asynchronous or offline processing
    • The system supports continuous batching and dynamic admission
    • Cache and memory management are robust enough to avoid OOM or jitter from long batches

    A simplified continuous batching scheduler looks like this:

    1. def schedule(requests, max_batch, max_wait_ms):
    2. batch = []
    3. while requests or batch:
    4. while len(batch) < max_batch and can_admit(requests):
    5. batch.append(requests.pop(0))
    6. run_prefill(batch)
    7. for step in decode_loop(batch):
    8. emit_tokens(step)
    9. batch = [r for r in batch if not r.finished]
    10. admit_new_requests(batch, max_wait_ms)

    The key idea: batches are not static but evolve dynamically as requests finish and new ones arrive. Continuous batching raises throughput without significantly increasing tail latency, making it a central lever for inference cost optimization.

    5. Pretraining Data Volume: Why Actual Token Counts May Far Exceed the Theoretical Optimum

    There is another often-overlooked variable on the training side: the ratio of data to compute. Following classic compute-data joint scaling analyses, for a given training compute budget there is a theoretically optimal number of tokens. Yet some public estimates suggest that frontier models may actually be trained on significantly more tokens than this optimum—by tens of times or even hundreds of times.

    Common explanations include:

    • Data quality and deduplication strategies change the effective data volume
    • When training compute is constrained, adding data is more feasible than adding parameters
    • Longer contexts, multimodality, and multi-stage training require more tokens
    • Repeated training and curriculum learning affect data efficiency
    • Scaling laws carry uncertainty, so teams tend to keep a safety margin

    This also affects inference architecture: larger pretraining data often corresponds to larger model capacity or stronger expert structures, which are in turn constrained by the rack-scale high-speed domain. Training data ratios, model structure, and deployment network topology are not three independent problems—they are mutually constrained parts of one system engineering effort.

    6. Inferring Architecture Trade-offs from Public Pricing

    Public pricing can reveal architectural signals, but should not be over-interpreted. Several dimensions are worth observing:

    • Input vs. output price gap: output is generated token by token and is more affected by decode bandwidth and batching
    • Long-context price gradient: reflects KV cache memory footprint and cache management cost
    • Fast vs. standard mode price gap: reflects batch size, priority scheduling, and capacity reservation
    • Expert scale and sparsity: highly sparse models need larger high-speed interconnect domains and cost more to deploy
    • Cache hit discounts: indicate prefix caching is reused to reduce repeated prefill cost

    That said, pricing is also shaped by business strategy, regional costs, peak/off-peak scheduling, and contract discounts. Pricing can only serve as “circumstantial evidence of architectural trade-offs,” not a substitute for real benchmarking.

    7. Engineering Practice Checklist

    For real-world deployment, optimization can be organized into four layers:

    1. Topology layer: keep communication-heavy expert and tensor-parallel groups within the same high-speed domain; apply topology-aware scheduling to cross-domain traffic
    2. Model layer: control expert count and activation ratio; add load-balancing constraints; replicate hot experts
    3. Inference layer: enable continuous batching; manage the KV cache; allocate resources differently between prefill and decode; set sensible maximum batch sizes and wait windows
    4. Operations layer: tier services by SLA; offer fast, standard, and offline queues; monitor throughput, tail latency, memory watermarks, and cross-domain traffic

    Metrics to monitor should include at minimum: cost per token, batch utilization, queueing latency, time to first token, decode throughput, KV cache hit rate, cross-domain communication share, and expert load skew.

    Conclusion

    Behind the “intelligence” of large models lies a system jointly constrained by interconnect domains, expert parallelism, batching, and data ratios. Rack size limits expert layer scale; batch size determines per-token inference cost; training data volume feeds back into model capacity and deployment difficulty. Once these constraints are understood, why fast modes cost more, why slow modes are viable, and why highly sparse models depend on large high-speed domains stop being black-box phenomena—and become engineering problems that can be computed, planned, and optimized.