Architecture-Aware Reinforcement Learning Makes Sliding-Window Attention Competitive in Math Reasoning

Kai Liu, Peijie Dong, Xinchen Xie, Jianfei Gao, Qipeng Guo, Xiaowen Chu, Shaoting Zhang, Kai ChenarXiv 2026

TL;DR

Sliding-Window Attention (SWA) offers a highly efficient, linear-complexity alternative to standard vanilla Self-Attention (SA), but it traditionally struggles with complex, long-generation tasks like mathematical reasoning. This paper introduces SWARR, a two-stage framework that uses on-policy Reinforcement Learning (RL) to bridge this performance gap. By forcing the model to optimize trajectories under its own architectural constraints, RL teaches SWA models to reason more "locally," recovering almost all the accuracy lost during conversion while delivering up to a 6.2× throughput speedup.

What Problem Does This Paper Address?

As large language models (LLMs) scale up their reasoning capabilities through extended chain-of-thought (CoT) generation, inference efficiency becomes a massive bottleneck. Standard Self-Attention (SA) scales quadratically ($O(N^2)$) with context length, making long generations computationally expensive and memory-intensive.

To fix this, researchers often turn to linear-complexity alternatives like Sliding-Window Attention (SWA), which restricts each token to only attend to a local neighborhood. However, SWA models historically underperform SA on multi-step mathematical reasoning.

The authors identify a subtle culprit behind this failure: data-architecture mismatch. Standard Supervised Fine-Tuning (SFT) datasets are architecture-agnostic and typically generated by SA models. Consequently, they contain long-range token dependencies that an SWA model simply cannot replicate due to its restricted window. When forced to copy these trajectories during SFT, SWA performance plummets.

Methods

The authors propose SWARR (Sliding-Window Attention with Reinforced Adaptation for Math Reasoning), a practical two-stage recipe to adapt SWA models to long-generation tasks without costly pretraining from scratch:

  1. Efficient SA-to-SWA Conversion & SFT: They initialize an SWA model directly from a pretrained SA model (reusing the QKV projections) and replace global attention with a local sliding window. They then apply standard SFT on math reasoning data to help the model recover from the structural shock.
  2. Architecture-Aware Reinforcement Learning: To fix the data-architecture mismatch, they apply on-policy RL using the CISPO objective. Because on-policy RL optimizes trajectories generated by the model under its own architectural constraints, it acts as an architecture-aware adapter. The model naturally learns to discover and reinforce successful reasoning paths that rely on local context rather than long-range dependencies.
Figure 1: Overview of the SWARR pipeline. Stage 1: Efficient conversion with architecture-agnostic SFT, avoiding costly pretraining. Because current SFT data are mainly collected for SA models, they may contain long-range dependencies that are difficult for SWA to model. Stage 2: RL policy adaptation under the SWA constraint, which may mitigate the resulting data-architecture mismatch.

To quantify this behavior, the authors also introduce mathematical metrics to measure the locality of generation, tracking how much predictive information remains within a fixed local window.

Datasets

  • Training:
  • SFT Stage: A 42-billion-token math-heavy dataset.
  • RL Stage: AceReason-Math (49k samples).
  • Ablation: GSM8k was used to validate RL stabilization techniques.
  • Evaluation:
  • Core math benchmarks: AMC, MATH500, OlympiadBench, AIME24, and AIME25.
  • Long-context benchmarks (for cross-domain analysis): LongBench and Needle-in-the-Haystack tasks.

Key Insights and Ideas

  • RL as an Architectural Adapter: Unlike SFT, which rigidly forces a model to mimic data it might not have the architecture to support, on-policy RL allows the model to adapt its generation style to its hardware constraints.
  • "Locality of Thought" at the Token Level: The authors show that effective mathematical reasoning does not strictly require unrestricted long-range token attention. SWA models adapt to smaller windows by generating shorter trajectories and structurally modifying how they think.
  • The Repetition Strategy: Qualitative analysis revealed that SWA models learn to frequently restate the final problem constraints during intermediate reasoning steps (e.g., repeating "and then add 7898"). This keeps crucial information active within their local attention window, compensating for their lack of long-term memory.

Key Results

The experiments were conducted using Qwen2.5-Math-1.5B-Base as the baseline.

  • Closing the Accuracy Gap: After the initial SFT stage, SWA models lagged significantly behind SA (SWA8k was 6.1 points behind SA-SFT). However, after RL training, SWA8k came within 0.4 points of SA under equal-step training.
  • Training Efficiency: Because SWA rollouts are computationally cheaper, SWA models can complete significantly more RL training steps than SA within the same time budget. Under an equal-time training budget, SWA4k actually matched or slightly exceeded SA performance.
Figure 2: RL training curves for SA and SWA models. Panel (left) reports accuracy as a function of RL steps, while panel (right) reports accuracy as a function of actual training time, highlighting the efficiency advantage of SWA.
  • Massive Throughput Gains: At a 32k context length, SWA4k achieved an approximate 6.2× throughput speedup over SA and maintained a stable maximum batch size under strict memory constraints (65GB), whereas SA's maximum batch size dropped by a factor of 8.
Figure 3: Efficiency comparison of SA and SWA4k. (a) Throughput as a function of context length. (b) Maximum batch size supported under a 65GB memory constraint. (c) Throughput as a function of batch size, where larger batch size leads to higher kernel efficiency. (d) Throughput with the maximum supported batch size, showing that SWA4k achieves an approximately 6.2× speedup over SA at 32k context length.

Limitations and Future Work

  • Domain Specificity: The SWARR recipe was explicitly optimized for short-input, long-generation tasks like math. On long-context understanding tasks (long input, short output), SWA still severely underperforms SA unless paired with external agentic frameworks like SmoothReading.
  • Scale Constraints: The empirical validation was limited to 1.5B and 4B parameter models. The authors note that verifying whether these quantitative trends hold at massive commercial scales (e.g., 200B+ parameters) remains future work.

Summary updated

BibTeX
@misc{liu2026architecture,
  author = {Kai Liu and Peijie Dong and Xinchen Xie and Jianfei Gao and Qipeng Guo and Xiaowen Chu and Shaoting Zhang and Kai Chen},
  title = {{Architecture-Aware Reinforcement Learning Makes Sliding-Window Attention Competitive in Math Reasoning}},
  year = {2026},
  eprint = {2606.11634},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2606.11634},
}
Figure