Manuscript Offprint

arXiv:2610.25621

Weighted State Souping for Efficient Long-Context Retrieval

William L. Tong, Aryo Lotfi, Emmanuel Abbe, Josh Susskind, Cengiz Pehlevan, Eran Malach

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

William L. Tong 2,∗^{2,*}, Aryo Lotfi 1^{1}, Emmanuel Abbe 1^{1}, Josh Susskind 1^{1}, Cengiz Pehlevan 2^{2}, Eran Malach 1^{1}

1^{1}Apple, 2^{2}Harvard University

*Work done while at Apple

State space models (SSMs) combine fast inference and fixed state size with competitive language-modeling performance. Recently, state souping has been proposed as a procedure whereby an SSM independently encodes chunks of tokens like documents, tool definitions, or memory records. The resulting state encodings may be cached and recombined to cheaply construct a context for downstream queries. However, both state souping and vanilla SSMs deteriorate on long, crowded contexts, limiting their utility for long-horizon domains. To address this issue, we propose weighted state souping, a simple method that learns query-dependent weights for composing cached states. The resulting models improve long-context performance substantially across both single- and multi-hop document question answering, needle-in-a-haystack retrieval, variable tracking, and tool use. Our method can be further adapted into an efficient sparse variant, yielding near-constant encoding cost with respect to context length while preserving (and sometimes improving) performance. We also present simple theoretical arguments that illustrate why souping works and when it may fail, and discuss informally the advantages of weighted souping. Weighted state souping thus combines reusable context representations with selective retrieval, offering an efficient approach to language modeling over large collections of documents, tools, and other forms of structured context that increasingly dominate modern agentic workloads.

Correspondence: William L. Tong: wtong@g.harvard.edu; Eran Malach: e_malach@apple.com

Date: October 18, 2026

1 Introduction

Many applications of large language models (LLMs) require long-lived context organized into discrete chunks of tokens: tool definitions for an agent (Schick et al., 2023; Patil et al., 2025), documents for question answering or retrieval-augmented generation (Rajpurkar et al., 2016; Yang et al., 2018; Trivedi et al., 2022; Lewis et al., 2020; Guu et al., 2020), and memory records or chat histories that persist across interactions (Packer et al., 2023; Wu et al., 2024; Salemi et al., 2024). A useful memory architecture must retrieve relevant chunks from an increasingly crowded store without repeatedly processing the entire history.

In these settings, common practice concatenates the chunks of tokens and processes them as a single flat sequence. With the rising popularity of state space models (SSMs) and related fixed-state architectures (Gu & Dao, 2024; Dao & Gu, 2024; Katharopoulos et al., 2020; Schlag et al., 2021; Sun et al., 2024), an alternative approach becomes possible. Rather than perform a single autoregressive pass on a concatenated sequence, each chunk can be independently encoded into a state. The resulting collection of states are then pointwise summed to initialize the model before it processes a query (Figure 1). By analogy to model souping (Wortsman et al., 2022), this procedure is called state souping (Pióro et al., 2024; Jafari et al., 2025; Liu et al., 2025): the quantities combined are input-dependent recurrent states, rather than model parameters.

State souping has an obvious efficiency advantage. State encodings can be computed in parallel and, for slowly changing chunks like memory records or tool definitions, cached and reused. This ability to cache representations makes souping naturally suited for handling the structured context that increasingly dominates modern agentic workloads: inference can depend on selected state encodings without repopulating the context with large memory artifacts, tool definitions, and documents. However, finite-state SSMs struggle to copy or retrieve from long contexts (Jelassi et al., 2024; Waleffe et al., 2024; Arora et al., 2024), and state souping performance similarly decays as more documents are added (Jafari et al., 2025). This loss of selectivity limits souping precisely where persistent memory is most useful.

In this work, we introduce weighted state souping, which learns attention-like weights over state encodings. Across document QA, needle-in-a-haystack retrieval, variable tracking, and tool use, weighting substantially improves robustness as contexts grow beyond training lengths. Our method can be further adapted into a sparse variant that permits near-constant encoding cost while preserving — and sometimes improving — performance. Our main contributions are:

  • a novel weighted state souping procedure that permits robust selectivity, strong generalization on long contexts, and substantial efficiency gains over both Transformers and traditional SSMs,

  • a comprehensive evaluation over diverse benchmarks including multi-document question answering, needle-in-a-haystack retrieval, variable tracking, and agentic tool use,

  • a simple theoretical account of how souping successfully retrieves and composes across chunks, and its potential weaknesses compared against sequential models. We also discuss informally the advantages of weighted state souping.

References (70)