MODULE 01 · AI SYSTEMS

LLM Inference Engine & PagedAttention

Serve high-concurrency LLM traffic on H100 GPUs without HBM fragmentation—combining iteration-level Continuous Batching, Virtual KV-Cache Block Tables, Copy-on-Write beam sharing, and Radix Prefix Caching.

Act I · Scope, Compute & VRAM Math

Back-of-the-Envelope GPU & KV-Cache Capacity

Step 1 of 5
70B FP16 Weights
140 GB

Minimum 2× H100 80GB (leaves 20 GB for KV-cache & activations; ~35 GB in INT4).

KV-Cache / Token
320 KB

Llama-3 70B GQA: 2 × 80L × 8H × 128D × 2B (4K ctx = 1.31 GB/req).

TTFT vs. TPOT
<250ms / <30ms

Prefill is compute-bound (FLOPS); Decode is HBM bandwidth-bound (3.35 TB/s).

HBM Efficiency
> 96% Util

Virtual 16-token KV pages eliminate ~60% contiguous memory fragmentation.

Act II · Wire Protocol, SSE & Block Table Contracts

Streaming SSE Contract & Virtual KV Block Table

Step 2 of 5
Inference API & SSE Streaming Frame
PagedAttention Block Table & Prefix Hash
Act III · Interactive GPU Inference Simulator & Chaos Switchboard

Continuous Batching, PagedAttention HBM Grid & Preemption Lab

GPU NOMINAL
Step 1 / 6
TTFT (P99)
142 ms
SLO < 250 ms
TPOT / ITL
21.4 ms
SLO < 30 ms
HBM KV Used
10 / 16 blocks · 62%
16 tokens / virtual page
Throughput
2,840 tok/s
H100 FP8 / Tensor Cores
GPU Engine Topology · Continuous Batching & Chunked Prefill
INGRESS SSE
stream API Gateway & SSE OpenAI / Token Stream STREAMING · 3 REQS schedule Continuous Scheduler Iteration-Level · Budget 2048 BATCH: 2 DEC + 1 PREFILL account_tree Block Table & Radix Virtual -> Physical · CoW PREFIX HIT: 2 BLKS developer_board GPU Compute (Prefill / Decode) H100 SXM · FlashAttention-3 Kernel STEP: CHUNKED HBM BW: 2.9 TB/s swap_horiz Host CPU RAM (KV Swap) PCIe Gen5 Offload · 64 GB/s 0 SWAPPED · STANDBY Zero-Drop Preemption Buffer GPU HBM PHYSICAL KV-CACHE BLOCK POOL (16 PAGES × 16 TOKENS) 10 / 16 USED Prefix Req A Req B Req C / CoW Swap Free
INGRESS SSE

Loading GPU inference simulator...

Invariant active
Chaos Engineering Switchboard
0 Active
Live GPU Event Console
Act IV · Zero-Dependency Python 3.12+ Blueprints

Standard-Library Python Core & Production Stack Mapping

Auto-Synced to Simulator
Production Stack Mapping Strip 6 AI Serving Primitives
Vendor-Agnostic Primitive Production Serving Systems Operational Role
Virtual KV-Cache / PagedAttention vLLM, TensorRT-LLM, SGLang Non-contiguous 16-token HBM pages eliminating ~60% memory waste
Radix Prefix Caching SGLang RadixAttention, vLLM Automatic Prefix Caching Reuses shared system prompts across requests for near-0ms prefill
Continuous Batching & Chunked Prefill vLLM V1 Scheduler, Sarathi-Serve, TensorRT-LLM In-Flight Batching Mixes prefill chunks + decode tokens per step to protect TPOT
Prefill / Decode Disaggregation Mooncake, DistServe, NVIDIA Dynamo (NIXL) Isolates compute-bound prefill nodes from bandwidth-bound decode pools
Fused Attention Kernels FlashAttention-3, FlashInfer, cuDNN SDPA SRAM-tiled attention avoiding O(N²) HBM materialization
Cross-Node KV Offload / Tiering LMCache, Mooncake Store, InfiniStore Tiers warm KV blocks across Host CPU RAM, NVMe, and RDMA pools
Act V · Quality / Latency / Cost Tradeoffs & Production SLOs

Serving Architecture Tradeoffs & SLO Targets

Step 5 of 5
Tradeoff 01 TTFT vs. TPOT

Chunked Prefill vs. Disaggregated P/D

Chunked Prefill

Slices long prompts into 512-token chunks piggybacked onto decode steps—simple single-pool ops with smooth TPOT.

Disaggregated P/D

Zero interference between prefill & decode, but requires RDMA / NVLink KV-cache transfer across separate GPU pools.

Verdict Start with Chunked Prefill; move to Disaggregated P/D at 100+ GPU scale with 32K–128K long-context traffic.
Tradeoff 02 OOM Recovery

Recompute vs. CPU Swap on Preemption

Recompute (Short Ctx)

Evicts KV blocks instantly and re-prefills tokens later—often faster than PCIe transfer when sequence length is under 2K.

CPU RAM Swap (Long Ctx)

Offloads KV pages over PCIe Gen5 (64 GB/s) to preserve expensive 16K+ prefill work at the cost of host RAM footprint.

Verdict Use Recompute for short interactive chats and PCIe CPU Swap for long-context agent or RAG sessions.
Tradeoff 03 Block Granularity

KV Block Size (16 vs. 64 Tokens)

16-Token Pages

Minimizes internal last-block fragmentation (< 4% waste) and maximizes fine-grained Radix prefix cache hit ratios.

64-Token Pages

Smaller block-table metadata and slightly better contiguous memory coalescing in attention kernels, but 4x higher tail waste.

Verdict 16 tokens/block is the production sweet spot for mixed conversational lengths and high-reuse prefix caching.
Tradeoff 04 Memory Bandwidth

FP16 vs. FP8 KV-Cache Compression

FP8 KV-Cache (E4M3)

Doubles effective KV-cache capacity (2x max batch size) and cuts decode HBM reads in half with < 0.1% accuracy delta on H100.

FP16 / BF16 KV-Cache

Zero quantization calibration needed, but hits HBM capacity walls 2x earlier on 70B+ models serving 8K+ contexts.

Verdict Enable FP8 E4M3 KV-Cache on Hopper/Blackwell GPUs with per-head scaling factors to nearly double serving throughput.
Production Observability SLOs
GPU Inference Targets
TTFT P99 < 250 ms Prefix cache + chunked prefill
TPOT / ITL P99 < 30 ms Smooth >33 tok/s reading
HBM KV Waste < 4.0% 16-token virtual KV pages
OOM Drop Rate 0.00% Graceful swap / preemption