Hardware

Dive into Deep Learning · §39.4

Hardware: Memory Capacity, Bandwidth Bounds, Unified Memory, and TCO
training memory budget · decode bandwidth bound · discrete GDDR7 GPUs · unified LPDDR5X · MoE arithmetic · rent-vs.-buy break-even

Three Quantities Decide Every Hardware Purchase

Motivation

  • 1. Memory Capacity (GB / GiB): Decides what can run at all—if 16N training state or inference weights + KV cache exceed RAM/VRAM, FLOP/s is irrelevant.
  • 2. Memory Bandwidth (GB/s or TB/s): Decides how fast a model generates tokens (\text{tok/s} \lesssim \beta / B_{\text{active}}).
  • 3. Compute Throughput (TFLOP/s): Decides training and prompt-prefill speed, where weights are reused across hundreds of tokens.

The Memory Capacity Constraint in Training

Capacity Budget

Why does training or full fine-tuning require 4\times\text{--}8\times more memory than loading the same model for inference?

  • Mixed-precision Adam state (16\text{ B/param}):
    • BF16 parameters (2\text{ B}) + BF16 gradients (2\text{ B}).
    • FP32 master weights (4\text{ B}) + two FP32 Adam moments m, v (8\text{ B}).
    • Without a separate master copy (12\text{ B/param}), state alone is already 6\times the BF16 model size.
  • Activations and workspace: Forward activations saved for backpropagation (scaling with batch \times sequence length) plus cuBLAS/cuDNN scratch workspace add several GiB on top.

Estimating Peak Training Memory by Model Scale

Full Fine-Tune vs. QLoRA

Our sizing function sums parameter state (12\text{ B/param} without master weights, or 16\text{ B/param} with them) plus activation and workspace overhead:

  • Full 7B fine-tune (\approx 86\text{--}112\text{ GiB}): Exceeds every consumer desktop GPU (16\text{--}32\text{ GB}).
  • How QLoRA fits 7B–8B on a 16 GB card:
    • Freezes the base weights in 4-bit NormalFloat (\sim 0.52\text{ B/param} \approx 4\text{ GiB} for 8B).
    • Trains low-rank adapters on \sim 1\% of parameters (\approx 0.08\text{B} \times 12\text{ B} \approx 1\text{ GiB}), leaving \sim 11\text{ GiB} for activations and logits.
def training_memory_gib(parameters_billion, weight_bytes=2,
                        gradient_bytes=2, optimizer_bytes=8,
                        activation_gib=6, workspace_gib=2):
    parameters = parameters_billion * 1e9
    state = parameters * (weight_bytes + gradient_bytes + optimizer_bytes)
    return state / 2**30 + activation_gib + workspace_gib

for b in [0.1, 1, 7]:
    print(f"{b:>4}B params: {training_memory_gib(b):6.1f} GiB")
 0.1B params:    9.1 GiB
   1B params:   19.2 GiB
   7B params:   86.2 GiB

The Autoregressive Decode Bandwidth Bound

Inference Roofline

\text{decode tokens/s} \lesssim \frac{\beta}{B_w + B_{\text{kv}}(n)}

  • Worked example (8B dense model at 4 bits): Streams B_w = 4.0\text{ GB} of weights plus B_{\text{kv}} \approx 0.5\text{ GB} of 4K BF16 KV cache (4.5\text{ GB/token} total).
  • Why compute is idle: Executing 16\text{ GFLOPs} across 4.5\text{ GB} yields I \approx 3.5\text{ FLOP/B}—40\times\text{--}85\times below the GPU ridge point.

Ranking Hardware by the Decode Bandwidth Bound

Bandwidth Ordering

Applying \beta / (4.5\text{ GB}) across consumer discrete cards, unified-memory boxes, and a datacenter H100 predicts generation speed to within a factor of two:

bandwidth_gbs = {"RTX 5070 Ti": 896, "RTX 3090 (used)": 936,
                 "RTX 5090": 1792, "RTX PRO 6000": 1792,
                 "DGX Spark": 273, "Strix Halo": 256,
                 "M5 Max": 614, "M5 Ultra": 1200, "H100 SXM": 3350}
active_gb = 4.5   # 8B model at 4-bit, including cache traffic
for device, bw in sorted(bandwidth_gbs.items(), key=lambda kv: -kv[1]):
    print(f"{device:>16s}: <= {bw / active_gb:5.0f} tok/s")
  • Bandwidth sets the ceiling:
    • An H100 SXM (3{,}350\text{ GB/s}) bounds decode at \le 744\text{ tok/s}.
    • An RTX 5090 or PRO 6000 (1{,}792\text{ GB/s}) reaches \le 398\text{ tok/s}.
    • A DGX Spark (273\text{ GB/s}) and Strix Halo (256\text{ GB/s}) both cap near \le 57\text{--}61\text{ tok/s}, even though the Spark costs twice as much and has far more compute.
        H100 SXM: <=   744 tok/s
        RTX 5090: <=   398 tok/s
...
       DGX Spark: <=    61 tok/s
      Strix Halo: <=    57 tok/s

How Long Contexts Shift the Bottleneck to KV Cache

Long-Context Arithmetic

B_{\text{kv}}(n) = 2 \cdot L \cdot H_{\text{kv}} \cdot d_h \cdot 2\text{ B} \cdot n

  • Llama 3.1 8B (128\text{ KiB/token}): KV cache grows from 0.5\text{ GB} at 4\text{K} (11\% of traffic) to 4.0\text{ GB} at 32\text{K} (50\%) and 16.0\text{ GB} at 128\text{K} (80\% of traffic, overflowing a 16 GB card).
  • Diminishing returns of weight-only quantization: 4-bit weights speed up decode 3.6\times at 4\text{K} context, but only 1.6\times at 128\text{K} unless the KV cache is also quantized.

Two Families of Local Hardware

The Hardware Landscape

Plotting machines on memory capacity (vertical) versus memory bandwidth (horizontal) reveals a sharp architectural split:

  • Discrete consumer GPUs (bottom right): Pair ultra-fast GDDR6X/GDDR7 (896\text{--}1792\text{ GB/s}) with modest capacity (16\text{--}32\text{ GB}). Fast for training and small/medium models.
  • Unified-memory systems (top left): Pair massive LPDDR5X capacity (64\text{--}512\text{ GB}) with lower bandwidth (256\text{--}1200\text{ GB/s}). Run huge models locally at lower token rates.
  • Workstation & datacenter cards (upper right): RTX PRO 6000 (96\text{ GB}, 1.79\text{ TB/s}) and H100 (80\text{ GB}, 3.35\text{ TB/s}) deliver both at five-figure prices.

Entry Discrete Training GPUs: 5070 Ti vs. Used 3090

16 GB to 24 GB Desktop Cards

  • New RTX 5070 Ti (16 GB GDDR7, 896\text{ GB/s}): Runs every single-GPU D2L notebook (< 13\text{ GiB}), 7B–8B QLoRA, and native Blackwell FP8/FP4 Tensor Cores at 300\text{ W} with a retail warranty.
  • Used RTX 3090 (24 GB GDDR6X, 936\text{ GB/s}): Trades newer FP8/FP4 support and warranty for +8\text{ GB} of extra VRAM at a similar street price (\sim\$1{,}250\text{--}1{,}450).

High-End Desktop Training: The RTX 5090 Workstation

Balanced System Design

Stepping up to 32 GB GDDR7 at 1.79\text{ TB/s} (RTX 5090, street price \approx \$6{,}000\text{--}8{,}000 in Nov 2026) supports full fine-tunes up to \sim 2\text{B} parameters and QLoRA up to \sim 30\text{B}:

  • Thermal & electrical envelope: The GPU alone dissipates 575\text{ W}; NVIDIA specifies a 1000\text{ W} PSU, high-airflow chassis, and a dedicated wall circuit capacity.
  • Feeding the GPU (\approx \$8{,}500\text{--}12{,}500 total build): Pair with a 16-core CPU, 64\text{--}128\text{ GB} DDR5 RAM, and fast PCIe Gen4/5 NVMe SSDs so data loading and checkpointing never bottleneck compute.
  • Multi-GPU consumer limits: No consumer card since the 3090 has NVLink, and desktop motherboards rarely offer multiple full x16 PCIe lanes without Threadripper/EPYC platforms.

Unified-Memory Architecture: Capacity Over Bandwidth

Local Large-Model Inference

How can a mini-PC or Mac Studio run a 70B or 120B language model that does not fit on an RTX 5090?

  • Eliminating the PCIe copy bottleneck: Discrete GPUs copy tensors across PCIe between host DDR5 and a small pool of soldered GDDR7 VRAM.
  • Shared LPDDR5X memory pool: Unified-memory systems attach both CPU and GPU cores directly to a single large pool of wide-bus LPDDR5X (64\text{--}512\text{ GB}).
  • The physical trade-off: You gain 4\times\text{--}16\times more memory capacity than a desktop GPU, at 15\%\text{--}65\% of an RTX 5090’s memory bandwidth.

Comparing Unified-Memory Systems (Nov 2026)

Unified-Memory Menu

  • 256\text{--}273\text{ GB/s} Tier (128 GB): AMD Strix Halo (\sim\$3.4\text{K--}4.4\text{K}) offers the lowest-cost 128 GB box, while NVIDIA DGX Spark (\$5\text{K--}7\text{K}) adds native CUDA and 2.4\times faster prompt prefill.
  • 614\text{--}1{,}200\text{ GB/s} Tier (Apple Silicon): Mac Studio / MacBook Pro M5 Max (128\text{ GB}, 614\text{ GB/s}) and M5 Ultra (up to 512\text{ GB}, 1.2\text{ TB/s}) double or quadruple unified-memory decode bandwidth.

Why Mixture-of-Experts (MoE) Shines on Unified Memory

Dense vs. Sparse Decode

  • Dense 70B (4-bit, \sim 40\text{ GB} read/token): Fits in 128 GB unified memory, but reading 40\text{ GB} per token crawls at < 7\text{ tok/s} on Strix Halo / Spark (256\text{--}273\text{ GB/s}).
  • MoE gpt-oss-120b (117B total, 5.1B active/token): Needs \sim 59\text{ GiB} capacity to hold all experts, but reads only \sim 3\text{--}3.5\text{ GB/token}—decoding at 50\text{--}60\text{ tok/s} on Strix/Spark and 115\text{--}120\text{ tok/s} on M5 Ultra.

Prefill Compute Separates Equal-Bandwidth Machines

Prompt Processing vs. Decode

  • Short chat (500-tok prompt + 500-tok reply): Decode bandwidth dominates, so DGX Spark (273\text{ GB/s}) and Strix Halo (256\text{ GB/s}) finish in similar time (8.5\text{ s} vs. 10.5\text{ s}).
  • 30,000-token coding-agent prompt: Prefill is compute-bound; Spark’s Blackwell Tensor Cores prefill at 2{,}400\text{ tok/s} vs. 1{,}000\text{ tok/s}, cutting Time to First Token from 30.0\text{ s} \to 12.5\text{ s} (2.4\times faster).

Workstation GPUs and the Rent-vs.-Buy Break-Even

Total Cost of Ownership

The RTX PRO 6000 Blackwell packs 96 GB GDDR7 at 1.79\text{ TB/s} (\$16{,}000, Nov 2026); four 300 W Max-Q cards put 384\text{ GB} in one chassis for \$64{,}000, linked by 64\text{ GB/s} PCIe 5.0. When does buying beat renting?

  • Simple break-even: Dividing a \$10{,}500 RTX 5090 workstation by a \$2.00/\text{hr} marketplace H100 rate gives 5{,}250 productive hours (\approx 1.8\text{ years} at 8\text{ hr/day}, every day).
  • Full TCO break-even with power, resale, and relative speed s: H = \frac{C_{\text{buy}} - R_{\text{resale}}}{s \cdot r_{\text{cloud}} - p_{\text{kW}} \cdot e_{\text{kWh}}} Accounting for the H100’s \sim 2\times\text{--}3\times higher throughput s and 0.9\text{ kW} \times \$0.20/\text{kWh} electricity pushes break-even to 3–5+ years of heavy utilization. Buy for privacy, instant access, and hardware tinkering; rent for bursty scale.
purchase = 10500.0                  # an RTX 5090 workstation, Nov. 2026
rental_per_productive_hour = 2.00   # H100 marketplace rate
print(f"{purchase / rental_per_productive_hour:.0f} "
      "productive hours to break even")
5250 productive hours to break even

Verifying Benchmarks and Filtering Out Synthetic Noise

Evidence Discipline

\frac{1}{\text{rate}} = t_0 + \frac{\text{bytes read}}{\eta \cdot \beta}

  • Physics sanity check: Any blog claiming a 900\text{ GB/s} card decodes a dense 35\text{ GB} model at 45\text{ tok/s} (1{,}575\text{ GB/s} > 900\text{ GB/s}) violates the bandwidth bound.
  • Calibrated affine model & primary sources: Fit per-token overhead t_0 and bus efficiency \eta \in [0.6, 0.85] from standardized llama-bench discussions, ServeTheHome/Level1Techs reviews, and r/LocalLLaMA logs.

Concept Check: Hardware Sizing and Roofline Bounds

Check Your Understanding

Work out these three hardware sizing calculations:

  1. You want to fine-tune Llama 3.1 8B using LoRA (1\% trainable parameters, 6\text{ GiB} activations, 2\text{ GiB} workspace) on a 16 GB RTX 5070 Ti. Does standard LoRA (frozen BF16 base weights) fit, or do you need QLoRA (frozen 4-bit base weights)?
  2. Compare a dense 30B model and a 30B-A3B MoE model (30\text{B} total parameters, 3\text{B} active per token), both quantized to 4 bits (0.5\text{ B/param}). Ignoring KV cache, what is the decode bandwidth bound on a Mac Studio M5 Max (614\text{ GB/s})?
  3. Why does the 30B-A3B MoE model fail to run on a 16 GB RTX 5070 Ti even though it only reads 1.5\text{ GB} of weights per token?

Concept Check: Hardware Sizing and Roofline Bounds (cont.)

Check Your Understanding

Answers:

  1. Standard BF16 LoRA does not fit: Frozen BF16 weights alone take 8\text{B} \times 2\text{ B} \approx 14.9\text{ GiB}, plus 1\text{ GiB} adapter state + 8\text{ GiB} activations/workspace \approx 23.9\text{ GiB} > 16\text{ GB}. QLoRA fits easily: 4-bit base weights take \approx 3.9\text{ GiB} + 0.9\text{ GiB} adapters + 8\text{ GiB} \approx 12.8\text{ GiB} < 16\text{ GB}.
  2. Dense 30B reads 15\text{ GB/tok} \implies 614 / 15 \approx \mathbf{41\text{ tok/s}}. 30B-A3B MoE reads 1.5\text{ GB/tok} \implies 614 / 1.5 \approx \mathbf{409\text{ tok/s}} (10\times faster).
  3. Capacity vs. bandwidth: All 30\text{B} parameters (\approx 15\text{ GB} plus KV cache and runtime buffers > 16\text{ GB}) must stay resident in memory because any expert can be routed on the next token.

Summary: Workload-Driven Hardware Selection

Key Takeaways

Workload Profile Binding Physical Constraint Recommended Hardware Class (Nov 2026)
D2L notebooks & 7B–8B QLoRA \ge 16\text{ GB} VRAM + CUDA software stack RTX 5070 Ti (16 GB) or Used RTX 3090 (24 GB)
Desktop training & 30B QLoRA 32\text{ GB} VRAM + high GDDR7 bandwidth (1.79\text{ TB/s}) RTX 5090 Workstation (1000\text{ W} PSU, 64–128 GB RAM)
Local 70B–120B MoE inference (chat) 64\text{--}128\text{ GB} capacity at low purchase price AMD Strix Halo (128 GB) or Mac Studio M5 Max
Local 70B–120B MoE + long-prompt agents 128\text{ GB+} capacity + fast prefill / higher bandwidth NVIDIA DGX Spark (128 GB) or Mac Studio M5 Ultra (up to 512 GB)
Local 70B LoRA / unquantized 70B 96\text{--}384\text{ GB} at full 1.79\text{ TB/s} bandwidth 1–4\times RTX PRO 6000 (96 GB) (price against rented H100 hours first)
Multi-GPU tensor-parallel training High-speed GPU-to-GPU interconnect (450+\text{ GB/s}) Rent NVLink cloud nodes (consumer/workstation cards use 64\text{ GB/s} PCIe)