Beyond Sliding Windows: Learning to Manage Memory in Non-Markovian Environments
Geraud Nangue Tasse, Matthew Riemer, Benjamin Rosman, Tim Klinger
TL;DR
This work tackles memory efficiency for reinforcement learning in real-world, non-Markovian environments by introducing Adaptive Stacking, a meta-algorithm that learns which past observations to retain within a fixed memory budget. It provides convergence guarantees for AS under unbiased value estimates and demonstrates substantial compute and memory reductions for MLP, LSTM, and Transformer agents, compared to standard Frame Stacking. Through extensive experiments on memory-heavy tasks (e.g., TMaze variants) and generalization tests across diverse domains (XorMaze, Rubik's Cube, FetchReach), AS matches oracle baselines while using far less memory and improving generalization. The approach reframes memory management as a reward-guided decision problem, integrating memory eviction into the RL loop and offering practical benefits for scalable, memory-constrained agents in big worlds.
Abstract
Recent success in developing increasingly general purpose agents based on sequence models has led to increased focus on the problem of deploying computationally limited agents within the vastly more complex real-world. A key challenge experienced in these more realistic domains is highly non-Markovian dependencies with respect to the agent's observations, which are less common in small controlled domains. The predominant approach for dealing with this in the literature is to stack together a window of the most recent observations (Frame Stacking), but this window size must grow with the degree of non-Markovian dependencies, which results in prohibitive computational and memory requirements for both action inference and learning. In this paper, we are motivated by the insight that in many environments that are highly non-Markovian with respect to time, the environment only causally depends on a relatively small number of observations over that time-scale. A natural direction would then be to consider meta-algorithms that maintain relatively small adaptive stacks of memories such that it is possible to express highly non-Markovian dependencies with respect to time while considering fewer observations at each step and thus experience substantial savings in both compute and memory requirements. Hence, we propose a meta-algorithm (Adaptive Stacking) for achieving exactly that with convergence guarantees and quantify the reduced computation and memory constraints for MLP, LSTM, and Transformer-based agents. Our experiments utilize popular memory tasks, which give us control over the degree of non-Markovian dependencies. This allows us to demonstrate that an appropriate meta-algorithm can learn the removal of memories not predictive of future rewards without excessive removal of important experiences. Code: https://github.com/geraudnt/adaptive-stacking
