Porting from JAX to TorchTPU: after fixing dedup bugs, beam search beats JAX by 25%
AndLukyane · x · 2026-11-25
A hands-on port of a puzzle-solving transformer and its beam search from A100/JAX to Google's new TorchTPU (native PyTorch TPU backend), with code written by coding agents (Claude Code, Codex). Initial results were bad: training 1.65x slower than A100, beam search 5.7x slower than JAX.
Key fixes: fused eager via one env var (234.8s → 176.5s per epoch), einsum attention (→132.0s vs A100's 142.7s), eliminating dynamic shapes, a subtle deduplication bug where unstable sorting let two score copies of the same state compete and drop shorter paths (fixed with keep min(score, index)), and Flash attention tuning (3.74s → 0.93s per beam level on a v6e chip).
Result: optimized TorchTPU beam search runs 25% faster per level than JAX on the same 8-chip v6e machine with identical solution lengths. The investigation led to upstream TorchTPU attention-routing fixes. Code available on free Kaggle TPU v5e-8 notebooks.
Related event: Developer Migrates Solver to TorchTPU, Beam Search Beats JAX by 25%(2 posts)→
More from Infra
- local-ai-harness Runs 768B DeepSeek-V4.1-Flash at 1M Context on a Single Strix Halo — stereohype · 2026-11-25
- First SGLang Summit draws 2,000+, launches v1.0 and consortium with Nvidia, Google, Meta — ying11231 · 2026-11-25
- Starcloud explains how space data centers shed chip heat: infrared radiators emitting 800W per square meter — ycombinator · 2026-11-25
- Microsoft AI open-sources details of Rocket, its in-house RL infrastructure now post-training MAI Base 2 — mustafasuleyman · 2026-11-25
- DreamcatcherAI serves Kimi K3.1 Pro on Tenstorrent cards, adds 256 more units — DavidBennett__ · 2026-11-25
- Redwood Materials builds off-grid data center power from old EV batteries and solar panels — Sethwinterroth · 2026-11-25