DEEP DIVE SERIES · #18
AI Training vs Inference: Inside the GPU Processing Pipeline
Pair with Deep Dive #16 & The AI Storage Atlas
This article focuses on the real-time execution mechanics of LLM inference, GPU HBM saturation, and KV-cache offloading. For foundational SAN-to-NVMe cluster fabrics and sovereign data topologies, explore our companion resources.
In modern enterprise computing, high-performance GPUs have become the defining computational currency. Whether an organization is training frontier foundation models or serving autonomous AI agent swarms, billions of dollars are invested in identical silicon: NVIDIA H100, H200, and Blackwell B200 HGX systems.
Yet beneath this shared hardware footprint lies a profound engineering contrast:
Training an AI model and running inference with that same model represent two entirely different computational paradigms.
When an engineering team builds a distributed GPU training cluster, they optimize for massive, sustained matrix throughput. The objective is to calculate weight gradients across trillions of tokens and synchronize mathematical updates across thousands of nodes without bottlenecking on network jitter or checkpoint storage stalls.
When that same team deploys the trained model into production to power interactive agents, coding copilots, or real-time document analysis, the entire performance profile flips. Training parameters become fixed, read-only weight matrices. Backpropagation disappears entirely. In their place emerges a severe memory-bandwidth and memory-capacity wall governed by autoregressive next-token decoding loops, dynamic Key-Value (KV) cache materialization, and unpredictable concurrent user sessions.
If you architect an inference infrastructure using the assumptions of a training cluster, your $30,000 accelerators will spend up to 80% of their operational cycles idling, waiting on memory bus transactions and networking handoffs.
In this deep dive, we deconstruct the exact physics of the GPU processing pipeline across both disciplines. We examine the mathematical mechanics of forward and backward propagation, distributed gradient synchronization, prompt prefill versus autoregressive decode, the memory hierarchy spanning GPU High Bandwidth Memory (HBM), host server DDR5, and distributed NVMe fabrics, and the economics governing modern AI infrastructure.
The Master Architecture: Training vs. Inference on GPUs
To establish our architectural baseline, we begin with the end-to-end processing topology illustrated in our primary engineering infographic below.
Technical Validation of the Architectural Infographic
Before analyzing each subsystem in detail, we must validate the infographic from an infrastructure architect’s perspective, noting both what it captures accurately and where production reality introduces additional nuance:
- The Core Asymmetry: The infographic correctly captures the fundamental operational divide: training is an iterative parameter-modification loop driven by forward and backward passes, loss functions, and optimizer states; inference is a read-only parameter execution pipeline that transforms static weights into dynamic streaming outputs via prompt prefill and autoregressive decode loops.
- Memory Hierarchy Representation: The illustration depicts a tiered memory stack on both sides: GPU HBM at the apex, host DDR DRAM in the middle, and NVMe/object storage at the base. In production, this hierarchy is conceptual rather than a universal hardware pipeline. During inference, many standard serving runtimes maintain active KV caches exclusively in GPU HBM, rejecting requests or dropping context if memory is exhausted. As discussed in our deep dive on Inside the AI Memory Wall, multi-tier offloading to host DDR5 or distributed NVMe fabrics requires specialized software architectures such as PagedAttention, prefix caching, or GPUDirect Storage (GDS) integrations.
- Model Weights During Inference: The infographic accurately notes that weights remain static during inference. In large-scale deployments, however, weights are rarely hosted entirely on a single GPU. Models spanning 70 billion to 405 billion parameters are partitioned across multiple GPUs via Tensor Parallelism (TP) or Pipeline Parallelism (PP), requiring continuous intra-node NVLink or inter-node InfiniBand communications even during forward-only execution.
- Checkpointing vs. Active Writes: The diagram correctly highlights that training generates massive, periodic burst writes of model weights and optimizer states to high-performance parallel filesystems, whereas inference produces virtually zero active storage writes, with the exception of telemetry and optional cache persistence.
1. Introduction: Two Very Different GPU Workloads
To understand why GPU clusters require different architectural optimizations for training versus inference, we must address the fundamental engineering question:
Why does training a large language model require coordinated clusters of thousands of GPUs operating synchronously for months, while serving that exact same model to users introduces an entirely different set of memory, latency, and networking bottlenecks?
The answer lies in the mathematical objective of each phase:
| Architectural Dimension | AI Model Training | LLM Inference Serving |
|---|---|---|
| Primary Objective | Learn model weights by minimizing loss across curated datasets | Apply learned weights to generate contextual predictions from user prompts |
| Computational Nature | Symmetric forward pass + asymmetric 2× backward automatic differentiation | Asymmetric forward pass: compute-dense prefill + memory-bandwidth-bound decode |
| Weight Modification | Dynamic: Parameters change continuously at every optimizer step | Static: Pretrained weights are strictly read-only |
| Optimization Target | Throughput & Scaling Efficiency: Model FLOPs Utilization (MFU), tokens/sec | Latency & Concurrency: Time to First Token (TTFT), tokens/sec/user, p99 SLA |
| Memory Pressure | Weights, weight gradients, optimizer states (Adam), and forward activations | Model weights, temporary activations, and dynamic Key-Value (KV) cache |
| Storage Interaction | Sustained high-throughput reads + massive periodic checkpoint write storms | One-time weight loading at startup + optional microsecond KV cache offloading |
| Network Dependency | Ultra-high-bandwidth, low-jitter inter-GPU all-reduce fabrics (NVLink/InfiniBand) | Request routing, tensor parallel intra-node links, or disaggregated prefill-decode |
Training is fundamentally throughput-oriented. If a training run takes 90 days instead of 95 days because the cluster maintains high computational efficiency, the enterprise saves millions of dollars in power, facility, and compute leasing costs. The workload is monolithic and predictable: batches of data are fed continuously into a tightly coupled supercomputer.
Inference, by contrast, is strictly latency-sensitive and concurrency-driven. An interactive user or an autonomous multi-agent state machine will not tolerate an 18-second delay waiting for a model response. Furthermore, incoming user requests are non-deterministic, varying in prompt length, generation length, arrival rate, and reasoning complexity.
While training seeks to maximize aggregate FLOPs across a fixed pipeline, inference seeks to maximize serving concurrency while preserving microsecond-scale token generation speeds.
2. Understanding the Transformer Model
Before dissecting the GPU hardware pipelines, we must examine the computational mechanics of the modern transformer architecture, which underpins virtually all contemporary generative models (e.g., Llama 3, GPT-4, Claude, Gemini, Mistral, and DeepSeek).
Transformer Processing: Parallel Matrix Compute vs. Sequential Token Generation
Internal Transformer Layer Data Path
Each transformer block processes token vectors through linear projections, scaled dot-product attention, and multi-layer perceptron (MLP) feed-forward networks:
S are multiplied simultaneously as large dense 2D matrices.
Parallel Matrix Multiply vs Autoregressive Loop
Why inference transforms from a compute-saturated matrix multiplication into a memory-bandwidth-bound serial loop:
All N input tokens are known upfront. Matrix multiplications are large and square.
Tokens are generated strictly one at a time (t+1 depends on t). The GPU multiplies a 1-token vector against all model weights and past KV tensors.
A transformer processes natural language through a sequence of mathematical matrix transformations:
- Tokenization: Raw text is decomposed into discrete integer tokens using Byte-Pair Encoding (BPE) or similar algorithms. Each token represents a character sequence, whole word, or subword fragment.
- Embedding: Integer tokens are mapped to high-dimensional continuous vector space through an embedding matrix
W_e ∈ R^(V × d_model), whereVis vocabulary size andd_modelis the model’s hidden dimension (e.g., 8,192 dimensions in Llama-3-70B). Positional encodings (such as Rotary Position Embeddings, or RoPE) are added to inject token sequence coordinates. - Transformer Layers: The token representations pass sequentially through a stack of identical transformer layers (e.g., 32 layers in an 8B model; 80 layers in a 70B model; 126 layers in a 405B model). Each layer contains two primary sub-components:
- Self-Attention Mechanism: Allows every token to dynamically weigh and attend to every other token in the sequence. Input vectors are linearly projected into Query (
Q), Key (K), and Value (V) tensors using learned weight matrices. - Feed-Forward Network (FFN / MLP): Projects the attended vectors through two or three linear transformations with non-linear activation functions (such as SwiGLU or GELU), typically expanding the hidden dimension by a factor of
3.5×to4×before projecting back tod_model.
- Self-Attention Mechanism: Allows every token to dynamically weigh and attend to every other token in the sequence. Input vectors are linearly projected into Query (
- Layer Normalization & Residual Connections: Each sub-layer is wrapped in a residual skip connection (
x + SubLayer(x)) and RMSNorm or LayerNorm to preserve stable gradient flow during deep backpropagation. - Final Projection (Unembedding): The final output representations are projected back across the full vocabulary dimension
Vto produce unnormalized log probabilities (logits).
What the current token is looking for across all other sequence positions.
What each candidate token contains; matched against Q via dot-product.
The contextual content extracted and aggregated according to attention weights.
1 / √d_k prevents dot-product magnitudes from pushing softmax into vanishing gradients Layer Dimension: d_k = 128 Parallel Prefill vs. Sequential Autoregressive Decoding
A critical architectural distinction governs transformer execution:
During AI training and during the initial inference prefill phase, all input tokens are known simultaneously. The GPU can process all sequence positions in parallel using large, dense matrix-matrix multiplications (General Matrix Multiply, or GEMM). Because the matrices are large and square, GPU Tensor Cores operate at peak arithmetic efficiency, easily achieving 60% to 80% Model FLOPs Utilization (MFU).
During the inference decoding phase, however, language models generate output tokens autoregressively, one token at a time. Token t+1 cannot be calculated until token t has been sampled and fed back into the model.
For every single emitted token, the GPU must execute a matrix-vector multiplication (GEMV). Instead of multiplying massive 2D matrices, the GPU multiplies a 1-token vector (1 × d_model) against all model weight matrices (d_model × d_model) across all layers.
Because very few mathematical operations are performed for each byte of memory transferred, arithmetic intensity collapses. The GPU Tensor Cores sit starved for data, bottlenecked entirely by the physical speed at which memory can be transferred across the HBM bus.
3. Inside the GPU Training Pipeline
Let us trace the step-by-step lifecycle of an AI model training run, following the left-hand pipeline of our architectural infographic.
The End-to-End GPU Training Processing Pipeline
Petabytes of tokenized binary shards (WebDataset, Parquet).
Asynchronous multi-worker tokenization, shuffling, and sequence packing.
Direct Memory Access from pinned host RAM directly into GPU High Bandwidth Memory.
Dense GEMM matrix multiplications across Q, K, V and FFN projections.
Compares predicted vocabulary logits with ground truth targets.
Automatic differentiation reverses computational graph (~2× compute of forward).
Synchronizes and averages gradients across all GPUs via InfiniBand & NVLink.
Momentum & variance vectors update model weights (16 bytes/param).
Refreshed weights immediately ready for next incoming token batch.
Synchronous dump of model weights, optimizer states, and training RNG states via GPUDirect Storage (>800 GiB/s).

Step 1: Data Ingestion and Preprocessing
Training begins with petabytes of raw text, code, audio, or multimodal data residing in S3-compatible object stores, distributed filesystems, or local storage.
- Extraction and Shuffling: High-performance data loader threads stream compressed binary shards (such as WebDataset, TFRecord, or Parquet format) into server host DRAM. Shuffling is applied across shards and within local buffers to prevent optimization bias.
- Tokenization and Packing: Text is tokenized into integer IDs and packed into uniform context lengths (e.g., 4,096 or 8,192 tokens) using sequence packing algorithms that eliminate wasteful padding tokens.
- Mini-Batch Construction: Batches are staged in host page-locked (pinned) DDR5 memory. Pinned memory bypasses OS kernel page translation tables, enabling Direct Memory Access (DMA) engines to transfer batches over PCIe Gen5 buses directly into GPU HBM at speeds up to 64 GB/s per direction without CPU intervention.
Step 2: Forward Propagation
Once a mini-batch resides in GPU HBM, the model executes a forward pass:
The GPU’s streaming multiprocessors (SMs) and specialized Tensor Cores execute millions of fused Multiply-Accumulate (FMA) instructions, calculating attention score matrices and feed-forward projections across every layer.
Crucially, every intermediate tensor produced during this forward pass (layer activations) must be retained in GPU memory. Unlike inference, where intermediate states can be discarded as soon as the next layer finishes computing, training requires these activations to compute mathematical derivatives during the backward pass.
Step 3: Loss Calculation
At the final transformer layer, the model emits unnormalized logits over the vocabulary dimension: ŷ ∈ R^(Batch × Sequence × Vocab). The training harness compares these predictions against the ground-truth target tokens using Cross-Entropy Loss:
Loss = - (1 / N) · Σ [ log( p̂target ) ]
Where p̂ is the softmax probability computed by the GPU Tensor Cores.
The loss scalar represents the mathematical distance between what the model predicted and what the target text actually contained. The objective of the entire training cluster is to iteratively reduce this scalar.
Step 4: Backpropagation (Automatic Differentiation)
Once the loss scalar is computed, the training framework (such as PyTorch) invokes automatic differentiation to reverse through the computational graph:
- The Chain Rule: Using the mathematical chain rule of calculus, the GPU traverses backward through each transformer layer, computing two sets of gradients:
- The gradient of the loss with respect to the layer inputs (
∂L/∂A), which is propagated backward to preceding layers. - The gradient of the loss with respect to the layer weights (
∂L/∂W), which will be used to modify the model’s parameters.
- The gradient of the loss with respect to the layer inputs (
- Arithmetic Demand: Computing derivatives through matrix multiplications involves multiplying activation matrices by gradient matrices. Mathematically, the backward pass requires approximately twice as many floating-point operations as the forward pass (
2× FLOPs). Consequently, a full training step requires roughly3×the FLOPs of a forward inference pass per token (1× forward + 2× backward = 3×). - Activation Memory Explosion: Storing all intermediate activations creates staggering memory consumption. To prevent out-of-memory (OOM) errors, engineers employ activation checkpointing (also known as gradient checkpointing). Instead of saving every activation, the runtime discards most intermediate tensors during the forward pass and recalculates them on the fly during the backward pass. This trades approximately 20% to 30% additional compute for a 70% reduction in activation memory.
Step 5: Distributed Gradient Synchronization
In production LLM training, models are far too large and datasets far too vast for a single GPU. Training is distributed across hundreds or thousands of GPUs using a combination of parallelism strategies:
- Data Parallelism (DP): Multiple GPUs hold identical copies of the model parameters. Each GPU processes a different mini-batch of training data.
- Tensor Parallelism (TP): Individual linear layers within a transformer block are split across multiple GPUs (e.g., Megatron-LM splits weight matrices across 8 GPUs within an SXM chassis).
- Pipeline Parallelism (PP): Different layers of the model are assigned to different GPUs sequentially along a physical pipeline.
- Fully Sharded Data Parallel (FSDP / ZeRO-3): Parameters, gradients, and optimizer states are sharded across all available GPUs, gathered just-in-time for forward and backward passes, and immediately released.
Multi-GPU Gradient Synchronization: NVLink Mesh & InfiniBand RDMA
At the conclusion of the backward pass, each GPU holds a local tensor of computed weight gradients. Before parameters can be updated, all GPUs in the data-parallel group must calculate the mathematical average of their gradients using a collective communication operation called All-Reduce (G_avg = (1 / K) · Σ G_k).
This synchronization is executed via NVIDIA NCCL (NVIDIA Collective Communications Library) using ring-based or tree-based all-reduce algorithms.
Because every GPU must wait for all other GPUs to finish communicating before updating its weights, any latency variance, network congestion, or packet drop on the inter-GPU fabric stalls the entire supercomputer. This is why training clusters invest millions in lossless InfiniBand or RoCE v2 networks with dedicated optical fabrics.
Step 6: Optimizer Updates
Once the synchronized gradient tensor is available, the optimizer updates the model parameters. While stochastic gradient descent (SGD) simply scales gradients by a learning rate, modern transformers are trained using adaptive optimizers such as Adam or AdamW:
Tracks the exponentially decaying moving average of past gradients to maintain direction through saddle points.
Tracks squared gradient variance to scale learning rates inversely for frequently updated parameters.
m̂_t and v̂_t are bias-corrected moments, η is learning rate, and λ is weight decay coefficient.
Crucially, the Adam optimizer requires maintaining momentum, variance, and a high-precision FP32 master copy of the weights for every single parameter in the model. This creates enormous memory overhead, which we quantify in Section 5.
Step 7: Model Checkpointing
Because frontier training runs execute continuously over weeks or months, hardware failures (GPU memory ECC errors, failed transceivers, host kernel panics) are a statistical certainty.
To prevent catastrophic loss of progress, the cluster periodically writes a complete checkpoint to persistent storage:
- Model weights (parameters in FP16/BF16)
- Optimizer state vectors (
m,v, master weights in FP32) - Training telemetry, step count, and random number generator (RNG) states
For a 70B model, a single checkpoint file exceeds 1.1 Terabytes. For a 405B model, it exceeds 6 Terabytes.
When a cluster of 1,024 GPUs triggers a checkpoint, thousands of processes simultaneously flush terabytes of state across the storage fabric. If the storage subsystem is built on slow legacy NAS or unoptimized object stores, checkpointing can take 15 to 30 minutes, during which all GPUs sit frozen. High-performance distributed parallel filesystems (such as WEKA or Lustre) with GPUDirect Storage allow checkpoints to complete in seconds, restoring GPU compute immediately.
4. Inside the GPU Inference Pipeline
Now, let us examine the right-hand pipeline of our infographic: serving a trained model to generate predictions from new inputs.
The End-to-End LLM Inference Execution Pipeline
User query, system instructions, tools, and multi-turn history.
BPE tokenization and iteration-level continuous batch scheduling.
Immutable parameters locked in GPU HBM (FP16: 140 GB; FP8: 70 GB for 70B).
Processes all N input prompt tokens simultaneously using dense 2D GEMM matrix multiplications.
Projects and stores all Key and Value attention tensors in GPU HBM (320 KB per token on Llama-3-70B).
Loads entire model weights and past KV tensors across the memory bus to emit one single token (t+1).
Appends new token to KV cache and transmits text chunk down HTTP SSE stream until EOS token.
Offloads idle conversation blocks to flash; restores context in microseconds via GPUDirect RDMA.

Step 1: User Prompt and Context Assembly
Inference begins with an external user prompt or autonomous agent turn:
- Context Construction: The inference harness aggregates system instructions, few-shot examples, retrieved external documents (RAG), tool call results, and prior conversation transcript history into a single contiguous context window.
- Tokenization: The text string is converted into integer token IDs using the model’s tokenizer on CPU host cores.
- Batch Queuing: In modern serving engines (such as vLLM or TensorRT-LLM), requests enter an advanced scheduling queue implementing continuous batching (iteration-level scheduling). Instead of waiting for all requests in a batch to complete, the runtime inserts newly arrived prompts into the active batch between generation steps.
Step 2: Model Loading and Memory Staging
Before serving requests, pretrained model weights are loaded from persistent NVMe storage into GPU HBM:
- Unlike training, where weights undergo constant mathematical alteration, inference model weights are immutable and read-only.
- If the model’s footprint exceeds a single accelerator’s memory (e.g., a 70B model requires ~140 GB in FP16), the runtime shards the weights across 2, 4, or 8 GPUs using Tensor Parallelism over intra-chassis NVLink interconnects.
- To maximize serving density, models are frequently quantized to FP8, INT8, or INT4 (AWQ/GPTQ), shrinking the static weight footprint by
50%to75%with negligible loss in reasoning precision.
Step 3: The Prefill Phase (Time to First Token)
When a prompt enters the GPU, it undergoes the prefill phase:
The model ingests all prompt tokens simultaneously in a single forward pass:
- Because the entire prompt sequence is known, the GPU computes dense matrix-matrix multiplications across all sequence positions.
- Arithmetic intensity is high; Tensor Cores operate near peak utilization.
- The latency of this phase determines Time to First Token (TTFT). If a user submits a 64,000-token codebase context, the prefill phase must execute billions of matrix operations before a single word of response can be emitted.
Step 4: Key-Value (KV) Cache Materialization
During the prefill forward pass, the model projects each input token into its corresponding Key (K) and Value (V) vectors across all attention heads and transformer layers.
In training, these vectors would be discarded or saved as activations. In inference, however, they represent the model’s active working memory of the conversation.
To avoid repeatedly recomputing these mathematical projections for every subsequent token generated, the inference engine stores the K and V tensors in GPU memory. This data structure is the Key-Value (KV) Cache.
Single-Token Generation: Query Projection & KV Cache Attending
As the conversation lengthens and user concurrency increases, the KV cache grows dynamically. Unlike static model weights, the KV cache expands linearly with context length and concurrent streams, creating the primary memory bottleneck of production serving.
Step 5: The Autoregressive Decode Loop
Once prefill finishes and the initial KV cache is materialized, the inference engine enters the autoregressive decode loop:
- Single-Token Forward Pass: The model takes the most recently emitted token vector and projects it into a single Query vector
q ∈ R^(1 × d_k). - Attention over Cached History: The Query vector is multiplied against all previously cached Key vectors (
K) stored in memory, producing attention weights:A = Softmax((q · K^T) / √d_k). These weights are multiplied against all cached Value vectors (V) to compute the attended output. - Sampling: The output passes through the final feed-forward layers to produce logits over the vocabulary. The runtime applies temperature scaling, top-
p(nucleus) filtering, or top-ksampling to select the next discrete token ID. - Cache Append & Stream: The new token’s own Key and Value vectors are appended to the KV cache, and the token is converted to a text string and streamed to the client over HTTP Server-Sent Events (SSE).
- Loop Termination: This cycle repeats iteratively, one token at a time, until the model emits an End-of-Sequence (
<|eos|>) token or reaches the maximum configured token limit.
During this entire loop, the GPU is severely memory-bandwidth bound. Every single token requires reading all model weights and all past KV tensors across the memory bus just to compute one single next-token prediction.
Step 6: Memory Hierarchy and Cache Offloading
Because GPU High Bandwidth Memory is extremely expensive and finite (e.g., 80 GB on an H100; 141 GB on an H200), production serving platforms cannot maintain unlimited KV caches in accelerator memory.
When HBM capacity is reached, the serving architecture faces three options:
- Request Queueing / Throttling: Reject or delay new incoming user turns until active streams complete.
- Context Eviction & Recomputation: Discard cached conversation histories. When that user turns next, the engine must recompute the entire prompt prefill from scratch, causing TTFT to spike from 100 milliseconds to tens of seconds.
- Hierarchical Memory Offloading: Selectively offload inactive KV cache blocks across a coordinated memory hierarchy:
- Tier 1 (GPU HBM): Microsecond-scale active cache supporting active token generation.
- Tier 2 (Host DDR5 DRAM): High-capacity server memory accessible over PCIe Gen5.
- Tier 3 (Distributed Parallel Flash): NVMe-over-Fabrics shared storage (such as WEKA NeuralMesh) restoring cached context blocks via GPUDirect RDMA.
As explored in our companion guide on The Storage Architecture Revolution, treating storage as an active memory extension is redefining the economics of long-context multi-agent systems.
5. GPU Memory: Training Versus Inference
To design robust infrastructure, systems engineers must calculate exact memory allocation. The formulas governing memory consumption differ radically between training and inference.
GPU High Bandwidth Memory: Training Allocation vs. Inference Allocation
A. Training Memory Allocation (70B BF16)
Training requires storing weights, gradients, optimizer state vectors, and forward activations simultaneously:
B. Inference Memory Allocation (70B Serving)
Inference eliminates gradients and optimizer states, replacing them with dynamic Key-Value attention cache:
KV_Bytes = 2 × n_layers × n_kv_heads × d_head × seq_len × bytes_per_element × batch_size Mathematical Anatomy of Training Memory
During distributed training of a model with N parameters in 16-bit mixed precision (BF16/FP16), total memory consumption per training step is the sum of four distinct components:
Training_Memory = M_weights + M_gradients + M_optimizer + M_activations + M_workspace- Model Parameters (
M_weights): Stored in 16-bit precision (2 × Nbytes) = 140 GB (70B model). - Weight Gradients (
M_gradients): Each parameter requires an identical 16-bit gradient tensor = 140 GB (70B model). - Optimizer States (
M_optimizer): Standard AdamW maintains three 32-bit state tensors per parameter (FP32 master weights4N+ momentum4N+ variance4N=12 × Nbytes) = 840 GB (70B model). - Activation Memory (
M_activations): Intermediate forward tensors staged for backprop. With activation checkpointing, consumes approximately 50 GB to 150 GB per node.
Total 70B Training Memory = 140 GB (weights) + 140 GB (gradients) + 840 GB (Adam) + 100 GB (activations) ≈ 1,220 GBEngineering Reality: You cannot train a 70B model on a single 80 GB GPU. Even with FSDP or ZeRO-3 sharding parameters, gradients, and optimizer states evenly across GPUs, an 8-way NVIDIA H100 node (640 GB aggregate HBM) is insufficient. Production training requires distributing across at least 16 to 32 accelerators just to satisfy physical memory allocation.
Mathematical Anatomy of Inference Memory
During inference, gradients and optimizer states are completely eliminated. Memory is governed by static weights plus the dynamic Key-Value cache:
Inference_Memory = M_weights + M_runtime + M_KV_Cache- Static Model Parameters (
M_weights): In FP16 = 140 GB; in FP8 = 70 GB; in INT4/AWQ = 35 GB (70B model). - Runtime Workspace (
M_runtime): Transient scratchpad buffers during single-token forward passes = 2 GB to 4 GB per GPU. - Dynamic Key-Value Cache (
M_KV_Cache): For every processed token, the model retains two vectors (KandV) across all layers:
KV_Bytes = 2 × n_layers × n_kv_heads × d_head × S_ctx × b_elem × B_concurrencyWhere:
2: Accounts for the two separate Key and Value tensors.n_layers: Total number of transformer layers (80 in Llama-3-70B).n_kv_heads: Number of Key-Value attention heads (8 heads using Grouped-Query Attention).d_head: Dimension of each attention head (d_head = d_model / n_q_heads = 8192 / 64 = 128).S_ctx: Active context length in tokens.b_elem: Precision bytes per element (2 for FP16; 1 for FP8; 0.5 for INT4).B_concurrency: Number of concurrent active user streams.
Worked Calculation: Llama-3-70B KV Cache Scaling
For a single token in FP16 (b_elem = 2):
Bytes Per Token = 2 × 80 × 8 × 128 × 2 = 327,680 bytes ≈ 320 KB / tokenNow examine how this scales under enterprise workloads:
Concurrency (B) | Context Length (S_ctx) | Cumulative KV Tokens | KV Cache Footprint (FP16) | KV Cache Footprint (FP8) |
|---|---|---|---|---|
| 1 User | 8,192 tokens | 8.19K | 2.62 GB | 1.31 GB |
| 1 User | 128,000 tokens | 128K | 41.94 GB | 20.97 GB |
| 16 Users | 32,000 tokens | 512K | 167.77 GB | 83.88 GB |
| 32 Users | 128,000 tokens | 4.09M | 1,342.17 GB (1.34 TB) | 671.08 GB |
| 64 Users | 128,000 tokens | 8.19M | 2,684.35 GB (2.68 TB) | 1,342.17 GB |
The Architectural Insight: While static weights occupy a fixed 70 GB (FP8), serving 32 concurrent developers working with long repository contexts requires 671 GB to 1.34 TB of pure KV cache.
In training, memory is dominated by optimizer states and activations. In inference, memory is dominated by the dynamic KV cache.
6. Why Networking Requirements Differ
Both training and inference rely on high-speed networking, but they stress completely different layers of the communications stack.
Interconnect Topologies: Training All-Reduce vs. Inference Disaggregation
A. Training Interconnect Fabric
Synchronizes millions of weight gradients simultaneously across data-parallel ranks at every mini-batch:
B. Inference Interconnect Fabric
Optimizes for microsecond request dispatching, intra-node tensor parallelism, and disaggregated KV cache transfer:
The Training Interconnect Fabric
During distributed training, GPUs must synchronize millions of gradient values simultaneously across data-parallel ranks at every single batch iteration:
- Ultra-Low Latency & High Bandwidth: Interconnect throughput must match GPU computation speeds. Inside an 8-GPU node, NVIDIA NVLink provides up to 900 GB/s bidirectional bandwidth per GPU over an NVSwitch fabric. Across nodes, clusters deploy dedicated InfiniBand (Quantum-2 400 Gbps or Quantum-X800) or RoCE v2 (RDMA over Converged Ethernet) fabrics delivering up to 3.2 Tbps of network I/O per server.
- Synchronous Barrier Sensitivity: All-reduce operations are collective synchronization barriers. If one GPU among 1,024 slows down due to an optical transceiver glitch or packet drop, all 1,023 other GPUs must wait at the barrier. Training fabrics require strict lossless configurations, priority-based flow control (PFC), and explicit congestion notification (ECN).
- Traffic Pattern: Coordinated, periodic, bursty, all-to-all and ring-collective communications.
The Inference Interconnect Fabric
Inference networking targets different optimization objectives:
- Tensor Parallel Intra-Node Communication: If a model is sharded across multiple GPUs in a single chassis, the GPUs exchange tiny activations after every attention and MLP block. Because decoding generates one token at a time, these all-reduce messages are minuscule (a few kilobytes). Here, nanosecond-scale message latency matters far more than raw network bandwidth. NVLink easily satisfies this requirement.
- Disaggregated Prefill and Decode (PD Separation): In state-of-the-art serving architectures (such as Mooncake or vLLM disaggregated serving), the prefill phase and decode phase are decoupled across separate GPU clusters:
- Prefill nodes are configured with high-compute GPUs (e.g., H100 SXM) to process prompts with high MFU.
- Decode nodes are configured with high-memory-bandwidth systems (e.g., H200 or GH200) to execute the autoregressive loop.
- When prefill finishes, the newly materialized KV cache is transmitted across an ultra-high-speed RDMA network fabric directly into the decode node’s memory.
- Traffic Pattern: Asynchronous, streaming, client-facing ingress/egress, and point-to-point RDMA cache transfers.
7. The Storage Architecture Behind AI
Storage infrastructure is frequently misunderstood in AI engineering. Infrastructure architects often assume that once a dataset is loaded or a model is deployed, storage is irrelevant.
In production AI systems engineering, storage architecture directly determines GPU return-on-investment.
| Storage Architecture Tier | Training Role | Inference Role | Key Protocols & Technologies |
|---|---|---|---|
| Durable Object Storage | Holds petabytes of raw uncompressed datasets, web scrapes, and final model artifacts | Archival repository for base weights, adapter checkpoints, and historical transcripts | S3 API, Ceph Object Gateway, MinIO |
| High-Performance Parallel Filesystems | Feeds tokenized batches at >50 GiB/s; absorbs multi-terabyte checkpoint write storms | Rapid cold-boot model loading; shared model weight distribution across thousands of serving nodes | POSIX, WEKA NeuralMesh, Lustre, IBM Spectrum Scale |
| Local NVMe SSDs | Temporary staging for local epoch caches and scratch files | Host-level PagedAttention KV-cache swap space; local Hugging Face weight cache | PCIe Gen5 NVMe, Direct I/O, io_uring |
| Distributed NVMe Fabrics (NVMe-oF) | Shared high-speed scratch space; multi-node checkpoint staging | Augmented Memory Grid: Shared multi-node KV-cache offload and cross-node prefix reuse | NVMe-oF RDMA, GPUDirect Storage (GDS), WEKA NeuralMesh |
High-Throughput Checkpointing vs. Cold-Start Model Boot
In training, storage performance is measured by its ability to prevent I/O starvation during data ingestion and absorb write bursts during checkpointing:
If a 1.25-trillion parameter model checkpoint requires 6 Terabytes of state, writing that file across a standard 10 GbE NFS share takes over an hour. With distributed parallel storage utilizing NVIDIA GPUDirect Storage (GDS), data moves directly from GPU HBM across local PCIe switches to NVMe drives, bypassing CPU socket and OS page-cache bottlenecks. Storage throughput exceeds 800 GiB/s, reducing checkpoint write stalls to seconds.
In inference, storage performance dictates cold-start recovery and dynamic auto-scaling:
When serving traffic spikes, the orchestrator (e.g., Kubernetes with KEDA) spawns new inference pods across the cluster. If each pod must download 140 GB of model weights over standard network storage, pod startup takes 10 to 15 minutes. High-throughput distributed NVMe fabrics allow hundreds of GPU pods to load weights concurrently at line-rate, achieving sub-30-second cold starts.
WEKA NeuralMesh and KV-Cache Memory Offloading
In long-context multi-agent systems, storage enters the inference critical path through prefix caching and KV-cache offloading:
When multiple enterprise agents share identical system instructions, API tool schemas, or large repository AST indexes (as detailed in our AST Skeletonization Guide), recomputing the attention state for every new turn wastes quadrillions of FLOPs.
Software-defined parallel storage architectures, such as WEKA NeuralMesh and its Augmented Memory Grid, provide microsecond-scale distributed flash fabrics. By pairing GPUDirect RDMA with distributed NVMe storage, inactive conversation KV caches can be offloaded directly from GPU HBM into shared NVMe fabrics.
When that user or autonomous agent resumes their session, the cached KV blocks are restored directly into GPU memory via DMA in milliseconds, completely bypassing the compute-heavy prefill phase.
8. Performance Engineering and GPU Economics
Designing AI infrastructure requires understanding the economic trade-offs between hardware cost and computational efficiency.
Key Performance Indicators: Training vs. Inference
The operational metrics that govern training cluster health are fundamentally distinct from inference service level agreements (SLAs):
Operational Benchmarks: Training Throughput vs. Inference Latency
A. Training KPI Targets (Hardware Efficiency)
B. Inference KPI Targets (Latency & Quality)
Training Metrics:
- Model FLOPs Utilization (MFU): The ratio of observed arithmetic throughput to the theoretical peak throughput of the hardware. Modern LLM training targets
45%to55%MFU. If MFU drops below35%, the cluster is stalling on network synchronization, data loading, or pipeline bubbles. - Tokens Per Second (Cluster Throughput): Total aggregate tokens processed across all GPUs per unit time (
S_tokens = Batch Size × Sequence Length / Step Time). - Time to Train: Total cluster operating hours required to process a training budget (e.g., 15 trillion tokens).
Inference Metrics:
- Time to First Token (TTFT): Duration between request submission and initial token emission. Dominated by prompt prefill speed and queue wait times. Target:
< 300 msfor interactive sessions. - Inter-Token Latency (ITL) / Time Per Output Token (TPOT): The time required to decode each subsequent token. Human reading speed is approximately 5 to 8 tokens per second; interactive coding copilots target
> 40 tokens/sec/stream. - Serving Concurrency: Number of simultaneous active streams an 8-GPU node can maintain before HBM exhaustion triggers request queueing.
The Economics of Underutilized Silicon
At enterprise scale, high-end accelerators (NVIDIA H100 / H200) cost between $3.00 and $5.00 per GPU-hour in sovereign cloud or hyperscaler environments. An 8-way node costs approximately $25,000 to $35,000 per month to operate.
If an infrastructure team provisions expensive GPUs but couples them with inadequate networking or slow storage:
- In training, an all-reduce network delay or slow checkpoint system that degrades MFU from 50% to 35% extends a 60-day training run to 85 days, wasting hundreds of thousands of dollars in idle operational overhead.
- In inference, a serving engine that lacks KV-cache memory offloading or continuous batching will leave Tensor Cores operating at 5% to 10% efficiency, driving the cost per million generated tokens to unsustainable levels.
9. Interactive Engineering Component: GPU Pipeline Inspector
Use our interactive engineering simulator below to toggle between Training Mode and Inference Mode. Click on any execution stage to inspect its real-time compute engines, memory bandwidth, network fabrics, and storage I/O demands.
GPU Processing Pipeline Inspector
SELECT EXECUTION STAGE TO INSPECT TELEMETRY: Stage 1 of 7
Tensor Core Operations
Dense matrix multiplications across attention layers and FFN projections.
Activation & Gradient Tensors
Stores full intermediate tensors required for backpropagation differential chains.
PCIe / Host Staging
DMA transfers over PCIe Gen5 x16 from CPU pinned RAM to GPU accelerator memory.
Continuous Read Stream
High-throughput sequential reads of tokenized binary dataset shards without GPU starvation.
If storage cannot feed token batches at least as fast as the GPU computes the forward pass, GPU Model Flops Utilization (MFU) plummets below 30%. Never let a $30,000 GPU wait on standard POSIX kernel file locks.
10. Architecture Decision Guide
To synthesize these architectural principles into actionable engineering practice, infrastructure architects should reference the following decision matrix when designing, sizing, and budgeting GPU clusters:
GPU Infrastructure Optimization Decision Framework
Frontier Pre-Training & Fine-Tuning
Prioritize InfiniBand 400G/800G or RoCE v2 with NCCL. Zero-drop lossless fabric is mandatory to prevent all-reduce stalls.
Ensure sufficient HBM to hold weights, gradients, Adam states (16B/param), and activations (FSDP / ZeRO-3).
Deploy parallel NVMe filesystems (WEKA, Lustre) supporting GPUDirect Storage to flush multi-terabyte checkpoints in < 30 seconds.
Production Inference & Agent Swarms
Prioritize maximum memory bandwidth (3.35+ TB/s) and large HBM (141 GB H200) to maximize concurrent KV-cache capacity.
Deploy vLLM or TensorRT-LLM with PagedAttention, FP8 quantization, and continuous iteration-level batching.
Implement multi-tier offload (host DDR5 + distributed NVMe flash) and disaggregated prefill-decode architectures.
When to Prioritize Specific Infrastructure Subsystems:
1. Prioritize Ultra-High Inter-GPU Network Bandwidth (InfiniBand / RoCE v2)
- When: Building multi-node distributed training clusters using Data Parallelism, FSDP, or Pipeline Parallelism.
- Why: All-reduce gradient synchronization across thousands of GPUs is an absolute synchronization barrier; any network jitter or dropped packet stalls the entire cluster.
2. Prioritize Maximum GPU HBM Capacity and Memory Bus Bandwidth (H200 / B200)
- When: Deploying high-concurrency LLM inference serving, multi-agent frameworks, and long-context (32k to 128k+) applications.
- Why: Autoregressive decoding is physically bound by memory bus bandwidth, while serving concurrency is governed strictly by the number of KV-cache blocks that can fit in accelerator memory.
3. Prioritize Ultra-Fast Distributed Parallel Filesystems (GPUDirect Storage / NVMe-oF)
- When: Managing multi-terabyte training checkpoint storms, large-scale dataset ingestion, or implementing cross-node KV-cache offloading for enterprise agent swarms.
- Why: Eliminates CPU socket and OS kernel bottlenecks, dumping checkpoints in seconds and restoring cached conversation contexts at microsecond latency.
4. Prioritize Disaggregated Serving Architectures (PD Separation)
- When: Serving multimodal or mixed-workload traffic with large prompt variances (e.g., 50,000-token prompt prefill followed by 200-token output generation).
- Why: Prevents compute-dense prefill operations from preempting and starving latency-critical autoregressive decoding streams.
11. Conclusion: The Dual Pillars of AI Infrastructure
The journey from raw data to real-time generative intelligence spans two complementary but fundamentally distinct computational universes:
- AI Training is the process of creating intelligence: It transforms vast, unstructured corpuses of human knowledge into billions of learned mathematical parameters. It demands brute-force arithmetic density, symmetric forward and backward automatic differentiation, tightly synchronized multi-GPU all-reduce fabrics, and burst-tolerant parallel storage systems capable of weathering terabyte-scale checkpoint storms.
- LLM Inference is the process of executing that intelligence: It transforms static, frozen weight matrices into responsive, context-aware reasoning streams. It demands memory-bandwidth efficiency, surgical handling of dynamic Key-Value attention states, continuous batching schedulers, and hierarchical memory tiers that bridge the gap between expensive GPU HBM, host server DRAM, and distributed flash storage.
Both pipelines run on GPUs. Both utilize matrix multiplications. But the systems engineering required to optimize them could not be more different.
As foundation models evolve toward multi-turn autonomous agents, multi-million-token context windows, and real-time reasoning loops, the infrastructure teams that succeed will be those who design not for generic FLOPs, but for the exact computational, memory, networking, and storage physics of the workload at hand.
Technical References and Further Reading
- Vaswani, A., et al. (2017). Attention Is All You Need. Advances in Neural Information Processing Systems (NeurIPS 2017). arXiv:1706.03762.
- Shoeybi, M., et al. (2019). Megatron-LM: Training Multi-Billion Parameter Language Models Using Model Parallelism. NVIDIA Applied Deep Learning Research. arXiv:1909.08053.
- Rajbhandari, S., et al. (2020). ZeRO: Memory Optimizations Toward Training Trillion Parameter Models. Microsoft Research. arXiv:1910.02054.
- Kwon, W., et al. (2023). Efficient Memory Management for Large Language Model Serving with PagedAttention. Proceedings of the ACM SIGOPS 29th Symposium on Operating Systems Principles (SOSP ‘23). arXiv:2309.06180.
- NVIDIA Corporation (2024). NVIDIA Collective Communications Library (NCCL) Architecture & Developer Guide. NVIDIA Developer Documentation.
- NVIDIA Corporation (2024). GPUDirect Storage (GDS): Architecture and Benchmarking Overview. NVIDIA Docs.
- Dao, T. (2023). FlashAttention-2: Faster Attention with Better Parallelism and Work Partitioning. arXiv:2307.08691.
- Zhong, Y., et al. (2024). DistServe: Disaggregating Prefill and Decoding for Goodput-Optimized Large Language Model Serving. arXiv:2401.09670.
- Viscomi, L. (2026). Inside the AI Memory Wall: GPU HBM, KV Cache, NVMe Fabrics and WEKA NeuralMesh. AgentJunky Engineering Deep Dive #17. agentjunky.com/posts/17-inside-the-ai-memory-wall-kv-cache-weka/.
- Viscomi, L. (2026). From SAN to Sovereign AI: The Storage Architecture Revolution. AgentJunky Engineering Deep Dive #16. agentjunky.com/posts/16-from-san-to-sovereign-ai-storage-revolution/.
- Viscomi, L. (2026). The AI Storage Atlas: Disaggregated NVMe Fabrics & Sovereign Cloud Reference Architectures. agentjunky.com/storage-atlas/.
Subscribe to The AgentJunky AI Brief
Get practical engineering thinking on AI storage fabrics, autonomous agents, Model Context Protocol, and sovereign infrastructure delivered straight to your LinkedIn feed.
Discuss an AI Opportunity
Need an architectural review, help transitioning an agent prototype to production, or designing governed tool gateways? Let's connect.