Manuscript Offprint

arXiv:2610.41850

Dynamical Memory Transformer: Selective Recurrent Memories with Constant Cost Attention

Yannis Bendi-Ouis, Xavier Hinaut

Abstract

Transformers retain an explicit history of the sequence, allowing attention to directly retrieve past representations. However, the size of the KV-Cache and the cost of a new token increase with the context length. State Space Models compress the past into a fixed-size recurrent state, at the cost of reduced addressability. We present the Dynamical Memory Transformer (DMT), a hybrid architecture that separates sequence encoding from information reading. The encoder uses several memory units, each implemented by a dynamical system with a complex diagonal recurrent matrix. An input-dependent leak rate controls their updates. The decoder then uses attention to read and combine their outputs, without going through the token history. The formulation of the recurrence allows an associative scan with O(T)\mathcal{O}(T) total work and O(log⁡T)\mathcal{O}(\log T) parallel depth, with fixed dimensions. During autoregressive inference, the recurrent states and the convolution cache remain fixed in size. We compare DMT with Mamba and Transformer on cognitive and language modeling tasks, and show its strengths and limitations: DMT achieves the best results on several cognitive tasks and language modeling performance close to that of Transformer, but remains behind Mamba in language modeling. On selective copy, DMT also shows stronger length extrapolation than Mamba and Transformer. These results demonstrate that parallel dynamical memory units are a promising mechanism for retaining and using information over sequences.

1 Introduction

Sequential processing requires selecting, maintaining and using, at the right time, the information contained in past inputs. Transformer architectures retain an explicit history of the representations of each token for this purpose (Vaswani et al., 2017). At each step, attention can retrieve a past representation from its content, without going through all the updates that separate it from the current token. We call this possibility the addressability of information. During training, known tokens can be processed in parallel. However, during autoregressive inference, the KV-Cache that retains keys and values grows with the context. The total work of dense attention is quadratic in sequence length, and the cost of each new token grows linearly. FlashAttention reduces memory transfer volume and improves GPU utilization (Dao et al., 2022), without eliminating this growth.

Recurrent architectures follow another strategy: they progressively compress the past into a fixed-size recurrent state. This state evolves with each input, but its dimension does not depend on the sequence length. It therefore allows constant incremental complexity during inference, for a given architecture. In return, information that has not been retained in the state can no longer be retrieved directly. State Space Models (SSMs) combine this principle with parallel formulations: S4 notably uses a convolutional view of the recurrence (Gu et al., 2022), while Mamba allows input-dependent selection and uses an associative scan (Gu & Dao, 2023). These two strategies therefore contrast an explicit addressable history with compression of the past into a fixed-size state.

Here, we explore a separation between encoding and reading. The Dynamical Memory Transformer (DMT) uses MM memory units, each with its own recurrent parameters. At each step, an input-dependent leak rate controls the interpolation between the previous state and a candidate state. Together, these units serve as an encoder of the sequence. The decoder then uses attention to read and combine the resulting representations, rather than going through past tokens. In a functional sense, these states constitute working memory: a temporary representation of information useful for the current sequence.

Our contributions are as follows:

  • a hybrid architecture that separates an encoder with selective memory units from an attention decoder, with a fixed-size memory medium during inference;

  • an exact formulation of the recurrence through associative scan, which distinguishes total work, the parallel depth of the algorithm and the limitations of the chunked implementation;

  • a comparison on cognitive tasks, memory unit activity, length extrapolation and language modeling;

  • a fixed-budget ablation of the selected TinyStories configuration, to measure the role of the components and their interactions.

The experiments show that this separation allows several tasks to be learned, but also that compression can limit recall.

References (100)

  • Cogscale: Scalable benchmark for sequence processing (opens arXiv in a new tab)
  • PIQA: Reasoning about physical commonsense in natural language (opens the publisher in a new tab)
  • Think you have Solved Question Answering? Try ARC, the AI2 Reasoning Challenge
  • Transformers are ssms: Generalized models and efficient algorithms through structured state space duality (opens arXiv in a new tab)
  • Flashattention: Fast and memory-efficient exact attention with io-awareness
  • Tinystories: How small can language models be and still speak coherent english? arXiv preprint arXiv:2305.07759, 2023 (opens arXiv in a new tab)
  • Hungry hungry hippos: Towards language modeling with state space models
  • Openwebtext corpus
  • Mamba: Linear-Time Sequence Modeling with Selective State Spaces
  • Efficiently modeling long sequences with structured state spaces
  • echo state
  • Transformers are rnns: Fast autoregressive transformers with linear attention
  • Real-time computing without stable states: A new framework for neural computation based on perturbations
  • Pointer sentinel mixture models
  • Can a suit of armor conduct electricity? a new dataset for open book question answering (opens the publisher in a new tab)
  • The LAMBADA dataset: Word prediction requiring a broad discourse context (opens the publisher in a new tab)
  • RWKV: Reinventing RNNs for the Transformer Era
  • Retentive network: A successor to transformer for large language models (opens arXiv in a new tab)
  • Kung, and David Cox
  • Attention is all you need
  • Crowdsourcing multiple choice science questions (opens the publisher in a new tab)
  • HellaSwag: Can a machine really finish your sentence? In Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics, pp. 4791–4800, 2019 (opens the publisher in a new tab)
  • According to Equation 7
  • The identity element is $(\mathbf{1}, \mathbf{0})$
  • The implementation applies RMS normalization to memory inputs, initializes leak rate biases using target rates distributed log-uniformly between 0.01 and 1, initially places $\lambda_m$ on the unit circle and applies SiLU after convolution, state reading and the pre-output projection
  • ><tr><td></td><td colspan=
  • the blue glass is on the center and that is a orange orange
  • on the left is a cup and that is the orange glass
  • on the center there is a blue bowl and there is the red cup on the right
  • Each plot presents one sentence and the two associated activities
  • CKA measures similarity between two sets of representations: a value close to 0 indicates low similarity, while a value close to 1 indicates high similarity
  • These results correspond to the first hyperparameter search phase
  • Configurations in bold are the five selected configurations for each architecture
  • Only completed training runs are included; some configurations therefore have fewer than five test seeds
  • The tables below report the dimensions and parameter counts recorded in the training logs
  • $D$ denotes the representation dimension and $L$ the number of blocks
  • Configuration c49, marked –, has no training log: its dimensions and parameter count come only from the configuration registry
  • We qualitatively selected the best of the 15 continuations independently for each prompt-model pair, yielding nine examples from 135 short generations
  • This year, they noticed a change that
  • The changes in the water quality in the past are not unexpected
  • We're seeing that the water changes significantly
  • It's quite dramatic
  • What they expect to get in the next year is a series of new studies, and the scientists hope to publish a detailed description of what they see and what they learn in the coming years
  • I do think that, for the sake of time, we have to start putting in more money
  • We're hoping that the current data from the survey will show this is a really interesting phenomenon
  • It's an issue of time, the city has to deal with the fact that they're making a lot of money off the project
  • I think that's a bad thing
  • The commission will be responsible for the project, and the city will seek to create a permanent design that will allow the public to have access to the site to be approved
  • This is not a place you go to school to go on the bus line
  • It's going to be the most expensive building and the least amount of activity and development, so the community is going to have to be really smart about what we do here and how we use that space
  • When you talk about redeveloping and improving the housing, for them to do that, that's not necessarily an easy decision
  • A lot of these issues really are cultural, not political
  • It's a wonderful example of how we can make this community better
  • I want to work with the community on the plan. We want to make the city better
  • I think I need to be the one who's in charge
  • I'll give you a clue
  • I could tell that the house had a lot of things, but that was the only thing that was ever built. I'd never been to a house before
  • I'm a builder now
  • I was just as surprised as everyone else when I found it in the mailbox
  • It was right there in the mailbox, in the box. It was the most precious thing. I don't think anybody has ever seen anything like that in my life
  • I'm very thankful for the support, the community
  • We won't have a secret plan. I'm not allowed to talk about it yet for now... But we could do it
  • To see more of her parents as their kids were in the house, they made her feel guilty as they made her feel guilty
  • One of the children tried to grab a bag of paper and said he wouldn't talk to her since it was so empty
  • It's a great idea
  • It's been helping to organize a public outreach campaign to help fund the site, which he hopes will help make the site possible in a big way
  • With the potential to transform a community, [the site] is a very big opportunity for us
  • He said the site is open to residents, tourists and visitors of the site, and is also open to people to join the site, where they could connect to the site's sites
  • I think if the site is going to grow on us, we can't wait to get the site ready
  • We know that there is a lot of interest in this site because it has a lot of people who have been working for years
  • truly get out and try to build a new site
  • We're not going to rush to the site anymore. We're going to give people a place to learn to walk
  • Anderson at alex@jjournal.ca
  • The site is open to all users, including the community, and is available to everyone in the community
  • We will update this page once we have a response
  • Our community is fully informed of our content and is working closely with us to complete the site
  • We do not condone any part of this content
  • We have a reputation for being open and honest about all of these issues - and now we are doing everything we can to make sure that the reader is not in the right place
  • As someone who uses the site, I hope that you will feel welcome to participate in it
  • We'll be sending out the link to the site at the same time as we search
  • We are planning to return to our site as soon as possible
  • If you are unable to reach us, we will contact you immediately
  • This is a unique part of town, and it's a huge asset to the community
  • a whole new dimension
  • best-case scenario
  • part of a larger effort to revitalize the city and attract and retain residents
  • rebuild the park around the station
  • Follow us @livescience, Facebook and Google+
  • the next great thing in town
  • There's a great mix of people, a little bit of history
  • It was a real challenge
  • We are very excited about the future of Penn Station
  • I’ve never been to a site in Pennsylvania when it comes to a new development where there is something unique and unique
  • The last plan we looked at was the Pflueger/Pflueger project in the mid-1980s
  • I hope that it will give us the ability to find a better site for the station as well as a better location for the new project
  • This will open up that possibility of an even more attractive option for Penn Station
  • This is a very large corridor. It will mean that we are in a very different state than it has ever been without Penn Station
  • It is going to be the first, the most diverse, the largest, the tallest, the least crowded station in Pennsylvania
  • It’s something that will help add to our community
  • We've been told that Penn Station will be a community hub

Couldn't load all references. Reload the page to try again.