Skip to content
E
Educatum

What is the Memory Hierarchy and why does it bottleneck AI workload scaling?

Curated by Educatum AI teamLast updated:
Hardware
Direct Answer

Modern AI accelerators face the Memory Wall because peak compute (TFLOPS) has scaled far faster than memory bandwidth, leaving workloads like autoregressive LLM decoding memory-bandwidth-bound rather than compute-bound. The GPU memory hierarchy trades capacity for speed—moving from ultra-fast, tiny on-chip SRAM (registers and L1/L2 caches) to high-capacity on-package HBM, off-chip system DRAM, and multi-GPU NVLink interconnects. When an operation's arithmetic intensity falls below the hardware's ridge point in the Roofline Model, Tensor Cores stall waiting for weights and KV-cache data from HBM.

Modern AI accelerators are governed by the “Memory Wall,” a phenomenon where the growth in compute throughput (TFLOPS) significantly outpaces the growth in memory bandwidth. In Large Language Model (LLM) training and inference, the bottleneck is rarely the arithmetic speed of the Tensor Cores, but rather the speed at which weights and activations can be moved through the hierarchy—from high-capacity DRAM to the high-speed Registers.

The hierarchy is a trade-off between Capacity, Bandwidth, and Latency:

  • Registers & L1/L2 Cache: These are SRAM-based, located directly on the chip. They provide near-instantaneous access (cycles) but are extremely limited in size (MBs). They store the immediate operands for the ALUs.
  • HBM (High Bandwidth Memory): This is the “on-package” memory for GPUs (e.g., H100). It uses 3D-stacked DRAM to provide TB/s of bandwidth, acting as the primary storage for model weights during active computation.
  • System DRAM: Traditional DDR memory on the CPU side. It offers massive capacity (TBs) but is an order of magnitude slower than HBM, typically used for offloading optimizer states or data loading.
  • NVLink: As models outgrow a single GPU, NVLink provides a high-speed, point-to-point interconnect that allows GPUs to share data at speeds far exceeding PCIe, effectively creating a “unified” memory pool across a node.

🧪 Core Insights & Mathematical Foundations

[Roofline Model]: Pattainable=min⁡(Peak FLOPS,Operational Intensity×Bandwidth)[Operational Intensity]: I=FLOPsBytes Transferred[Little’s Law for Memory]: Concurrency (Bytes)=Bandwidth (B/s)×Latency (s)[NVLink Bandwidth]: BWtotal=∑i=1nBWlinki(unidirectional or bidirectional aggregate)[HBM Power Efficiency]: EJ/bit=Ptotal (W)BWtotal (bits/s)  ⟹  EpJ/bit=Ptotal (W)BWtotal (Tb/s)[KV Cache Footprint]: SKV=2×B×nlayers×nkv_heads×dhead×L×pbytes\begin{aligned} & \text{[Roofline Model]: } P_{\text{attainable}} = \min(\text{Peak FLOPS}, \text{Operational Intensity} \times \text{Bandwidth}) \\ & \text{[Operational Intensity]: } I = \frac{\text{FLOPs}}{\text{Bytes Transferred}} \\ & \text{[Little's Law for Memory]: } \text{Concurrency (Bytes)} = \text{Bandwidth (B/s)} \times \text{Latency (s)} \\ & \text{[NVLink Bandwidth]: } BW_{\text{total}} = \sum_{i=1}^{n} BW_{\text{link}_i} \quad (\text{unidirectional or bidirectional aggregate}) \\ & \text{[HBM Power Efficiency]: } E_{\text{J/bit}} = \frac{P_{\text{total}}\text{ (W)}}{BW_{\text{total}}\text{ (bits/s)}} \implies E_{\text{pJ/bit}} = \frac{P_{\text{total}}\text{ (W)}}{BW_{\text{total}}\text{ (Tb/s)}} \\ & \text{[KV Cache Footprint]: } S_{\text{KV}} = 2 \times B \times n_{\text{layers}} \times n_{\text{kv\_heads}} \times d_{\text{head}} \times L \times p_{\text{bytes}} \end{aligned}

Follow-up 1: Explain the physical differences between SRAM caches and HBM, and why we cannot simply use more SRAM.

SRAM (used in Registers and L1/L2) uses a 6-transistor (6T) cell design that is volatile but incredibly fast because it does not require refresh cycles. However, SRAM is physically large and expensive in terms of “silicon real estate.” Adding enough SRAM to store a 70B parameter model (roughly 140GB in FP16) is physically impossible with current photolithography limits, as the chip would be several times larger than the maximum reticle size.

HBM (High Bandwidth Memory) solves the density problem by using DRAM technology, which stores data in a 1-transistor 1-capacitor (1T1C) cell. These cells are much smaller than SRAM but slower. HBM achieves high bandwidth by stacking these DRAM dies vertically and connecting them to the GPU via a wide 1024-bit interface per stack routed across a silicon interposer. This allows HBM to provide the capacity needed for LLMs while maintaining a bandwidth that, while slower than SRAM, is far superior to standard off-chip DRAM.

When a model’s weights or KV cache exceed the HBM capacity of a single GPU (e.g., 80GB on an H100), the workload must be partitioned using Tensor or Pipeline Parallelism. Standard PCIe connections often become a bottleneck here because they use a shared bus architecture with high overhead. NVLink addresses this by providing dedicated, high-speed differential signaling paths directly between GPUs.

  • P2P Memory Access: NVLink allows a GPU to read/write directly to the HBM of another GPU without involving the CPU or system DRAM. This reduces latency to the sub-microsecond range.
  • NVSwitch Scaling: In a cluster, NVSwitches allow every GPU in an 8-GPU node to communicate with every other GPU at full NVLink bandwidth simultaneously. This effectively turns the aggregate HBM of all GPUs into a single, high-speed memory fabric.
  • Collective Operations: NVLink is optimized for “All-Reduce” and “All-Gather” operations, which are the mathematical heart of distributed training. By offloading these to the interconnect hardware, the compute cores can stay focused on matrix multiplication rather than data movement.
View all →

Try keywords like RoPE, FlashAttention, DPO, or Blind 75.