Lecture 17 · NVIDIA GPU Architecture for AI (guest lecture), and Course Review

Hardware Accelerators for Machine Learning · Lecture 17。个人学习讲义与配套实验,按主题整理并持续修订。

课程源码 ZIP ↓

个人整理的学习笔记,非官方讲义;课程来源与整理说明见课程介绍。配套示例未逐一运行验证。

本篇目录

Maps to: Stanford CS 217 Hardware Accelerators for Machine Learning (Winter 2026), Lecture 17 · Tue 03/10/2026 · NVIDIA GPU Architecture for AI, guest lecture by Ronny Krashinsky; the last lecture of the course before the poster session (03/12). Reading: none listed on the schedule.

Basis: The talk and its slides are not public. This lecture is written only from public material:

  • NVIDIA’s datasheets and architecture announcements: K40 to B200, the GB200 NVL72 specification page with its footnotes;
  • press coverage of Bill Dally’s Hot Chips 2023 keynote (the 1000× decomposition);
  • Meta’s Llama 3 paper (the 405B training setup and its MFU).

Published numbers are labelled as such. The experiments use a model written for these notes (cluster.py):

  • GPU generations and a decomposition of their gains;
  • collectives on NVLink and InfiniBand;
  • serving and 3D-parallel training models that reuse Lecture 11’s GEMM model.

Latencies, overlap factors, power and a few hardware details are assumed and labelled. The course review (§7) recomputes one number from each earlier lecture’s model. Nothing here reflects what was said in class. Code: code/lecture17/ (4 scripts + 1 module; ~2 s in total) Reading time: 2.5 hours including running the code


0. How to read this lecture

0.1 Learning goals

After this lecture you should be able to:

  1. Trace NVIDIA’s data-center GPUs from Kepler to Blackwell: what each generation added, and how peak, bandwidth, capacity and power grew.
  2. Decompose a decade of speedup into number formats, specialized instructions (tensor cores) and the rest (process, area, power). Compare this with Dally’s published decomposition.
  3. Explain why the ridge point rose 75-fold, and what that did to decode versus prefill.
  4. Estimate collectives in NVLink domains (ring vs in-switch reduction) and over InfiniBand.
  5. Explain why large scale-up domains (NVL72) change serving and the best training layout.
  6. Model an LLM training step with 3D parallelism: GEMM efficiency, pipeline bubble, communication, memory, MFU. Compare it with Meta’s published numbers.
  7. Name the levers left for the next 10× and what limits each.
  8. Summarize the course: every lever of Lecture 1, where it was applied, and how the architectures studied compare.

0.2 Prerequisites and scope

AssumedIntroduced here
Lecture 1: roofline, energy, leversa decade of GPU generations; decomposing the gains
Lecture 4: FP8, MX, NVFP4NVLink domains, in-switch reduction (NVLS), hierarchical collectives
Lecture 11: SMs, tensor cores, the GEMM modeltensor/pipeline/data parallelism for training; MFU
Lectures 13–16: decode is memory-bound; collectives are latency-boundrack-scale power; the course review

0.3 Map

§1  a decade of data-center GPUs                                  ← code 01 (Parts 1, 3)
§2  where the speedup came from, and what is left                 ← code 01 (Parts 2, 4, 5)
§3  co-designing numerics, architecture and software
§4  scale-up and scale-out for serving                            ← code 02
§5  training at scale: 3D parallelism                             ← code 03
§6  rack-scale computers: power and cooling                       ← code 02 (Part 4), code 03 (Part 4)
§7  course review                                                 ← code 04
§8  summary   §9 pitfalls   §10 exercises   §11 further reading   §12 where to go from here

0.4 Notation

SymbolMeaning
TP, PP, DP, EPtensor, pipeline, data, expert parallelism (degrees)
NVLSNVLink SHARP: reduction inside the NVLink switches
m, vmicrobatches per pipeline per step; virtual stages per GPU (interleaving)
MFUmodel FLOPs utilization = model FLOPs / (time × GPUs × peak)
αlatency of one collective step
ridgepeak FLOP/s ÷ memory bandwidth

1. A decade of data-center GPUs

Script 01, Part 1 (datasheets, dense):

GPUyearprocessFP32best tensor formatTB/sGBWridge (best format)
K40201328 nm4.3—0.291223515
P100201616 nm11FP16 21 (no tensor cores)0.731630029
V100201712 nm16FP16 1250.9032300139
A10020207 nm20BF16 3122.0480400306
H10020224N67FP8 1,9793.3580700591
B20020244NP, 2 dies80FP4 9,0008.001921,0001,125

(TFLOPS, dense.)

What each generation added, from NVIDIA’s announcements:

  • Volta introduced the tensor core: a small matrix multiply-accumulate unit (4 × 4 × 4 per tensor core per clock, Lecture 11).
  • Ampere added BF16 and TF32 tensor-core formats, 2:4 structured sparsity (2× on paper), and asynchronous copies into shared memory.
  • Hopper added FP8 with the “Transformer Engine” (per-tensor scaling managed by software), the TMA (asynchronous tensor copies), thread-block clusters with distributed shared memory, and warpgroup MMA (wgmma) reading operands from shared memory (Lecture 11).
  • Blackwell added FP4 (and the block-scaled NVFP4 format, Lecture 4) and two reticle-sized dies acting as one GPU. It moved to fifth-generation NVLink at 1.8 TB/s per GPU and to racks of 72 GPUs in one NVLink domain (GB200 NVL72).

A decade

Script 01, Part 3 (relative to the K40):

GPUbest dense peakHBM bandwidthHBM capacity
V10029×3.1×2.7×
A100145×7.1×6.7×
H100461×11.6×6.7×
B2002,098×27.8×16.0×

Compute grew ~75× faster than bandwidth: the ridge point rose from 15 to 1,125 FLOP per byte. The memory wall of Lectures 1 and 14 was built one generation at a time.


2. Where the speedup came from, and what is left

2.1 Decomposing a decade

Script 01, Part 2. The best dense peak of a GPU can be written as a product of three factors:

PbestnewPbestK40=PbestnewP16-bit tensornew⏟format×P16-bit tensornewPFP32new⏟tensor cores×PFP32newPFP32K40⏟FP32 engine.\frac{P_{\text{best}}^{\text{new}}}{P_{\text{best}}^{\text{K40}}} = \underbrace{\frac{P_{\text{best}}^{\text{new}}}{P_{16\text{-bit tensor}}^{\text{new}}}}_{\text{format}} \times \underbrace{\frac{P_{16\text{-bit tensor}}^{\text{new}}}{P_{\text{FP32}}^{\text{new}}}}_{\text{tensor cores}} \times \underbrace{\frac{P_{\text{FP32}}^{\text{new}}}{P_{\text{FP32}}^{\text{K40}}}}_{\text{FP32 engine}} .

The K40 is the reference because its best format is FP32 on ordinary cores, so the factors do not overlap.

totalformattensor coresFP32 engine(power)(silicon)bandwidth
K40 → V10029×1.0×8.0×3.7×1.28×1.45×3.1×
K40 → A10073×1.0×16.0×4.5×1.70×1.47×7.1×
K40 → H100461×2.0×14.8×15.6×2.98×1.45×11.6×
K40 → B2002,098×4.0×28.1×18.6×4.26×2.85×27.8×

(B200’s silicon area of 2 × 800 mm² is assumed.)

Dally’s decomposition (Hot Chips 2023, published): a ~1000× gain in single-chip inference performance over about ten years, made of:

  • 16× from number representation;
  • 12.5× from complex instructions (tensor cores, and instructions that do more work per fetch);
  • 2.5× from process;
  • 2× from sparsity.

Both decompositions say the same thing. Most of the gain is architecture and number formats; process technology contributes single-digit factors. Our “FP32 engine” factor (19×) mixes process with 4.3× the power, 2.9× the silicon and higher clocks; Dally’s “process” is the per-transistor gain alone.

The lesson of Lecture 1 (the instruction overhead, the energy of a narrower multiplier) turned into a decade of products.

2.2 Prefill vs decode

Script 01, Part 4. One GPU on Llama 3 8B, roofline bounds, weights in the GPU’s best format:

GPUprefill tokens/s (compute bound)decode tokens/s, batch 1 (bandwidth bound)
K402679
V1007,78356
H100123,215417
B200560,3801,992

From K40 to B200, the prefill bound grew 2,098× and the batch-1 decode bound 222×: 28× from bandwidth, 8× from fewer bytes per weight. Every gain beyond bandwidth and bytes reaches decode only through batching. This is the course’s theme (Lectures 1, 10, 14) in one table.

2.3 What limits the next 10×

Script 01, Part 5 lists the levers with illustrative headroom:

leverwhere it standsheadroomwhat limits it
narrower formatsFP4~2× (FP2/ternary)accuracy (Lecture 4)
structured sparsity2:4 = 2× on paper~2×models must be sparse
process2.5× per decade~1.3× per generationcost per transistor
power per GPU235 → 1,000–1,200 W~1.5×cooling, rack power
silicon per GPU1 → 2 reticle dies~2× per steppackaging, yield, die-to-die links
memory bandwidth28× per decade~1.5–2× per generationHBM stacks, I/O energy
scale-up domain8 → 72 GPUslarger domains announcedcopper reach, switch radix, power

The two levers that delivered most of the past decade are close to their ends:

  • number formats: below FP4 little is left;
  • specialized instructions: tensor cores already do nearly all the math.

The next 10× is a systems problem: more silicon and power per package, more memory bandwidth, larger and faster scale-up domains, and models co-designed with the hardware’s numerics.


3. Co-designing numerics, architecture and software

The guest lecture’s theme is co-design: no single layer delivers the gains alone.

  • Numerics follow the hardware. FP8 training needs per-tensor scales (Hopper’s Transformer Engine). FP4 needs block scales: NVFP4 uses blocks of 16 with an E4M3 scale plus a per-tensor FP32 scale (Lecture 4). Each format is useful only if training and inference recipes keep accuracy. That is work on the model and software side.
  • The architecture follows the numerics. Narrower formats multiply the math per byte of operand. That raises the pressure on everything that feeds the tensor cores: register files and shared memory (Lecture 11: wgmma reads from shared memory, TMA moves tiles asynchronously). It also raises the pressure on the non-matrix units: the exps of softmax (Lecture 6, Lecture 16 §3.4).
  • Software follows both.
    • Kernels must overlap TMA copies, tensor-core math and softmax across warp groups: FlashAttention-3 and -4.
    • Compilers and libraries must choose tile shapes and cluster sizes (Lecture 11’s GEMM model).
    • Serving and training systems must place tensor, pipeline, data and expert parallelism on the right links (§4–§5).
  • Systems follow the models. Mixture-of-experts models need all-to-all traffic among many GPUs. Long contexts need KV-cache capacity and bandwidth. Large dense models need tensor parallelism beyond 8 GPUs. All of this motivated NVLink domains of 72 GPUs.

4. Scale-up and scale-out for serving

4.1 Collectives inside and across domains

An NVLink domain connects GPUs through NVLink switches at ~1 TB/s per GPU (published: 900 GB/s for H100, 1.8 TB/s for Blackwell, counted here as half per direction).

The switches can reduce in the network (NVLink SHARP, “NVLS”): each GPU sends its data once, the switch sums, and multicasts the result back. A ring instead sends each byte twice and takes 2(p − 1) steps. Domains are joined by InfiniBand at 400 Gb/s (50 GB/s) per GPU.

Script 02, Part 1 (ASSUMED step latency 1 µs on NVLink, 5 µs on IB):

message8 × H100 ring8 × H100 in-switch72 × GB200 ring72 × GB200 in-switch72 × H100 as 9 servers (NVLink + IB)
32 kB14.1 µs2.07 µs142 µs2.04 µs82.2 µs
64 MB263 µs144 µs282 µs73.1 µs509 µs
1 GB3.9 ms2.22 ms2.33 ms1.11 ms6.75 ms

In-switch reduction removes the latency of large rings: 2 steps instead of 142. Across servers, the 9–18× lower bandwidth and the IB latencies make the same 72 GPUs 3–6× slower on large messages.

4.2 Decoding a 405B model

Script 02, Part 2. Llama 3.1 405B, BF16, 4,096-token context. Each layer streams its weights and KV cache from HBM (85% efficiency, ASSUMED) and does two all-reduces.

configurationGPUstokens/s per user (batch 1)tokens/s per GPU (batch 64)
2 × HGX H100: TP 8 × PP 2162893
2 × HGX H100: TP 16 over IB1648138
HGX B200: TP 8865436
NVL72: TP 3636261259
NVL72: TP 7272456170

Serving

  • Pipelining does not speed up one user. A token passes the stages one after another. TP 8 × PP 2 takes as long as TP 8 alone; PP only adds capacity.
  • Tensor parallelism does, as long as its all-reduces are cheap. Across servers they cost 6× more (3.06 vs 0.51 ms per token) but still beat pipelining. Inside one NVL72 domain they stay ~2 µs each, and the whole rack serves one user at 456 tokens/s.
  • Speed for one user is bought with GPUs. Per-GPU throughput at batch 64 falls from 436 (TP 8) to 170 (TP 72). With 8 KV heads, splits wider than 8 replicate the KV cache, so the KV reads per GPU stop shrinking.

The model first divided the KV cache by 72. Fixing that cut TP 72’s batch-64 speed from 332 to 192 tokens/s per user.

4.3 Mixture of experts

Script 02, Part 3. A DeepSeek-V3-like layer (hidden 7,168, top-8 experts) sends each token’s hidden state to its experts and back, in every MoE layer. For 4,096 tokens per GPU:

  • 1.04 ms per layer with expert parallelism 64 on NVL72’s NVLink;
  • 18.6 ms across 8 HGX H100 servers over IB.

That is why NVIDIA’s published “30×” NVL72 inference claim is made for a 1.8T-parameter MoE under real-time latency targets, against HGX H100 over InfiniBand (the footnotes on NVIDIA’s page). The comparison mixes GPU generation, numerics (FP4) and the domain size.


5. Training at scale: 3D parallelism

5.1 The three parallelisms

what is splitcommunicationwhere it must run
tensor (TP)every layer’s matrices4 all-reduces per layer per microbatch (2 forward, 2 backward)inside the fast domain
pipeline (PP)the layers into stagespoint-to-point activations; a bubble of (pp − 1)/(v·m)across domains is fine
data (DP)the batchone reduce-scatter + all-gather of gradients per step, overlappableanywhere, mostly hidden

5.2 Llama 3.1 405B on 16,384 H100s

Meta’s published layout:

  • TP 8 × PP 16 × DP 128;
  • 16M-token batches of 8,192-token sequences;
  • 38–43% BF16 MFU on 8K–16K H100s.

Script 03, Part 1:

schedulestep (s)computebubbleTP commDP comm (exposed)GEMM efficiencyMFUmemory per GPU
1F1B6.633.143.140.280.0592%37.7%80.4 GB
interleaved, v = 25.083.141.570.280.0592%49.3%80.4 GB
interleaved, v = 44.343.140.780.280.0592%57.7%80.4 GB
  • The bubble dominates. With DP = 128 and a 16M-token batch, each pipeline gets only 15 microbatches per step. A 16-stage 1F1B pipeline then idles as long as it computes.
  • The model lands in the published range without interleaving and overshoots with it. Its GEMM efficiency (92%, from Lecture 11’s model) and its 15% non-GEMM overhead are not calibrated against Meta’s system. The agreement is partly luck, and we say so.
  • The memory estimate says the layout does not fit in 80 GB: the first stage holds 15 microbatches of activations at 34·s·b·d/tp per layer. Real runs recompute more or rebalance stages.

5.3 The domain shapes the layout

Script 03, Part 2 (16,384 GPUs, interleave 2):

layoutHGX H100: TP comm (s/step)HGX H100: MFUNVL72: TP commNVL72: MFUmemory per GPU
TP 8 × PP 16 × DP 1280.2849.3%0.1447.3%80.4 GB
TP 16 × PP 8 × DP 1281.2147.1%0.2850.8%48.9 GB
TP 32 × PP 8 × DP 643.1934.3%0.5944.2%24.6 GB
TP 64 × PP 4 × DP 647.2021.4%1.1733.4%15.6 GB

On HGX H100, tensor parallelism beyond 8 leaves NVLink, and its all-reduces cross InfiniBand. On NVL72, TP 16–32 stays in the rack. Fewer pipeline stages mean a smaller bubble and less memory per GPU. The best layout depends on the size of the scale-up domain.

5.4 Scaling the cluster

Script 03, Part 3 (fixed 16M-token batch):

GPUsH100 (TP 8 × PP 16): microbatchesMFUNVL72 (TP 16 × PP 8): MFU
2,04812268.3%60.1%
8,1923158.8%55.6%
16,3841549.3%50.8%
32,768838.3%43.3%

Training

At a fixed batch, more replicas mean fewer microbatches per pipeline, so the bubble grows. Large clusters need larger batches, which optimization limits, or less pipelining, which a larger domain allows. In this model the bubble, not the network, sets the limit.


6. Rack-scale computers: power and cooling

A GB200 NVL72 rack holds:

  • 72 Blackwell GPUs and 36 Grace CPUs;
  • 13.4 TB of HBM3E at 576 TB/s, 130 TB/s of NVLink (published);
  • liquid cooling.

Its power is reported around 120 kW: we ASSUME 120 kW, i.e. ~1.67 kW per GPU including CPUs, switches and cooling. Power and cooling, not silicon, decide how many such racks a data center can hold.

Script 02, Part 4 (tokens per joule at batch 64, ASSUMED wall power):

configurationpower per GPUtokens/s per GPUjoules per token
2 × HGX H100, TP 8 × PP 21,050 W9311.3 J
HGX B200, TP 81,500 W4363.4 J
NVL72, TP 81,667 W4363.8 J
NVL72, TP 721,667 W1709.8 J

Energy per token follows bytes moved per GPU-second. Newer GPUs move more bytes per joule, and wide splits that make one user fast cost energy per token.

Script 03, Part 4. Pre-training Llama 3.1 405B on 15.6T tokens (published token count) on 16,384 GPUs with the best layout that fits:

systemMFUtime to trainenergy (ASSUMED wall power)model FLOPs
HGX H10047.1%~60 days24.8 GWh3.96 × 10²⁵
GB200 NVL7250.8%~22 days14.4 GWh3.96 × 10²⁵

Meta reports ~3.8 × 10²⁵ FLOPs for this pre-training.


7. Course review

7.1 Every lever, one number

Lecture 1 listed the levers that move a kernel or its roofs. Script 04, Part 1 imports the course’s models and recomputes one result per lever, with the same arguments as the lecture that measured it:

leverlecturesmeasuredresult
specialize (cut instruction overhead)L1, L3, L11RISC instruction energy / the 32-bit add it does (45 nm)700×
use fewer bitsL4, L16, L17FP32 MAC / FP8 MAC energy4.1×
reuse operands in an arrayL3, L5, L9128 × 128 WS utilization, M = 1 vs 1280.008 vs 1.00
reuse data in on-chip buffersL7, L9, L164096³ GEMM traffic, 64 KiB vs 1 MiB3.9× less
fuse operatorsL10, L12, L13attention traffic, unfused / FlashAttention (96 KiB)2.8× less
hide latency (parallelism, pipelines)L2, L6, L11H100 GEMM 8192³: fraction of peak92%
compute in spaceL12, L13Plasticine MLP block: kernels / spatial2.56×
orchestrate in hardwareL10, L13SN40L decode: kernel looping / per-kernel calls3.3×
compute near memoryL7, L14Llama 3 70B GEMV on HBM-PIM vs H1003.7×, 3.2× less energy
compute in memoryL15INT8-class MVM: digital from SRAM / analog array19× less energy
balance heterogeneous enginesL6, L16Trainium2 prefill shard: serial / parallel engines1.35×
scale up the fast domainL8, L16, L17405B, one user: NVL72 TP 72 / 2 × HGX H10016×

Every lever is about operations and the bytes that feed them:

  • specialization and fewer bits cut the cost of an operation;
  • reuse, fusion, spatial pipelines and near- or in-memory computing cut the bytes moved per operation;
  • parallelism, orchestration and balanced engines keep the units busy;
  • scale-up domains extend all of it beyond one chip.

7.2 The architectures of the course

Script 04, Part 2:

architecturelectureorganizationpeak (16-bit, TFLOPS)memory TB/sridgeon-chip SRAMwins at
NVIDIA H100L11repurposed: SIMT + tensor cores9893.3529550 MB L2everything, with mature software
Google TPU v4L5bespoke: systolic arrays + VLIW2751.20229160 MiBlarge dense matmuls, pods
PlasticineL12reconfigurable: patterns in space12.3 (FP32)0.0524016 MiBpipelined parallel patterns
SambaNova SN40LL13reconfigurable dataflow, 3 memory tiers6382.00319520 MiBfused layers, many models
H100 + HBM-PIM (model)L14host + bank-level units98913.4 (inside)7450 MBGEMV, low-intensity decode
IBM HERMES (PCM)L15analog in-memory crossbars63 (8-bit TOPS)———small weight-stationary networks
AWS Trainium2L164 engines + software-managed SRAM6672.90230224 MiBcost per token at cloud scale
NVIDIA GB200 (per GPU)L17GPU in a 72-GPU NVLink domain2,5008.00312—large models across a rack

The ridge points cluster at a few hundred FLOP per byte, except where the memory moves to the compute (PIM) or the compute to the memory (HERMES needs no weight bandwidth at all).

The organizations differ in who decides what moves where:

  • the hardware: GPU caches and warp schedulers;
  • a compiler: TPU, Trainium, SambaNova;
  • the physics of the array: in-memory computing.

Each wins where its assumption about the workload holds.

7.3 The course in one paragraph

  • Lecture 1: arithmetic is cheap and moving data is not, and the roofline tells which one limits a kernel.
  • Lectures 2–9 built an accelerator from that principle: HLS and pipelining, SIMD PEs, number formats, systolic arrays, vector units, memories, interconnects and the mapping that ties them together.
  • Lecture 10 fused operators and managed memory for LLMs.
  • Lectures 11–13 compared three ways of organizing compute: GPUs, reconfigurable dataflow, SambaNova’s RDU.
  • Lectures 14–15 moved compute toward and into memory.
  • Lectures 16–17 looked at industry’s answers at chip, system and rack scale.

The constant across all of it: LLM decoding is memory-bound on every machine, and it is where the next decade of accelerator design will be decided.


8. Summary

  1. A decade of GPUs: K40 → B200 grew the dense peak 2,098× but bandwidth only 28×; the ridge point rose from 15 to 1,125 FLOP/byte.
  2. Where it came from: 4× from formats, 28× from tensor cores, 19× from the FP32 engine (process, clocks, 4.3× power, 2.9× silicon). Dally’s published decomposition gives 16 × 12.5 × 2.5 × 2. Architecture and numerics dominate; process is a single-digit factor.
  3. Prefill vs decode: the prefill bound grew 2,098×, the batch-1 decode bound 222×.
  4. What is left: formats and specialized instructions are nearly spent. The next 10× is packages, power, bandwidth, interconnect, and co-designed models.
  5. Scale-up:
    • In-switch reduction makes a 72-GPU all-reduce ~2 µs.
    • A 405B model serves one user at 456 tokens/s on an NVL72 (TP 72) vs 28 on two HGX H100 servers.
    • Pipelining never speeds up one user.
    • MoE all-to-alls need NVLink: 1.04 vs 18.6 ms per layer.
  6. Training: with Meta’s layout, the pipeline bubble is as large as compute (the model gives 37.7% MFU vs the published 38–43%). Larger domains allow more TP and less PP (51% MFU on NVL72 with TP 16 × PP 8). At a fixed batch, MFU falls as clusters grow.
  7. Racks: power and cooling set the scale. The model gives 3.4–11.3 J per token for 405B decode at batch 64, and 14–25 GWh to pre-train it.
  8. The course: every lever reduces the cost of operations or the bytes that feed them, or keeps units busy. Each architecture wins where its workload assumption holds.

9. Common pitfalls

  • “Moore’s law did it.” Process contributed single-digit factors to the decade’s 1000×; formats and instructions did most (§2.1).
  • “Peak FLOPs tell the story.” Bandwidth grew 75× slower: decode gained 222×, not 2,098× (§2.2).
  • “Add pipeline stages to go faster.” Pipelining adds capacity, never per-user speed (§4.2), and it costs a bubble in training (§5.2).
  • “TP is always best inside a server.” The best TP degree is the size of the fast domain, which is 8 on HGX and 72 on NVL72 (§5.3).
  • “Model MFU that matches a paper validates the model.” Our match came with uncalibrated assumptions that cancel (§5.2).
  • “Vendor speedups compare chips.” NVIDIA’s “30×” compares racks, formats and interconnects for one workload (§4.3).
  • “Wider TP always reduces per-GPU bytes.” Not beyond the number of KV heads (§4.2).

10. Exercises

Exercise 1 (ridge). Compute the B200’s ridge point for FP4, FP8 and BF16. Which of a decode GEMV (1 FLOP/byte in BF16), a prefill GEMM (~1,000 FLOP/byte) and attention at batch 64 with GQA G = 4 (~4 FLOP/byte) are compute-bound?

Answer

Ridge points: FP4: 9,000 / 8 = 1,125; FP8: 562; BF16: 281 FLOP/byte.

Which kernels are compute-bound:

  • the prefill GEMM is compute-bound for BF16 and FP8, and borderline for FP4;
  • the GEMV and attention are deeply memory-bound in every format.

Exercise 2 (decomposition). Using the datasheets, decompose K40 → A100 into format, tensor cores and FP32 engine. Why is the format factor 1?

Answer

The factors:

  • the A100’s best floating-point dense format is BF16 (312 TFLOPS), equal to its 16-bit tensor rate, so format = 1;
  • tensor cores = 312 / 19.5 = 16;
  • FP32 engine = 19.5 / 4.29 = 4.5.

Total: 73×.

Why the format factor is 1. Ampere’s narrower formats (INT8, INT4) are integers, which we excluded; its gain came from the tensor cores.

Exercise 3 (decode bound). A B200 serves Llama 3 70B in FP4 at batch 1. What is its decode bound? What if the KV cache of a 32K context is read too (8 KV heads × 128 × 2 × 80 layers, BF16)?

Answer
  • Weights: 70.6 B × 0.5 B = 35.3 GB, so 8 TB/s / 35.3 GB = 227 tokens/s.
  • KV: 32,768 × 2 × 8 × 128 × 80 × 2 B = 10.7 GB, so 8 / 46.0 = 174 tokens/s.

Long contexts erode the gains of FP4 weights.

Exercise 4 (ring vs in-switch). Derive the 32-KB all-reduce times on 72 GPUs from §4.1’s formulas (900 GB/s per direction, α = 1 µs).

Answer

Ring: 2 × 71/72 × 32 KB / 900 GB/s + 142 × 1 µs ≈ 0.07 + 142 = 142 µs.

In-switch: 32 KB / 900 GB/s + 2 µs ≈ 2.04 µs.

The ring is latency-bound by 70×.

Exercise 5 (pipelining and one user). A 2-stage pipeline holds half the layers on each server. Why is a token’s latency the same as with all layers on one server (same TP)? What does PP buy?

Answer

Same latency. A token must pass stage 1 and then stage 2. Each stage reads half the weights on its own GPUs, so the total time is the same as one server reading all the weights, plus a hop.

What PP buys. Capacity: the model fits. And throughput: with several tokens or batches in flight, both stages work at once.

Exercise 6 (the bubble). With PP = 16 and m = 15 microbatches, what fraction of a step is bubble under 1F1B? With interleaving v = 4? How many microbatches would 1F1B need for a 10% bubble?

Answer
  • 1F1B: bubble / compute = 15/15 = 1, so the bubble is 50% of the step (ignoring communication).
  • v = 4: 15/60 = 0.25, so 20% of the step.
  • 10% of the step (bubble/compute = 0.11): m ≈ 15 / 0.11 = 135 microbatches. With 8,192-token sequences that means 1.1M tokens per pipeline per step, or a 142M-token global batch at DP 128.

Exercise 7 (TP communication). For Llama 3.1 405B (d = 16,384), one microbatch of 8,192 tokens and TP 16, how many bytes does each all-reduce carry, and how long does it take inside NVL72 (in-switch) vs across two HGX servers (hierarchical)?

Answer

8,192 × 16,384 × 2 B = 268 MB per all-reduce.

  • NVL72: 268 MB / 900 GB/s ≈ 0.30 ms.
  • Two HGX H100 servers:
    • an in-switch all-reduce among 8 at 450 GB/s: 0.60 ms;
    • plus a 2-server ring over IB on 33.5 MB: 2 × 1/2 × 33.5 MB / 50 GB/s ≈ 0.67 ms;
    • total ≈ 1.27 ms.

That is 4× slower, and there are 4 of them per layer per microbatch.

Exercise 8 (KV heads and TP). Why does splitting a model with 8 KV heads 72 ways not divide the KV cache by 72? What would?

Answer

Why not. Each GPU computes some query heads, and needs the KV head of their group. With 72 GPUs and 8 KV heads, each KV head serves 9 GPUs and must be present on each: the cache is replicated 9 times.

What would. Sequence (context) parallelism: split the cached tokens across GPUs and combine partial attention results (Lecture 10’s split-KV decoding).

Exercise 9 (MoE all-to-all). Estimate the all-to-all bytes per GPU of one MoE layer for 4,096 tokens, top-8 experts, d = 7,168, BF16, both directions. Why does EP over IB hurt more for MoE than TP does for dense models?

Answer

Bytes. 4,096 × 8 × 7,168 × 2 B = 470 MB each way. That is ~0.94 GB per layer per GPU, in every MoE layer.

Why it hurts.

  • TP all-reduces move one activation tensor per all-reduce, and can be reduced in the switch.
  • An all-to-all multiplies the volume by top-k and cannot be reduced: every byte must cross the network.

Exercise 10 (energy). Using §6’s numbers, how many tokens does 1 kWh buy for 405B decode at batch 64 on HGX B200? On two HGX H100 servers?

Answer
  • HGX B200: 3.6 MJ / 3.4 J ≈ 1.06 M tokens.
  • Two HGX H100 servers: 3.6 MJ / 11.3 J ≈ 0.32 M tokens.

Most of the gap is bytes per joule: HBM bandwidth per watt, and BF16 vs the same model on twice the GPUs.

Exercise 11 (review: the roofline). Using the course’s models, rank these by arithmetic intensity, and say which architecture of §7.2 suits each:

  • a prefill GEMM;
  • batch-1 decode;
  • attention at long context;
  • a 1-bit bulk AND;
  • a keyword-spotting CNN.
Answer

From high to low intensity:

  • prefill GEMM (~1,000 FLOP/B): any of the GPUs, TPU or Trainium;
  • keyword-spotting CNN (weights reused across pixels): small on-chip or in-memory arrays (HERMES-like) when weights fit;
  • attention at long context (~G FLOP/B): HBM bandwidth, PIM with enough compute (Lecture 14);
  • batch-1 decode (~1 FLOP/B): bandwidth, PIM GEMV, or SRAM-resident weights across many chips;
  • bulk AND (no arithmetic intensity at all): processing using DRAM rows (Lecture 14).

Exercise 12 (design your own). You have a 1 MW budget and must serve a 400B dense model at ≥ 100 tokens/s per user to as many users as possible. Using §4–§6, outline the system: GPU type, domain size, TP, batch, and the main risk.

Answer

The system.

  • 1 MW at ~1.67 kW per GPU is ~600 GPUs, about 8 NVL72 racks.
  • §4.2: TP 36 gives ~261 tokens/s per user at batch 1 and ~146 at batch 64. Choose the largest batch that keeps ≥ 100 tokens/s per user. That is around batch 64–100 at TP 36, ~2 replicas per rack.
  • Use FP8 or FP4 weights to halve or quarter the bytes, and paged KV memory (Lecture 10).

The main risk is the KV cache at long contexts. It is replicated beyond 8 KV heads, so per-user speed at large batches falls. Mitigations: context parallelism, or KV quantization.


11. Further reading

  • NVIDIA, Tesla V100, A100 Tensor Core GPU, H100 Tensor Core GPU architecture whitepapers; Blackwell architecture technical brief; GB200 NVL72 specifications (nvidia.com).
  • W. Dally, “Hardware for deep learning”, Hot Chips 2023 keynote; W. Dally et al., “Evolution of the graphics processing unit (GPU)”, IEEE Micro 2021.
  • A. Dubey et al., “The Llama 3 herd of models”, 2024 (arXiv:2407.21783), §3.3: training infrastructure, 3D parallelism, MFU.
  • D. Narayanan et al., “Efficient large-scale language model training on GPU clusters using Megatron-LM”, SC 2021 (interleaved 1F1B).
  • V. Korthikanti et al., “Reducing activation recomputation in large transformer models”, 2022 (arXiv:2205.05198).
  • N. Shazeer et al., “Outrageously large neural networks: the sparsely-gated mixture-of-experts layer”, ICLR 2017; DeepSeek-AI, “DeepSeek-V3 technical report”, 2024.
  • J. Choquette, W. Gandhi, O. Giroux, N. Stam, R. Krashinsky, “NVIDIA A100 tensor core GPU: performance and innovation”, IEEE Micro 2021; J. Choquette, “NVIDIA Hopper H100 GPU: scaling performance”, IEEE Micro 2023: the designers’ own accounts.

12. Where to go from here

The course ends with the poster session (03/12) and the final report (03/19). The project guide (Lecture 10, §7) describes how to:

  • pose a question that one of these models, or a new one, can answer;
  • choose an honest baseline;
  • report what the numbers do and do not show.

The README of every code folder ends with “Plan vs reality”: the places where our models disagreed with the planned story. Keep that habit. In hardware design, as in this course, the surprises are where the learning is.

← 返回课程目录