« All posts

Gherkin Labs Reverse-Engineers Google's TPU Driver Protocol

Gherkin Labs reverse engineers Google's TPU driver protocol, building a cycle-accurate simulator for the real TPU software stack.

Gherkin Labs has built a simulator capable of running Google's real, unmodified TPU software stack after fully reverse engineering the communication protocol between the TPU driver and hardware. The simulator ships as a shared library, libsymtpu.so, which when loaded via LD_PRELOAD exposes virtual TPU devices that mimic real chip interfaces, decoding instruction streams and simulating both tensor and sparse cores on the CPU.

Because TPUs issue exactly one instruction bundle per cycle with fixed, compiler-scheduled latencies, replaying that schedule reproduces the chip's actual timing, giving cycle-accurate traces. The only non-deterministic elements the team had to model separately were DMA transfer times, inter-chip message latency, and sync-flag read/write costs.

The project matters because TPUs remain far less documented than Nvidia GPUs despite being easier to access, and their entire software stack funnels through Google's own compiler used by JAX, Torch, and Pallas. By detailing the VLIW-style architecture of TPU v7 (Ironwood) — including its systolic-array MXU, XLU, and fully explicit, cache-free memory hierarchy — Gherkin Labs positions the simulator as a harness for evaluating and tracing kernels, including those generated by LLM-driven kernel search.

This synthesis was produced from its source by AI; there is no human editor or manual review step. How we work