Sequential Parallel Duality in Prefix Scannable Models

Morris Yau, Sharut Gupta, Valerie Engelmayer, Kazuki Irie, Stefanie Jegelka, Jacob Andreas

Abstract This paper introduces Prefix-Scannable Models (PSMs), a theoretical framework that unifies modern sequence models like Mamba, Linear Transformers, and standard Transformers. By generalizing the classic parallel prefix scan algorithm to handle non-associative operators (like softmax attention), the authors create models that enjoy the best of both worlds: parallelizable training and fast, $O(\log N)$ memory sequential inference.

Introduction: The Dual Mandate of Sequence Modeling

In the world of AI sequence modeling, architectures face a "dual mandate": they must be parallelizable during training to utilize GPUs effectively (like Transformers), but also efficient during inference with constant-time updates and low memory overhead (like RNNs).

Standard Transformers excel at training but suffer from quadratic complexity during inference, as their "KV cache" grows linearly with sequence length. Conversely, State Space Models (SSMs) like Mamba are fast at inference but can struggle with complex tasks requiring precise state tracking or associative recall.

This raises a fundamental question: What is the full class of models that satisfy this "sequential-parallel duality" (SPD)? Can we build a model that trains like a Transformer but generates text with the efficiency of an RNN?

Methods: Prefix-Scannable Models (PSMs)

To bridge this gap, the researchers identify the Blelloch Scan—a classic parallel algorithm—as the unifying mechanism.

The Associative Case: Models like Mamba, Gated Linear Attention (GLA), and Linear Transformers are essentially "Affine Scans." Their state updates rely on associative operations (like addition or matrix multiplication), allowing them to be computed in $O(\log N)$ parallel depth.

The Non-Associative Breakthrough: The core innovation of PSMs is relaxing the strict requirement for associativity. Traditionally, prefix scans require $(a + b) + c = a + (b + c)$. The authors demonstrate that by fixing the tree structure of the computation (the Blelloch parenthesization), non-associative operators—such as standard softmax attention—can be seamlessly integrated into the scan.

Upsweep and Downsweep phases of the prefix scan algorithm

Transformer-PSM: Instantiating this theory, the authors built a model using Transformer blocks as the "aggregation" and "inference" modules within a chunked prefix-scan structure. This allows the model to use local attention over chunks while maintaining a global state that updates via the scan tree.

Key Insights and Theoretical Advantages

  • The Tree is the Key: Committing to a fixed binary tree for computations ensures that parallel training results exactly match sequential inference results, even with non-associative math.
  • Logarithmic Memory Scaling: While standard RNNs use $O(1)$ memory, PSMs with non-associative operators use $O(\log N)$ memory. This is a massive improvement over the $O(N)$ memory required by standard Transformers, making long-context generation highly feasible.
  • A Unified Framework: The PSM framework acts as a "periodic table" for sequence models, revealing that Mamba and Linear Transformers are specific, associative instances of a much broader class of scannable models.

Experimental Evaluation

The framework was evaluated across synthetic and real-world tasks:

  • Synthetic State Tracking ($S_5$): A permutation task testing the ability to track complex internal states. The Transformer-PSM (T-PSM) generalized to sequences of 160+ tokens after training on only 18 tokens, significantly outperforming GPT-2 and Mamba.
  • Multi-Query Associative Recall (MQAR): T-PSM achieved perfect accuracy, matching Transformers, whereas Mamba's performance degraded as sequence length increased.
  • Language Modeling (WikiText-103): T-PSM maintained nearly constant inference time per token as sequences grew to 40,000 tokens. In contrast, standard GPT-2 inference time grew linearly, becoming roughly 5x slower. Furthermore, as chunk sizes in T-PSM decrease to save compute, perplexity increases only slightly, offering a flexible accuracy-speed trade-off.

Limitations and Future Work

While theoretically sound, the experiments were conducted on relatively small models and datasets. Scaling the Transformer-PSM to billions of parameters remains an open challenge. Additionally, to fully realize the $O(\log N)$ memory benefits in practice, custom CUDA kernels for the non-associative Blelloch scan must be developed and optimized for modern hardware. Finally, model performance is sensitive to chunk size, requiring careful tuning based on the specific task.

Summary updated

BibTeX
@inproceedings{yau2026sequential,
  author = {Morris Yau and Sharut Gupta and Valerie Engelmayer and Kazuki Irie and Stefanie Jegelka and Jacob Andreas},
  title = {{Sequential Parallel Duality in Prefix Scannable Models}},
  booktitle = {International Conference on Learning Representations},
  year = {2026},
  url = {https://openreview.net/forum?id=tuLF84azND},
}
Figure