Prefix Sliding for efficient test-time scaling

2026-08-26Computation and Language

Computation and LanguageArtificial IntelligenceMachine Learning
AI summary

The authors study a way to help language models think longer without slowing down too much. They notice that many parts of the model's thinking process become less important over time, so keeping all of it in memory is wasteful. They introduce Prefix Sliding, which keeps important instructions at the start and only the most recent thoughts, while discarding older, less useful parts. This technique makes models much faster without losing accuracy and can even improve performance when combined with training. Their method works better than similar approaches like summarizing or just sliding windows.

test-time scalinglanguage modelsreasoning tracefull attentionprefix tokenssliding windowreinforcement learningmemory efficiencytoken importancemodel inference speed
Authors
Niklas Muennighoff, Zhengyang Wang, Zeyi Chen, Weijia Shi, Binyuan Hui, John Yang, Dapeng Jiang, Mika Senghaas, Fares Obeid, Johannes Hagemann, Sami Jaghouar, Ludwig Schmidt, Percy Liang, Jason Wei, Andrew Y. Ng, Luke Zettlemoyer, Yejin Choi, Mike Lewis
Abstract
Test-time scaling uses extra test-time compute to improve performance, such as letting language models reason longer when solving a problem. As models keep the entire reasoning trace in memory via full attention, hard tasks that need long thinking can be prohibitively expensive. However, we find most intermediate reasoning tokens lose importance as the model continues reasoning. This calls into question whether retaining them is worth the cost. Based on this insight, we propose Prefix Sliding, which discards tokens during reasoning that are not part of the prefix or the window of the last few thousand tokens. The prefix has key instructions and tools available to the model, while the most recent tokens are the current reasoning the model is working on. This caps the total memory requirement regardless of how long the model reasons, allowing for efficient long-horizon test-time scaling. Without training, Prefix Sliding can make existing models 3x faster while maintaining performance. Training with Prefix Sliding using reinforcement learning can achieve better performance by enabling scaling to reasoning traces beyond a hundred thousand tokens. Ablations show Prefix Sliding outperforms summarizing intermediate tokens or vanilla sliding window. Our code is at https://github.com/Muennighoff/prefix-sliding