To Infinity and Beyond: Tool-Use Unlocks Length Generalization in State Space Models
Eran Malach (Apple), Omid Saremi (Apple), Sinead Williamson (Apple), Arwen Bradley (Apple), Aryo Lotfi (Apple), Emmanuel Abbe (Apple), Joshua Susskind (Apple), Etai Littwin (Apple)
International Conference on Learning Representations 2026 · Oral
Overview
This talk, "To Infinity and Beyond: Tool-Use Unlocks Length Generalization in State Space Models," presented by Aryo Lotfi and his collaborators at Apple, delves into a critical limitation of modern large language models: their ability to generalize to sequence lengths far beyond what they were trained on. The presentation highlights the inherent challenges faced by both Transformers and State Space Models (SSMs) in handling long-form tasks. While Transformers struggle with quadratic computational complexity, SSMs, despite their linear scaling, are often constrained by a fixed memory capacity, hindering their performance on memory-intensive reasoning tasks.

Key moments
- 0:00 Introduction: SSMs vs. Transformers and memory limits
- 0:40 Key finding: Tool-use unlocks length generalization for SSMs
- 1:47 Theoretical limits and positive results of tool-use
- 2:15 Addition task: SSMs achieve 1000-digit length generalization
- 3:20 Code-fixing agents: A practical, interesting use case
- 4:10 Conclusion: Tool-use enables powerful, efficient SSM agents
- 4:50 Q&A: Recency bias explains SSMs' tool-use advantage
- 6:00 Q&A: Challenges scaling to larger, realistic models
To Infinity and Beyond: Tool-Use Unlocks Length Generalization in State Space Models
Speakers: Eran Malach (Apple), Omid Saremi (Apple), Sinead Williamson (Apple), Arwen Bradley (Apple), Aryo Lotfi (Apple), Emmanuel Abbe (Apple), Joshua Susskind (Apple), Etai Littwin (Apple)
Conference: ICLR 2026
YouTube: https://slideslive.com/39062225
Overview
This talk, "To Infinity and Beyond: Tool-Use Unlocks Length Generalization in State Space Models," presented by Aryo Lotfi and his collaborators at Apple, delves into a critical limitation of modern large language models: their ability to generalize to sequence lengths far beyond what they were trained on. The presentation highlights the inherent challenges faced by both Transformers and State Space Models (SSMs) in handling long-form tasks. While Transformers struggle with quadratic computational complexity, SSMs, despite their linear scaling, are often constrained by a fixed memory capacity, hindering their performance on memory-intensive reasoning tasks.
The core contribution of this work is the demonstration that by integrating tool-use capabilities, SSMs can overcome their memory limitations, achieve remarkable length generalization, and even surpass the performance of Transformers on complex algorithmic and reasoning tasks. The authors propose an agentic setting where SSMs can interact with external "tools" or "oracles," effectively augmenting their internal state with external memory and computational power. This paradigm shift allows SSMs to tackle problems requiring iterative processing and long-term state management, which were previously inaccessible to them.
This research is particularly significant for the future of efficient and scalable AI. As the demand for models capable of processing and generating increasingly long and complex sequences grows, finding alternatives to the computationally expensive Transformer architecture becomes paramount. By showing that SSMs, when properly equipped with tool-use, can achieve superior length generalization at a linear computational cost, this work opens new avenues for developing more efficient and powerful AI agents. It suggests a path toward building truly general-purpose reasoning agents that can leverage specialized tools for specific sub-problems, mirroring human problem-solving strategies.
Background
▶ Watch: Introduction: SSMs vs. Transformers and memory limits (0:00)
The landscape of modern AI, particularly in natural language processing, has been dominated by the Transformer architecture since its introduction. Its key innovation, the attention mechanism, allows the model to weigh the importance of different parts of the input sequence when processing each token, capturing long-range dependencies effectively. However, this power comes at a significant cost: the computational complexity of the attention mechanism scales quadratically with respect to the sequence length ($O(L^2)$), where $L$ is the sequence length. This quadratic scaling makes Transformers prohibitively expensive for very long sequences, both during training and inference, requiring substantial memory and computational resources. Attempts to mitigate this, such as sparse attention or linear attention mechanisms, often introduce trade-offs in terms of representational capacity or architectural complexity.
In response to the quadratic scaling issue, State Space Models (SSMs) have emerged as a promising alternative. Architectures like Mamba and its variants, along with earlier models such as Recurrent Neural Networks (RNNs) and linear Transformers, process sequences by maintaining a fixed-size hidden state that is updated sequentially. This characteristic grants SSMs a linear computational complexity ($O(L)$) with respect to sequence length, making them inherently more efficient for long inputs. However, this efficiency comes with a trade-off: the fixed-size memory of the hidden state limits their capacity to retain and process information over very long durations, especially for tasks requiring extensive memory or complex reasoning that cannot be compressed into a constant-size state. As the talk highlights, without external aid, SSMs "cannot really solve any long-form generation task that is non-trivial," particularly those requiring length generalization, where the model must perform well on inputs much longer than those seen during training. This limitation stems from their inability to "generate infinitely many outputs" or maintain complex, evolving states over extended periods.
The concept of tool-use or agentic AI has gained traction as a powerful paradigm to extend the capabilities of language models. Instead of relying solely on internal parametric knowledge, models equipped with tool-use can interact with external environments, execute code, query databases, or perform arithmetic operations using specialized modules. This approach effectively offloads computationally intensive or memory-bound sub-tasks to external, reliable tools, allowing the core language model to focus on higher-level reasoning and planning. While tool-use has been explored with Transformers to augment their reasoning abilities, its application to SSMs presents a unique opportunity: potentially combining the linear scaling of SSMs with the extended memory and computational power offered by external tools, thereby addressing the fundamental memory bottleneck of SSMs and opening them up to complex, long-form reasoning tasks previously dominated by Transformers or requiring hybrid architectures.
Key Findings
▶ Watch: Theoretical limits and positive results of tool-use (1:47)
The research presented in "To Infinity and Beyond" uncovers several pivotal findings that challenge conventional wisdom regarding the capabilities of State Space Models (SSMs) and their potential for complex reasoning:
- Theoretical Limit of SSMs Without Tool-Use: The authors establish a theoretical limit demonstrating that SSMs, when operating in a standalone, non-agentic setting (i.e., without tool-use), are fundamentally incapable of solving arbitrary long-form generation tasks that require length generalization. The intuition behind this finding is rooted in the inherent memory limit of SSMs, which maintain a fixed-size internal state. This constant memory capacity prevents them from effectively managing and generating "infinitely many outputs" or solving tasks where the complexity grows with the input/output length, such as multi-digit addition or complex algorithmic problems.
- Tool-Use Unlocks Length Generalization for SSMs: Contrasting the theoretical limitation, the talk presents a powerful positive result: if SSMs are empowered with interactive tool-use, they can learn to solve any long-form generation task and achieve length generalization "for free." This breakthrough is contingent upon providing appropriate training data that incorporates suitable chain-of-thought reasoning and tool-use trajectories. By externalizing memory and computation through tools, SSMs can bypass their internal memory bottleneck, effectively gaining access to an "infinite" working memory akin to a Turing machine tape.
- SSMs Outperform Transformers with Tool-Use: Perhaps the most striking empirical finding is that not only do SSMs achieve length generalization with tool-use, but they can also outperform Transformer models in these scenarios. The experiments on tasks like multi-digit addition, multiplication, logical reasoning, and code fixing consistently show SSMs (specifically Mamba and LSTM variants) generalizing to significantly longer sequences (e.g., from 5 digits to 1000 digits for addition) while Transformer models like Pythia and Mistral exhibit limited or no length generalization capability, even when also equipped with tool-use.
- Recency Bias as a Key Advantage for SSMs: A critical insight provided during the Q&A session is the role of recency bias in SSMs. Unlike Transformers, where the attention mechanism can "spread out between different tokens" as context size increases, leading to a breakdown in performance on long sequences, SSMs maintain a very strong recency bias. When the essential "state of the algorithm" or critical information is consistently maintained and updated at the "end of context" (i.e., in the most recent tokens accessible to the state update), SSMs are highly effective at remembering and leveraging this information. This makes them particularly well-suited for iterative algorithms where the current state is frequently updated and needed for the next step, allowing for robust generalization.
- Practical Demonstrations Across Diverse Tasks: The research validates these findings across a diverse set of tasks, moving beyond simple arithmetic to more complex algorithmic challenges. These include:
- Multi-digit Addition: Generalizing from 5-digit to 1000-digit additions.
- Multiplication: Demonstrating similar length generalization.
- Logical Reasoning Graph Tasks: Solving computations based on graph structures.
- Tower of Hanoi: A classic algorithmic puzzle, where SSMs show significant gains, especially noting the exponential scaling of steps per task.
- Code-Fixing Agents: A highly practical use case where SSMs equipped with tool-use (e.g., fixing files iteratively) outperform Transformer baselines, generalizing to a higher number of tool calls (e.g., up to 30 tool calls from 16 functions trained).
These findings collectively suggest a paradigm shift in how we approach building capable AI agents, particularly for tasks requiring extensive reasoning over long sequences. By combining the inherent efficiency of SSMs with the power of external tools, it becomes possible to achieve robust length generalization, often surpassing the performance of more computationally intensive Transformer architectures.
Technical Deep Dive
▶ Watch: Code-fixing agents: A practical, interesting use case (3:20)
The core technical innovation presented in this work revolves around augmenting State Space Models (SSMs) with tool-use capabilities to overcome their inherent fixed-memory limitations and achieve length generalization. The talk frames SSMs as models with a fixed-size memory, encompassing architectures like RNNs, linear Transformers, and Mamba and its variants. These models process sequences token-by-token, updating a compressed hidden state that summarizes the past context. The challenge is that this fixed state cannot store an arbitrarily growing amount of information required for tasks like multi-digit arithmetic or complex multi-step reasoning.
To address this, the authors introduce an agentic setting where the SSM acts as an agent capable of three primary actions:
- Thought: Internal reasoning processes, generating intermediate thoughts.
- Command Execution: Sending commands to an external oracle or tool.
- Observation Reception: Receiving observations or results back from the oracle.
- Output Generation: Producing the final answer tokens.
This multi-turn interactive loop allows the SSM to externalize its "memory" and "computation." For instance, in the addition task, the tools provided to the SSM are conceptualized as giving "pointer access to this context," similar to a Turing machine tape. This means the model can:
- Move pointers: Navigate through a conceptual external memory.
- Read from pointers: Access specific pieces of information stored externally.
- Write to external memory: Store intermediate results (e.g., carry digits, partial sums).
The internal logic of the SSM then focuses on coordinating these tool calls and interpreting their outputs, rather than directly managing the entire state of the computation within its fixed internal memory. For example, to perform multi-digit addition, the SSM might:
- Read a pair of digits from the "tape" using a pointer tool.
- Perform a local addition operation (or call an arithmetic tool for this).
- Store the sum digit and any carry to the "tape" using a write tool.
- Move pointers to the next pair of digits.
- Repeat this iterative process, with the carry being explicitly managed on the "tape."
This iterative, tool-augmented approach is particularly effective because of the recency bias inherent in SSMs. The speaker explains that SSMs are very strong at focusing on the most recent information in their context. By designing the chain of thought and tool interactions such that the critical "state of the algorithm" (e.g., the current carry, the current position on the tape) is always explicitly updated and appears at the "end of context" in the prompt or observation stream, the SSM can reliably attend to and utilize this information. This contrasts with Transformers, where even if the relevant state is at the end of the context, the global attention mechanism can sometimes "spread out" and fail to consistently focus on the most recent, critical tokens as context length increases.
The code-fixing agent example further illustrates this sophisticated tool-use. Here, the task involves fixing bugs across multiple interdependent files. The system considers three settings:
- Single-turn model: The model sees all files at once (putting all info in context), then tries to fix the bug. This is a baseline without iterative tool-use.
- Hard-coded iterative agent: The agent repeatedly runs a pre-defined algorithm. In each turn, it attempts to fix up to three files, and this process repeats until no bugs are left. This simulates a structured, iterative tool-use strategy.
- Distillation setting: A larger, more capable SWE-agent 32B Transformer model is used to generate trajectories (sequences of thoughts, tool calls, and observations) for solving these tasks. A smaller SSM model is then fine-tuned on these collected trajectories in a distillation manner. This allows the SSM to learn complex tool-use strategies from a powerful teacher model.
In all these scenarios, the SSM's ability to maintain and update a relevant state via external tools, combined with its strong recency bias, enables it to generalize effectively to much longer and more complex problem instances than Transformers, even when the latter are also given tool-use capabilities. The efficiency of SSMs (linear complexity) then becomes a significant advantage for scaling these agentic capabilities to real-world applications.
Experimental Setup & Results
▶ Watch: Conclusion: Tool-use enables powerful, efficient SSM agents (4:10)
The experimental validation of tool-augmented SSMs focused on demonstrating their ability to achieve length generalization across a variety of tasks, particularly in comparison to Transformer models.
Model Architectures and Sizes:
The primary State Space Model used in the experiments was Mamba, a prominent SSM variant known for its linear scaling properties. Additionally, LSTMs (Long Short-Term Memory networks), another type of recurrent neural network with linear complexity, were also included as SSM representatives. For comparison, Transformer models like Pythia and Mistral were employed. The models used for synthetic tasks (addition, multiplication, Tower of Hanoi) were relatively small, in the range of 160 million to 200 million parameters. For the more complex code-fixing agent task, a larger SWE-agent 32B model was used as a teacher for distillation, with the fine-tuned SSM likely being a smaller model trained on these trajectories.
Datasets and Tasks:
The experiments covered a diverse set of tasks designed to test long-form reasoning and length generalization:
- Multi-digit Addition: The model was trained on adding numbers with a small number of digits (e.g., 5 digits). The test set involved numbers with significantly more digits.
- Multiplication: Similar to addition, testing generalization to longer input numbers.
- Simple Logical Reasoning Graph: Tasks requiring computation based on a graph structure, implicitly testing iterative traversal or logical deduction.
- Tower of Hanoi: A classical recursive algorithmic puzzle, where the number of steps grows exponentially with the number of disks. This task rigorously tests the ability to manage complex state and plan multi-step sequences.
- Code-Fixing Agents: This involved a more realistic scenario where agents had to fix bugs in code distributed across multiple files with dependencies. The task required identifying bugs and iteratively applying fixes, potentially involving multiple "tool calls" (e.g., editing files, running tests).
Experimental Settings for Code-Fixing Agents:
For the code-fixing task, three distinct settings were evaluated:
- Single-turn model: A baseline where the model processes all files in a single pass, trying to fix the bug. This represents a non-agentic approach.
- Hard-coded iterative agent: An agent that follows a predefined algorithm, iteratively fixing up to three files per turn until the bug is resolved. This showcases structured tool-use.
- Distillation setting: Leveraging the capabilities of a large SWE-agent 32B Transformer model to generate expert trajectories (sequences of actions and observations) for bug fixing. A smaller SSM model was then fine-tuned on these trajectories, learning to imitate the expert's tool-use strategy.
Key Results and Headline Numbers:
- Addition Task: SSMs (Mamba and LSTM) trained on 5-digit additions demonstrated near-perfect length generalization up to 1000 digits. In stark contrast, Transformer models (Pythia, Mistral) showed "no remarkable length generalization capability," failing significantly as the number of digits increased beyond the training distribution.
- Tower of Hanoi: While the exact numbers were not given, the speaker noted "significant length generalization" for the SSM model. The remark that the number of steps per task scales exponentially for Tower of Hanoi underscores the difficulty and the significance of even a smaller gain in generalization.
- Code-Fixing Agents: The Mamba model consistently outperformed the Transformer baseline. Specifically, with the hard-coded iterative version, the SSM could "easily generalize up to 30 tool calls," even though it was trained on tasks involving up to 16 functions. The blue curves (SSM) on the provided plot (right) showed superior performance compared to the red curves (Transformer).
Ablations and Insights:
The key insight from the results and subsequent discussion was the role of recency bias in SSMs. When asked why Transformers underperformed even with tool-use, the speaker explained that Transformers' attention mechanism tends to "spread out between different tokens" as context length grows, leading to a breakdown. SSMs, however, maintain a strong recency bias. By structuring the tool-use chain of thought such that the "state of the algorithm" (e.g., current carry, pointer position, bug status) is consistently updated and presented in the "last tokens in the context," SSMs can reliably access and leverage this crucial information. This makes them exceptionally good for iterative algorithms that rely on a small, frequently updated working memory, effectively managed by external tools.
In summary, the experiments robustly demonstrate that tool-use effectively circumvents the memory limitations of SSMs, enabling them to achieve unprecedented length generalization and, in many cases, surpass the performance of Transformers on complex reasoning and algorithmic tasks, primarily due to their efficient architecture and strong recency bias when paired with an appropriate agentic framework.
Practical Implications
▶ Watch: Q&A: Challenges scaling to larger, realistic models (6:00)
The findings from "To Infinity and Beyond" carry profound practical implications for the development and deployment of AI/ML systems, especially as the demand for more capable and efficient models grows.
For Practitioners and Model Builders:
- Efficient Reasoning Agents: The work suggests a viable path to build highly efficient reasoning or coding agents using State Space Models (SSMs). For tasks that are inherently iterative or require managing a small, evolving state over long sequences (e.g., code generation, debugging, complex arithmetic, data manipulation), SSMs with tool-use could be a superior choice compared to Transformers. This is particularly true for applications where computational budget or latency are critical constraints.
- Overcoming Transformer Limitations: Developers struggling with the quadratic complexity and memory demands of Transformers for long context windows now have a strong alternative. By adopting an agentic framework with SSMs, they can achieve length generalization without incurring the high computational cost, potentially leading to faster inference and lower operational expenses.
- Specialized AI Agents: The success of SSMs with tool-use highlights the power of modularity in AI. Instead of attempting to cram all knowledge and computational ability into a single, monolithic model, the approach advocates for a central, efficient reasoning core (the SSM) that delegates specific tasks to specialized, reliable tools. This mirrors how humans solve complex problems by using calculators, IDEs, or knowledge bases.
- Designing Effective Chains of Thought: The emphasis on recency bias in SSMs offers a crucial design principle for practitioners. When structuring prompts and tool interactions, it is vital to ensure that the most critical, current state information is consistently updated and presented at the end of the context. This "active management" of the context for the SSM can significantly improve its ability to generalize and perform complex iterative tasks.
For Infrastructure Teams and Deployers:
- Reduced Inference Costs: The linear scaling of SSMs ($O(L)$) compared to Transformers ($O(L^2)$) translates directly into lower computational resource requirements for processing long sequences. This can lead to significant cost savings on GPU/TPU infrastructure, especially for high-throughput inference scenarios.
- Scalability for Long Sequences: Deploying models that can robustly handle variable and extremely long sequence lengths without performance degradation is a major challenge. Tool-augmented SSMs offer a more scalable solution for applications like long-document summarization, extended dialogue systems, or complex code analysis.
- Hardware and Software Stack Optimization: The efficiency characteristics of SSMs might influence future hardware and software stack designs. Optimizations for recurrent operations and efficient state management could become more prominent, potentially leading to new specialized accelerators or software frameworks tailored for SSMs and agentic workflows.
- Challenges in Pre-trained Models: Acknowledged limitation is the current disparity in the strength of readily available pre-trained checkpoints for SSMs compared to Transformers. For practical adoption, infrastructure teams will need access to robust, large-scale pre-trained SSMs to match the baseline capabilities of existing Transformer models before fine-tuning for agentic tasks. This points to a need for more investment in pre-training SSMs.
Tradeoffs and Limitations:
- Synthetic vs. Real-world Data: While the results on synthetic tasks like addition and Tower of Hanoi are compelling, scaling these capabilities to more "realistic coding data" or highly unstructured real-world problems remains a challenge. The speaker noted that their current work is mostly in a "synthetic setting."
- Complexity of Tool Integration: Designing and integrating effective tools, along with training data that teaches the model how to use them, adds an additional layer of engineering complexity. This is not a "model-alone" solution but requires careful system design.
- Pre-trained Model Gap: As mentioned, the availability of strong, large-scale pre-trained SSMs is still catching up to Transformers. This means that while the architectural advantages are clear, achieving competitive performance on broad tasks might first require significant investment in SSM pre-training.
- Suitability for All Tasks: While excellent for iterative, state-dependent tasks, it's important to remember that not all tasks benefit from strong recency bias or iterative tool-use. Transformers might still be superior for tasks requiring holistic, global context understanding where the importance of information isn't strictly time-dependent.
Overall, this research provides a compelling blueprint for building the next generation of efficient, length-generalizing AI agents, leveraging the strengths of SSMs through a sophisticated tool-use paradigm.
Key Takeaways
- SSMs are Efficient but Memory-Limited: State Space Models (SSMs) offer linear computational complexity ($O(L)$) for sequence length $L$, making them more efficient than Transformers ($O(L^2)$). However, their fixed-size internal memory prevents them from solving complex, long-form tasks requiring length generalization without external aid.
- Tool-Use Unlocks Length Generalization: By integrating interactive tool-use, SSMs can overcome their memory bottleneck, effectively gaining external memory and computational power. This agentic setting enables them to achieve robust length generalization on tasks like multi-digit arithmetic, algorithmic puzzles, and code fixing.
- SSMs Outperform Transformers with Tools: Experiments show that tool-augmented SSMs (e.g., Mamba, LSTM) can significantly outperform Transformer models (e.g., Pythia, Mistral) in length generalization tasks, even when Transformers also use tools. This highlights a fundamental advantage for iterative problem-solving.
- Recency Bias is Key: The strong recency bias of SSMs is a critical factor in their success with tool-use. By consistently updating the "state of the algorithm" at the end of the context, SSMs can reliably track and leverage critical information for iterative processes, where Transformers' global attention can diffuse.
- New Paradigm for Agentic AI: This work proposes a powerful paradigm for building efficient AI agents: combining the linear scaling of SSMs with the extended capabilities of external tools. This enables the development of scalable reasoning and coding agents for real-world applications.
- Future Directions and Challenges: While promising, scaling these findings to larger models and more realistic, unstructured datasets remains a challenge. Further investment in robust pre-trained SSMs is needed to fully realize their potential in practical applications.
About the Speaker(s)
The talk "To Infinity and Beyond: Tool-Use Unlocks Length Generalization in State Space Models" was presented by Aryo Lotfi, who is part of a collaborative research team at Apple. The work is a joint effort with Eran Malach, Omid Saremi, Sinead Williamson, Arwen Bradley, Emmanuel Abbe, Joshua Susskind, and Etai Littwin, all affiliated with Apple. While Aryo Lotfi delivered the presentation, the research represents the collective contributions of this interdisciplinary team, likely spanning expertise in machine learning, theoretical computer science, and practical AI systems development. Their collective work focuses on advancing the capabilities and efficiency of AI models, particularly in the context of sequence processing and agentic intelligence.
Reviews
→ Top-rated talks at International Conference on Learning Representations 2026
All talks from International Conference on Learning Representations 2026