TL;DR
Building new AI chips is hard, but getting existing software to actually run on them without rewriting everything from scratch is often harder. Libtt solves this for Tenstorrent processors by disguising them as Google TPUs at the compiler-interface level, bundling an entire heavily optimized compiler and multi-chip runtime into a single sub-90 MB shared library. As a result, standard PyTorch and JAX workloads—from LLM serving to reinforcement learning—run out of the box with competitive performance.
What Problem Does This Paper Address?
Modern machine learning runs overwhelmingly on PyTorch and JAX. When alternative hardware arrives—like Tenstorrent’s Blackhole chip, a grid of 120 small, tile-based "Tensix" computers each driven by five tiny RISC-V processors—developers hit a software wall.
Previously, getting good performance on Tenstorrent meant manually porting models to the vendor's custom Python API (TTNN) and hand-tuning memory layouts. Meanwhile, Tenstorrent's upstream framework integration (tt-xla) lacked operation coverage, suffered from subtle numerical bugs, and relied on an awkward lazy-tensor model for PyTorch that broke standard torch.compile and eager workflows. The authors set out to make unmodified PyTorch and JAX code run seamlessly and fast on Tenstorrent hardware.
Methods
Instead of inventing a new framework backend, libtt implements PJRT—the standard C interface that XLA-based frameworks use to talk to Google TPUs. Because TPUs and Tenstorrent chips share the two traits compilers care about most (computing on 2D tiles of data and linking chips via high-speed meshes), the TPU software stack is a natural blueprint. JAX connects directly, while PyTorch connects via Google's TorchTPU backend.
Building on Tenstorrent's open-source stack (tt-xla, tt-mlir, tt-metal), the authors applied ~400 patches (>50,000 lines changed) and added 15,000 lines of new code, shipping everything—including an embedded RISC-V GCC compiler—inside a single libtt.so file:
- Semantic & Numerical Fidelity: Added native IEEE FP16 and FP8 (
e4m3fn/e5m2) support, exact 32-bit integer reductions, proper NaN/signed-zero handling, and new general indexing operations (rows_gatherandrows_scatter) so embedding lookups don't copy entire tables. - Tile-Aware Compiler & Fusions: Tensors on Blackhole live in $32 \times 32$ tiles. During LLM decoding, a single token row wastes 31/32 of a tile on padding. Libtt reshapes wide vectors to pack tiles, skips empty rows in kernels, and fuses multi-op sequences (like residual RMSNorm, SwiGLU, and attention prep) so intermediate data stays in local core SRAM rather than round-tripping to DRAM.
- Conditional Device Traces: Launching tiny programs takes microseconds that add up across thousands of ops. Libtt records execution sequences ("traces") on-chip and adds hardware-level conditional commands, allowing dynamic branches (like token sampling) to execute without host CPU synchronization.
- Dual Multi-Chip Execution: Supports both JAX’s single-controller mesh sharding (via Shardy) and PyTorch’s one-process-per-chip model over 800 Gbps Ethernet links.
Datasets
No new benchmarks are introduced; standard datasets evaluate end-to-end correctness and training:
- C4: Pre-training throughput measurements.
- ToolACE & BFCL (Berkeley Function-Calling Leaderboard): Supervised fine-tuning (11,300 examples) and single-turn tool-calling evaluation (1,240 tests).
- MetaMathQA: CPU-vs-chip numerical loss verification.
- GSM8K: Reinforcement learning training and test accuracy (1,319 test questions).
- MMLU: Full-model numerical verification during serving (13,757 questions).
Key Insights and Ideas
- Piggybacking on the TPU Ecosystem: By acting as a drop-in replacement for
libtpuand substituting Pallas custom kernels via lightweight Python import adapters, complex TPU-targeted engines like SGLang-TorchTPU, TorchTitan, and Miles run on Tenstorrent without editing application source code. - Bandwidth Parity with TPUs: Decoding LLMs at batch size 1 is essentially a memory-bandwidth race. By spreading weight reads across GDDR6 banks and keeping activations resident on-core, Blackhole matches or exceeds a Google TPU v6e per unit of memory bandwidth.
- Tile Padding Lurks Everywhere—Even in Gradients: In Llama 3, rotary embeddings create a trailing tensor dimension of 2, which pads out to 32 columns—a $16\times$ waste during backpropagation. Rewriting the compiler pass to split heads into halves eliminates that overhead automatically.
Key Results
Evaluated primarily on a 4-chip TT-QuietBox 2 workstation:
- Framework Test Suites: Under JAX 0.7.1,
libttpasses 24,075 tests vs. upstreamtt-xla's 17,824 (and under newer JAX 0.11.2 andtorch_tpu0.2.0,libttpasses 26,110 and 7,324 tests respectively, whereas upstream crashes at startup). - LLM Serving: SGLang-JAX reaches 124.4 tokens/s on Qwen3-8B and 127.4 tokens/s on Qwen3-30B-A3B (MoE) across 4 chips, scaling to 1,139 tokens/s at 16 concurrent requests. Speculative decoding speeds up Qwen3.8-27B by up to $2.6\times$.
- TPU & Upstream Comparisons: A TPU v6e is $2.8\text{--}3.2\times$ faster than one Blackhole P150 on FP8 decode, closely tracking its $3.2\times$ memory bandwidth advantage (1,638 vs. 512 GB/s). On the same chip,
libttmatches or beats Tenstorrent's hand-ported vLLM stack on single-request decode. - Training & RL: TorchTitan trains Llama 3 8B at 372 tokens/s/chip and Qwen3-8B at 435 tokens/s/chip. Fine-tuning Qwen3.5-9B-Base boosts BFCL accuracy from 64.8% to 91.0%. Using Miles, 90 steps of GRPO reinforcement learning lift Qwen3-0.6B GSM8K accuracy from 58.0% to 73.3%.
Limitations and Future Work
- Missing Features & Numerics: Dynamic tensor shapes, eigenvalue decompositions, true 64-bit floats/integers (currently legalized to 32-bit), and
float8_e8m0fnuare not yet supported. - Host-Driven Loops & Scale:
whileloops with data-dependent termination still step through the host CPU, and distributed execution is currently limited to chips within a single host machine rather than multi-node clusters. - Brittle Fusions & Custom Kernels: Graph fusions currently rely on rigid pattern-matching; the authors plan to adapt upstream's automatic kernel generator (D2M) once compile times and speeds improve, explore supporting a kernel language like Pallas or TileLang, and upstream their patches to Tenstorrent.
Summary updated