Adam on Local Time: Addressing Nonstationarity in RL with Relative Adam Timesteps

Benjamin Ellis, Matthew Thomas Jackson, Andrei Lupu, Alexander David Goldie, Mattie Fellows, Shimon Whiteson, Jakob N. Foerster

TL;DR

Reinforcement learning (RL) often struggles with nonstationary objectives, leading to unstable training with standard optimizers like Adam. This paper introduces "Adam-Rel," a simple modification to Adam that resets its internal timestep counter after significant objective changes. Adam-Rel significantly improves performance in both on-policy and off-policy RL tasks by preventing overly large, destabilizing updates.

What Problem Does This Paper Address?

Deep learning optimizers, like Adam, are incredibly powerful but were primarily developed for stationary supervised learning tasks. In contrast, Reinforcement Learning (RL) is inherently nonstationary. An agent's policy changes as it learns, which in turn changes the data distribution it experiences and the objective function it's trying to optimize. This nonstationarity can cause standard optimizers to behave erratically, leading to unstable training and suboptimal performance. Existing solutions often involve ad-hoc "hacks" like target networks or clipped updates. This paper argues for a more principled approach: adapting the optimizer itself to better handle RL's nonstationary nature. Specifically, they focus on how Adam's internal timestep counter, used for normalizing gradient estimates, can lead to excessively large updates when the underlying objective changes abruptly.

Methods

The core contribution is Adam-Rel (Adam with Relative Timesteps). The standard Adam optimizer uses a global timestep t that increments with every update. This t is used in the bias correction terms for the first and second moment estimates (m_t and v_t). When the objective function changes drastically (e.g., due to a target network update), the gradient magnitude can suddenly increase. In Adam, this large gradient, when combined with the existing momentum terms and the bias correction factor 1/(1-beta*t), can result in an enormous update step, destabilizing training.

Adam-Rel's key innovation is to reset the timestep t to 0 whenever a significant change in the objective is detected. In the context of PPO, this typically means resetting t after collecting a new batch of trajectories. This effectively "resets" the bias correction, preventing the optimizer from being overly influenced by past gradients and thus avoiding the large, unstable updates. The paper shows theoretically and empirically that this simple change prevents overshooting and, in the absence of large gradient changes, behaves like learning rate annealing.

They also compare against Adam-MR (Adam with Momentum Reset), which resets both the momentum terms (m and v) and the timestep t.

Datasets

The paper evaluates Adam-Rel on several standard RL benchmarks:

  • Atari-10: A subset of Atari games used for off-policy evaluation with DQN.
  • Atari-57: The full suite of Atari games for on-policy evaluation with PPO.
  • Craftax-Classic: A JAX-based benchmark for open-ended RL, used for on-policy evaluation with PPO.

Key Insights and Ideas

  • Adam's Achilles' Heel in RL: The paper clearly demonstrates that Adam's reliance on a global timestep for bias correction is a significant vulnerability in nonstationary RL environments. Abrupt changes in gradient magnitude can lead to massive, destabilizing updates.
  • Simplicity is Key: The proposed Adam-Rel is a one-line change (resetting t) that offers substantial benefits. This highlights that sometimes, small, principled modifications to existing tools can be more effective than complex, ad-hoc solutions.
  • Adam-Rel as Annealing: When gradient magnitudes don't change drastically, Adam-Rel naturally acts like learning rate annealing, a well-established technique for stabilizing training in stationary settings. This dual benefit makes it broadly applicable.
  • Momentum Matters: The comparison with Adam-MR (which resets momentum too) suggests that retaining momentum information across objective changes, even with the timestep reset, is crucial for good performance, especially in on-policy settings where updates are less frequent.
  • Theoretical Model Matches Practice (Qualitatively): The paper develops a theoretical model for Adam's update size under nonstationary gradients. While not perfectly matching empirical results (due to simplifying assumptions), it captures the core phenomenon of overshooting and provides a strong intuition for why Adam-Rel works.

Key Results

  • Off-policy RL (DQN on Atari-10): Adam-Rel achieved a human-normalized performance of 65.7%, significantly outperforming Adam (28.8%) and Adam-MR (23.5%).
  • On-policy RL (PPO on Craftax-Classic): Adam-Rel consistently outperformed Adam and Adam-MR across various metrics, including score and specific achievements.
  • On-policy RL (PPO on Atari-57): Adam-Rel improved performance, outperforming Adam in 33 out of 55 games and showing a notable advantage at higher performance percentiles (e.g., 75th percentile score of 338% vs. 220% for Adam).
  • Gradient Increases Occur: The paper empirically verifies that gradient magnitudes do increase significantly after abrupt objective changes in RL practice, supporting the theoretical motivation for Adam-Rel.

Limitations and Future Work

  • Abrupt vs. Continuous Nonstationarity: The current work primarily addresses "abrupt" nonstationarity (e.g., target network updates). The authors suggest further investigation into applying Adam-Rel to "continuous" nonstationarity, such as that arising from Polyak averaging.
  • Understanding Update Size Desirability: While Adam-Rel prevents large updates, a deeper understanding of what constitutes "desirable" update sizes in nonstationary settings could lead to further improvements.
  • Broader Applicability: The authors encourage exploring Adam-Rel in other domains with nonstationarity, such as RLHF, synthetic data training, or continual learning, and in continuous control settings.
  • Theoretical Model Simplifications: The theoretical model makes simplifying assumptions (e.g., step-function gradient changes) that don't perfectly align with observed training dynamics. Future work could refine this model.

Summary updated

BibTeX
@inproceedings{ellis2024adam,
  author = {Benjamin Ellis and Matthew Thomas Jackson and Andrei Lupu and Alexander David Goldie and Mattie Fellows and Shimon Whiteson and Jakob N. Foerster},
  title = {{Adam on Local Time: Addressing Nonstationarity in RL with Relative Adam Timesteps}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2024},
  url = {https://openreview.net/forum?id=biAqUbAuG7},
}
Figure