Hardware Logic Behind Large Model Training and Inference

    This article breaks down how hardware topology, interconnect bandwidth, and batch size shape large model architecture, deployment limits, and inference pricing. It explains the roughly 8x bandwidth drop across racks, why sparse MoE expert layers are bounded by rack capacity, how batching drives per-token cost, and why pretraining data often exceeds the theoretical optimum, ending with a practical checklist for developers.

    1. Why Understanding Large Models Starts with Hardware

    Most discussions of large models stay at parameter counts and benchmark scores. What actually determines how a model looks, what it costs, and how fast it improves is the hardware topology underneath it. The chip engineer’s perspective matters because model architecture is not a pure mathematical choice; it is an engineering compromise squeezed repeatedly by communication bandwidth, memory capacity, and the power wall. A whiteboard and a few equations are enough to push the cost structure of training and inference to its limit.

    Training and inference for modern frontier models both run on clusters of accelerators. The cluster has clear tiers: on-chip memory bandwidth is highest within a single card, cards inside one machine communicate over high-speed interconnects, cards in a rack form a scale-up domain through a switching fabric, and once traffic leaves the rack for the data center network, bandwidth and latency drop by orders of magnitude.

    2. The 8x Bandwidth Gap: The Physical Ceiling for Sparse Models

    The key quantitative intuition is this: once communication crosses out of the rack, effective communication speed falls to roughly one eighth of in-rack speed. This 8x gap is not an implementation problem but the result of stacked physical and engineering constraints, and it directly sets the deployment ceiling for Mixture-of-Experts (MoE) architectures.

    Take a publicly documented sparse architecture as an example: the model has 256 experts, and each inference activates only about 32 of them. The most natural deployment is expert parallelism, placing different experts on different accelerators, where any card may send tokens to any other card, forming all-to-all communication. This pattern fits the topology of in-rack high-speed interconnects very well.

    1. # Expert parallelism communication sketch (pseudocode)
    2. for layer in model.layers:
    3. # 1. Routing: select top-k experts for each token
    4. expert_id, weight = router(token) # 32 of 256
    5. # 2. All-to-all dispatch: send token to the card holding the expert
    6. token_shard = all_to_all(token, expert_id) # in-rack: high bandwidth
    7. # 3. Expert computation
    8. out = experts[expert_id](token_shard)
    9. # 4. All-to-all gather
    10. result = all_to_all(out, origin_rank)

    Once experts are spread across two racks, about half the tokens must travel the link that is 8x slower, communication immediately becomes the bottleneck, and compute utilization collapses. The conclusion is direct: the capacity of one rack limits how large an expert layer you can build. This also explains why high-sparsity models must run on a larger scale-up domain: the larger the domain, the more experts it can hold, the higher the achievable sparsity, while inference efficiency is preserved. A cloud provider’s long-term investment in its own accelerator systems and larger interconnect domains reflects exactly this logic.

    The practical takeaway: when doing distributed inference in the cloud, keep an expert’s shards of the same model within the same high-speed interconnect domain; when orchestrating with a container platform, use topology-aware scheduling to bind processes with strong communication dependencies to the same rack and avoid cross-domain all-to-all.

    3. Batch Size: The Real Variable in Inference Pricing

    “Fast mode costs several times more and is only a little faster” is a common market pattern. The core of it is not product tiering but a different batch size.

    Autoregressive decoding is memory-access intensive: every generated token requires reading the weights and the KV cache again. With a single request and a small batch, compute sits largely idle and per-token cost is very high; packing many requests into one large batch amortizes weight reads and throughput rises sharply. Therefore:

    • Small batch, latency first: high cost per token, but low time to first token;
    • Large batch, throughput first: low cost per token, but requests must queue to fill a batch.

    This explains why “without batching requests, the cost of a single inference can be three orders of magnitude higher.” It also shows that trading speed for a lower price is technically entirely feasible: allowing a longer queue window to assemble a large batch naturally lowers cost. In cloud practice, a message queue can buffer requests and tier priorities, while monitoring and alerting track batch utilization and queue latency to balance cost against SLA.

    1. # Core idea of continuous batching (illustrative)
    2. while serving:
    3. batch = scheduler.form_batch(max_size=B, wait_ms=T)
    4. # Larger B and longer T -> higher throughput, lower cost per token
    5. outputs = engine.decode(batch)
    6. scheduler.evict_finished(outputs)

    4. Why Pretraining Data Volume Far Exceeds the “Theoretical Optimum”

    Scaling laws give the optimal ratio of data to parameters for a given compute budget, yet frontier models are often pretrained on data volumes on the order of 100x the theoretical optimum. There are three reasons: first, data reuse has diminishing returns, and feeding an extra pass is worse than finding new data; second, the optimal ratio at small model scale does not extrapolate directly to very large models; third, engineering practice favors pushing data up first to raise the capability ceiling, then aligning through post-training. For developers, the implication is that investment in the data pipeline (collection, deduplication, quality filtering) often pays off more than simply adding compute, and object storage plus data processing services can build a reproducible data pipeline.

    5. A Practical Checklist for Developers

    1. Topology first: place parallel shards with strong communication dependencies in the same high-speed interconnect domain, and use data parallelism across racks.
    2. Cost modeling: use “cost per token ≈ weight read cost / batch size” for capacity planning instead of looking only at unit price.
    3. Tiered service: separate fast and slow lanes by batch window, and use queues and monitoring to deliver a committable SLA.
    4. Data first: turn deduplication and quality evaluation into a pipeline to avoid wasted repeated training.

    Once you understand these hardware and batching constraints, model architecture choices, pricing tiers, and iteration speed stop being mysterious; they are all optimal solutions under physical boundaries.