Dynamics Generalisation in Reinforcement Learning via Adaptive Context-Aware Policies

Michael Beukman, Devon Jarvis, Richard Klein, Steven James, Benjamin Rosman

Abstract

Generalization to varying environmental dynamics remains a significant challenge in Reinforcement Learning (RL). Standard agents often prove brittle when faced with changes in physical properties like friction or mass. We present the Decision Adapter, a novel architecture designed to decouple state processing from environmental context. By utilizing a hypernetwork to generate weights for a bottleneck adapter module, the Decision Adapter enables policies to adapt dynamically to new environments. Our results across ODE, CartPole, and Mujoco Ant benchmarks demonstrate that this approach not only improves extrapolation to out-of-distribution contexts but also provides remarkable robustness against irrelevant distractor variables that typically degrade the performance of standard context-aware agents.

Introduction

Reinforcement Learning (RL) has achieved remarkable success in controlled environments, yet its real-world utility is often limited by a lack of dynamics generalization. An agent trained to perform a task under specific conditions—such as a robot walking on a flat, high-friction surface—frequently fails when those conditions change slightly, such as moving to grass or carrying an unexpected load. This failure stems from the agent's inability to distinguish between the state (the current configuration of the agent and environment) and the context (the underlying rules governing the transition dynamics).

The conventional approach to this problem involves concatenating contextual information directly onto the state vector. However, this "Concat" method often leads to confounding state and context, making the agent sensitive to noise and irrelevant data. This paper introduces the Decision Adapter to address these limitations by treating context as a high-level modulator of the policy's behavior rather than just another input feature.

Methodology

The Decision Adapter Architecture

The core innovation of this work is the separation of state and context processing through a Hypernetwork and an Adapter module. Instead of a single monolithic network, the architecture is split into two functional components:

  1. The Main Policy Network: This network processes the state observations to produce actions.
  2. The Hypernetwork: This secondary network takes the environmental context (e.g., mass, length, friction) as input and generates the weights for a small "Adapter" layer embedded within the main policy.

Key Technical Features

  • Factored Processing: By separating the inputs, the hypernetwork effectively "reconfigures" the main network's behavior for the specific environment before an action is even taken.
  • Bottleneck Design: The adapter uses a down-projection and up-projection architecture. By reducing the dimensionality of the features before expanding them again, the model introduces a low-rank inductive bias. This limits the number of parameters the hypernetwork must generate, preventing overfitting and ensuring the adapter focuses on the most salient contextual adjustments.
  • Skip Connections: The adapter’s output is integrated using a residual connection ($x + A(x)$). This allows the network to maintain a stable base behavior while the adapter applies context-specific "tweaks."
  • Algorithm Agnostic: The Decision Adapter is a modular architectural change that can be integrated with various RL algorithms. For this study, the authors utilized Soft Actor-Critic (SAC) as the base learner.

Experimental Setup

The researchers evaluated the Decision Adapter across three distinct environments, each targeting a specific aspect of generalization:

  1. ODE (Ordinary Differential Equation): A synthetic environment where dynamics are governed by polynomial functions. This provided a controlled setting to measure the agent's ability to extrapolate to contexts far beyond the training range.
  2. CartPole with Distractors: A standard benchmark modified to include up to 100 "distractor" variables—random noise or constant values—in the context vector. This tested the agent's ability to ignore irrelevant information.
  3. Mujoco Ant: A complex locomotion task where a four-legged robot must adapt to significantly varying body masses (ranging from 0.5 to 100), testing the architecture's scalability to high-dimensional state spaces.

Key Insights and Results

Theoretical Intuition: Non-overlapping Goals

The authors identify that context-unaware policies fail most significantly when an action required for progress in one context (e.g., moving left in low gravity) results in negative progress in another (e.g., moving left in high gravity). The Decision Adapter resolves this by allowing the policy to shift its fundamental strategy based on the context.

Robustness to Distractor Variables

One of the most significant findings is the architecture's resilience to noise. In the CartPole environment, standard concatenation models saw a precipitous drop in performance as irrelevant variables were added to the context. In contrast, the Decision Adapter trained with 100 distractor variables actually outperformed a standard Concat model trained with only 20 distractors. This suggests that the hypernetwork structure acts as a natural filter, effectively isolating the true underlying dynamics from environmental noise.

Superior Extrapolation

In the ODE and Mujoco Ant tasks, the Decision Adapter demonstrated a superior ability to generalize to "unseen" dynamics. While baseline models (such as cGate and FLAP) struggled when the environment's mass or physical constants moved outside the training distribution, the Decision Adapter maintained high reward levels, showing a robust understanding of how context modulates transitions.

Discussion and Limitations

While the Decision Adapter represents a significant step forward, several challenges remain:

  • Computational Overhead: Generating weights for every forward pass (or context change) increases the wall-clock training time compared to simpler MLP architectures.
  • Context Availability: The current model assumes access to ground-truth context. In many real-world applications, these variables (like the exact friction coefficient of a floor) are latent and must be inferred from sequences of observations.
  • Training Range Sensitivity: The hypernetwork can still overfit if the training contexts are too narrow, potentially leading to failures when faced with extreme shifts in dynamics.

Conclusion

The Decision Adapter provides a powerful framework for dynamics generalization by leveraging hypernetworks to create context-aware policies. By decoupling state and context and utilizing a bottleneck adapter, the model achieves high performance and unprecedented robustness to irrelevant information. Future research will focus on integrating this architecture with context-inference modules to enable adaptation in environments where the underlying physical parameters are not explicitly known.

Summary updated

BibTeX
@inproceedings{beukman2023dynamics,
  author = {Michael Beukman and Devon Jarvis and Richard Klein and Steven James and Benjamin Rosman},
  title = {{Dynamics Generalisation in Reinforcement Learning via Adaptive Context-Aware Policies}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2023},
  url = {https://openreview.net/forum?id=PJhjkSFlbG},
}
Figure