Inside the GPU

From transistors to tensor cores

agent37.club

Why GPUs for AI?

CPUs — few cores, deep pipelines

  • 8-64 powerful cores
  • Optimized for serial execution
  • Complex branch prediction, out-of-order execution
  • Great for: OS, databases, control flow

GPUs — thousands of cores, wide parallelism

  • 18,944 CUDA cores (B200)
  • Optimized for doing the same thing to lots of data
  • Simple cores, massive throughput
  • Great for: matrix math, neural networks, rendering

Neural networks are fundamentally matrix multiplications — multiply matrices of weights by matrices of activations, billions of times. This is exactly what GPUs were designed for.

The Streaming
Multiprocessor

The fundamental building block

Inside a Streaming Multiprocessor (SM)

Each SM contains

  • 128 CUDA cores (FP32) — general-purpose math
  • 4 Tensor cores — matrix multiply acceleration
  • 256 KB register file (64K × 32-bit)
  • 228 KB shared memory / L1 cache
  • Warp schedulers (select which threads run)
  • Special function units (sin, cos, sqrt)

H100: 132 active SMs
B200: 148 active SMs (74 per die)

// The SM is a mini-computer
// with its own memory hierarchy

SM {
  cuda_cores:     128 FP32
  tensor_cores:   4
  registers:      256 KB
  shared_memory:  228 KB
  l1_cache:       shared with above
  warp_schedulers: 4
  max_threads:    2,048
  max_warps:      64
}

// H100: 132 SMs = 16,896 CUDA cores
// B200: 148 SMs = 18,944 CUDA cores

Warps, Threads & Thread Blocks

The execution hierarchy

  • Thread: A single execution unit running your kernel function
  • Warp: 32 threads executing in lockstep (SIMT — Single Instruction, Multiple Threads)
  • Thread Block: A group of threads (up to 1,024) that share an SM’s shared memory and can synchronize
  • Grid: All thread blocks in a kernel launch — the full computation

Warp divergence

All 32 threads in a warp must execute the same instruction. If threads branch differently (if/else), both paths execute serially. This is why GPU code avoids branching.

// CUDA programming model
// CPU (host) launches kernel on GPU (device)

// Define a kernel
__global__ void add(float* a, float* b,
                    float* c, int n) {
    int i = blockIdx.x * blockDim.x
            + threadIdx.x;
    if (i < n) c[i] = a[i] + b[i];
}

// Launch: 256 threads per block
// ceil(n/256) blocks in the grid
add<<<(n+255)/256, 256>>>(a, b, c, n);

// GPU distributes blocks to SMs
// Each SM runs multiple blocks
// Each block = warps of 32 threads

How Work Gets Scheduled

1. Kernel Launch — CPU sends a grid of thread blocks to the GPU
2. GigaThread Engine — distributes thread blocks to SMs (hardware scheduler)
3. SM Assignment — each SM runs multiple thread blocks concurrently (limited by registers/shared memory)
4. Warp Scheduling — within each SM, the warp scheduler picks warps ready to execute (hides memory latency by switching warps)
5. Execution — up to 64 concurrent warps per SM, 2,048 threads simultaneously

Occupancy

The ratio of active warps to maximum warps on an SM. Higher occupancy means more warps available to hide memory latency. But more warps also means less registers per thread.

The art of GPU programming: balance occupancy vs register usage.

Latency hiding

When one warp stalls on a memory access (~400 cycles for HBM), the scheduler instantly switches to another ready warp. This is how GPUs achieve high utilization despite slow memory.

The Memory
Hierarchy

1000× bandwidth gap from top to bottom

GPU Memory Hierarchy

Registers (256 KB / SM) ~19 TB/s • ~1 cycle
Shared Memory / L1 (228 KB / SM) ~15-20 TB/s • ~30 cycles
L2 Cache (50 MB chip-wide) ~5.5 TB/s • ~150 cycles
HBM3 (80 GB on H100) 3.35 TB/s • ~400-800 cycles

~1,000× bandwidth gap between registers and HBM. Every optimization in AI — FlashAttention, KV cache compression, quantization — exists to keep data as high in this hierarchy as possible.

Shared Memory — The Programmable Cache

  • Explicitly managed by the programmer (not automatic like L2)
  • 228 KB per SM on H100 (up from 164 KB on A100)
  • Shared across all threads in a block
  • ~100× faster than HBM
  • Threads within a block can cooperate via shared memory

FlashAttention

The breakthrough that made long-context LLMs practical. Instead of materializing the full attention matrix in HBM, FlashAttention keeps computation in shared memory (SRAM), tiling the attention computation to fit.

// Without FlashAttention:
// Attention matrix lives in HBM
Q, K, V = load_from_hbm()
S = Q @ K.T       // [seq, seq] in HBM!
P = softmax(S)    // [seq, seq] in HBM!
O = P @ V         // read from HBM again
// 128K context → 128K² = 16B elements
// = 32 GB just for attention!

// With FlashAttention:
// Tile Q, K, V into SRAM-sized chunks
for tile_q in tiles(Q):
  for tile_k, tile_v in tiles(K, V):
    // Compute attention in SRAM
    // Never materialize full matrix
    update_output(tile_q, tile_k, tile_v)
// 100x less HBM traffic

Why Memory Bandwidth Is Everything

The LLM inference bottleneck

  • Generating each token requires loading the entire model from HBM
  • A 70B model in FP16 = 140 GB of weights
  • At H100’s 3.35 TB/s, loading 140 GB takes ~42 ms
  • This sets a hard floor on latency — no amount of compute can help
  • The GPU’s tensor cores sit mostly idle during decode, waiting for data

The memory wall

GPU compute has grown ~10× faster than memory bandwidth per generation. The gap is widening. This is THE constraint for LLM inference.

Strategies to fight the wall

  • Batching: Amortize weight loads across multiple sequences
  • Quantization: FP16 → FP8 → FP4 reduces bytes loaded
  • KV cache optimization: MLA, GQA reduce cache memory
  • Speculative decoding: Generate multiple tokens per weight load
  • More HBM bandwidth: B200 at 8 TB/s, Rubin at 22 TB/s

Tensor Cores

The specialized hardware that makes AI possible

CUDA Cores vs Tensor Cores

CUDA Cores

  • General-purpose floating-point units
  • One scalar operation per core per cycle: a * b + c
  • 128 per SM on Hopper/Blackwell
  • Good for: element-wise ops, non-matrix workloads

Tensor Cores

  • Specialized matrix multiply-accumulate (MMA) units
  • Process entire small matrices in a single instruction
  • 4 per SM (592 total on B200)
  • Good for: matrix multiplication, convolution, attention — the core of neural networks

The difference in practice: On a matrix multiply, tensor cores deliver ~60× the throughput of CUDA cores. An H100 does 67 TFLOPS FP32 on CUDA cores vs 990 TFLOPS FP16 on tensor cores.

Tensor Core Evolution

Gen Architecture Key Formats Notable Feature Peak TFLOPS
1st Volta V100 (2017) FP16 First tensor cores ever 125
2nd Turing (2018) +INT8, INT4 Integer formats for inference 130
3rd Ampere A100 (2020) +BF16, TF32 2:4 Structured sparsity 312 (624 sparse)
4th Hopper H100 (2022) +FP8 Transformer Engine, warp-group MMA 990 (1,979 sparse)
5th Blackwell B200 (2024) +FP4, FP6 2nd-gen Transformer Engine 2,250 (9,000 FP4)

Each generation adds lower-precision formats. Lower precision = more operations per cycle = higher throughput. The art is maintaining quality at lower precision.

The Transformer Engine

Automatic precision management

  • Introduced in Hopper H100, enhanced in Blackwell
  • Dynamically manages precision per-layer during training
  • Monitors statistics (max values) per tensor
  • Automatically picks optimal scaling factors for FP8
  • No manual tuning needed — just enable it

Why FP8 matters

FP8 uses half the memory of FP16. This means 2× more data per memory access, effectively doubling memory bandwidth utilization. Blackwell’s FP4 goes even further — 4× the throughput of FP16.

// The Transformer Engine workflow

// 1. Forward pass in FP8
for layer in model:
    // Monitor activation statistics
    stats = observe(activations)

    // Compute scaling factor
    scale = compute_scale(stats.max_val)

    // Scale to FP8 range
    x_fp8 = quantize(x, scale)

    // Matrix multiply in FP8
    // Accumulate in FP32
    out = tensor_core_mma(x_fp8, w_fp8)

    // Dequantize output
    out = dequantize(out, scale)

// All automatic — no manual tuning

The Roofline Model

Are you compute-bound or memory-bound?

  • Arithmetic Intensity = FLOPs per byte of memory accessed
  • If intensity is low: memory-bound (GPU starved for data)
  • If intensity is high: compute-bound (GPU at full throttle)

H100 Ridge Point

  • 990 TFLOPS ÷ 3.35 TB/s = ~295 FLOP/byte
  • Operations below 295 FLOP/byte are memory-bound
  • LLM decode: ~0.5-1 FLOP/byte — deeply memory-bound
  • LLM prefill (batch): 100-1000+ FLOP/byte — compute-bound

LLM decode is memory-bound

Each generated token loads the entire weight matrix from HBM but performs very few operations per weight. The tensor cores are massively underutilized during decode.

LLM prefill is compute-bound

Processing an entire prompt at once — all tokens hit the weight matrix simultaneously. Large matrix multiplies = high arithmetic intensity. GPU runs at full speed.

This is why batching helps so much — serving multiple requests together increases arithmetic intensity, moving from memory-bound to compute-bound.

The NVIDIA
Roadmap

Hopper → Blackwell → Vera Rubin → beyond

H100 vs B200 — The Numbers

Spec H100 SXM B200 Change
Process TSMC 4N TSMC 4NP Refined
Transistors 80B 208B 2.6×
Die Size 814 mm² ~1,600 mm² (2 dies) 2×
SMs 132 148 1.12×
FP16/BF16 TFLOPS 990 2,250 2.3×
FP8 TFLOPS 1,979 4,500 2.3×
FP4 TFLOPS N/A 9,000 New
HBM 80 GB HBM3 192 GB HBM3e 2.4×
Mem Bandwidth 3.35 TB/s 8 TB/s 2.4×
TDP 700W 1,000W 1.43×

Blackwell — Two Dies, One GPU

  • B200 is a dual-die package — two 104B-transistor dies
  • Connected via 10 TB/s NV-HBI chip-to-chip link
  • Each die: ~800 mm² (near reticle limit)
  • Appears as a single GPU to software
  • This is how NVIDIA gets 208B transistors — can’t fit on one die

Manufacturing cost breakdown

ComponentEst. Cost
Logic dies (2×)~$900
HBM3e (8 stacks)~$2,200
CoWoS-L packaging~$1,100
Packaging yield loss~$1,000
Total~$6,400

HBM is 1/3 of the cost

The “GPU” logic die is actually the cheapest part (~$900). HBM memory (~$2,200) and advanced packaging (~$2,100) dominate the bill of materials.

Sell price vs cost

Manufacturing cost: ~$6,400
Sell price: ~$30,000-$40,000
~5-6× markup — this is NVIDIA’s margin story.

Vera Rubin — What’s Next

Rubin GPU (R200) — H2 2026

  • 336 billion transistors (2 dies, TSMC 3nm)
  • 288 GB HBM4 per GPU
  • 22 TB/s memory bandwidth (2.8× Blackwell)
  • 50 PFLOPS FP4 inference per GPU
  • 5× inference, 3.5× training vs Blackwell
  • 10× reduction in inference token cost

Vera CPU

  • 227 billion transistors
  • Custom Arm “Olympus” cores, 88 cores / 176 threads
  • CPU↔GPU link: 1.8 TB/s (2× Grace’s 900 GB/s)

Vera Rubin NVL72

72 Rubin GPUs + 36 Vera CPUs per rack. 260 TB/s NVLink. 20,736 GB HBM4 total. Up to 3.6 ExaFLOPS FP4 inference.

NVIDIA GPU Roadmap

Year Architecture Transistors HBM Mem BW FP4 PFLOPS
2020 Ampere (A100) 54B 80 GB HBM2e 2.0 TB/s N/A
2022 Hopper (H100) 80B 80 GB HBM3 3.35 TB/s N/A
2024 Blackwell (B200) 208B 192 GB HBM3e 8 TB/s 9
H2 2026 Rubin (R200) 336B 288 GB HBM4 22 TB/s 50
H2 2027 Rubin Ultra TBD 1 TB HBM4e TBD 100
2028 Feynman TBD Next-gen HBM TBD TBD

Huang’s Law: GPU AI performance more than doubles every 2 years — more aggressive than Moore’s Law. Achieved through architecture + memory + interconnect + software co-optimization. NVIDIA claims 1,000× improvement over 8 years.

The Competition

AMD, Google, Amazon, and the fight for AI silicon

AMD MI300X & MI350

MI300X (current, CDNA 3)

  • 192 GB HBM3 (2.4× H100’s 80 GB)
  • 5.3 TB/s memory bandwidth (1.6× H100)
  • ~750W TDP
  • Price: $10,000-$15,000 (vs $25,000-$40,000 for H100)

MI350X (2025, CDNA 4)

  • 288 GB HBM3E, 8 TB/s bandwidth
  • TSMC 3nm, native FP4/FP6
  • Up to 18-20 PFLOPS FP4
  • 2.7× tokens/second vs MI325X

Where AMD wins

  • Memory capacity: whole 405B model fits on one MI300X
  • Large-model inference where H100 needs 2+ GPUs
  • Price/performance on memory-bound workloads
  • Cost per GPU: 2-3× cheaper

Where AMD loses

  • Multi-GPU scaling (~74% of H200 single-GPU throughput)
  • ROCm software ecosystem still catching up
  • Training workloads: CUDA optimizations matter

ROCm — AMD’s CUDA Alternative

Progress (as of 2026)

  • ROCm 7.1+ with PyTorch 2.9 support
  • vLLM: ROCm is now a “first-class platform”
  • 93% of vLLM AMD test groups passing
  • Dedicated CI pipeline went live Dec 2025
  • Pre-built Docker images (no more build-from-source)
  • FP8/FP4 quantization, DeepSeek V3 support

The CUDA moat

NVIDIA’s real moat isn’t hardware — it’s the software ecosystem. CUDA has 20 years of libraries, optimized kernels, and developer familiarity. Every ML framework is CUDA-first.

ROCm is closing the gap, but “closing the gap” isn’t the same as “parity.” For training at scale, CUDA optimization still matters enormously.

Custom Silicon — The Hyperscaler Chips

Chip Company Performance Memory Key Users
TPU v7 Ironwood Google 4,614 TFLOPS FP8 192 GB HBM3e, 7.4 TB/s Gemini models
TPU v6e Trillium Google ~918 TFLOPS BF16 144 GB HBM3 Google Cloud customers
Trainium2 Amazon ~667 TFLOPS BF16 96 GB HBM3e Anthropic, Apple
Maia 100 Microsoft ~800 TFLOPS BF16 64 GB HBM2E Internal only (Copilot)

Google is the real threat

Google is the only company that trains frontier models entirely on custom silicon. Ironwood (TPU v7) scales to 9,216 chips = 42.5 ExaFLOPS. Proprietary ICI interconnect. Full vertical stack. Amazon’s Trainium2 is gaining traction (Anthropic uses it). Microsoft Maia 100 has seen limited production deployment.

The Competitive Landscape

NVIDIA: ~80%+ data center AI share

Dominant in training and inference. Full-stack moat: hardware + NVLink + networking + CUDA software. Blackwell demand exceeds supply.

AMD: ~10-15% and growing

Wins on memory capacity and price. MI300X/MI350 are compelling for inference. ROCm improving. The value play — but software gap limits training adoption.

Google TPUs: ~5-10% (internal)

Only for Google Cloud and Google’s own models. Not sold externally as chips. The most advanced non-NVIDIA AI silicon, but captive.

Everyone else: <5%

Amazon Trainium, Intel Gaudi, Cerebras, Groq, Microsoft Maia. Niche use cases and specific workloads. None threaten NVIDIA broadly — yet.

GPU Pricing & Economics

GPU Purchase Price Cloud $/hr
H100 80GB $25,000-$40,000 ~$1.50-$4.69
MI300X 192GB $10,000-$15,000 ~$4.89
B200 192GB ~$30,000-$40,000 ~$6-8 (early)

H100 price collapse: Cloud rental dropped from $8/hr (2024) to ~$1.50/hr (2026) as Blackwell supply expanded and H100 supply increased.

NVIDIA’s margin machine

B200 manufacturing cost: ~$6,400
Sell price: ~$30,000-$40,000
Gross margin: ~75-85%

This is why NVIDIA is the most profitable chip company in history. HBM and packaging are the cost bottleneck, not the GPU die itself.

Putting It
Together

From transistors to AI inference

The Full Picture

How a single token gets generated

1. Model weights loaded from HBM 8 TB/s on B200
2. Data flows through SM memory hierarchy registers → shared mem → L2
3. Tensor cores execute matrix multiply FP8/FP4 with Transformer Engine
4. Attention computed via FlashAttention stays in SRAM, avoids HBM
5. Next token probability output sample → decode → repeat

Every optimization in the AI stack — from FlashAttention to FP4 quantization to MoE routing — exists to feed the tensor cores faster and move less data through the memory hierarchy.

Key Takeaways

  • SMs are mini-computers — 128 CUDA cores + 4 tensor cores + 228 KB shared memory, replicated 132-148 times
  • Memory bandwidth, not FLOPS, is the bottleneck for LLM inference. The roofline model shows decode is deeply memory-bound
  • Tensor cores deliver 60× the throughput of CUDA cores on matrix ops. Five generations have evolved from FP16 to FP4
  • FlashAttention exploits the memory hierarchy to make long-context practical
  • Blackwell B200: 208B transistors, 192 GB HBM3e, 8 TB/s bandwidth, dual-die design. Costs ~$6,400 to make, sells for ~$35,000
  • Vera Rubin (H2 2026): 336B transistors, HBM4, 22 TB/s. 5× inference over Blackwell
  • AMD is the value play — MI300X wins on memory capacity and price, but ROCm software gap limits adoption
  • Google TPUs are the real alternative — full vertical stack, no NVIDIA dependency

208B transistors.
592 tensor cores.
8 TB/s bandwidth.
One token at a time.

Inside the GPU.

agent37.club