Modern SoC Design Series · Presentation 06

SoCs for
ML Inference

From INT8 pipelines and on-device LLMs to NPU scheduling, memory bandwidth management, and the power-performance trade-offs that determine what runs on the edge — a rigorous tour of how SoCs are architected specifically for inference workloads.
Training vs Inference Quantisation INT8 / INT4 Pipelines On-Device LLMs NPU Scheduling Edge vs Cloud Power Management Case Studies
02

Training vs Inference — Fundamentally Different Problems

different bottlenecks demand different silicon

Training Characteristics

  • Forward + backward pass — 3× the compute of inference per sample
  • FP16 / BF16 / FP32 — precision critical for gradient stability
  • All activations retained — for backprop, VRAM scales with batch × seq
  • Throughput-optimised — maximise FLOPS utilisation, latency tolerated
  • Cluster-scale — data, tensor, and pipeline parallelism across racks
  • Intermittent — runs once; result is a model checkpoint
Training SoCs (H100, TPU v5p) optimise for raw FLOPS and interconnect bandwidth. NVLink / ICI all-reduce bandwidth is often the dominant bottleneck.

Inference Characteristics

  • Forward pass only — activations discarded after each layer
  • INT8 / INT4 / FP8 — lower precision acceptable; massive efficiency gain
  • KV-cache retained — decode phase is severely memory-bandwidth-bound
  • Latency-constrained — user-facing; time-to-first-token < 500 ms target
  • Continuous batching — maximise GPU utilisation across many requests
  • Always-on — edge devices run 24/7; power budget is paramount
Inference SoCs optimise for TOPS/W, memory bandwidth per watt, and latency predictability — not raw TFLOPS.
03

The Inference Deployment Landscape

cloud · on-premise · edge · endpoint

Cloud / Hyperscale

  • H100, A100, MI300X, TPU v5p
  • Models: GPT-4, Gemini, Claude
  • Batch sizes: 128–4096
  • Latency budget: >100 ms acceptable
  • TDP: 300–1000 W per accelerator
  • Memory: HBM3/3E, 80–192 GB
BottleneckKV-cache BW, NIC fabric

On-Premise / Workstation

  • RTX 4090, L40S, Gaudi 2, RX 7900
  • Models: Llama 3, Mistral, Qwen
  • Batch sizes: 1–32
  • Latency budget: 50–200 ms
  • TDP: 150–450 W
  • Memory: GDDR7 / HBM3, 24–96 GB
BottleneckWeight load BW (GEMV)

Edge / Endpoint

  • Apple M4, Snapdragon X Elite, Tensor G4
  • Models: Phi-3, Gemma 2B, MobileNet
  • Batch sizes: 1
  • Latency budget: <50 ms
  • TDP: 2–15 W
  • Memory: LPDDR5X/6, 8–32 GB unified
BottleneckPower & DRAM bandwidth

MCU / Microcontroller (TinyML)

Devices: STM32, Nordic nRF, RP2350
Models: MobileNetV3-tiny, keyword spotting
RAM: 256 KB – 8 MB SRAM
TDP: <100 mW — often <1 mW
04

Quantisation — The Foundation of Efficient Inference

mapping floating-point tensors to fixed-width integers

x_int = clamp( round( x_float / scale ) + zero_point, q_min, q_max )

Quantisation Taxonomy

Symmetric (INT8)zero_point = 0; scale = max(|x|)/127
Asymmetric (UINT8)zero_point ≠ 0; full range used
Per-tensorone scale for entire tensor
Per-channelone scale per output channel
Per-group (AWQ/GPTQ)one scale per 32–128 weights
NF4 (QLoRA)non-uniform, normally-distributed

PTQ vs QAT

  • Post-Training Quantisation (PTQ) — no retraining; calibration dataset only; GPTQ, AWQ, SmoothQuant
  • Quantisation-Aware Training (QAT) — fake-quant nodes in training graph; STE gradient; best accuracy
  • GGUF / llama.cpp — CPU-friendly mixed-precision: Q4_K_M, Q5_K_M, Q8_0

Precision Formats & Efficiency

FormatBitsRelative SizeTOPS (H100)
FP32324×67
BF16162×989
FP16162×989
FP8 (E4M3)81×1,979
INT881×3,958
INT440.5×N/A — removed on Hopper
FP4 (B200)40.5×9,000+
Key insight: INT8 cuts model size 4× vs FP32 and doubles throughput on Tensor Cores. INT4 halves again — at the cost of careful per-group calibration to maintain accuracy.
SmoothQuant: migrates quantisation difficulty from activations (large dynamic range) to weights (stable range) via a per-channel smoothing factor — enabling accurate W8A8 without QAT.
05

INT8 & INT4 Hardware Pipelines

from MAC arrays to dequantisation and accumulation

INT8 GEMM PIPELINE Weights INT8 Activations INT8 INT8 × INT8 MAC Array INT32 Accumulate Dequant → FP16 scale_w × scale_a W8A8: 4× memory saving vs FP32, 2× vs FP16 Accumulator must be INT32 to prevent overflow Dequant fused with bias add and activation

INT4 Weight-Only Quantisation (W4A16)

  • Weights stored as INT4, unpacked to FP16 before MAC — no INT4 accumulator needed
  • 2× weight load bandwidth saving vs INT8 — critical for memory-bound GEMV
  • GPTQ: second-order Hessian-guided rounding; per-group scale every 128 weights
  • AWQ (Activation-Aware): protects salient weights by per-channel scaling
  • Hopper H100 has no native INT4 Tensor Core (removed after Ampere); W4A16 dequantises INT4 weights to FP16 before MMA. Ampere A100 retains INT4 at 1,248 TOPS sparse.

Tensor Core Evolution (NVIDIA)

GenerationGPUFormatsPeak TOPS
V1 (Volta)V100FP16125
V2 (Turing)T4INT8, INT4130 / 260
V3 (Ampere)A100BF16, TF32, INT8312 / 624
V4 (Hopper)H100FP8, INT8, INT43,958 (INT8)
V5 (Blackwell)B200FP4, FP6, FP89,000+ (FP4)

Accuracy vs Efficiency Trade-off

FP32 baseline0.0% accuracy loss
BF16 / FP16<0.1% — lossless in practice
W8A8 INT8 (PTQ)<0.5% on most tasks
W4A16 GPTQ0.5–2% typical; task-dependent
W4A8 (aggressive)1–4% — needs careful calibration
W2 / binaryLarge loss except specialised nets
Rule of thumb: INT8 is generally safe for large models (>7B); INT4 requires per-group quantisation and calibration for <2% accuracy loss. Below 7B parameters, quantisation sensitivity rises sharply.
06

The LLM Inference Pipeline

prefill · decode · KV-cache — three distinct hardware problems

LLM INFERENCE PHASES PREFILL (prompt) All tokens processed in parallel Compute-bound: large GEMM KV-cache populated DECODE (generation) One token at a time Memory-bound: GEMV + KV load ~1–4 FLOP/byte KV-CACHE (HBM / SRAM) K,V tensors: 2 × L × H × D × seq × bytes Llama-3-70B, seq=4096: ~67 GB KV-cache (FP16) Llama-3-8B, seq=4096: ~8 GB KV-cache (FP16)

KV-Cache Sizing

KV_bytes = 2 × n_layers × n_heads × head_dim × seq_len × bytes_per_element
Llama 3.1 8B (FP16, 4K ctx)~1 GB
Llama 3.1 70B (FP16, 4K ctx)~18 GB
Llama 3.1 70B (FP16, 128K ctx)~576 GB
GQA (Llama 3, 8 kv-heads)8× reduction

KV-Cache Optimisations

  • Grouped Query Attention (GQA) — share K,V heads across Q groups; 8× KV reduction in Llama 3
  • Multi-Query Attention (MQA) — extreme: one K,V head shared; used in Falcon
  • PagedAttention (vLLM) — non-contiguous KV blocks in virtual memory; eliminates fragmentation
  • KV quantisation — INT8/INT4 KV: 2–4× reduction; KV-Quant, KIVI
  • Streaming LLM — sliding window + attention sinks; O(1) memory for unbounded generation
Prefill/decode disaggregation: route prefill to compute-optimised nodes (batch GEMM), decode to bandwidth-optimised nodes (high HBM BW). Used in production at scale by Google, Anthropic, and OpenAI.
07

Memory Bandwidth — The Dominant Inference Bottleneck

why decode is nearly always memory-bound

Arithmetic Intensity of Inference Operations

Large GEMM (prefill, large batch)100–500+ FLOP/B
GEMV (decode, batch=1)1–4 FLOP/B
Attention (prefill, seq=2K)~15 FLOP/B
Attention (decode, KV-load)<2 FLOP/B
MoE routing + expert GEMM~20 FLOP/B
LayerNorm / elementwise<1 FLOP/B

H100 SXM5 Roofline

Peak FP16 TFLOPS989
HBM3 bandwidth3.35 TB/s
Ridge point295 FLOP/B
GEMV (batch=1)~2 FLOP/B ← far below ridge
Practical GPU utilisation (decode)<5%
Implication: A 70B model decode pass on H100 utilises roughly 0.7% of available FLOPS. The silicon is mostly idle — waiting for weights and KV vectors to arrive from HBM.

Escaping the Memory Wall

Batching
Increase batch size → weights amortised across many tokens → higher FLOP/B. Continuous batching (iteration-level scheduling) in vLLM, SGLang.
Speculative Decoding
Draft model proposes N tokens, target model verifies in parallel. Achieves 2–3× decode speedup at same quality — turns serial decode into a parallel verification GEMM.
Quantisation (W4)
INT4 weights: 4× fewer bytes from HBM per token. Direct bandwidth improvement — 70B model ≈ 35 GB at INT4 vs 140 GB at FP32.
Near-Memory Compute
Samsung HBM-PIM, SK Hynix AiM — DRAM with embedded compute. Eliminates off-chip BW entirely for targeted operations.
GQA / MQA
Grouped Query Attention slashes KV-cache load bandwidth. Llama 3's 8 KV heads vs 64 Q heads = 8× KV traffic reduction.
08

NPU Micro-Architecture for Inference

dataflow, scratchpad, DMA, and scheduling

NPU BLOCK DIAGRAM Host Interface / AXI Command Processor / Scheduler DMA Engine Unified SRAM 4–32 MB scratchpad MAC Array systolic / SIMD Activation ReLU/GELU/LN LPDDR5 / HBM / Unified Memory (via DMA) double-buffered ping/pong DMA prefetches next tile while MAC processes current tile Activation fused with dequant to avoid SRAM round-trip

Key Design Decisions

  • Scratchpad vs cache — NPUs favour software-managed scratchpad; deterministic latency, no cache miss stalls, compiler controls data residency
  • Double-buffering — DMA loads next weight tile while MAC processes current; hides DRAM latency entirely when compute time ≥ DMA time
  • Dataflow: weight-stationary for conv (reuse weights), output-stationary for GEMV (accumulate partial sums)
  • Activation unit — dedicated hardware for GELU, SiLU, RMSNorm, LayerNorm; avoids SRAM round-trip
  • DMA engine — supports stride, gather, scatter; critical for non-contiguous KV-cache layouts

Scheduling & Operator Fusion

  • Layer fusion — MatMul → Dequant → Add bias → GELU → next MatMul as single dispatch; eliminates SRAM store/load between ops
  • Tile scheduler — partitions tensors into SRAM-sized tiles; handles bank conflict avoidance
  • DMA priority — weight prefetch vs activation write-back arbitration; stall-free pipeline requires careful budget
09

Sparsity Exploitation in Inference

skipping zeros for free compute and bandwidth savings

Activation Sparsity

  • ReLU networks: 50–80% of activations are zero after rectification
  • Zero-gating: skip MAC if activation = 0 → power saving proportional to sparsity
  • GELU / SiLU (LLMs) — near-zero but not exactly zero; less exploitable
  • Hailo-8 NPU: dedicated zero-skipping hardware for ReLU CNNs

Weight Sparsity (Pruning)

  • Unstructured pruning — individual weights zeroed; requires sparse accumulator or VLIW schedule; poor hardware efficiency
  • Structured pruning — channels, heads, or layers removed; standard dense matmul on smaller tensors
  • 2:4 structured sparsity — exactly 2 non-zeros per 4 weights; 2× throughput on NVIDIA Tensor Cores from Ampere onwards; negligible accuracy loss at 50%

Mixture-of-Experts (MoE)

  • Architecture-level sparsity — only K of N expert FFN blocks activated per token
  • Mixtral 8×7B: 8 experts, top-2 active — 46.7B total params, ~12.9B active per token
  • Expert routing: gating network adds overhead; load-balance critical for utilisation
  • All-to-all expert dispatch: dominant communication overhead in distributed inference
  • DeepSeek-V3: 256 routed experts + 1 shared expert; top-8 routed per token; pairs with Multi-Head Latent Attention (MLA) for ~10–30× KV-cache reduction

NVIDIA 2:4 Structured Sparsity — Hardware Detail

  • Compressed sparse weight matrix: 50% values stored + 2-bit metadata per group-of-4
  • Sparse Tensor Core decompresses and computes in single pass
  • 2× TOPS / 2× bandwidth saving — equivalent to doubling effective HBM bandwidth
  • H100 sparse INT8: 3,958 TOPS → effectively 7,916 TOPS with 2:4 weights
FlashAttention sparsity: Online softmax computation with block-sparse attention masks. O(N) HBM reads vs O(N²) for standard attention — transforms attention from memory-bound to compute-bound for long contexts.
Speculative Decoding as "temporal sparsity": small draft model generates candidate tokens; large model verifies N at once. Effective throughput gain: 2–4× on typical LLM tasks without quality loss.
10

On-Device LLM SoC Architecture

unified memory, heterogeneous compute, and the Apple M-series blueprint

ON-DEVICE AI SoC (APPLE M4-STYLE) CPU P-cores + E-cores Prefetch / decode GPU Prefill GEMM Metal / SIMD NPU / ANE 38 TOPS (M4) INT8 / INT4 System-Level Cache (SLC) · Coherent Interconnect Fabric ISP / Camera Media Encode/Decode Secure Enclave / Crypto Unified LPDDR5X Memory (128+ GB/s) CPU · GPU · NPU share bandwidth — no PCIe copy overhead Apple M4: 16–32 GB unified · 120 GB/s · 38 TOPS ANE

Unified Memory Architecture Advantages

  • Zero-copy — GPU tokenises, NPU runs LLM decode, CPU runs runtime logic — all share the same physical DRAM pages
  • Coherent — no explicit DMA transfers or pinned buffers between engines
  • LLM-friendly — 70B INT4 model ≈ 35 GB: fits M3 Ultra (192 GB) easily; fits M4 Pro (48 GB) at smaller models
  • Bandwidth pooled — 120–800 GB/s shared; no PCIe bottleneck (≤64 GB/s)

Heterogeneous Dispatch Strategy

Tokenisation / samplingCPU (low latency)
Prefill (long prompt)GPU (parallel GEMM)
Decode (token gen)NPU (low power, INT4)
Embedding lookupCPU cache-friendly
KV-cache managementCoreML runtime
Apple Intelligence (iOS 18.1+) runs 3B on-device model on ANE with stateful KV-cache — persistent state across calls eliminates re-prefill overhead. MLX framework enables research-grade flexibility on the same hardware.
11

Mobile & Edge NPU Comparison

flagship SoC inference capabilities — 2024/2025

SoC NPU TOPS Process Memory BW LLM Capability TOPS/W est.
Apple A18 Pro ANE Gen 5 38 TSMC N3E 8–16 GB LPDDR5X 120 GB/s On-device 3B INT4 ~45
Apple M4 ANE Gen 5 38 TSMC N3E 16–32 GB LPDDR5X 120 GB/s 7B–13B INT4 ~50
Qualcomm SD X Elite Hexagon NPU 45 TSMC N4P 32–64 GB LPDDR5X 135 GB/s 13B–30B INT4 ~35
Qualcomm SD X2 Elite Hexagon NPU 80 TSMC N3 — — Windows AI PC (2025) —
Qualcomm SD 8 Gen 3 Hexagon NPU 45 TSMC N4P 8–16 GB LPDDR5X 77 GB/s 7B INT4 ~38
Samsung Exynos 2500 Mach-1 NPU 40 Samsung 3GAP 12 GB LPDDR5X 77 GB/s 7B INT4 ~30
MediaTek D9400 APU 790 50 TSMC N3E 12–16 GB LPDDR5T 102 GB/s 7B–13B INT4 ~40
Google Tensor G4 TPU (custom) ~17 Samsung 4nm 12 GB LPDDR5X 68 GB/s Gemini Nano INT8 ~25
Memory bandwidth is the binding constraint for on-device LLMs. TOPS matters little if the DMA can't feed the NPU fast enough. Qualcomm's 135 GB/s explains why SD X Elite runs larger models than A18 Pro despite similar TOPS.
INT4 is the practical sweet spot for on-device: 7B model = ~3.5 GB at W4, fits in 8 GB LPDDR with headroom for activations and OS. INT8 doubles this to ~7 GB — tight for 8 GB devices.
12

Power Management for ML Inference

DVFS, power domains, and thermal budget

Inference Power Breakdown (Mobile NPU)

MAC Array
~55%
SRAM (scratchpad)
~25%
DMA / Fabric
~12%
Control / Scheduler
~8%
SRAM leakage grows with size; at 16 MB+ scratchpad, SRAM can exceed MAC array power at idle.

DVFS Strategy for NPU

  • Compute-bound ops (prefill, large conv): max frequency, max voltage — utilise Tensor Cores fully
  • Memory-bound ops (decode GEMV): reduce NPU frequency; performance limited by DRAM BW not clock
  • Clock gating — idle MAC rows gated cycle-by-cycle; partial utilisation common in sparse layers
  • Power gating — entire NPU domain powered down between inference requests; critical for mobile

Thermal Management

  • TDP envelope — mobile: 3–8 W sustained; tablet: 5–15 W; thin laptop: 10–25 W
  • Thermal throttling — PMIC and thermal sensor feedback; frequency reduced when Tj > 85–95°C
  • Workload spreading — PPEM (Performance-Per-Milliwatt) scheduling; distribute load across CPU, GPU, NPU to balance heat
  • Sustained vs burst — Apple M4: 38 TOPS sustained, ~50 TOPS burst (10 s); throttling policy is OS-controlled
  • Vapour chamber / heat pipe — Snapdragon X Elite laptop: required for 45W PC TDP

Energy Minimisation Techniques

  • Zero-skipping — detect zero activations before MAC; save dynamic power proportional to sparsity
  • Data compression — compress activations in SRAM to DRAM transfers; reduce bandwidth energy (α 0.5–1 pJ/bit saved)
  • Near-threshold compute — sub-0.5 V operation for background inference; 10× energy reduction at 10× slower frequency
  • Quantisation — INT4 vs FP16: 4× fewer bits moved → ~4× DRAM energy saving (dominant energy source)
13

The Inference Compiler & Runtime Stack

from model checkpoint to efficient silicon execution

INFERENCE COMPILER STACK PyTorch / JAX / TensorFlow (Model checkpoint + weights) .pt / .safetensors / .gguf Graph IR (torch.export / ONNX / StableHLO) Quantisation, operator fusion, graph simplification Optimisation Passes Constant folding · dead code elimination · layout transform · tiling Hardware Backend Codegen cuDNN / TensorRT / Hexagon SDK / ANE toolchain / TFLite Runtime / Execution Engine vLLM / SGLang / llama.cpp / ONNX Runtime / CoreML Silicon: GPU · NPU · CPU

Key Optimisation Passes

  • Operator fusion — MatMul + GELU + residual add as single kernel; eliminates intermediate tensor writes
  • Layout transformation — NCHW → NHWC → custom NPU-native tile layout; maximises SRAM reuse
  • Constant folding — embed quantisation scales, bias, and fixed masks into weight tensors at compile time
  • Tiling & scheduling — partition tensors to fit SRAM; schedule DMA ahead of MAC by Δt = DMA_latency
  • Kernel selection — cuDNN / TensorRT chooses fastest kernel variant at runtime via auto-tuning

Inference Runtimes Compared

TensorRT (NVIDIA)INT8 engine, graph fusion, FP8
vLLMPagedAttention, continuous batching
SGLangRadixAttention, prefix caching
llama.cppCPU + GPU, GGUF Q4/Q8, portable
CoreML / ANEStateful KV, on-device Apple
ONNX RuntimeCross-platform EP dispatch
Triton / OpenAI: Python-embedded DSL that compiles to GPU PTX; enables research teams to write custom attention kernels (FlashAttention-2/3) at near-cuBLAS efficiency without CUDA expertise.
14

TinyML — Inference at the Extreme Edge

sub-milliwatt neural networks on microcontrollers

Constraints

Flash (model)256 KB – 4 MB
SRAM (inference)32 KB – 512 KB
Clock16 – 400 MHz
Power budget<1 mW – 100 mW
Latency target<10 ms (keyword)
Battery lifeYears on coin cell

Model Architectures

  • MobileNetV3-Small — 1.5 MB, INT8, ~2 ms on Cortex-M55
  • DS-CNN (keyword spotting) — 80 KB, 20 classes, 98% accuracy
  • TinyBERT 4-layer — INT8, 14 MB — tight on 16 MB MCU
  • MCUNet — co-designed for 256 KB SRAM; neural architecture search targeting MCU
  • Binary / ternary nets — XNOR-Net: replace MAC with bitwise AND+popcount; 32–64× MAC reduction

Hardware & Frameworks

  • Arm Cortex-M55 + Ethos-U55 — SIMD Helium, 128-bit SIMD; Ethos-U55: 64–512 MAC/cycle, <0.5 mW
  • STM32N6 (ST) — Neural-ART NPU, 600 GOPS, Cortex-M55+Ethos-U55
  • RP2350 — Cortex-M33 × 2 + RISC-V option; CMSIS-NN optimised kernels
  • TFLite Micro — zero-dynamic-allocation inference; static memory arena
  • Edge Impulse — cloud training → TFLM/EON deployment pipeline

Quantisation for TinyML

  • Full INT8 post-training — TFLite converter + representative dataset; fits 256 KB SRAM with careful planning
  • Layer-wise mixed precision — sensitive first/last layers in INT16, bulk in INT8; automated by TFLite
  • Power-of-2 scales — scale = 2^(-n); replace multiply by shift; critical for shift-only MCUs (no multiplier)
  • Activation range clipping — aggressive clipping during QAT narrows dynamic range → better INT8 fidelity
Ethos-U55 / U65 architecture: 64 or 512 MAC units, weight streaming from Flash via DMA, activation SRAM double-buffered. Power: 8 mW at 64 MACs/cycle. A keyword spotting network runs continuously on Ethos-U55 at <0.1 mW average — less than an LED.
15

CNN Inference Optimisation

convolution, tiling, im2col, and depthwise separability

Conv2D as GEMM — im2col Transform

  • Input feature map patches unrolled into rows of an Toeplitz matrix (im2col)
  • Kernel filters become columns of a weight matrix
  • Conv2D becomes GEMM → fully exploits Tensor Core / SIMD hardware
  • Cost: im2col buffer = K×K×C_in×H_out×W_out — can exceed 10× input size
  • Implicit GEMM (cuDNN): computes im2col on-the-fly; no extra buffer needed

Winograd Convolution (F(2,3))

  • Reduces multiplications: 3×3 conv from 9 to 4 MACs per output element
  • Adds additions — beneficial when multiply is more expensive than add
  • Used in cuDNN for 3×3 conv with FP16; INT8 Winograd less common (accumulation error)
  • 2.25× throughput improvement for 3×3 conv in ideal conditions

Depthwise Separable Convolution

Standard: K×K×C_in×C_out MACs → DW-Sep: K×K×C_in + C_in×C_out MACs
  • Depthwise — one filter per channel; K×K×C_in MACs; very low compute density
  • Pointwise (1×1) — mixes channels; C_in×C_out×H×W MACs; GEMM-friendly
  • MobileNetV2: 8–9× fewer operations vs standard conv; backbone of most mobile CNNs
  • Efficiency trap — depthwise layers are memory-bandwidth-bound, not compute-bound; high TOPS NPUs underutilised

Loop Tiling & Scheduling

  • 7-deep loop nest (N, K, C, H, W, R, S) — tiling order determines cache reuse distance
  • Output-stationary: accumulate partial output in registers; min register spill
  • Row-stationary (Eyeriss): maximise reuse of both weight and activation rows simultaneously
  • Halide, TVM, MLIR Linalg — compiler frameworks for automated tiling search
16

Inference Serving Systems & Batching Strategies

maximising GPU utilisation across concurrent requests

Static vs Continuous Batching

  • Static batching — pad all sequences to max length; wait for full batch before starting; simple but wasteful
  • Continuous (iteration-level) batching — insert new requests at token boundaries; no waiting; GPU utilisation 2–3× higher
  • Chunked prefill — interleave prefill chunks with decode tokens; prevents decode starvation during long prompts
STATIC: WASTED CONTINUOUS: No padding — requests join/leave at each decode step

PagedAttention (vLLM)

  • KV-cache fragmentation wastes 20–40% of GPU memory in naive implementations
  • PagedAttention: KV stored in fixed-size pages (e.g. 16 tokens); pages non-contiguous in physical memory like OS virtual memory
  • Copy-on-write for prefix sharing — same prompt prefix shared across many requests
  • Enables 3× more concurrent requests at same GPU memory budget

Prefix Caching & Radix Attention

  • Prefix caching — reuse KV-cache of repeated system prompts (chatbot context, RAG documents) across requests
  • SGLang RadixAttention — LRU cache of KV blocks indexed by token sequence hash; hit rate >80% in multi-turn workloads
  • Speculative decoding integration — draft and verify within same batch, sharing KV-cache pages
Latency vs throughput trade-off: larger batch → better GPU utilisation (throughput) but higher time-to-first-token (TTFT). Disaggregated prefill/decode routing resolves both simultaneously at hyperscale — separate pools for each optimisation objective.
17

Distributed Inference — Tensor & Pipeline Parallelism

splitting models across multiple accelerators

Why Distribute?

  • Model doesn't fit one device — Llama 3.1 405B FP16: 810 GB; requires 10+ A100 80GB
  • Latency requirements — distribute GEMM across devices → smaller per-device matrix → lower latency per layer
  • Throughput scaling — additional devices handle more concurrent requests

Tensor Parallelism (Megatron-LM)

  • Column-parallel: split weight matrix along output dimension; each GPU computes partial output columns
  • Row-parallel: split along input dimension; each GPU holds partial input rows; all-reduce to combine
  • MLP sharding: FFN first Linear column-parallel, second row-parallel — one all-reduce per transformer block
  • Attention sharding: Q,K,V heads distributed across GPUs; each GPU handles subset of heads
  • Communication: all-reduce per layer — NVLink 5 (1.8 TB/s) vs PCIe (64 GB/s) matters enormously

Pipeline Parallelism

  • Transformer layers partitioned into stages; each GPU holds a stage
  • GPipe micro-batching: split batch into micro-batches; pipeline flush eliminates bubble
  • 1F1B interleaved (Megatron): interleave forward/backward across stages; ~1/N pipeline bubble
  • Communication: point-to-point activation tensors between stages — lower volume than all-reduce but sequential
  • Inference-only: no backward pass — pipeline bubble eliminated; pure latency / throughput balance

Expert Parallelism (MoE)

  • MoE experts distributed across GPUs — each GPU owns subset of experts
  • All-to-all dispatch: route tokens to correct GPU for expert execution — dominant communication cost
  • DeepSpeed-MoE, Tutel — dynamic load-balancing to handle expert load imbalance
  • Combined TP + EP for Mixtral: tensor-parallel within expert, expert-parallel across nodes
LLM serving at hyperscale: GPT-4 class models use TP=8 within a node (NVLink) + PP across nodes (InfiniBand). Expert parallelism on top for MoE — 3D parallelism in production.
18

Case Study: NVIDIA H100 / H200 for Inference

the dominant cloud inference platform — 2024

H100 SXM5 Specifications

ProcessTSMC N4 (4nm)
Transistors80 billion
SMs132 (MIG: up to 7 instances)
FP8 TOPS (sparse)3,958
INT8 TOPS (sparse)3,958
HBM3 capacity80 GB
HBM3 bandwidth3.35 TB/s
NVLink 4 bandwidth900 GB/s
TDP700 W

H200 — Memory Upgrade

HBM3E capacity141 GB
HBM3E bandwidth4.8 TB/s
LLM decode speedup vs H100~1.9× (BW-bound)
Llama 3.1 70B fits without offload?Yes — 35 GB INT4

Hopper Inference Features

  • Transformer Engine — FP8 Tensor Cores; dynamic per-layer precision selection; loss-free FP8 inference for most LLMs
  • WGMMA (Warpgroup MMA) — asynchronous matrix multiply across warp groups; decouples data movement from compute
  • TMA (Tensor Memory Accelerator) — hardware-managed multi-dimensional tile DMA; no software prefetch code needed
  • MIG (Multi-Instance GPU) — partition H100 into up to 7 isolated inference instances; efficient for small-model serving
  • Confidential Computing — TEE for sensitive inference workloads (medical, financial)

Inference Performance (Llama 3.1 70B, INT8)

1× H100 SXM5 (batch=1)~30–50 tok/s decode
1× H200 (batch=1)~55–80 tok/s decode
8× H100 NVL (TP=8, batch=32)~1,800 tok/s
Time-to-first-token (4K prompt)~200–400 ms
Bottleneck (batch=1)HBM bandwidth
19

Case Study: Qualcomm Cloud AI 100 Ultra

purpose-built inference ASIC — not a repurposed training GPU

AI 100 Ultra Specifications

ProcessTSMC 5nm
INT8 TOPS870
On-chip SRAM128 MB
LPDDR5X memory136 GB
Memory bandwidth2.2 TB/s
TDP150 W
TOPS/W (INT8)~5.8 — vs H100's ~5.7
Form factorHHHL PCIe card
LPDDR vs HBM trade-off: LPDDR5X is cheaper per GB than HBM3, enabling 136 GB at lower cost. Bandwidth (2.2 TB/s) lags HBM3 (3.35 TB/s) but for INT4 decode the gap narrows — 4× fewer bytes fetched per weight element.

Inference-First Architecture Choices

  • No FP64 / FP32 training paths — die area focused entirely on INT8/INT4 MAC arrays and SRAM
  • 128 MB on-chip SRAM — KV-cache tiers: hot tokens in SRAM, cold in LPDDR; reduces off-chip reads for short-context decode
  • Multi-chip module — two dies per Ultra card; 2× die yield benefit from smaller die; NVLink-equivalent internal interconnect
  • Compiler-driven scheduling — Qualcomm's AIC compiler statically schedules all DMA and compute; no dynamic dispatch overhead
  • Network-attached inference — designed for rack-scale pod with PCIe fabric; flexible scaling from 1 to 64 cards

Competitive Positioning

MetricH100 SXM5AI 100 Ultra
INT8 TOPS3,958870
Memory80 GB HBM3136 GB LPDDR5X
BW3.35 TB/s2.2 TB/s
TDP700 W150 W
TOPS/W~5.7~5.8
20

Case Study: Groq LPU — Compiler-as-Hardware

deterministic dataflow execution for ultra-low inference latency

Groq TS-P1 Specifications

ArchitectureTensor Streaming Processor
ProcessTSMC 14nm (TS-P1)
On-chip SRAM230 MB — vast scratchpad
INT8 TOPS188
Memory bandwidth80 TB/s (SRAM bandwidth)
External memoryNone — model must fit in SRAM
TDP300 W
Llama-3.3 70B tok/s (standard)~280 tok/s
Llama-3.3 70B tok/s (w/ spec-dec)~1,665 tok/s
80 TB/s SRAM bandwidth completely eliminates HBM as the bottleneck — GEMV becomes compute-bound, not memory-bound. Result: 750 tok/s single-stream latency vs H100's ~50 tok/s — 15× faster decode.

Tensor Streaming Processor Principles

  • No caches, no branch prediction, no out-of-order execution — compiler determines all data movement statically at compile time
  • Deterministic execution — every instruction scheduled at compile time; zero runtime overhead
  • Spatial dataflow — data streams through fixed functional units in programmed order; no dynamic dispatch
  • 230 MB SRAM — holds model weights of 8B INT8 entirely on-chip; zero HBM stall for decode
  • Compiler = hardware — Groq Compiler expresses the full execution plan; chip is a programmable dataflow engine

Trade-offs & Limitations

  • Model size ceiling — 70B INT4: ~35 GB; requires 200+ chips in a GroqRack for on-chip storage
  • No dynamic shapes — variable-length sequences require recompilation or padding
  • Older process (14nm) — raw TOPS far below H100; wins purely on bandwidth-to-compute ratio
  • Ideal for latency-critical serving — chatbots, auto-complete, real-time speech — batch=1 scenarios
21

Security Considerations in Inference SoCs

model protection, TEE, and inference-time attacks

Model Intellectual Property

  • Weight encryption — AES-256 encrypted weights in Flash/DRAM; decrypt only within NPU boundary
  • Secure boot — NPU firmware authenticated with hardware root of trust before any model load
  • Secure Enclave partition — model weights never accessible to application CPU in plaintext
  • Apple Neural Engine: model loading through CoreML only; weights never exposed to user process

Trusted Execution for Cloud Inference

  • NVIDIA Confidential Computing (H100) — GPU Trusted Execution Environment; attestation of GPU firmware integrity
  • AMD SEV-SNP + Instinct — encrypted VM memory; inference data encrypted end-to-end
  • Remote attestation — cloud customer verifies model and runtime integrity before submitting sensitive inputs
  • Use case: medical imaging, financial document inference, PII-containing prompts

Inference-Time Attacks

  • Prompt injection — adversarial input manipulates model output; not hardware-level but system design concern
  • Model extraction — repeated queries to reconstruct weights; mitigated by rate-limiting and output perturbation
  • Side-channel timing — inference latency leaks token probabilities; fixed-time decode with dummy padding
  • Data poisoning — fine-tuning attacks; hardware signing of model checkpoints provides provenance
On-device privacy advantage: edge inference never transmits user data to cloud — inference is local by design. Apple Intelligence Private Cloud Compute extends this: cloud inference uses TEE, no user data retained, independently auditable firmware.
Differential privacy for output: adding calibrated noise to logits before sampling provides formal privacy guarantees in scenarios where model outputs might leak training data membership.
22

Emerging Inference Techniques

speculative decoding · medusa · SSMs · analog compute

Speculative Decoding — Deep Dive

  • Algorithm: draft model generates K tokens autoregressively; target model verifies all K+1 in single forward pass (parallel GEMM)
  • Acceptance probability: p_accepted = min(1, p_target / p_draft) per token via rejection sampling
  • Speedup: K_accepted × (T_target / T_draft) — effective when draft model is 10–50× smaller
  • Self-speculative (Medusa, Eagle): draft heads attached to target model; share hidden states
  • EAGLE-3 (NeurIPS'25): feature-level speculative decoding with multi-layer fusion; 2–6.5× speedup over vanilla decode; now the standard spec-dec head in vLLM and SGLang. Medusa / EAGLE-2 remain common.
  • Hardware implication: turns memory-bound GEMV decode into compute-bound GEMM verification — transforms the roofline operating point

State Space Models (Mamba / S4)

  • Alternative to Transformer attention; recurrent state representation with linear-time decode
  • Inference advantage: O(1) memory per token (fixed state vector vs O(N) KV-cache growth)
  • Hardware implication: no KV-cache → no KV bandwidth bottleneck; fits tiny SRAM even at long context
  • Mamba-2: structured state space; selective SSM — matches Transformer quality at 1B+ parameters
  • Hybrid architectures (Jamba, Zamba): interleaved attention + SSM layers — best of both

Analog & Photonic Compute

  • Analog in-memory compute (IBM PCM/ReRAM): GEMV at 85 TOPS/W; no weight movement → zero DRAM bandwidth energy
  • Photonic MAC (Lightmatter Passage): optical matrix multiplication at speed-of-light; 0 dynamic power for MAC
  • 3D SRAM-on-logic (TSMC SoIC): >100 TB/s on-die bandwidth — Groq-style architecture at advanced node
23

Power-Performance Trade-off Summary

TOPS/W across the deployment spectrum

Device / Accelerator Class Process Peak TOPS TDP TOPS/W Best Fit
Arm Ethos-U65 (512 MACs)TinyML MCUAny0.58 mW~60Keyword, IMU, gesture
Apple ANE (A18 Pro)MobileN3E38~1.5 W~45On-device 3B LLM, CV
Qualcomm Hexagon (SD 8 Gen 3)MobileN4P45~2 W~387B INT4 on Android
Groq TS-P1Inference ASIC14nm188300 W~0.6Ultra-low latency LLM (SRAM-resident)
Qualcomm AI 100 UltraInference ASIC5nm870150 W~5.8Cost-efficient LLM serving
NVIDIA H100 SXM5Data Centre GPUN43,958700 W~5.7Training + inference, large batches
NVIDIA H200Data Centre GPUN43,958700 W~5.7Large model BW-optimised inference
AMD MI300XData Centre GPUN5/N65,220750 W~7.0Large model, 192 GB HBM3
Google TPU v5pTPU7nm459 (BF16)450 W~1.0Google internal, TPU pods
TOPS/W divergence: edge NPUs achieve 40–60 TOPS/W; datacenter GPUs sit at 5–7 TOPS/W. The 10× gap reflects power delivery, cooling infrastructure, and the absence of DRAM bandwidth overhead on-edge with unified memory.
Selection criteria: choose by model size (requires DRAM capacity), latency requirement (requires SRAM bandwidth or low-latency fabric), throughput (requires TOPS × utilisation), and cost-per-token (TCO analysis including power, rack space, and DRAM cost).
24

Summary & Key Takeaways

SoCs for ML Inference

Core Principles

Memory Bandwidth Dominates
Inference decode is bandwidth-bound at batch=1. The right question is not TOPS but bytes-per-second from DRAM to MAC array.
Quantisation Is Non-Optional
INT8 is the minimum for production LLM inference; INT4 with per-group scaling is the practical edge sweet spot. FP8 is training's gift to inference.
KV-Cache Shapes System Design
Context length × batch size × precision × layers determines DRAM capacity requirement. PagedAttention and GQA are mandatory at scale.
Heterogeneous Compute Wins
CPU + GPU + NPU unified memory (Apple, Qualcomm) or tensor + pipeline + expert parallelism (hyperscale) — no single accelerator type is optimal for all phases.
Compiler Is Co-Designer
Operator fusion, tiling, and DMA scheduling are as important as silicon. Groq's compiler-as-hardware is the extreme case; every NPU requires this thinking.

Emerging Directions

  • FP4 / FP6 — Blackwell native FP4; model quality at sub-INT4 bitwidths approaching INT8 with careful calibration
  • State Space Models — Mamba / Jamba eliminate KV-cache; O(1) decode memory enables extreme context lengths
  • Speculative + medusa decoding — becoming standard in production serving stacks
  • Analog / photonic compute — elimination of weight movement energy; 10–100× efficiency gains demonstrated in research
  • Near-memory compute — HBM-PIM, 3D SRAM-on-logic: bring compute to data rather than data to compute
  • On-device foundation models — 7B–13B running locally at <10 W is now engineered reality

Series Navigation

✅ 01 SoC Packaging ✅ 02 On-Chip Interconnect ✅ 03 Memory Hierarchy ✅ 04 SerDes & I/O ✅ 05 AI/ML Accelerator Architectures ▶ 06 SoCs for ML Inference 07 Security in SoC 08 CXL in ML SoCs … 13 Clocks & Resets