SepSeq: A Training-Free Framework for Long Numerical Sequence Processing in LLMs
Authors: Jie Sun, Yu Liu, Lu Han, Qiwen Deng, Xiang Shu, Yang Xiao, Xingyu Lu, Jun Zhou, Pengfei Liu, Lintao Ma, Jiancan Wu, Xiang Wang
Organizations: University of Science and Technology of China · Shanghai Innovation Institute · Nanjing University · University of Edinburgh · East China Normal University · Hong Kong Polytechnic University · Zhejiang University · Ocean University of China
While transformer-based Large Language Models (LLMs) theoretically support massive context windows, they suffer from severe performance degradation when processing long numerical sequences. We attribute this failure to the attention dispersion in the Softmax mechanism, which prevents the model from concentrating attention. To overcome this, we propose Separate Sequence (SepSeq), a training-free, plug-and-play framework to mitigate dispersion by strategically inserting separator tokens. Mechanistically, we demonstrate that separator tokens act as an attention sink, recalibrating attention to focus on local segments while preserving global context. Extensive evaluations on 9 widely-adopted LLMs confirm the effectiveness of our approach: SepSeq yields an average relative accuracy improvement of 35.6% across diverse domains while reducing total inference token consumption by 16.4% on average.
Figures & tables
Figure 1: (A) Average accuracy across six synthetic tasks, performance drops sharply with increasing numerical sequence length (S: 2–32, M: 33–128, L: 129–256, XL: 257–512), while SepSeq remains largely unaffected. (B) visualize the attention scores given the input: “… How many 1’s in [0 1 0 1 0 1 0 0 0] …”. (C) show the attention scores for the input with segmentation: “… How many 1’s in [0 1 0 1\n0 1 0 0\n0] …”. (B) exhibits dispersed attention across the entire sequence while (C) demonstrates segment-focused attention.
Figure 2: Visualization of the Separator Attention effect. (A-B) The separator τsep serves as a prominent attention sink, demonstrating consistently higher attention scores than τsp across both (A) model layers and (B) attention heads. (C) This concentrated attention on τsep results in a substantial reduction of cross-segment attention weights, thereby localizing the attention scope relative to the vanilla τsp .
Task
Answer Rate (%, ↑ )
Accuracy (%, ↑ )
Vanilla
CoT
ICL
SepSeq (Incr.)
Vanilla
CoT
ICL
SepSeq (Incr.)
counting
100.0 ± 0.0
100.0 ± 0.0
100.0 ± 0.0
100.0 ± 0.0 ( 0 +0.0%)
42.7 ± 2.7
41.2 ± 3.0
37.9 ± 3.2
76.7 ± 1.2 ( 0 +79.6% )
indexing
100.0 ± 0.0
100.0 ± 0.0
100.0 ± 0.0
100.0 ± 0.0 ( 0 +0.0%)
38.8 ± 3.1
33.4 ± 3.4
34.9 ± 2.9
86.6 ± 0.8 ( +123.0% )
max-float
100.0 ± 0.0
100.0 ± 0.0
100.0 ± 0.0
100.0 ± 0.0 ( 0 +0.0%)
63.9 ± 1.9
60.5 ± 2.1
63.3 ± 1.7
81.0 ± 1.1 ( 0 +26.8% )
max-int
100.0 ± 0.0
100.0 ± 0.0
100.0 ± 0.0
100.0 ± 0.0 ( 0 +0.0%)
75.3 ± 1.1
68.8 ± 1.7
71.0 ± 1.4
92.4 ± 0.4 ( 0 +22.7% )
min-float
100.0 ± 0.0
100.0 ± 0.0
100.0 ± 0.0
100.0 ± 0.0 ( 0 +0.0%)
63.1 ± 1.7
60.2 ± 2.2
60.4 ± 1.9
79.3 ± 1.0 ( 0 +25.7% )
Table 1: The average answer rate and accuracy for each task over 10 independent runs, reported as mean ± standard deviation. Bold indicates the best average performance, while underlined values denote the best average performance excluding our method. “Incr.” indicates the percentage improvement of SepSeq over the strongest non-SepSeq baseline. Green and red indicate improvement and degradation in performance, respectively.
Model
Answer Rate (%, ↑ )
Accuracy (%, ↑ )
Vanilla
CoT
ICL
SepSeq (Incr.)
Vanilla
CoT
ICL
SepSeq (Incr.)
Qwen3-8B
0 79.4 ± 1.1
0 79.5 ± 0.9
0 75.2 ± 1.3
0 87.3 ± 0.6 ( 0 +9.8% )
45.5 ± 2.8
40.3 ± 2.9
38.5 ± 3.2
69.6 ± 1.6 ( +53.0% )
Qwen3-30B-A3B
0 80.6 ± 0.9
0 80.9 ± 1.1
0 81.0 ± 0.8
0 90.2 ± 0.5 ( +11.4% )
54.3 ± 2.4
52.7 ± 2.2
52.3 ± 2.5
80.7 ± 1.1 ( +48.6% )
QwQ-32B
0 72.7 ± 1.5
0 72.2 ± 1.3
0 72.7 ± 1.2
0 75.6 ± 1.1 ( 0 +4.0% )
34.2 ± 3.4
28.9 ± 3.7
28.5 ± 3.5
57.8 ± 2.0 ( +69.0% )
DeepSeek-V3
100.0 ± 0.0
100.0 ± 0.0
100.0 ± 0.0
100.0 ± 0.0 ( 0 +0.0%)
45.7 ± 2.6
44.5 ± 2.9
45.2 ± 2.7
50.9 ± 2.5 ( +11.4% )
DeepSeek-R1
0 99.9 ± 0.1
0 99.9 ± 0.0
0 99.8 ± 0.1
0 99.9 ± 0.0 ( 0 +0.0%)
61.1 ± 1.8
56.6 ± 2.3
57.9 ± 2.0
70.5 ± 1.4 ( +15.4% )
Table 2: The average answer rate and accuracy of each model across 10 tasks, computed over 10 independent runs and reported as mean ± standard deviation. Bold indicates the best average performance, while underlined values denote the best average performance excluding our method. “Incr.” indicates the percentage improvement of SepSeq over the strongest non-SepSeq baseline. Green and red indicate improvement and degradation in performance, respectively.
Figure 3: (A): Average Accuracy across different separate intervals. (B): Average Accuracy across different separator symbols. (C): Average Answer Rate and Accuracy across different Qwen3 model sizes: 0.6B to 14B.
Figure 4: Comparison between Vanilla and SepSeq across tasks. The left panel shows that SepSeq significantly reduces token consumption during inference (average -16.4%).
Prompting
Input Formatting
Standard
SepSeq
Vanilla
53.25
70.35
PoT
78.90
84.45
Table 3: Average results for PoT across 10 tasks (200 samples/task).
Appendix figures & tables2 assets
Supplementary material from the paper’s appendix.
Appendix
Size
Total
Qwen3-30B-A3B-Instruct Model
Qwen3-30B-A3B-Thinking-2507
# Correct
Accuracy
# Correct
Accuracy
S: 2-32
50
50
100.00%
50
100.00%
M: 33-128
50
50
100.00%
36
72.00%
L: 129-256
50
50
100.00%
16
32.00%
XL: 257-512
50
7
14.00%
0
0.00%
XXL: 513-1024
50
0
0.00%
0
0.00%
Appendix
Table 4: Performance of Qwen3-30B-A3B-Instruct-2507 and Qwen3-30B-A3B-Thinking-2507 on the strict numerical sequence repetition task. The table shows the number of correct reproductions and accuracy for each sequence length range.
Task Type
Question Only (Tokens)
Full Prompt (Tokens)
#Samples
Min
25%
50%
Mean
75%
Max
Min
25%
50%
Mean
75%
Max
max_int
56
56
56
56.0
56
56
88
153
341
411.9
594
1070
200
min_int
56
56
56
56.0
56
56
88
149
341
410.3
594
1104
200
max_float
56
56
56
56.0
56
56
106
318
957
1252.8
1867
3613
200
min_float
56
56
56
56.0
56
56
99
334
968
1232.3
1869
3562
200
counting
24
24
24
24.0
24
24
56
117
309
392.9
565
1076
200
Appendix
Table 5: Comprehensive Token Length Statistics. Comparison between Question Only and Full Prompt across six statistical dimensions: Minimum, Quartiles (25%, 50%, 75%), Mean, and Maximum. All tasks consist of 200 samples.
Large-language-models (LLMs) demonstrate enormous utility in long-context tasks which require processing prompts that consist of tens to hundreds of thousands of tokens. However, existing LLM training libraries do not provide easy to use abstractions to optimize for long-context training, instead focusing on optimizations for models with large parameter counts through ZeRO-3/FSDP, Tensor and Pipeline parallelism. This forces users to rewrite LLM training libraries to incorporate compositions of various complex long-context optimizations, such as sequence-parallelism, to training pipelines; a process that requires in-depth expertise, reducing developer productivity. To tackle these challenges, we introduce AutoSP: the first automated solution to automatically optimize LLM training for longer-contexts. AutoSP compiles models and applies a targeted set of optimizations: automated sequence parallelism, and long-context aware activation-checkpointing, to drastically enhance LLM trainability at negligible cost to throughput. Our evaluation demonstrates AutoSP's capability on both NVIDIA and AMD hardware, increasing training contexts by upto 2.7× and 2.5× respectively over competitive hand-written baseline at negligible cost to runtime performance.
Ahan Gupta, Zhihao Wang, Neel Dani +3
SSAIL Lab, University of Illinois Urbana-Champaign Champaign, IL, USA · Anyscale San Francisco, CA, USA · Snowflake San Mateo, CA, USA
Transformer-based large language models face severe scalability challenges in long-context generation due to the computational and memory costs of full-context attention. Under practical computation and memory constraints, many inference-efficient long-context methods improve efficiency by adopting bounded-context or segment-level execution only during inference, while continuing to train models under full-context attention, resulting in a mismatch between training and inference execution and state-transition semantics. Based on this insight, we propose a training-inference consistent segment-level generation framework, in which training and inference follow the same segment-level forward execution semantics. During training, consistency with inference is enforced by restricting gradient propagation to KV states carried over from the immediately preceding segment, while permitting head-specific access to past KV states during the forward pass without involving them in gradient propagation. Across long-context benchmarks, our approach achieves performance comparable to full-context attention, while achieving competitive latency-memory trade-offs against strong inference-efficient baselines, and substantially improving scalability at very long context lengths (e.g., approximately 6x lower peak prefill memory at 128K compared to full-context attention with FlashAttention).
Xianpeng Shang, Jiang Li, Zehua Duo +2
College of Computer Science, Inner Mongolia University, Hohhot 010021, China · National & Local Joint Engineering Research Center of Intelligent Information Processing Technology for Mongolian, Hohhot 010021, China · Inner Mongolia Key Laboratory of Multilingual Artificial Intelligence Technology, Hohhot 010021, China +1
Long-context inference enhances the reasoning capability of Large Language Models (LLMs), but incurs significant computational overhead. Token-oriented methods, such as pruning and skipping, have shown great promise in reducing inference latency, yet still suffer from inherently insufficient structure optimization, outdated selection criteria, and redundancy interference, resulting in suboptimal speed-accuracy trade-off. To address these issues, we propose a novel training-free framework dubbed Self-Predictive Token Skipping (SPTS), for efficient long-context LLM inference. Specifically, motivated by probing the influence of target layers prior to skipping, we design two selective token skipping strategies for typical structures, including Partial Attention Probing (PAP) for multi-head attention and Low-rank Transformation Probing (LTP) for feed forward network. The former selects informative tokens via partial forward attention computation, while the latter constructs a low-rank proxy network to predict token transformations. In addition, a Multi-Stage Delayed Pruning (MSDP) strategy reallocates skipping budgets and progressively removes redundant tokens across layers. Extensive experiments display the effectiveness of our method, achieving up to 2.46× and 2.29× speedups for prefilling and end-to-end generation, respectively, while maintaining state-of-the-art accuracy. The source code is available at https://github.com/Wuzimeng/SPTS.
Zimeng Wu, Donghao Wang, Chaozhe Jin +2
School of Computer Science and Engineering, Beihang University, Beijing, China · State Key Laboratory of Virtual Reality Technology and Systems, Beihang University, Beijing, China