Stabilizing Extrapolation in Looped Transformers via Learned Stochastic Stopping
Hsun-Yu Kuo, El Mahdi Chayti, Patrik Reizinger, Wieland Brendel, Martin Jaggi
NeurIPS page · Open on the map
Category: LLM Reasoning, Memory & RAG › Diffusion LLM Inference · Type: new method · Keywords: looped transformers, stochastic stopping, RL-halting, length generalization, algorithmic tasks, out-of-distribution stability
Summary
The paper introduces learned stochastic stopping (RL-Halting) to stabilize extrapolation in looped transformers by making the number of loops a stochastic training-time schedule.
Explained to a 5-year-old
Some computer programs repeat a part many times to solve puzzles. When they repeat too many or too few times, the answers can be wrong. The researchers noticed that the number of repeats was linked to how long the puzzle was. They taught the program to decide randomly when to stop repeating, so it works better. This helps the program give stable answers even when the puzzle length changes.
Explained to a 5-year-old, longer
Computers sometimes need to solve problems that involve sequences of symbols. They can use a special kind of network called a looped transformer that repeats the same part many times. When the network repeats the part a certain number of times, it often matches how long the problem is. But if the number of repeats changes, the answer can become very different, making it unstable. The researchers found that this instability happens because the repeats and the problem length are linked in a way that is not always helpful. To fix this, they added randomness to how many times the network repeats the part during training. Instead of always using the same number of repeats, the network learns when to stop on its own. This learning is done by a method that chooses the stopping point based on what it sees. By practicing with different stopping points, the network becomes better at giving consistent answers. It can now handle problems of different lengths without breaking. The new approach also sometimes helps even when the network was not originally the best at solving the problem. Overall, the idea is to let the network decide when to stop looping, making it more reliable.
For a technical reader
The paper addresses the instability of looped transformers when the number of repeated processing steps (loops) changes during inference. It shows that a spurious correlation between sequence length and loop count causes high variance on out-of-distribution inputs. The authors replace fixed or heuristic loop counts with a learned stochastic stopping schedule trained alongside the model. This schedule, derived from an RL-halting formulation, balances accuracy and stability, improving performance on tasks like binary addition and Dyck-1. Experiments demonstrate that the learned schedule often yields better accuracy-stability trade-offs than simple randomization.
Problem
Looped Transformers exhibit brittle length generalization because the number of loops used during training correlates with sequence length, leading to high variance when the loop count differs at inference.
Method
The approach introduces stochasticity into the number of loops during training, learning a schedule for when to stop looping (RL-Halting) rather than using fixed or heuristic randomization. This learned schedule is trained to balance accuracy and stability across varying loop counts, reducing OOD variance.
Results
The approach generally improves the accuracy-stability trade-off on the tested tasks, though it may also stabilize a suboptimal computation.
Contributions
The paper identifies the spurious length-loop correlation as a source of OOD variance and proposes a learned stochastic stopping schedule trained at the same time as the model to control loop counts. This provides a principled alternative to heuristic randomization and demonstrates improved stability-accuracy trade-offs on algorithmic tasks.
This page was written by language models from the title and abstract of each paper, and the answers were checked by two other models. It can be wrong: check the paper itself. Suggest a correction