Dynamics-Aligned Shared Hypernetworks for Contextual RL under Discontinuous Shifts

Jan Benad, Pradeep Kr. Banerjee, Frank Röder, Nihat Ay, Martin V. Butz, Manfred EppearXiv 2026

TL;DR

Contextual reinforcement learning (RL) often fails when hidden environmental factors cause sudden, discontinuous changes in how actions affect the world—such as a control stick suddenly reversing its polarity. This paper introduces DMA*-SH, a framework that uses a single hypernetwork trained purely on dynamics prediction to generate shared adapter weights across the policy, value function, and dynamics model. This approach achieves robust zero-shot generalization by cleanly separating mode identification from control.

What Problem Does This Paper Address?

Imagine opening a colleague's laptop only to find that the trackpad scrolls in the exact opposite direction of your own. Your deeply ingrained muscle memory suddenly works against you. In contextual RL, this is known as a discontinuous context-to-dynamics shift.

Standard contextual RL algorithms typically assume that changes in the environment (like varying mass or friction) happen smoothly. They rely on "smooth" inductive biases, such as concatenating a latent context vector to the network inputs or applying Gaussian priors. However, when a shift is discontinuous—such as an actuator inversion or swapped control channels—these smooth biases end up blurring distinct operational modes into an unviable "averaged" behavior.

The authors tackle the challenge of achieving zero-shot adaptation when the context is latent (hidden) and changes the action-effect map discontinuously, meaning there is no valid interpolation between incompatible control laws.

Methods

The authors propose DMA*-SH (Dynamics Model-Aligned, Shared Hypernetwork), which builds on Dynamic Model-Aligned (DMA) representation learning through three core architectural choices:

  1. Robust Context Inference (DMA*): The agent infers a latent context embedding ($z_t$) from a history window of past transitions. To make this encoder robust against noise, they introduce random input masking (corrupting features during training) and strict input/output normalization layers (AvgL1Norm and SimNorm) to prevent representation collapse.
  2. Multiplicative Hypernetwork Modulation: Instead of simply concatenating the inferred context $z_t$ to the inputs of the policy or value networks, $z_t$ is fed into a hypernetwork. This hypernetwork generates a small set of bottleneck adapter weights ($\omega$) that multiplicatively modulate the layers of the main networks.
  3. Dynamics-Grounded Weight Sharing: A single hypernetwork is shared across the forward dynamics model, the policy ($\pi$), and the action-value function ($Q$). Crucially, during RL updates, the gradients from the policy and critic are detached (using a stop-gradient) before reaching the hypernetwork. This ensures the context representation is shaped exclusively by the objective of predicting forward dynamics, acting as a strong structural prior.
Figure 1: (a) In vanilla DMA, the inferred context zt is concatenated to the RL inputs. (b) In DMA*-SH, a hypernetwork hη conditioned on zt generates adapter weights ω that are used by the forward dynamics model and the RL networks. The context encoder and hypernetwork are trained via the reconstruction objective Lϕ,θ,η in (2), while during RL updates gradients through ω = hη(zt) are stopped so that the policy and critic losses do not backpropagate to η (or to zt) through the shared adapter pathway zt →ω →(π, Q).

Datasets

To evaluate their method on these specific types of disruptions, the authors introduce the Actuator Inversion Benchmark (AIB). AIB spans several simulated environments (built on MuJoCo, DeepMind Control Suite, and Gymnasium) and categorizes them into:

  • Non-overlapping (Discontinuous): Environments featuring binary sign flips (actuator inversion) or swapped control channels (actuator permutations). Examples include modified versions of Double Integrator (DI), Cartpole, Cheetah, and Reacher.
  • Overlapping / Weakly Non-overlapping: Environments varying continuous physical parameters like mass, friction, or gravity (e.g., BallInCup, Walker, Hopper).

Key Insights and Ideas

  • The Power of Multiplicative Adapters: The authors mathematically prove an expressivity separation result. Standard concatenation networks (which are continuous piecewise-linear) struggle to exactly represent sudden coordinate swaps or sign flips without an inefficiently large number of partitions. Hypernetworks inherently introduce bilinear/multiplicative interactions, allowing them to execute sharp, discrete mode switches perfectly.
  • The Informativeness-Variability Paradox: Intuitively, you might think a context encoder should capture as much information about the environment as possible. However, the authors show that capturing too much continuous "nuisance" variation (like slight mass changes) increases policy-gradient variance. DMA*-SH compresses within-mode variations while keeping the critical discontinuous modes well-separated, stabilizing the learning process.
  • Factorization of Identity and Control: By blocking reward gradients from altering the hypernetwork, the architecture cleanly separates mode identification (handled by dynamics prediction) from mode-conditioned control (handled by the RL policy).

Key Results

On the held-out tasks of the Actuator Inversion Benchmark, DMA*-SH demonstrated substantial performance gains:

  • Zero-Shot Generalization: It outperformed standard Domain Randomization (DR) by 58.1% on average across all evaluation tasks.
  • Surpassing Baselines: It outperformed a standard context-aware concatenation baseline (Concat) by 11.5% and a strong context-aware hypernetwork baseline (Decision Adapter) by 4.6%.
  • Robustness to Non-Overlap: The edge was most pronounced in non-overlapping (discontinuous) environments, where it beat Domain Randomization by 97.3% in out-of-distribution testing.

Limitations and Future Work

While DMA*-SH excels at handling action-effect flips, the authors note a few limitations:

  • Error Propagation: Because control is tightly coupled to the dynamics model through the shared hypernetwork, any severe modeling errors or unmodeled dynamics can corrupt the generated adapter weights and degrade control performance.
  • Reward-Modifying Contexts: The current framework assumes that context changes transition dynamics while rewards remain fixed. It may be less effective if the hidden context primarily alters the reward function or requires non-factorizable policy changes.
  • Hypernetwork Capacity: Finding the right capacity bottleneck for the hypernetwork remains a practical challenge—too small limits expressiveness, while too large risks overfitting.

Summary updated

BibTeX
@misc{benad2026dynamics,
  author = {Jan Benad and Pradeep Kr. Banerjee and Frank Röder and Nihat Ay and Martin V. Butz and Manfred Eppe},
  title = {{Dynamics-Aligned Shared Hypernetworks for Contextual RL under Discontinuous Shifts}},
  year = {2026},
  eprint = {2602.06550},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2602.06550},
}
Figure