The AI Gazette

Listen to this story

5 min · read by an AI voice

ResearchGoogle

Google makes its RL sampler and trainer agree to the last bit on TPUs

In reinforcement learning for language models, the sampler that generates answers and the trainer that learns from them can score the same token differently, even with the same weights. A Google post explains how floating-point arithmetic causes this and gives a four-part recipe, now in Tunix, that removes it.

Reinforcement learning after pre-training runs in a loop. A sampler generates attempts and records, for every token it picks, the log-probability that the model gave that token. A trainer then runs the same tokens through the model again to compute gradients. On-policy learning assumes that both steps evaluate exactly the same policy. In production the two run on different code paths, the sampler decoding one token at a time and the trainer processing whole batches, and even with identical weights they can assign different log-probabilities to the same token. The schedule is on-policy, but the arithmetic is not, and the gap compounds over trajectories with many turns.

The cause is that floating-point addition is not associative. A sum computed in a different order rounds at different places. The post shows this in bfloat16, which keeps less precision than float32: near 2.0, a value of 0.0078125 added on its own is rounded away, while several such values grouped first reach the next representable number. Matrix products, normalisation statistics and the combining of tensor-parallel shards are all sums of this kind. In Google's original stack the sampler and the trainer used different array shapes and forward implementations, and JAX compiles a separate program for each shape. In the post's words, the weights and model equations were identical; the arithmetic was not.

The post sets a strict contract. Sampler decode, serving prefill and trainer forward must produce bitwise-identical log-probabilities for every sampled action, compared as raw bytes with no tolerance. The middle step is there for diagnosis: decode against prefill tests whether the serving engine agrees with itself, and prefill against the trainer tests the boundary between serving and training. The recipe has four parts. Batch-invariant Pallas kernels fix the order and precision of the sums within each shard, accumulating in float32 however many token rows there are. Sums across shards are made explicit: ppermute moves the partial results and every rank adds them in the same source-rank order. All three paths score the sampled token with one shared, fixed log-softmax. And the trainer reuses the serving kernels for its forward pass through custom vector-Jacobian products, with --xla_allow_excess_precision=false passed to the compiler.

The implementation, called Zero-TIM, lives in Tunix, Google's open-source JAX library for post-training on Cloud TPU, and was verified on 64 TPU v5p chips arranged as 8-way data parallelism by 8-way tensor parallelism. The test trained a public Qwen3-8B checkpoint for 200 steps on FrozenLake, a synthetic grid puzzle in sizes from 2×2 to 9×9 with up to five turns, using a GSPO-token loss. Zero-TIM recorded a mean absolute log-probability difference of zero at every logged step and reached higher solve rates than standard training and than truncated importance sampling, a common correction that reweights the mismatch instead of removing it.

These are single-seed runs in a toy environment, so they show that the mechanism works rather than how large the gain is on real tasks. The post credits recent open-source work on the same contract, with vLLM and TorchTitan and in RadixArk and LMSys's Miles; what it adds is an implementation for JAX, Pallas and multi-host TPU meshes. Google says it is extending the TPU version to linear attention and mixture-of-experts models.

From other editions

Say hi.