arXiv(opens in a new tab)cs.CLAug 2026Cited by 2 papers on PaperVantage

Manuscript Offprint

arXiv:2608.26070

Prefix Sliding for efficient test-time scaling

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

Niklas Muennighoff s^{s} Zhengyang Wang c^{c} Zeyi Chen w^{w} Weijia Shi w^{w} Binyuan Hui John Yang s^{s} Dapeng Jiang w^{w} Mika Senghaas p^{p} Fares Obeid p^{p} Johannes Hagemann p^{p} Sami Jaghouar p^{p} Ludwig Schmidt s^{s} Percy Liang s^{s} Jason Wei Andrew Y. Ng s^{s} Luke Zettlemoyer w^{w} Yejin Choi s^{s} Mike Lewis w^{w}

s^{s}Stanford University c^{c}University of California at Santa Barbara p^{p}Prime Intellect

w^{w}University of Washington

n.muennighoff@gmail.com

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

Figure

Figure 1: Prefix Sliding without any training is more efficient than full attention. Prefix Sliding performs better as it can generate more tokens in the same thinking time than full attention, not because each token it generates is better. Both use the same Qwen3 model (section 3). Here, Prefix Sliding uses a window size of 4096; see Appendix B for other sizes, and Appendix C for the results in tabular form.

Figure

Figure 2: The first and last few tokens receive most attention during reasoning with full attention. We plot post-softmax attention probabilities averaged across layers and attention heads in Qwen3-1.7B for an AIME25 reasoning trace. Probabilities are Gaussian smoothed.

1 Introduction

Test-time scaling improves the performance of language models by using extra compute for hard problems (OpenAI, 2024). Commonly, this compute is used by letting the model reason longer (DeepSeek-AI et al., 2025a; Muennighoff et al., 2025). However, scaling this approach further is limited by the need to keep the entire reasoning trace in memory via full attention, as used in most language models (Sadhukhan et al., 2025). With full attention, the cost of each new token grows linearly with the number of already generated tokens, making long context windows prohibitively expensive. Long contexts have more issues, including distraction by old irrelevant tokens (Gema et al., 2025), context poisoning (Comanici et al., 2025), repetitive loops (Pipis et al., 2025), and lost knowledge (Liu et al., 2023b).

We explore a simple solution based on two observations. First, intermediate reasoning tokens quickly lose importance. For example, when solving an expression like “ (42+84)×4(42 + 84) \times 4 - 5”, once the addition 42+8442 + 84 is completed, the reasoning behind that step is no longer needed; only the result matters for the next operation. Second, the prefix and the most recent reasoning tokens, however, are of high importance during generation. The prefix, which includes the system instruction and prompt, contains key information about tools the model can use and the task to complete. It also serves as an “attention sink” allowing the model to allocate excess probability weight (Xiao et al., 2024c). Meanwhile, the most recent reasoning tokens capture what the model is currently working on. This has motivated prior work on letting models generate using a sliding window (Ainslie et al., 2020; Gupta & Berant, 2020; Beltagy et al., 2020; Zaheer et al., 2021; Zhang et al., 2025b; Fu et al., 2025c).

We combine these two observations to propose Prefix Sliding. During reasoning, Prefix Sliding keeps only the prefix and a sliding window in memory. The prefix contains the model instructions. As the model generates, the sliding window advances, removing older intermediate tokens. For example, a 40-token system instruction and a 60-token task prompt could constitute a 100-token prefix. With a 4096-token sliding window, at most 4196 tokens are then kept in memory. The cost of generating an additional token is the same regardless of whether the model has already generated millions or billions of tokens. Such constant cost is necessary to enable very long-horizon test-time scaling.

Empirically, Prefix Sliding can match full-attention performance while running 3×3 \times faster without training, and enables reinforcement learning rollouts beyond 100,000 tokens.

References (100)

Couldn't load all references. Reload the page to try again.