Skip to main content
Miles runs on Google Cloud TPU v7x through torch_tpu. The torchtitan backend trains and sglang-torchtpu serves rollouts as an external engine. Megatron-LM is not supported on TPU.

Layout

One v7x 2x2x1 host has 4 chips with 2 TensorCores each, so 8 devices. The trainer runs as 4 ranks on devices 0-3 and the engine serves on devices 4-7. Both jobs share the host’s slice, so weights move from trainer to engine over ICI (--update-weight-transfer-mode ici) without touching disk.

Image

The engine and the trainer share one Python environment, built by docker/Dockerfile.tpu on sglang-torchtpu’s release image. CI rebuilds it next to the CUDA image and publishes it as radixark/miles:dev-tpu (and latest-tpu). To build it yourself:
To set the environment up by hand instead, see scripts/tpu/README.md.

Launch training

The TPU launchers live under scripts/tpu/, one per model family: Qwen3-4B, Qwen3-30B-A3B, a 4-layer GLM-4.7-Flash, and run_qwen3_5_torchtitan.py for Qwen3.5 / Qwen3.6 / Qwen3.8, which picks its row with --model-name (Qwen3.5-4B, Qwen3.5-27B, Qwen3.6-35B-A3B or Qwen3.8-27B). Each launcher has a prepare, a sglang and a train command. prepare fetches the model and datasets. Start the engine in its own shell, then start training a minute or two later without waiting for the engine’s /health: the engine compiles only after the trainer has joined the slice.
The first step of a cold run compiles the trainer’s programs, and sglang has to be restarted with every training run. The README covers both, along with the recipes, the compile cache, and per-model trainer settings.

Next steps