Modern Deep Reinforcement Learning/Hierarchical RL: Goal-Conditioned Hierarchies and Skills

Lesson 5.162,339 words

Hierarchical RL: Goal-Conditioned Hierarchies and Skills

A companion to the options lesson. Options package a behavior; goal-conditioned hierarchies instead give the top level an explicit language of goals — a manager proposes a target state or a latent direction, and a worker is rewarded for reaching it (FeUdal Networks, HIRO).

╌╌╌╌

This builds on Hierarchical RL: Options and the Option-Critic, which formalized temporal abstraction with the option — an initiation set, an internal policy, and a termination condition — showed how options turn an MDP into a semi-Markov decision process that shortens the effective horizon, and learned options end to end with the option-critic.

An option packages a sub-behavior, but nothing in the framework specifies what a useful sub-behavior is; the option-critic discovers them only implicitly, and often collapses. This lesson takes the complementary route: give the hierarchy an explicit language of goals, so a manager can name what the worker should achieve.

Goal-conditioned hierarchies

The option-critic learns a fixed, small set of options. A different and now dominant design makes the top level emit a continuous subgoal rather than pick from a discrete set. The structure is a manager and a worker (equivalently a high-level and low-level policy). The manager, running at a slow timescale, looks at the state and outputs a subgoal — a target for the worker to achieve. The worker, running at the fast primitive timescale, is a goal-conditioned policy that takes the current state and the manager's subgoal and emits primitive actions trying to reach . Every steps the manager looks again and issues a fresh subgoal.

The division of labor is what shortens the horizon. The manager acts once every steps, so its effective horizon is of the flat horizon — a five-hundred-step task becomes fifty manager decisions if . The worker never sees the sparse task reward at all; it is handed a dense intrinsic reward for moving toward whatever subgoal it was given, so its learning problem is short and never reward-starved.

A manager/worker hierarchy. Every steps the manager reads the state and emits a subgoal ; the goal-conditioned worker acts for primitive steps to reach , driven by an intrinsic reward for progress toward it. The manager is trained on the environment's task reward, so its horizon is shortened by the factor .

FeUdal Networks

FeUdal Networks (FuN) of Vezhnevets et al. (2017) is the neural realization of this manager/worker idea, borrowing the feudal framing — a hierarchy of managers setting goals for sub-managers — from much older work.1 Its central design choice is that the manager sets its subgoal as a direction in a learned latent space, not a raw state. The manager, running at low temporal resolution, outputs a goal vector in a -dimensional embedding; the worker is rewarded for moving the state embedding in that direction, measured by cosine similarity.

Two decisions make FuN work. First, the subgoal is directional: the worker's intrinsic reward is the cosine similarity between the direction the state embedding actually moved and the direction the manager requested,

so the worker is pushed to make progress along the manager's goal rather than to arrive at a specific point. Second, the manager is trained with a transition policy gradient that treats the direction the state embedding traveled over steps as the manager's action, so the manager learns which directions in latent space lead to reward without ever needing gradients to flow through the worker. Decoupling the two levels this way — the manager never differentiates through the worker — is what keeps the architecture stable, and it let FuN outperform a flat actor-critic on long-horizon Atari games such as Montezuma's Revenge, where directed subgoals supply the exploration flat agents lack.

FeUdal's directional subgoal. The manager emits a goal direction g in a learned latent space (arrow). The worker is rewarded by the cosine similarity between the direction the state embedding actually moved (s minus its past) and the requested direction g, so it is pushed to make progress along the manager's goal rather than to hit any specific point.

HIRO and off-policy goal relabeling

FeUdal Networks are on-policy and sample-hungry. HIRO — Hierarchical Reinforcement learning with Off-policy correction — of Nachum et al. (2018) makes the manager/worker design off-policy and therefore far more sample-efficient, which is what makes it practical for real continuous-control robotics.2 HIRO makes two choices opposite to FuN's. First, the manager's subgoal is a target in the raw state space (or a subset of it), not a latent direction: the manager outputs a goal state , and the worker's intrinsic reward is simply the negative distance to it,

using a directional goal that is shifted each step so it always points at the target from the current state. Second, both levels are trained off-policy with a replay buffer, reusing every transition many times.

Training the manager off-policy introduces one genuine difficulty — the off-policy correction in HIRO's name. A stored high-level transition records that in state the manager issued subgoal , and steps of worker behavior later received task reward and landed in . But the worker's policy has changed since that experience was collected. Replaying the old transition to update the manager is invalid, because the same subgoal would no longer produce the same behavior from the current worker. HIRO corrects this with off-policy goal relabeling: it re-labels the stored subgoal with the subgoal that would have made the current worker most likely to have produced the actions actually observed,

found by a small search over candidate goals. The manager is then updated as though it had issued the corrected subgoal , so its target matches the behavior the current worker would actually produce. This one correction is what lets the manager learn off-policy at all, and it moved hierarchical RL from Atari scores to learning multi-stage locomotion (a simulated ant navigating and pushing objects) directly from primitive torques.

HIRO's off-policy goal relabeling. A stored high-level transition recorded subgoal g and the c worker actions it induced. Since the worker has changed, g no longer explains those actions; HIRO searches candidate subgoals for the g-tilde under which the CURRENT worker would most likely have taken the same actions, and updates the manager as if it had issued g-tilde.
Algorithm:HIRO\textsc{HIRO} — off-policy manager/worker with goal relabeling
  1. 1
    initialize manager μhi\mu_{\text{hi}}, worker πlo\pi_{\text{lo}}, replay buffers
  2. 2
    for each episode do
  3. 3
    initialize state s0s_0
  4. 4
    for t=0,c,2c,t = 0, c, 2c, \ldots do
  5. 5
    gtμhi(st)g_t \gets \mu_{\text{hi}}(s_t)
    manager sets a subgoal every cc steps
  6. 6
    for i=ti = t to t+c1t + c - 1 do
  7. 7
    aiπlo(si,gi)a_i \gets \pi_{\text{lo}}(s_i, g_i)
    worker acts toward the subgoal
  8. 8
    take aia_i, observe rir_i, si+1s_{i+1}
  9. 9
    riisi+gisi+1r^i_i \gets -\lVert s_i + g_i - s_{i+1} \rVert
    intrinsic worker reward
  10. 10
    gi+1si+gisi+1g_{i+1} \gets s_i + g_i - s_{i+1}
    shift goal to stay directional
  11. 11
    store worker transitions in the low-level buffer
  12. 12
    g~t\tilde g_t \gets relabel gtg_t to best explain the actions taken
  13. 13
    store (st,g~t,ri,st+c)(s_t, \tilde g_t, \textstyle\sum r_i, s_{t+c}) in the high-level buffer
  14. 14
    update πlo\pi_{\text{lo}} and μhi\mu_{\text{hi}} off-policy from their buffers

A note on hindsight for sparse goals

Goal-conditioned learning has a companion technique for the same sparse-reward problem. When a worker is asked to reach goal and fails, the standard reward is or throughout — an uninformative signal, and if the goal is hard to reach, every early episode returns the same signal, so the worker learns nothing. Hindsight Experience Replay (HER) of Andrychowicz et al. (2017) extracts a learning signal from failure by a simple relabeling: an episode that failed to reach did reach whatever state it ended in.3 So store the trajectory twice — once with the original goal (a failure), and once with the achieved final state as the goal (a success). Under the same actions earn the success reward, and the goal-conditioned policy learns how to reach from a trajectory that reached it, even though was never what we asked for.

A worked relabeling. Say a robot arm is asked to move a puck to goal cell on a grid, with reward on reaching and every other step. An early, clumsy episode pushes the puck along the states and stops there, nowhere near . Under the original goal the whole trajectory scores at every step, with no signal about what worked. HER stores the same four transitions a second time with the achieved final state substituted as the goal. Now the last transition, with goal , earns reward (goal reached), and the goal-conditioned value function gains a positive example: from , this action reaches . The policy learns to reach from a trajectory that did reach , even though was never what we asked for. Repeated across episodes, the arm becomes able to reach an ever-wider set of nearby goals; the set of reachable goals expands outward until it includes the real target .

Hindsight relabeling. The trajectory (blue) aimed at goal g fails, earning -1 throughout under g. Relabeled with the achieved final state g' as the goal (green), the same transitions now include a success, so the policy learns how to reach g' from a run that actually reached it. Every failed episode becomes a success for some goal.

HER's advantage is that every trajectory teaches the policy how to reach the goals it happened to hit, and as the policy improves those achieved goals drift toward the real ones. It composes directly with the hierarchies above: a HIRO or FeUdal worker is a goal-conditioned policy, so HER-style relabeling of its subgoal transitions gives it dense signal even before it can reach the manager's harder requests, which is why hindsight relabeling and goal-conditioned hierarchies are so often deployed together on sparse-reward robotics.

Unsupervised skills and goal-space learning

The methods above still need a task reward to discover their abstractions. Post-Sutton-&-Barto work asks a sharper question: can useful skills be learned before any task reward, from the structure of the environment alone, and can the goal space itself be learned rather than hand-picked?

Unsupervised skill discovery. DIAYNDiversity is All You Need (Eysenbach et al. 2018) — learns a set of distinguishable skills with no reward at all.4 It samples a latent skill , runs a skill-conditioned policy , and rewards the policy by how well a discriminator can infer from the states visited — an intrinsic reward for making each skill visit a distinctive region of state space. Formally it maximizes the mutual information between visited states and the skill. The result is a repertoire of diverse behaviors (a cheetah that learns to run, flip, and bound, each a different ) that can then serve as the option set for a hierarchy, learned entirely before the downstream task is known.

Unsupervised skill discovery (DIAYN). A skill latent z conditions the policy; a discriminator tries to predict which skill produced the visited states. Rewarding the policy for being easy to identify pushes different skills into different regions of state space, yielding a diverse behavior repertoire with no task reward.

Related information-theoretic objectives — empowerment, variational intrinsic control (Gregor et al. 2016) — share the idea that a good skill is one whose outcome the agent can reliably control and distinguish.

Learning the goal space. HIRO and FeUdal fix the space subgoals live in — raw states or a latent direction. HAC (Levy et al. 2019) stacks more than two levels and uses hindsight at every level to train them in parallel, and a line of work on learned goal representations (e.g. representation objectives that make the goal space metric match reachability) tackles the problem that raw-state subgoals are a poor target in high-dimensional observation spaces like images. The manager should propose goals in a space where distance means steps to reach, not pixels different.

Automatic curricula over goals. Once a worker is goal-conditioned, which goals should it practice? Hindsight practices the goals the policy happened to hit; a complementary line generates goals of intermediate difficulty on purpose — GoalGAN (Florensa et al. 2018) trains a generator to propose goals the current policy solves neither always nor never, keeping the worker at the edge of its competence. This is the single-agent analogue of the autocurriculum that self-play produced in the multi-agent lesson: difficulty that tracks competence, generated automatically.

These directions share the hierarchical premise — a level of decision above primitives — but push the source of the abstraction from the task reward toward the environment's own structure, which is what lets hierarchy scale to tasks where no one can name the right subgoals in advance.

The shared idea

Every method here is one answer to the same question: how do you get an agent to act coherently over a horizon far longer than one-step credit assignment can manage? The answer is always to introduce a level of decision above the primitive one, so that a single high-level choice commits the agent to a directed, extended course of behavior.

MethodAbstraction unitLearned byKey mechanism
Options (SPS 1999)option designed; planned via SMDPtemporally-extended action, discount
Option-criticdiscrete optionsend-to-end policy gradientintra-option + termination gradients
FeUdal Networkslatent-direction subgoalon-policy, decoupled levelsdirectional intrinsic reward, transition gradient
HIROraw-state subgoaloff-policy, replaygoal relabeling for off-policy manager
HERachieved-goal relabelany off-policy learnerturn failures into successes for some goal

The rows form a progression. The options framework supplied the abstraction and the SMDP planning to use it, but assumed the options were given. Option-critic made the options themselves differentiable. FeUdal Networks and HIRO replaced the discrete option menu with a continuous subgoal a manager emits on the fly, and HIRO's off-policy correction plus HER's hindsight relabeling made that design sample-efficient enough for real control. Underneath all of it sits the one claim that motivated the frontiers discussion of temporal abstraction: a hierarchy makes a hard problem easier by arithmetic. It turns one problem of horizon into a shallow tree of problems of horizon , and short-horizon RL is the part we already know how to solve.

Footnotes

  1. Vezhnevets, Osindero, Schaul, Heess, Jaderberg, Silver, Kavukcuoglu (2017), FeUdal Networks for Hierarchical Reinforcement Learning, ICML — a manager sets directional subgoals in a learned latent space at low temporal resolution and a worker is rewarded by cosine similarity for moving in that direction; the manager is trained by a transition policy gradient that decouples it from the worker.
  2. Nachum, Gu, Lee, Levine (2018), Data-Efficient Hierarchical Reinforcement Learning, NeurIPS — HIRO: a two-level manager/worker with raw-state subgoals trained off-policy, using off-policy goal relabeling to correct high-level transitions for the changing worker, enabling sample-efficient continuous control.
  3. Andrychowicz, Wolski, Ray, Schneider, Fong, Welinder, McGrew, Tobin, Abbeel, Zaremba (2017), Hindsight Experience Replay, NeurIPS — relabels failed goal-conditioned trajectories with goals actually achieved along them, so every episode yields a success signal for some goal and sparse-reward goal-conditioned tasks become learnable.
  4. Eysenbach, Gupta, Ibarz, Levine (2018), Diversity is All You Need: Learning Skills without a Reward Function, ICLR 2019 — DIAYN learns a set of distinguishable skills by maximizing the mutual information between visited states and a skill latent, rewarding the policy for making each skill identifiable, with no task reward; see also Gregor, Rezende, Wierstra (2016), Variational Intrinsic Control, for the empowerment-style precursor.

╌╌ END ╌╌