Abstract
Standard offline reinforcement learning (RL) assumes a stationary environment, yet real-world datasets often exhibit "structured non-stationarity" due to factors like mechanical wear or sensor drift. This paper introduces COSPA (Contrastive Predictive Non-Stationarity Adaptation), a framework that leverages contrastive learning to identify and predict hidden environmental shifts. By modeling the environment as a Dynamic-Parameter MDP (DP-MDP), COSPA uses Contrastive Predictive Coding (CPC) for latent inference and a recurrent neural network for future state prediction. Experimental results on complex locomotion tasks demonstrate that COSPA achieves near-optimal performance, significantly outperforming existing generative methods in high-dimensional state spaces.
Introduction: The Challenge of Structured Non-Stationarity
Most RL algorithms operate under the assumption of stationarity—the underlying physics and reward structures remain constant. However, real-world robotic deployments often span months, during which hardware degrades, joints loosen, or payloads change. When these diverse experiences are aggregated into a single offline dataset, standard agents often learn a "one-size-fits-none" policy that fails to account for these subtle but critical shifts.
The authors formalize this as structured non-stationarity within a Dynamic-Parameter MDP (DP-MDP). In this model, hidden parameters (e.g., friction, mass) remain constant during a single episode but evolve slowly between deployments.
The COSPA Framework
To address this, the authors propose COSPA, a multi-stage pipeline designed to infer, predict, and adapt to these hidden shifts.
1. Latent Inference via Contrastive Predictive Coding (CPC)
Instead of using generative models like Variational Autoencoders (VAEs), which can struggle with high-dimensional state reconstruction, COSPA employs CPC. The model learns a representation $z$ by distinguishing between trajectory segments from the same deployment versus those from different ones. This discriminative approach focuses on features relevant to environmental shifts rather than irrelevant state details.
2. Latent Prediction
Because environment parameters evolve over time, an agent must anticipate the conditions of the upcoming episode. COSPA trains a Recurrent Neural Network (RNN) to predict the next latent state ($z_{i+1}$) based on a historical window of previous trajectories.
3. Policy Training and Adaptation
The final step involves training a conditional policy using TD3+BC. By conditioning both the policy and the critic on the predicted latent state, the agent can adapt its behavior—for instance, applying more torque when it predicts a "heavy" robot configuration.
Experimental Evaluation
COSPA was evaluated across several simulated environments, ranging from low-dimensional navigation to high-dimensional locomotion tasks like the Brax Ant (with evolving leg lengths or body mass) and Barkour-Weight (a quadruped carrying varying payloads).
Key Results
- Performance: COSPA consistently matched or exceeded "Oracle" baselines that had direct access to ground-truth parameters.
- High-Dimensional Robustness: In the Ant-Weight task, COSPA achieved a reward of ~3104, outperforming state-of-the-art methods like BOReL (~2637) and ContraBAR (~2715).
- Representation Quality: T-SNE visualizations confirmed that COSPA's contrastive representations clustered environmental states more effectively than generative alternatives.
Discussion and Limitations
A core insight of this work is that Contrastive > Generative in high dimensions. Generative models often waste capacity on "fluff," whereas CPC focuses on discriminative features. However, COSPA assumes intra-episode stationarity; it is not currently designed for "online" shifts that occur mid-episode. Additionally, the method requires a "context" of previous trajectories for inference, meaning it cannot adapt instantly to a completely novel, unobserved deployment.
Conclusion
COSPA provides a robust framework for offline RL in non-stationary environments. By combining contrastive latent inference with temporal prediction, it enables agents to navigate the complexities of real-world data collection where "wear and tear" is the rule rather than the exception.
Summary updated