Simple Algorithm
Reinforcement Learning · Fixed Point · 28 min

Options & Hierarchical RL

Semi-MDPs, the option-critic and feudal agents.

An option is an action that can last: walk to the door, grasp the cup. Adding options to an MDP changes its time scale without changing its theory, because the result is a semi-MDP with Bellman equations of its own. Options can then be planned with, interrupted, learned about off-policy, trained end to end and even discovered. This lesson develops that theory and then asks the empirical question that has followed hierarchical RL from the start: when does any of it actually help?

What you’ll learn

  • Derive the Bellman equations over options from the return, show that they contract at rate max⁡E[γτ]\max\E[\gamma^\tau], and prove that interrupting options never hurts.
  • Write intra-option Q-learning and state the conditions under which it learns the values of all options from a single stream of experience.
  • State the option-critic's intra-option policy gradient and termination gradient theorems, derive the termination gradient, and explain why learned options degenerate.
  • Explain HIRO's off-policy correction for goal-setting managers, option discovery from the graph Laplacian, and what the evidence says about when hierarchy helps.

Options make a semi-MDP

Recall the definition from Hierarchy, Meta-Learning & Generalist Agents: an option ω=(Iω,πω,βω)\omega=(\mathcal I_\omega,\pi_\omega,\beta_\omega) starts in a state of Iω\mathcal I_\omega, follows πω\pi_\omega, and stops on arrival in ss with probability βω(s)\beta_\omega(s). It is Markov if πω\pi_\omega and βω\beta_\omega depend only on the current state, and semi-Markov if they may depend on the history since the option started, which allows, for example, time-outs and options that call other options. A policy μ\mu over options chooses among the options Ω(s)\Omega(s) available in ss whenever the current one ends.

DerivationBellman equations over options
  1. Gt=∑k=0τ−1γkRt+k+1 + γτGt+τG_t=\sum_{k=0}^{\tau-1}\gamma^kR_{t+k+1}\ +\ \gamma^{\tau}G_{t+\tau}

    Start option ω\omega in ss at time tt and let τ\tau be its random duration. Split the return where the option ends: what was collected while ω\omega ran, plus the return from where it ended, τ\tau steps later:

  2. Qμ(s,ω)=rω(s)+∑s′pω(s′∣s) Vμ(s′)Q^\mu(s,\omega)=r^\omega(s)+\sum_{s'}p^\omega(s'\mid s)\,V^\mu(s')

    Take expectations given St=sS_t=s and the choice of ω\omega. For Markov options the future after termination depends only on St+τS_{t+\tau}, so the value splits into the option's model, its discounted reward rω(s)r^\omega(s) and discounted end-state measure pω(s′∣s)=∑kγkPr⁡(τ=k,St+k=s′)p^\omega(s'\mid s)=\sum_k\gamma^k\Pr(\tau=k,S_{t+k}=s'):

  3. VΩ⋆(s)=max⁡ω∈Ω(s)[rω(s)+∑s′pω(s′∣s) VΩ⋆(s′)]V^\star_\Omega(s)=\max_{\omega\in\Omega(s)}\Big[r^\omega(s)+\sum_{s'}p^\omega(s'\mid s)\,V^\star_\Omega(s')\Big]

    Choosing the best option at every decision gives the optimality equation. It is an ordinary Bellman equation with the discount folded into pωp^\omega, and its operator contracts with modulus max⁡s,ω∑s′pω(s′∣s)=max⁡s,ωE[γτ]≤γ\max_{s,\omega}\sum_{s'}p^\omega(s'\mid s)=\max_{s,\omega}\E[\gamma^\tau]\le\gamma. If every option lasts at least kk steps the modulus is at most γk\gamma^k. Once the primitive actions are included, as they must be for the equality below, the modulus is γ\gamma again; options then speed planning in another way, when it starts from pessimistic values (the four-rooms demonstration started from 0): a long option carries value many cells in one backup (Mann & Mannor, 2014).

  4. VΩ⋆ ≤ V⋆,with equality if A⊆ΩV^\star_\Omega\ \le\ V^\star,\qquad\text{with equality if }\mathcal A\subseteq\Omega

    Every policy over options is a (generally non-Markov) policy of the underlying MDP, so options cannot beat the MDP's optimum. If Ω\Omega contains every primitive action, a deterministic optimal MDP policy is itself a policy over Ω\Omega, and equality holds:

Check your understanding

In a four-rooms gridworld, Ω\Omega contains only hallway options, each taking the agent from anywhere in a room to one of its doorways, and no primitive actions. The goal is a cell in the middle of a room. What is true?

  1. VΩ⋆=V⋆V^\star_\Omega=V^\star, since options are only shortcuts
  2. VΩ⋆≥V⋆V^\star_\Omega\ge V^\star, since options plan further ahead
  3. VΩ⋆≤V⋆V^\star_\Omega\le V^\star, and here strictly less: no policy over these options ever reaches the goal
  4. The semi-MDP is not well defined without primitive actions
Show the answer

C. VΩ⋆≤V⋆V^\star_\Omega\le V^\star, and here strictly less: no policy over these options ever reaches the goal

Every option ends in a doorway, so no sequence of them reaches a cell inside a room. Options restrict the set of policies unless they include the primitives (or options that can express an optimal policy). Sutton, Precup & Singh's remedy is to plan with options and primitive actions, which keeps V⋆V^\star and still speeds planning.

Interruption and intra-option learning

Call-and-return execution commits to an option until it ends. That is wasteful when, halfway along, the option has become a bad idea, and it is wasteful in learning, where each experience updates only the option that happened to be running. Both can be fixed without leaving the theory.

DerivationProof sketch: interruption is policy improvement
  1. max⁡(Qμ(s,ω), Vμ(s)) ≥ Qμ(s,ω)\max\big(Q^\mu(s,\omega),\,V^\mu(s)\big)\ \ge\ Q^\mu(s,\omega)

    Treat every time step as a decision point with two choices while ω\omega runs: continue, worth Qμ(s,ω)Q^\mu(s,\omega), or terminate and re-choose, worth Vμ(s)V^\mu(s), both evaluated under μ\mu. Wherever μ′\mu' deviates from μ\mu, it picks the better of the two:

  2. Vμ′ ≥ VμV^{\mu'}\ \ge\ V^\mu

    So μ′\mu' is greedy, at its deviation points, with respect to μ\mu's own values, and the policy improvement theorem applies in this finer semi-MDP: following μ′\mu' for one decision and μ\mu afterward is no worse than μ\mu, and by induction neither is following μ′\mu' throughout.

Intra-option learning extracts more from each step. While one option runs, every other Markov option whose policy would have taken the same action in the same state could have produced exactly this transition, so the transition is a valid sample for it as well, an off-policy argument at the level of options. The update bootstraps from the value of arriving in the next state with the option still running.

Q(St,ω)←Q(St,ω)+α[Rt+1+γ U(St+1,ω)−Q(St,ω)]  for all ω with πω(St)=At,U(s,ω)=(1−βω(s)) Q(s,ω)+βω(s)max⁡ω′Q(s,ω′)Q(S_t,\omega)\leftarrow Q(S_t,\omega)+\alpha\big[R_{t+1}+\gamma\,U(S_{t+1},\omega)-Q(S_t,\omega)\big]\ \ \text{for all }\omega\text{ with }\pi_\omega(S_t)=A_t,\qquad U(s,\omega)=\big(1-\beta_\omega(s)\big)\,Q(s,\omega)+\beta_\omega(s)\max_{\omega'}Q(s,\omega')
One-step intra-option Q-learning. UU averages continuing the option with terminating and switching to the best one. Sutton, Precup & Singh (1999) proved that for Markov options with deterministic policies it converges with probability 1 to the optimal option values, whatever options are executed, provided every primitive action is taken in every state infinitely often and the step sizes satisfy the usual conditions.
Predict before you look

An option ω\omega is running; the agent takes the action ω\omega prescribes, receives R=1R=1 and lands in s′s', where βω(s′)=0.25\beta_\omega(s')=0.25, Q(s′,ω)=4Q(s',\omega)=4 and max⁡ω′Q(s′,ω′)=8\max_{\omega'}Q(s',\omega')=8. With γ=0.9\gamma=0.9, what is the intra-option target R+γ U(s′,ω)R+\gamma\,U(s',\omega)?

Show the answer

5.5

U=0.75⋅4+0.25⋅8=5U=0.75\cdot4+0.25\cdot8=5, and the target is 1+0.9⋅5=5.51+0.9\cdot5=5.5. The same transition also updates every other option whose policy would have chosen this action in this state, each with its own β\beta and QQ.

Learning options end to end: the option-critic

So far the options were given. The option-critic (Bacon, Harb & Precup, 2017) learns them by gradient ascent: each option has a parameterized policy πω,θ\pi_{\omega,\boldsymbol\theta} and termination function βω,ϑ\beta_{\omega,\boldsymbol\vartheta}, and a policy over options picks among them (in the paper, ε\varepsilon-greedily with respect to QΩQ_\Omega). Three value functions organize the computation:

QΩ(s,ω)=∑aπω,θ(a∣s) QU(s,ω,a),QU(s,ω,a)=r(s,a)+γ∑s′P(s′∣s,a) U(ω,s′),U(ω,s′)=(1−βω,ϑ(s′))QΩ(s′,ω)+βω,ϑ(s′) VΩ(s′)Q_\Omega(s,\omega)=\sum_a\pi_{\omega,\boldsymbol\theta}(a\mid s)\,Q_U(s,\omega,a),\qquad Q_U(s,\omega,a)=r(s,a)+\gamma\sum_{s'}P(s'\mid s,a)\,U(\omega,s'),\qquad U(\omega,s')=\big(1-\beta_{\omega,\boldsymbol\vartheta}(s')\big)Q_\Omega(s',\omega)+\beta_{\omega,\boldsymbol\vartheta}(s')\,V_\Omega(s')
QΩQ_\Omega is the value of running option ω\omega from ss, QUQ_U the value of taking action aa inside it, and UU the value of arriving in s′s' with ω\omega running, which either continues or terminates and hands control back to the policy over options, whose value is VΩV_\Omega.
DerivationWhere the termination gradient comes from
  1. ∂U(ω,s′)∂ϑ=−∂βω(s′)∂ϑ(QΩ(s′,ω)−VΩ(s′))+(1−βω(s′))∂QΩ(s′,ω)∂ϑ+βω(s′) ∂VΩ(s′)∂ϑ\frac{\partial U(\omega,s')}{\partial\boldsymbol\vartheta}=-\frac{\partial\beta_\omega(s')}{\partial\boldsymbol\vartheta}\big(Q_\Omega(s',\omega)-V_\Omega(s')\big)+\big(1-\beta_\omega(s')\big)\frac{\partial Q_\Omega(s',\omega)}{\partial\boldsymbol\vartheta}+\beta_\omega(s')\,\frac{\partial V_\Omega(s')}{\partial\boldsymbol\vartheta}

    Differentiate the value upon arrival. The product rule gives a direct term, through β\beta, and indirect terms, through the values:

  2. (1−βω)∂QΩ(s′,ω)∂ϑ+βω∂VΩ(s′)∂ϑ=γ E[∂U(ωnext,S′′)∂ϑ ∣ s′,ω]\big(1-\beta_\omega\big)\frac{\partial Q_\Omega(s',\omega)}{\partial\boldsymbol\vartheta}+\beta_\omega\frac{\partial V_\Omega(s')}{\partial\boldsymbol\vartheta}=\gamma\,\E\Big[\frac{\partial U(\omega_{\text{next}},S'')}{\partial\boldsymbol\vartheta}\ \Big|\ s',\omega\Big]

    QΩ(s′,ω)Q_\Omega(s',\omega) depends on ϑ\boldsymbol\vartheta only through UU one step later, and VΩ(s′)V_\Omega(s') is an average of QΩ(s′,⋅)Q_\Omega(s',\cdot) under the (fixed) policy over options. So the indirect terms are the same derivative one step later, averaged over which option runs next: ω\omega if it continued, a fresh choice if it stopped:

  3. Unrolling the recursion collects the direct term at every future state–option pair, with its discounted probability, which is the theorem. Gradient ascent therefore raises the probability of terminating where the running option is worse than average, AΩ<0A_\Omega<0, and lowers it where the option is better. In practice the sum is sampled along the trajectory and AΩA_\Omega is estimated from the learned QΩQ_\Omega.

Maximizing the return of one task gives options no reason to be distinct or to last, and learned options degenerate: they terminate at almost every step (back to primitive actions) or never terminate (one option does everything). Bacon et al. added a small margin ξ\xi to the advantage in the termination gradient, AΩ+ξA_\Omega+\xi, which discourages switching; Harb, Bacon, Klissarov & Precup (2018) framed it as a deliberation cost, a price paid at each switch, motivated by bounded rationality. The deeper issue is that one task's return does not define what makes an option good. Options pay off through reuse, across tasks or over a long lifetime, which a single-task objective cannot see.

Check your understanding

At state s′s' the running option ω\omega has QΩ(s′,ω)=3Q_\Omega(s',\omega)=3, while VΩ(s′)=5V_\Omega(s')=5. Ignoring the margin, what does the termination gradient do to βω(s′)\beta_\omega(s')?

  1. It raises it
  2. It lowers it
  3. It leaves it unchanged
  4. It pushes it toward 0.5
Show the answer

A. It raises it

AΩ(s′,ω)=3−5=−2<0A_\Omega(s',\omega)=3-5=-2<0: continuing is worse than handing control back. The term −∂β∂ϑAΩ-\frac{\partial\beta}{\partial\boldsymbol\vartheta}A_\Omega points in the direction that increases βω(s′)\beta_\omega(s'), so the option learns to stop here.

Managers and workers

Feudal RL (Dayan & Hinton, 1993) organizes learners as managers and sub-managers. A manager issues commands at a coarser time scale and rewards its sub-managers for carrying them out, whether or not that served the manager's own goal (reward hiding), and sub-managers need not know the manager's task (information hiding). FeUdal Networks (Vezhnevets et al., 2017) revived the idea with deep networks: a manager running at a lower temporal resolution emits a goal direction in a learned latent state space, and the worker is rewarded intrinsically for moving the latent state in that direction.

HIRO (Nachum, Gu, Lee & Levine, 2018) uses raw state displacements as goals, with off-policy learning at both levels. Every cc steps the high-level policy proposes a goal gtg_t, a desired change of state; between proposals the goal is carried along, gt+1=st+gt−st+1g_{t+1}=s_t+g_t-s_{t+1}, so that it keeps pointing at the same target, and the low-level policy is rewarded with −∥st+gt−st+1∥-\norm{s_t+g_t-s_{t+1}}. The difficulty is non-stationarity: a stored high-level transition (st,gt,∑R,st+c)(s_t,g_t,\sum R,s_{t+c}) was produced by an older low-level policy, and today the same goal would lead elsewhere. HIRO relabels the stored goal with the one that best explains the stored low-level actions under the current low-level policy μlo\mu^{\text{lo}}.

g~t=arg max⁡g ∑i=tt+c−1log⁡μlo(ai∣si,g~i),g~t=g,g~i+1=si+g~i−si+1\tilde g_t=\argmax_{g}\ \sum_{i=t}^{t+c-1}\log\mu^{\text{lo}}\big(a_i\mid s_i,\tilde g_i\big),\qquad\tilde g_t=g,\quad\tilde g_{i+1}=s_i+\tilde g_i-s_{i+1}
HIRO's off-policy correction, maximized approximately over a handful of candidate goals that include the original one and the displacement actually achieved, st+c−sts_{t+c}-s_t. With a deterministic low-level policy and Gaussian exploration noise, the log-likelihood is a negative squared distance between the stored actions and the ones the current policy would take.

Hindsight at every level of the hierarchy gives Hierarchical Actor-Critic (Levy, Konidaris, Platt & Saenko, 2019). Some language-model agents of the mid-2020s are hierarchical too: ArCHer (Zhou et al., 2024) trains a high-level critic over whole utterances and a token-level policy beneath it (Training Multi-Turn Agents). In every case each level sees the others as part of a changing environment, the same non-stationarity that multi-agent learners face.

Where options come from, and when they help

Good options often end at bottlenecks, states such as doorways that join otherwise separate regions, which can be found from visitation statistics or graph cuts. Eigenoptions (Machado, Bellemare & Bowling, 2017) use spectral structure. Let ee be an eigenvector of the normalized Laplacian of the state-transition graph, a proto-value function (Mahadevan & Maggioni, 2007). It defines an intrinsic reward, the eigenpurpose re(s,s′)=e(s′)−e(s)r^e(s,s')=e(s')-e(s), and its option is the policy that maximizes it, terminating where no action increases ee further. Eigenvectors with small eigenvalues vary slowly over the graph (the second one splits it into its two most weakly connected halves), so their options travel between distant regions.

For a random walk on an undirected graph, the successor representation has the same eigenvectors as the normalized Laplacian up to a fixed rescaling, which lets eigenoptions be computed from learned successor representations in large state spaces (Machado et al., 2018; Successor Representations & Features).

DerivationCovering options: bridge the extremes of the Fiedler vector
  1. λ2(L+(ei−ej)(ei−ej)⊤) ≈ λ2(L)+(vi−vj)2\lambda_2\big(L+(\mathbf e_i-\mathbf e_j)(\mathbf e_i-\mathbf e_j)^\top\big)\ \approx\ \lambda_2(L)+(v_i-v_j)^2

    Covering options (Jinnai, Park, Abel & Konidaris, 2019) target exploration directly. The expected time for a random walk to visit every state, its cover time, has an upper bound that falls as the algebraic connectivity λ2\lambda_2, the second-smallest Laplacian eigenvalue, grows. An option acts like a new edge. The paper works with the normalized Laplacian; the combinatorial Laplacian LL shows the idea most simply. For an unweighted edge (i,j)(i,j), a simple λ2\lambda_2 and its unit eigenvector vv (the Fiedler vector), first-order perturbation theory gives

  2. (i⋆,j⋆)=(arg min⁡ivi, arg max⁡jvj)(i^\star,j^\star)=\Big(\argmin_iv_i,\ \argmax_jv_j\Big)

    The first-order gain is largest for the two states at the extremes of vv. Covering options connects those two states with a pair of options, one in each direction, recomputes the Fiedler vector, and repeats, so each new option bridges the currently worst-connected parts of the state space:

When does hierarchy help? Nachum, Tang, Lu, Gu, Lee & Levine (2019) asked why hierarchical methods beat flat ones on their locomotion, navigation and manipulation tasks. Their experiments attributed most of the gain to exploration, temporally extended and semantically meaningful, rather than to easier policy learning: training the high level on temporally extended or semantically meaningful actions added little beyond the multi-step rewards that a flat agent can also use, and flat agents given exploration strategies inspired by hierarchy were competitive with the hierarchical methods. They state the conclusion as empirical and limited to the tasks they studied.

Theory points the same way. Regret analyses of learning with options (Fruit, Pirotta, Lazaric & Brunskill, 2017) make the dependence on the option set explicit, so that suitable options shrink the bounds and unsuitable ones enlarge them, and approximate value iteration with options, started from pessimistic values, can reach good policies in fewer iterations (Mann & Mannor, 2014). Options are a prior about the structure of good behavior: valuable when right, costly when wrong.

Key takeaways

  • A set of options turns an MDP into a semi-MDP: values satisfy Bellman equations over discounted option models, which contract at rate max⁡E[γτ]\max\E[\gamma^\tau]; VΩ⋆≤V⋆V^\star_\Omega\le V^\star, with equality when the primitive actions are included.
  • Interrupting an option wherever continuing is worth less than re-choosing never hurts, and intra-option Q-learning learns the values of every consistent option from one stream of experience, bootstrapping from U=(1−β)Q+βmax⁡QU=(1-\beta)Q+\beta\max Q.
  • The option-critic trains intra-option policies with QUQ_U and terminations with −∂β AΩ-\partial\beta\,A_\Omega; without a margin or deliberation cost, learned options degenerate.
  • Feudal agents let managers set goals for workers; HIRO's relabeling of stale high-level actions makes off-policy hierarchies work; eigenoptions and covering options come from the graph Laplacian.
  • The evidence suggests hierarchy helps mostly through exploration, and that options are a prior: valuable when they fit the problem, harmful when they do not.

Check yourself

In the interactive lesson these are scored with your confidence, and what you miss comes back for review.

Question 1

Why does value iteration over a good set of long options need fewer iterations than over primitive actions?

  1. Options have fewer parameters
  2. Its Bellman operator contracts with modulus max⁡s,ωE[γτ]\max_{s,\omega}\E[\gamma^\tau], which is smaller than γ\gamma when options last many steps, and each backup moves value across many cells
  3. Options make the MDP deterministic
  4. Value iteration over options skips the max over actions
Show the answer

B. Its Bellman operator contracts with modulus max⁡s,ωE[γτ]\max_{s,\omega}\E[\gamma^\tau], which is smaller than γ\gamma when options last many steps, and each backup moves value across many cells

The discount is folded into the option models, ∑s′pω(s′∣s)=E[γτ]\sum_{s'}p^\omega(s'\mid s)=\E[\gamma^\tau], so an option lasting at least kk steps contracts by γk\gamma^k or better. In the corridor example a single backup through the 5-step option moved the door's value five cells.

Question 2

Intra-option Q-learning updates options that were not being executed. What makes a transition (St,At,Rt+1,St+1)(S_t,A_t,R_{t+1},S_{t+1}) a valid sample for option ω\omega?

  1. ω\omega was initiated in StS_t
  2. ω\omega terminates in St+1S_{t+1}
  3. ω\omega's deterministic policy would have chosen AtA_t in StS_t
  4. Any transition is valid for any option
Show the answer

C. ω\omega's deterministic policy would have chosen AtA_t in StS_t

If πω(St)=At\pi_\omega(S_t)=A_t, then running ω\omega in StS_t would have produced exactly this transition, so it is an unbiased sample of ω\omega's one-step backup, whichever option was actually running: off-policy learning at the level of options.

Question 3

Why do options learned by the option-critic without regularization tend to degenerate, terminating at every step or never?

  1. The termination gradient has the wrong sign
  2. The intra-option policy gradient is biased
  3. The policy over options is ε\varepsilon-greedy
  4. A single task's return gives options no reason to be distinct or to last, so switching every step or never switching can be just as good
Show the answer

D. A single task's return gives options no reason to be distinct or to last, so switching every step or never switching can be just as good

Both gradient theorems are exact for the return, and the return of one task is indifferent to how behavior is chunked. A margin or deliberation cost, or objectives that reward reuse across tasks, supply the missing pressure.

Question 4

Why does HIRO relabel the goals stored in its high-level replay buffer?

  1. Because the low-level policy has changed, the stored goal no longer explains the low-level actions in that transition; a goal that makes them likely under the current low-level policy keeps the high-level data consistent
  2. To turn failures into successes for the goals actually reached, as in HER
  3. To save replay memory
  4. To make the high-level policy on-policy
Show the answer

A. Because the low-level policy has changed, the stored goal no longer explains the low-level actions in that transition; a goal that makes them likely under the current low-level policy keeps the high-level data consistent

A high-level transition is "action gtg_t led to st+cs_{t+c}", but the low-level behavior that produced it came from an older policy. Choosing the goal that maximizes the likelihood of the stored low-level actions under the current policy makes the transition look as if today's hierarchy had produced it.

Further reading

  • R. S. Sutton, D. Precup & S. Singh, "Between MDPs and semi-MDPs: A framework for temporal abstraction in reinforcement learning," Artificial Intelligence 112, 181–211 (1999).
  • P.-L. Bacon, J. Harb & D. Precup, "The option-critic architecture," AAAI (2017).
  • O. Nachum, S. Gu, H. Lee & S. Levine, "Data-efficient hierarchical reinforcement learning," NeurIPS (2018).
  • M. C. Machado, M. G. Bellemare & M. Bowling, "A Laplacian framework for option discovery in reinforcement learning," ICML (2017).
  • O. Nachum, H. Tang, X. Lu, S. Gu, H. Lee & S. Levine, "Why does hierarchy (sometimes) work so well in reinforcement learning?," arXiv:1909.10618 (2019).