Skip to content

Guides

Task pages for when you already know why and need the steps. Each guide says when to use it, lists prerequisites, gives numbered steps with exact commands and a check for most steps, and ends with a troubleshooting table and references. Each one links back to the chapter that explains the reasons; where a chapter already gives the recipe, the guide uses the same values.

Setup

Guide Use it when Why, in the Book
Install TorchTPU on a TPU VM You need TorchTPU on a v6e, v5p or v5e VM or on every worker of a multi-host slice, verified per host Chapter 8
Run TorchTPU on GKE Your TPUs are GKE node pools (always for v7x) and you run Job or JobSet workloads Chapter 8

Porting

Guide Use it when Why, in the Book
Port a Hugging Face model A Transformers causal LM (including MoE) or a Diffusers pipeline, on one chip or sharded Chapter 9
Port a custom model Your own PyTorch model and loop, written for CUDA or the CPU Chapter 9

Profiling

Guide Use it when Why, in the Book
Capture and read an XProf trace A correct step is slower than expected and you need to know where the time goes Chapter 10

Kernels

Guide Use it when Why, in the Book
Write a Pallas kernel One memory-bound op dominates the profile and no existing kernel covers it Chapter 12

Training

Guide Use it when Why, in the Book
Run TorchTitan on TPU Training an LLM with TorchTitan's TPU recipes, on one VM or a GKE slice Chapter 14
FSDP on TorchTPU Your own training loop needs its parameters and optimizer state sharded Chapter 14
Ray on TPU Ray actors, Ray Train, Ray Serve LLM or an RL loop on TPU Chapter 15

Serving

vLLM-TorchTPU:

Guide Use it when Why, in the Book
Serve a first model with vLLM-TorchTPU You need a first vllm serve endpoint and offline batch on a TPU VM, verified with a request Chapter 18
Recipes for TPU v6e You serve on v6e and want a configuration sized for 32 GB chips Chapter 18
Recipes for TPU v7x You serve on v7x and want the CI benchmark configuration for your model Chapter 18
Run vLLM-TorchTPU on GKE A multi-host slice or disaggregated pools run as JobSets on GKE Chapter 18, Chapter 20
Offline inference Batch outputs, a LoRA adapter or a vision-language model without a server Chapter 18
Choose a parallelism layout A model needs several devices and you must pick TP, DP plus EP, PP or context parallelism Chapter 18
Quantize weights and KV cache The model does not fit, KV runs out, or decode sits at the bandwidth floor Chapter 18
Speculative decoding Decode latency matters more than peak throughput Chapter 18
Serve across several TPU hosts A layout needs more devices than one host has Chapter 18
Disaggregate prefill and decode Long prompts stall decodes, or prefill and decode want different layouts Chapter 18, Chapter 20
Keep compiled programs across restarts Every start compiles for minutes, or you must prove nothing compiles after warmup Chapter 18
Benchmark vLLM-TorchTPU You need TTFT, TPOT, throughput or accuracy numbers someone else can trust Chapter 18, Chapter 24

Profiling serving:

Guide Use it when Why, in the Book
Profile vLLM-TorchTPU serving A server is correct but slow: one shape offline, a serving window, one trace per phase, or a disaggregated request Chapter 10, Chapter 18

SGLang-TorchTPU:

Guide Use it when Why, in the Book
Serve a first model with SGLang-TorchTPU You want SGLang's server and radix cache on a TPU7x host from a recipe Chapter 19
Serve agents with SGLang-TorchTPU Agent or multi-turn traffic, where prefix reuse decides TTFT Chapter 19

llm-d

Start with the quickstart, then add the well-lit paths your traffic needs. Pages that cover paths with no TPU configuration in llm-d 1.0 say so in their opening paragraph and point to the TPU alternative.

Guide Use it when Why, in the Book
llm-d quickstart on GKE TPU Your first router plus vLLM-TorchTPU pool on v6e or TPU7x, then a GKE Gateway Chapter 20

Well-lit paths:

Guide Use it when Why, in the Book
Optimized baseline Any new deployment: prefix-cache affinity plus token-load balancing, static or dynamic TPU7x slices Chapter 20
Precise prefix-cache routing Long shared prefixes and the approximate index is not enough Chapter 20
P2P prefix-cache sharing Pods should pull prefixes from peers (GPU only; TPU alternative named) Chapter 20
Tiered prefix cache Hit rate limited by HBM: host DRAM and Lustre tiers through TPU Sync Chapter 20
P/D disaggregation Prefill and decode must scale separately; v6e TPUConnector, TPU7x TPURaidenConnector Chapter 20
Wide expert parallelism Large MoE across nodes (GPU only; TPU EP lives in the model recipes) Chapter 20
Predicted-latency routing Output lengths vary widely, or requests carry latency SLOs Chapter 21
Multimodal and omni models Image inputs on TPU7x; speech or image outputs (GPU only) Chapter 20
Stateful Responses API Agents and coding harnesses that need previous_response_id and tool loops Chapter 20
Model recipes Qwen3.5-397B or GLM-5.2 on TPU7x; DeepSeek-V4 and Nemotron 3 Ultra on GPU Chapter 20

Operations:

Guide Use it when Why, in the Book
Autoscale an llm-d pool Replicas should follow demand: in-flight, queue, tokens or SLO, with KEDA Chapter 21
Batch and async serving Offline or background work should fill slack TPU capacity Chapter 21
Roll out changes You change an image, flag, model, adapter or slice without dropping requests Chapter 21
Cut pod startup New TPU pods take minutes to become Ready Chapter 21
Manage traffic and tenants Priorities, fairness, several models or adapters share pools Chapter 21
Observe a deployment Metrics, TPU exporter, PromQL, dashboards, alerts, traces and cost Chapter 21
Validate a deployment Smoke test after every change; benchmark against the SLO Chapter 21
Put an AI gateway in front One entry point for llm-d and external APIs (LiteLLM, Kong) Chapter 21

Correctness and evidence

Guide Use it when Why, in the Book
Parity-check a port You need evidence a TPU result is correct, or to find the layer where it is not Chapter 23
Benchmark a training run You need a step time, throughput or MFU figure someone else can trust Chapter 24

Using a guide

Run the companion code's --cpu-smoke path on a laptop first where a guide offers one: it checks the method without a TPU, and every such command ends with a line you can compare (cpu-smoke: OK). Then run the TPU path. The references at the end of each guide name the public documentation behind its commands.