Abstract
Multistep reinforcement learning algorithms, such as DQN($\lambda$), often utilize return caching to manage the computational cost of calculating $\lambda$-returns. However, traditional caching methods introduce significant memory overhead by duplicating high-dimensional state-action data. This paper introduces the Virtual Replay Cache (VRC), a memory-efficient refactor that employs the principle of indirection. By storing pointers to experiences rather than duplicating data, the VRC reduces cache memory consumption by over 99.9% while maintaining identical learning performance and slightly improving training speed.
Introduction
In Reinforcement Learning (RL), agents frequently use the $\lambda$-return to estimate future rewards, balancing the trade-off between bias and variance. While effective, calculating $\lambda$-returns is computationally intensive in deep neural networks because it requires multiple passes through a target network.
To mitigate this, the DQN($\lambda$) framework introduced return caching, where $\lambda$-returns are precomputed for a batch of experiences and stored in a separate cache. However, this creates a massive memory bottleneck. In high-dimensional tasks, such as those involving Atari frames, the cache traditionally duplicates data already present in the main replay memory. This redundancy wastes gigabytes of RAM and slows training due to unnecessary data copying.
Methods: The Principle of Indirection
The authors propose the Virtual Replay Cache (VRC) as a solution to this redundancy. The core innovation is a shift from a "physical" cache to a "virtual" one. Instead of copying high-dimensional state-action pairs, the VRC stores only two lightweight elements for each cached experience:
- A 32-bit integer index: A pointer to the original data's location in the primary replay memory.
- A 32-bit float: The precomputed $\lambda$-return value.
When the agent samples a minibatch, it looks up the indices in the VRC and "dereferences" them to pull the actual state data directly from the primary replay memory. This ensures that each high-dimensional experience exists in only one place in memory at any given time.
Experimental Evaluation
The VRC was evaluated using the Atari 2600 benchmark suite via the Arcade Learning Environment. Six games were tested: Beam Rider, Breakout, Pong, Qbert, Seaquest, and Space Invaders*. These games are standard benchmarks because their high-dimensional visual input (84x84 grayscale frames) makes memory management a critical concern.
Because the VRC is a "pure refactor," it does not alter the underlying mathematics of the DQN($\lambda$) algorithm. It produces identical training targets, ensuring that the agent's learning curve and final performance remain unchanged while efficiency is significantly improved.
Key Results
The VRC achieved transformative improvements in memory efficiency and modest gains in processing speed:
- Massive Memory Savings: In a standard Atari setup with a cache size of 80,000 experiences, the original DQN($\lambda$) cache required 2,154 MB. The VRC reduced this to just 0.61 MB—a reduction of over 99.9%.
- Per-Experience Efficiency: Each entry in the VRC occupies only 8 bytes, compared to over 28,000 bytes in the traditional implementation.
- Reduced Runtime: By eliminating large-scale data copying, the VRC achieved a statistically significant speedup of approximately 1%, saving roughly 1.5 minutes over a standard multi-hour training run.
Discussion and Future Work
The Virtual Replay Cache demonstrates that the primary role of a cache in this context is logical (tracking eligible experiences) rather than physical (holding data). The memory savings of the VRC scale linearly with input dimensionality, suggesting that as RL moves toward higher-resolution images or 3D sensor data, the benefits of indirection will become even more pronounced.
While the memory savings are substantial, the relatively small runtime improvement suggests that modern hardware bottlenecks remain centered on neural network computation rather than RAM data movement. Future work may involve extending the VRC's modular design to other multistep estimators and complex, high-dimensional environments where memory constraints currently limit scalability.
Summary updated