Learning to Optimize for Reinforcement Learning

Qingfeng Lan, A. Rupam Mahmood, Shuicheng Yan, Zhongwen Xu · OpenReview

Abstract

In recent years, by leveraging more data, computation, and diverse tasks, learned optimizers have achieved remarkable success in supervised learning, outperforming classical hand-designed optimizers. Reinforcement learning (RL) is essentially different from supervised learning and in practice these learned optimizers do not work well even in simple RL tasks. We investigate this phenomenon and identify three issues. First, the gradients of an RL agent vary across a wide range in logarithms while their absolute values are in a small range, making neural networks hard to obtain accurate parameter updates. Second, the agent-gradient distribution is non-independent and identically distributed (non-IID), leading to inefficient meta-training. Finally, due to highly stochastic agent-environment interactions, the agent-gradients have high bias and variance, which increase the difficulty of learning an optimizer for RL. We propose gradient processing, pipeline training, and a novel optimizer structure with good inductive bias to address these issues. By applying these techniques, for the first time, we show that learning an optimizer for RL from scratch is possible. Although only trained in toy tasks, our learned optimizer can generalize to unseen complex tasks in Brax.

Introduction

While learned optimizers have revolutionized supervised learning (SL), they historically fail in the unstable, non-stationary environments of reinforcement learning (RL). This failure stems from two primary challenges. First, unlike the independent and identically distributed (IID) data in SL, RL training data depends on the agent's current policy. As the policy evolves, the distribution of gradients shifts dramatically, creating a non-stationary landscape for the meta-learner. Second, the bilevel optimization problem in RL is plagued by high-variance gradients due to stochastic environments and temporal difference (TD) learning, leading to noisy meta-gradients and a potential "vicious spiral" where poor optimization leads to poor data collection.

Evolution of agent-gradient distributions from the beginning (a) to the end (c) of training.

As illustrated above, agent-gradient distributions shift from bimodal peaks at the start of training to being heavily centered at zero by the end. This confirms that an RL optimizer must be capable of handling vastly different gradient regimes throughout an agent's lifecycle.

Methods: Optim4RL

To address these challenges, the authors propose Optim4RL, which incorporates two key innovations to stabilize the meta-learning process:

Pipeline Training

To combat the non-IID nature of RL gradients, Optim4RL utilizes "pipeline training." By running multiple agents in parallel and staggering their resets, the meta-optimizer is exposed to a mixture of gradients from agents at various stages of expertise (from "newbies" to "experts") simultaneously. This technique effectively creates a more stationary, IID-like distribution for the meta-learner.

Inductive Bias via Dual-RNNs

Rather than using a generic black-box model, Optim4RL employs a structure inspired by classical adaptive optimizers. It uses two Gated Recurrent Units (GRUs): one to estimate a momentum-like term ($m$) and another for a variance-like term ($v$). The final update follows a familiar adaptive form: $\Delta\theta = -\alpha \frac{m}{\sqrt{v} + \epsilon}$. This inductive bias restricts the search space to effective optimization rules, facilitating learning from scratch.

Overview of (a) Pipeline training and (b) the Dual-RNN optimizer structure of Optim4RL.

Experimental Results

Optim4RL was meta-trained on six custom Gridworld toy tasks and evaluated on significantly more complex environments, including the Catch task and the Brax Suite (Ant, Humanoid, Pendulum, and Walker2D).

Key findings include:

  • Superior Generalization: Optim4RL was the only learned optimizer to achieve satisfactory performance across all tested tasks, successfully scaling from gridworlds to high-dimensional robotic simulations.
  • Outperforming Baselines: In the "Ant" environment, Optim4RL significantly outperformed VeLO—a state-of-the-art SL optimizer trained for thousands of TPU-months—and remained competitive with hand-tuned Adam and RMSProp.
  • Robustness: While other learned optimizers like STAR exhibited instability or "crashed" with NaN errors in complex environments like Humanoid, Optim4RL remained stable. Ablation studies confirmed that Pipeline Training was crucial for this stability, boosting average returns in Humanoid from ~6557 to ~8440.

Conclusion

Optim4RL demonstrates that domain-specific inductive bias and stabilized training techniques are more critical than massive-scale general training for RL optimization. While the results are promising, future work remains to scale meta-training to even more diverse environments and to develop a deeper theoretical understanding of learned optimizer convergence in non-stationary landscapes.

Summary updated

BibTeX
@misc{lan2023learning,
  author = {Qingfeng Lan and A. Rupam Mahmood and Shuicheng Yan and Zhongwen Xu},
  title = {{Learning to Optimize for Reinforcement Learning}},
  year = {2023},
  eprint = {2302.01470},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2302.01470},
}
Figure