TL;DR
FOCAL++ improves context-based offline meta-reinforcement learning by combining dual-branch intra-task attention with an inter-task matrix momentum contrastive objective. This architecture provably shrinks the variance of learned task representations and significantly boosts robustness against reward sparsity and dataset distribution shifts across continuous control benchmarks.
What Problem Does This Paper Address?
Offline meta-reinforcement learning (OMRL) aims to train an agent entirely from pre-collected, static datasets across multiple tasks so that it can rapidly generalize to unseen tasks without risky online exploration. A standard approach is context-based offline meta-RL (COMRL), where a context encoder maps transition history into a latent task vector $z$, augmenting the state space for a universal policy.
However, standard COMRL methods struggle with two major failure modes:
- Markov Decision Process (MDP) Ambiguity: Fixed offline datasets often exhibit task-specific state-action distributions (e.g., expert trajectories visiting distinct regions). The context encoder can spuriously latch onto state-action visitation patterns rather than genuine differences in reward or transition dynamics.
- Reward Sparsity: When rewards are mostly zero, vast numbers of transition tuples provide virtually no signal to differentiate tasks, leading to high-variance or degenerate task representations that degrade under distribution shift.
Methods
Building on the prior state-of-the-art framework FOCAL, the authors introduce FOCAL++, which replaces naive MLP encoders and metric learning with:
- Intra-Task Dual Attention:
- Batch-Wise Gated Attention: Uses a squeeze-and-excitation–style gating mechanism across transitions within a batch to adaptively down-weight uninformative, zero-reward transitions and highlight task-critical transitions.
- Sequence-Wise Self-Attention (Transformer): Employs multi-head self-attention along the $(s, a, s', r)$ tuple dimension to model correlations among dynamics and rewards better than standard feed-forward layers.
- The two branches operate in parallel and their outputs are summed to yield the task representation.
- Inter-Task Matrix Momentum Contrast:
- Adapts Momentum Contrast (MoCo) to meta-batches sampled on the fly. A fast query encoder and an EMA (exponential moving average) key encoder produce task vectors compared across tasks via an InfoNCE-style matrix contrastive loss: $\mathcal{L}_z = -\text{Tr}(M)$.
- Theoretical Grounding:
- Surrogate Equivalence (Theorems 3.1 & 3.2): Proves that the matrix momentum contrast objective is mathematically equivalent to the average supervised loss of a mean task classifier, providing a strictly tighter bound on supervised error than standard unsupervised contrastive losses: $$\mathcal{L}_{sup}(E) \le \mathcal{L}_{sup}^\mu(E) \le \mathcal{L}_{un}(E)$$
- Variance Reduction (Theorem 3.3): Proves that learned batch attention strictly reduces representation variance compared to uniform weighting whenever the reward sparsity ratio exceeds a derived analytical threshold.
Offline Transitions (B × C)
├──> Batch-Wise Gated Attention (reweights uninformative steps) ──┐
└──> Sequence-Wise Self-Attention (models (s,a,s',r) relations) ──┴──> Latent Task Vector z
│
Inter-Task Matrix MoCo Loss <──────────┘
Datasets
The authors evaluated on continuous control meta-environments based on MuJoCo and 2D navigation:
- Reward-variation tasks: Sparse-Point-Robot, Sparse-Cheetah-Vel, Sparse-Ant-Fwd-Back, and Sparse-Cheetah-Fwd-Back (where rewards are artificially sparsified outside a spatial or velocity threshold).
- Dynamics-variation tasks: Point-Robot-Wind (transitions drift by task-specific wind vectors) and Walker-2D-Params (randomized mass, inertia, and friction).
- Newly Introduced Benchmark: A Relabeled Sparse-Point-Robot dataset. Transitions from all tasks are pooled to enforce identical state-action coverage across tasks before rewards are computed and sparsified per task. This eliminates state-distribution leakage and isolates whether an encoder can truly infer tasks from reward dynamics alone.
Key Insights and Ideas
- Attention naturally identifies informative transitions: In the relabeled sparse dataset, batch-wise attention assigned near-zero weights to uninformative transitions (0 reward) and peak weights to informative ones, achieving a binary classification AUC of 0.969 without explicit supervision on transition quality.
- Sparsity-driven variance control: The empirical finding that attention lowers representation variance is backed by proof: once dataset sparsity surpasses a threshold determined by the variance ratio between sparse and non-sparse transitions, attention is guaranteed to reduce latent variance.
- Isolating MDP ambiguity through data relabeling: Traditional benchmarks accidentally leak task identities via behavior policy trajectory distributions. Uniformly combining state-action supports and re-evaluating rewards cleanly exposed that baseline methods had relied heavily on this spurious shortcut.
Key Results
- Asymptotic Policy Performance: FOCAL++ consistently outperformed FOCAL, Batch PEARL, Contextual BCQ, and MBML. On Sparse-Ant-Dir, FOCAL++ attained an average return of 719.77 (vs. 429.92 for FOCAL); on Walker-2D-Params, it reached 391.02 (vs. 302.70 for FOCAL).
- Lower Representation Variance: Across all six benchmark suites, FOCAL++ variants reduced the variance of context embeddings over training tasks by up to an order of magnitude (e.g., from $4.31\times 10^{-3}$ down to $7.82\times 10^{-4}$ in Sparse-Cheetah-Dir).
- Robustness to Distribution Shifts: When evaluating policies on contexts from different behavioral distributions (expert, medium, random, mixed), FOCAL++ exhibited substantially lower performance degradation (e.g., a drop of only 13.56 vs. 31.01 for FOCAL on Walker-2D-Params).
- Relabeled Benchmark Diagnostic: While FOCAL failed completely on the relabeled Sparse-Point-Robot benchmark (achieving near-zero return), FOCAL++ variants maintained strong learning performance.
Limitations and Future Work
- Decoupled Training Assumption: Sparse rewards are used exclusively to train the context encoder; the actor-critic policy itself is trained on mini-batches with non-sparse rewards, side-stepping the separate challenge of policy optimization under extreme sparsity.
- Shared State-Action Spaces: The formulation assumes stationary MDPs sharing identical state and action dimensions, which may limit applicability across radically heterogeneous task sets.
- Sample Generation: Evaluating representations still depends on pre-collected offline datasets containing sufficient coverage of transitions with non-zero rewards.
Summary updated