In the world of Deep Reinforcement Learning (DRL), agents have mastered complex games like StarCraft II and even controlled nuclear fusion plasmas. However, many of these successes rely on massive compute or environments where "memory" is easily bypassed—often solvable by simply stacking the last few frames of observation. To truly develop agents that can reason over time, the field requires environments that are mathematically impossible to solve without robust, long-term memory.
Enter Memory Gym, a novel benchmark designed to push memory-based agents to their absolute limits.
The "Memory Gap" in DRL
Most existing DRL benchmarks suffer from a "memory gap." Many tasks are either fully observable (the agent sees everything it needs at once) or only weakly partially observable, where providing the last four frames of video is enough to infer the state of the world. Even specialized memory tasks often only require an agent to remember a single "initial cue" (e.g., "the goal is behind the red door") and then act on it.
True intelligence requires frequent agent-memory interactions. We need agents that can navigate invisible paths, remember long sequences of commands, and filter out moving noise. Memory Gym addresses this by providing environments with a strong dependency on memory, where the difficulty can be scaled smoothly from simple tutorials to unsolved challenges.
The Memory Gym Environments
To test these capabilities, the researchers developed three distinct 2D environments using Python and PyGame. Each is designed to isolate and test specific memory functions:
- Mortar Mayhem: The agent is shown a sequence of commands (e.g., move to specific tiles) while frozen. It must then execute that exact sequence from memory.
- Mystery Path: The agent must traverse a $7 \times 7$ grid where the correct path is invisible. If the agent steps off the path, it is reset to the start. To succeed, it must map the path in its memory through trial and error.
- Searing Spotlights: The environment is pitch black except for small, randomly moving spotlights. The agent must find coins and an exit while avoiding the "searing" light, which drains its health.
Benchmarking and Meta Desiderata
Memory Gym is rigorously compared against existing benchmarks like Procgen, DeepMind Lab, VizDoom, and MiniGrid. The paper highlights several "Meta Desiderata" where Memory Gym excels:
- Speed: It achieves over 10,000 frames per second (FPS), making it significantly faster than 3D benchmarks like DM Lab.
- Accessibility: It runs "headless" (no window needed) natively on Linux, macOS, and Windows without complex dependencies like Docker.
- Scalability: Difficulty can be adjusted by changing sequence lengths, grid sizes, or the number of spotlights.
Key Insights and Results
To establish baselines, the authors used Proximal Policy Optimization (PPO), comparing a memory-less version against versions equipped with Gated Recurrent Units (GRU), frame stacking, and HELM (a transformer-based architecture).
- Memory-less Failure: As intended, memory-less PPO failed completely on all tasks, proving the benchmark successfully isolates memory as the required skill.
- The "Spotlight Puzzle": The most surprising finding was that Searing Spotlights remains largely unsolved for standard recurrent agents (GRU-PPO). Even though the spotlights reveal parts of the ground truth, their random movement acts as a severe perturbation. The agents struggle to figure out what they actually control amidst the moving light.
- Memory is a Workspace: Unlike initial cue tasks, these environments require the agent to constantly update and query its memory. In Mystery Path, the agent isn't just remembering a goal; it is actively building a mental map of where it previously fell.
- Recurrence vs. Transformers: While GRUs performed well on sequence-based tasks (successfully executing 10-command sequences in Mortar Mayhem), the transformer-based HELM showed better potential for the noisy, visual challenges of Searing Spotlights, albeit at a 6x slower computational cost.
- Efficiency and Generalization: Agents trained on 100,000 procedurally generated levels generalized well to novel, unseen levels. Furthermore, Memory Gym's high FPS allows for 150 million steps of training in roughly 10 hours on a single GPU/CPU setup.
Future Directions
The authors acknowledge that Searing Spotlights is a significant hurdle for current popular architectures. Future work should investigate why randomly moving observations so effectively break the internal state of recurrent networks.
They also propose expanding the benchmark into open-ended versions—for example, a Mortar Mayhem where the command sequence grows infinitely to test the absolute capacity limits of an agent's memory. Finally, newer architectures like Structured State-Space models (S4) are highlighted as promising candidates to solve the puzzles Memory Gym has introduced.
Summary updated