Use a CPU suffix-automaton to recall distant tokens and let windowed attention match global-attention quality

January 14, 20268 min

Overview

Decision SnapshotNeeds Validation

The method is practical: retrieval runs on CPUs and is overlapped with GPU attention to keep latency and GPU memory low. Experiments on Qwen3-Base-1.7B and multiple benchmarks support claims, but training was not to full convergence and results depend on CPU/GPU balance.

Citations0

Evidence Strength0.80

Confidence0.85

Risk Signals11

Trust Signals

Findings with numeric evidence: 4/4

Findings with evidence refs: 4/4

Results with explicit delta: 5/5

Reproducibility

Status: Code + data available

Open source: Partial

At A Glance

Cost impact: 60%

Production readiness: 60%

Novelty: 70%

Authors

Yunao Zheng, Xiaojie Wang, Lei Ren, Wei Chen

Links

Abstract / PDF / Code / Data

Why It Matters For Business

ROSA lets teams support very long inputs (documents, multi-turn chat history) with near-global-attention accuracy while avoiding large GPU memory and compute increases, lowering inference cost for long-context applications.

Who Should Care

Summary TLDR

ROSA-Tuning adds a cheap CPU-side retrieval module (ROSA: suffix automata over binarized hidden bits) that finds relevant past positions and injects their values into a pretrained model. On Qwen3-Base-1.7B, this restores most long-context ability of windowed-attention models (close to global attention on LongBench and MQAR) while keeping GPU compute and memory similar to sliding-window attention by running retrieval on CPU and using an async CPU–GPU pipeline.

Problem Statement

Windowed and other efficient attention schemes cut GPU cost but often miss important past tokens because the model state does not cover all relevant history. Global attention recovers those tokens but costs O(T^2) compute and high GPU memory. The paper seeks a low-cost way to recall specific historical positions and feed them into the model without expanding GPU attention state.

Main Contribution

ROSA-Tuning: a retrieval-and-recall pathway using many small suffix automata (SAMs) over binarized per-route symbols to locate relevant past positions and inject their values into the model.

A binary discretization and counterfactual-gradient training method to backpropagate through discrete retrieval decisions.

Key Findings

ROSA largely recovers long-context accuracy lost by windowed attention.

NumbersLongBench AVG: Global 59.21; Window 29.41; Window+ROSA 57.14

Practical UseAdd ROSA to a windowed-attention model to regain most global-attention performance on long-context tasks while keeping windowed efficiency.

Evidence RefTable 2

General capabilities remain effectively unchanged after ROSA-Tuning.

Numberslm-eval AVG: Global 0.71; Window+ROSA 0.705

Practical UseYou can enable ROSA without harming broad language understanding and commonsense performance.

Evidence RefTable 1

Results

MetricValueBaselineDeltaSplit / DatasetEvidenceEvidence Ref
LongBench AVG (higher is better)57.14 (Window+ROSA) vs 59.21 (Global) vs 29.41 (Window)Global-Attn and Window-AttnWindow+ROSA nearly matches Global (+ -2.07) and greatly outperforms Window (+27.73)LongBench (multi-task long-context)Table 2: per-task scores and averagesTable 2
lm-eval average (higher is better)0.705 (Window+ROSA) vs 0.71 (Global)Global-Attn−0.005lm-eval-harness subsetTable 1 shows minor fluctuations after ROSA-TuningTable 1

What To Try In 7 Days

Run the ROSA repo on a windowed-attention Qwen3 checkpoint and reproduce LongBench or a target long-input task.

Benchmark end-to-end latency and GPU memory with post-attn (async) pipeline to measure hidden CPU overhead.

Compare post-attn (async) vs pre-attn quality on a small validation set to trade throughput for best quality.

Optimization Features

Token Efficiency
binary discretization of hidden featuresrun-length encoding (RLE) to fold repeated symbols
Infra Optimization
keeps GPU memory like windowed attention (states on CPU)
System Optimization
per-route independent retrieval to scale across CPU cores
Training Optimization
counterfactual gradient through discrete retrievaladapter warm-up then full fine-tuning
Inference Optimization
CPU-side parallel SAM retrievalasynchronous CPU–GPU pipeline to overlap retrieval with attention

Reproducibility

Code AvailableYes
Data AvailableYes
Open Source StatusPartial
LicenseUnknown

Data URLs

LongBench (Bai et al., 2024)MQAR (Arora et al., 2023)PG19 (Rae et al., 2019)lm-eval-harness (Biderman et al., 2024)

Risks & Boundaries

Limitations

Authors did not train to full convergence; reported gains are on the presented checkpoints only.

Throughput and end-to-end latency depend on CPU cores, memory bandwidth, and implementation details.

When Not To Use

When your deployment has no spare CPU cores or cannot tolerate any CPU–GPU transfers.

When you already run global attention and can afford its GPU cost for your sequence lengths.

Failure Modes

Retrieval returns no valid destination (τ = -1) and yields zero injection for that route.

Symbol collisions or poor discretization can cause spurious matches and wrong recall.

Core Entities

Models

Qwen3-Base-1.7BQwen3-0.6B (ablation)

Metrics

LongBench AVGlm-eval AVGAccuracyPerplexity (PPL)

Datasets

LongBenchMQARPG19lm-eval-harness

Benchmarks

LongBenchMQARlm-eval-harness