Horizon Generalization in Reinforcement Learning

Vivek Myers, Catherine Ji, Benjamin Eysenbach · DOI

Abstract

Reinforcement learning (RL) agents frequently struggle with "long-horizon" tasks where the complexity of finding a solution grows exponentially with the distance to the goal. This paper introduces the concept of Horizon Generalization: the capacity for a policy trained exclusively on nearby goals to successfully reach distant, unseen goals. We demonstrate that this property is fundamentally linked to Planning Invariance—the principle that an optimal policy should select the same action whether it is aiming for a final destination or a waypoint along the optimal path. By leveraging Quasimetric Architectures, we provide a theoretical and empirical framework for achieving zero-shot generalization across temporal scales.

Introduction

In Goal-Conditioned Reinforcement Learning (GCRL), the objective is to train agents capable of reaching any arbitrary state within an environment. However, a significant bottleneck exists: collecting data for distant goals is often prohibitively expensive or physically impossible. While existing research has extensively explored "perceptual generalization" (e.g., robustness to changes in lighting or textures), "temporal generalization"—or the ability to bridge the gap between short-term training and long-term execution—remains under-addressed.

The core challenge lies in whether an agent can learn from "easy" local tasks and automatically apply that knowledge to "hard" distant tasks. Standard RL agents typically fail this test because their internal representations do not capture the underlying geometry of the state space. When a goal exceeds the horizon seen during training, the policy often degrades, failing to stitch together known local trajectories into a global path.

Theoretical Framework: Planning Invariance and Quasimetrics

To address the horizon gap, this research bridges short-term training and long-term execution through two primary concepts:

1. Planning Invariance

A policy is defined as "invariant to planning" if decomposing a complex task into a series of simpler waypoints provides no additional performance benefit. In an ideal scenario, an optimal policy should inherently "know" the path; if a planner is required to improve the policy's success rate, the policy has not yet achieved full generalization.

2. Quasimetric Architectures

The authors utilize quasimetrics—distance functions that satisfy the triangle inequality ($d(s, g) \le d(s, w) + d(w, g)$) while allowing for asymmetry. Asymmetry is crucial in RL because moving between two states may have different costs depending on direction (e.g., moving uphill versus downhill).

The paper proves that if a policy is defined greedily with respect to a learned quasimetric, it is inherently planning invariant. Using an inductive proof, the authors show that this invariance facilitates horizon generalization: if an agent is optimal over a small radius $c$, planning invariance allows that optimality to extend to $2c$, then $4c$, and eventually the entire reachable state space.

Experimental Methodology

The theories were evaluated across a range of environments with varying degrees of complexity:

  • Didactic Tabular Maze: Used for visualizing action alignment and verifying core theoretical proofs.
  • JaxGCRL Benchmarks: High-dimensional continuous control tasks including Ant (27D observation space), AntMaze (complex S-shaped navigation), and Humanoid (complex locomotion).
  • Baselines: The proposed Contrastive Metric Distillation (CMD-1) was compared against standard Soft Actor-Critic (SAC) and Contrastive RL (CRL).

Key Insights

  • Triangle Inequality as Inductive Bias: By constraining neural network architectures to obey the triangle inequality via quasimetric layers, the model gains a geometric "sense" that allows it to effectively stitch short paths into long-range trajectories.
  • The $\eta$ Parameter: The authors introduce a horizon generalization parameter ($\eta$). A value of $\eta \ge 0.5$ theoretically implies that the policy's reach is infinite, meaning it can generalize to any distance regardless of the training horizon.
  • Bellman Error Correlation: Architectures that exhibit superior horizon generalization also demonstrate lower Bellman errors during training, even without explicit TD-loss training, suggesting that geometric constraints improve the fundamental learning signal.

Results and Discussion

The quasimetric-based CMD-1 method significantly outperformed standard MLP-based contrastive RL in all long-horizon evaluations. In the Ant environment, CMD-1 maintained high success rates at distances of 25 meters, even when the training data was restricted to goals within 10 meters.

In the more complex Humanoid and AntMaze tasks, quasimetric policies achieved substantially higher $\eta$ values (e.g., 0.93 for CMD vs. 0.10 for CRL in AntMaze). This confirms that these policies retain their efficacy as goals move further away, whereas standard architectures experience rapid performance decay. Furthermore, even simple geometric constraints, such as using an L2-distance parameterized architecture, provided a measurable boost in generalization compared to standard MLPs.

Conclusion

Horizon generalization represents a significant step toward more sample-efficient and robust RL. By embedding geometric inductive biases into policy architectures, we can move beyond simple pattern matching toward a structural understanding of environment connectivity.

However, limitations remain. The "base case" requirement is strict: the agent must be successful at all nearby goals for the recursive generalization to function; any "holes" in local knowledge will cause the system to fail. Future work will explore extending these geometric biases to stochastic environments, robotic manipulation, and raw pixel-based observations.

Summary updated

BibTeX
@inproceedings{myers2025horizon,
  author = {Vivek Myers and Catherine Ji and Benjamin Eysenbach},
  title = {{Horizon Generalization in Reinforcement Learning}},
  booktitle = {International Conference on Learning Representations},
  year = {2025},
  url = {https://openreview.net/forum?id=BH8Nrt2dPf},
}
Figure