Compositional Transfer in Hierarchical Reinforcement Learning
Markus Wulfmeier Abbas Abdolmaleki Roland Hafner Jost Tobias Springenberg Michael Neunert Tim Hertweck Thomas Lampe Noah Siegel Nicolas Heess Martin Riedmiller






Compositional Transfer in 
Hierarchical Reinforcement Learning
    
Markus Wulfmeier*, 
    Abbas Abdolmaleki*,
    Roland Hafner,
    Jost Tobias Springenberg,

    Michael Neunert,
    Tim Hertweck,
    Thomas Lampe,
    Noah Siegel,
    Nicolas Heess,
    Martin Riedmiller
DeepMind,
London, United Kingdom

    December 30, 2023
=======================================================================================================================================================================================================================================================




The successful application of general reinforcement learning algorithms to real-world robotics applications is often limited by their high data requirements. We introduce Regularized Hierarchical Policy Optimization (RHPO) to improve data-efficiency for domains with multiple dominant tasks and ultimately reduce required platform time. To this end, we employ compositional inductive biases on multiple levels and corresponding mechanisms for sharing off-policy transition data across low-level controllers and tasks as well as scheduling of tasks. The presented algorithm enables stable and fast learning for complex, real-world domains in the parallel multitask and sequential transfer case. We show that the investigated types of hierarchy enable positive transfer while partially mitigating negative interference and evaluate the benefits of additional incentives for efficient, compositional task solutions in single task domains. Finally, we demonstrate substantial data-efficiency and final performance gains over competitive baselines in a week-long, physical robot stacking experiment. 




[1]Correspondence to: mwulfmeier, abdolmaleki@google.com Shared first-authorship. 




§ INTRODUCTION


Creating real-world systems that learn to achieve many goals directly through interaction with their environment is one of the long-standing dreams in robotics. Although recent successes in deep (reinforcement) learning for computer games (Atari <cit.>, StarCraft <cit.>), Go <cit.> and other simulated environments (e.g. <cit.>) have demonstrated the potential of these methods when large amounts of training data are available, the high cost of data acquisition has limited progress for many problems involving systems directly acting in the physical world. 

Data efficiency in machine learning generally relies on inductive biases or prior knowledge to guide and accelerate the learning process. One strategy for injecting prior knowledge that is widely and successfully used in robotics learning problems is the use of human expert demonstrations to bootstrap the learning process. But the perspective of a system with a permanent embodiment capable of achieving many goals in a persistent environment provides us with a complementary opportunity: an efficient learning strategy should allow us to share and reuse experience across tasks –  such that the system does not have to experience or learn the same thing multiple times, and such that solutions to simpler tasks can bootstrap the learning of harder ones.

Rather than providing prior knowledge or biases specific to a particular task this suggests focusing on more general inductive biases that facilitate the sharing and reuse of experience and knowledge across tasks while allowing other aspects of the domain to be learned <cit.>. 

Previous approaches to transfer learning have, for example, built on optimizing initial parameters <cit.>, sharing models and parameters across tasks either in the form of policies or value functions <cit.>, data-sharing across tasks <cit.>, or through the use of task-related auxiliary objectives <cit.>. 

Transfer between tasks can, however, lead to either constructive or destructive transfer for humans <cit.> as well as for machines <cit.>. That is, jointly learning to solve different tasks can provide both benefits and disadvantages for individual tasks, depending on their similarity. Finding a mechanism that enables transfer where possible but avoids interference is one of the long-standing research challenges.





In this paper, we propose a general reinforcement learning architecture that benefits from learning multiple tasks simultaneously and is sufficiently data-efficient and reliable to solve non-trivial manipulation tasks from scratch directly on robotics hardware. We achieve efficiency through three forms of transfer: (1) robust off-policy learning allows to effectively share all generated transition data across tasks and skills; (2) a modular hierarchical policy architecture allows skills to be directly reused across tasks; and (3) switching between the execution of policies for different tasks within a single episode leads to effective exploration.

The model uses deep neural networks to parameterize state-conditional Gaussian mixture distributions as agent policies, similar to Mixture Density Networks <cit.>. To obtain robust and versatile low-level behaviors in the multitask setting we shield the mixture components from information about the task at hand. Task information is thus only communicated through the choice of mixture component by the high-level controller, and the mixture components are trained as domain-dependent but task-independent skills. To efficiently optimize hierarchical policies in a multitask setting, 
we develop robust off-policy learning schemes enabling us to use all transition data to train each low-level controller independent of the actually executed one. We focus on Maximum A-Posteriori Policy Optimization (MPO) <cit.> but also consider a variant of Stochastic Value Gradients (SVG) <cit.>. For both algorithms we employ trust-region like constraints at both levels of the hierarchy.

We evaluate the approach on several real and simulated robotics manipulation tasks and demonstrate that it outperforms competitive baselines. In particular, it dramatically improves data efficiency on a challenging real-world robotics manipulation task similar to the one considered in <cit.>: 
Our model learns to stack blocks from scratch on a single Sawyer robot arm within about a week at which point it demonstrates up to three times higher performance compared to our baselines. 

We further perform a number of careful ablations. These highlight, among others, the importance of the hierarchical architecture and the importance of the trust-region like constraints for the stability of the learning scheme. 
Finally, to gain a better understanding of the role of this type of hierarchy in RL, we compare its benefits in the single task and multitask setting. We find that it shows clear benefits advantages in the multitask setting. However, it can fail to improve performance in the single-task case, where additional incentives are required to encourage component specialization similar to the multitask case. These results shed further light on the interaction of model and domain in RL.


In summary, our contributions are as follows,

    
  * Algorithmic improvements: 
    We propose a new method for robust and efficient off-policy optimization of hierarchical policies. Our approach controls the rate of change at both levels of the hierarchy via trust-region like constraints thus ensuring stable learning. Furthermore, it can use all data to train any given low-level component, independent of the component which generated the transition. This enables data efficient training with experience replay and data sharing across tasks.
    
  * Performance improvements:
    We evaluate our approach on a range of real and simulated robotic manipulation domains. The results confirm that the algorithm scales to complex tasks and significantly reduces interaction time. Particular benefits arise in more complex task sets and the low-data regime. When learning to stack from scratch on the Sawyer robot arm in a week-long experiment, the approach demonstrates up to three times better performance for the most complex tasks.
    
  * Investigation of benefits, shortcomings and requirements: We perform a careful analysis and ablation of our algorithm and its properties, highlighting in particular, the impact of individual algorithmic and environment properties, as well was the overall robustness to hyperparameter settings.






§ PRELIMINARIES

 
We consider a multitask reinforcement learning setting with an agent operating in a Markov Decision Process (MDP) consisting of the state space 𝒮, the action space 𝒜, the transition probability p(s_t+1|s_t,a_t) of reaching state s_t+1 from state s_t when executing action a_t. The actions are drawn from a probability distribution over actions π(a | s) referred to as the agent's policy. Jointly, the transition dynamics and policy induce the marginal state visitation distribution p(s). The discount factor γ together with the reward r(s, a) gives rise to the expected reward, or value, of starting in state s (and following π thereafter) V^π(s) = 𝔼_π[∑^∞_t=0γ^t r(s_t, a_t) | s_0 = s, a_t∼π(·|s_t), s_t+1∼  p(·|s_t,a_t)]. 
We define multitask learning over a set of tasks i ∈ I with common agent embodiment as follows: We assume shared state and action spaces and shared transition dynamics; tasks only differ in their reward function r_i(s, a). We consider task conditional policies π(a | s, i) with the overall objective defined as


    J(π)    =𝔼_i ∼ I[𝔼_π, p(s_0)[∑_t=0^∞γ^t r_i(s_t, a_t) | s_t+1∼ p(·|s_t,a_t) ]] 
       = 𝔼_i ∼ I[𝔼_π, p(s)[ Q^π(s, a, i) ]],


where all actions are drawn according to the policy π conditioned on task i, that is, a_t ∼π(· | s_t, i) and we used the following definition of the task-conditional state-action value function (Equation <ref>). 


    Q^π(s,a,i) = 𝔼_π[ ∑_t=0^∞γ^t r_i(s_t, a_t) | a_0 = a, 
    
    s_0 = s, a_t∼π(·|s_t,i), s_t+1∼  p(·|s_t,a_t) ]





§ METHOD

This section introduces  () which focuses on efficient training of modular policies by sharing data across tasks. 
We first describe the underlying class of mixture policies, followed by details on the critic-weighted maximum likelihood optimization objective used to update structured hierarchical policies in a multitask, off-policy setting. For efficiency in the multitask case,  extends data-sharing and scheduling mechanisms from Scheduled Auxiliary Control with randomized scheduling (SAC-U) <cit.>.



 §.§ Hierarchical Policies

We start by defining the hierarchical policy class which supports sharing sub-policies across tasks. Formally, we decompose the per-task policy π(a | s, i) as

    π_θ(a | s, i) = ∑^M_o=1π^L_θ(a | s, o) π^H_θ(o | s, i),

where π^H and π^L respectively represent a high-level switching controller (a categorical distribution) and a low-level sub-policy (components of the resulting mixture distribution), and o is the index of the sub-policy. θ denotes the parameters of both π^H and π^L, which we seek to optimize. While the number of components has to be decided externally,  is robust with respect to this parameter (Appendix <ref>).
Note that in the above formulation only the high-level controller π_H is conditioned on the task information i. This choice introduces a form of information asymmetry <cit.> that enables the low-level policies to acquire general, task-independent behaviours. 
This choice strengthens the decomposition of tasks across domains and prevents degenerate solutions that bypass the high-level controller. Intuitively, these sub-policies can be understood as building reflex-like low-level control loops, which perform domain-dependent but task-independent behaviours and can be modulated by higher cognitive functions with knowledge of the task at hand. Figure <ref> illustrates the used hierarchical policy architecture.  







 §.§ Data-efficient Multitask Policy Optimization

In the following sections, we present the core principles underlying ; for the complete pseudocode algorithm please see Algorithm <ref> and Appendix <ref>. 
We build on an Expectation-Maximization based policy optimization algorithm (similar to MPO <cit.>) and adapt it to the application to hierarchical policies in the multitask case. We update the parametric policy in 2 stages and decouple the policy improvement step from the fitting of the parametric policy. 

We begin by describing the policy improvement steps below, assuming that we have an approximation of the ground-truth state-action value function Q̂(s, a, i) ≈Q^π(s, a, i) available (see Equation (<ref>) for details on learning Q̂ from off-policy data). Starting from an initial policy π_θ_0 we can then iterate the following steps to improve the policy π_θ_k:





    
   Policy Evaluation: Update Q̂ such that Q̂(s, a, i) ≈Q̂^π_θ_k(s, a, i), see Equation (<ref>).
    
   Policy Improvement:
    
        
  * Step 1: Obtain q_k = max_q J(q), under KL constraints with π_ref = π_θ_k (Equation (<ref>)).
        
  * Step 2:  Obtain 
 θ_k+1 = min_θ𝔼_s ∼𝒟, i ∼ I[ KL( q_k(· | s, i) π_θ(· | s, i) ) ], under additional regularization (Equation (<ref>)).
    







  
Policy Improvement 1: Obtaining Non-parametric Policies
Concretely, we first introduce an intermediate non-parametric policy q(a | s, i) and optimize J(q) while staying close, in expectation, to a reference policy π_ref(a | s, i) 

    max_q J(q) = 𝔼_i ∼ I   [𝔼_q, s ∼𝒟[ Q̂(s, a, i) ]], 
    s.t. 𝔼_s ∼𝒟, i ∼ I   [
        KL(q(·|s, i) π_ref(·|s, i))] ≤ϵ,

where KL(··) denotes the Kullback Leibler divergence, ϵ defines a bound on the KL, 𝒟 denotes the data contained in a replay buffer. 

We find the intermediate policy q by maximizing Equation (<ref>) and can obtain a closed-form solution with a non-parametric policy for each task, as 

    q_k(a|s,i) ∝π_θ_k(a|s,i) exp(Q̂(s,a,i)/η),

where η is a temperature parameter (corresponding to a given bound ϵ) that is obtained by optimizing the dual function,


    g(η)    = ηϵ+η𝔼_s ∼𝒟, i ∼ I[log(∫π_θ_k(a|s,i)
       exp(Q̂(s,a,i)/η) a)]
        ,

(see Appendix <ref> for a detailed derivation of the dual function).
This policy representation is independent of the form of the parametric policy π_θ_k; i.e. q only depends on π_θ_k through its requirement for obtaining samples. This, crucially, makes it easy to employ complicated structured policies (such as the one introduced in Section <ref>). The only requirement here, and in the following steps, is that we must be able to sample from π_θ_k and calculate the gradient (w.r.t. θ_k) of its log density (but the sampling process itself need not be differentiable).



  
Policy Improvement  2: Fitting Parametric Policies
In the second step we fit a policy to the non-parametric distribution obtained from the previous calculation by minimizing the divergence 𝔼_s ∼𝒟, i ∼ I[ KL( q_k(· | s, i) π_θ(· | s, i))].
Assuming that we can sample from q_k this step corresponds to maximum likelihood estimation (MLE). 
Furthermore, we introduce a trust-region constraint on policy updates. In this way, we can regularize towards a target policy, effectively mitigating optimization instabilities. 
Trust-region constraints have been used in on- and off-policy RL <cit.>. We adapt the formulation of <cit.> to our hierarchical setting, and as the analysis in Section <ref> shows, it is critical for the success of our algorithm.
Formally, we aim to obtain the solution in Equation <ref>, where ϵ_m defines a bound on the change of the new policy. 

Here, we drop constant terms and the negative sign in the second line (turning min into max), and explicitly insert the definition π_θ(a | s, i) = ∑^M_o=1π_L(a | s, o) π_H(o | s, i), highlighting that we are marginalizing over the high-level choices in this fitting step. The update is independent of the specific policy component from which the action was sampled, enabling joint updates of all components. This reduces the variance of the update and also enables efficient off-policy learning. 


    θ_k+1   = min_θ𝔼_s ∼𝒟, i ∼ I[ KL( q_k(· | s, i) π_θ(· | s, i) ) ] 
        = max_θ𝔼_s ∼𝒟, i ∼ I[ 𝔼_π_θ_k[
        exp(Q̂(s,a,i)/η) 
        
       log∑^M_o=1π^L_θ(a | s, o) π^H_θ(o | s, i)
        ] ],
    s.t.    𝔼_s ∼𝒟, i ∼ I[ KL(π^H_θ_k(o | s, i) π^H_θ(o | s, i)) + 
       1/M∑_o=1^M KL(π^L_θ_k(a | s, o) π^L_θ(a | s, o)) ] < ϵ_m



Different approaches can be used to control convergence for both the high-level categorical choices and the action choices to change slowly throughout learning.
The average KL constraint in Equation  (<ref>) is similar in nature to an upper bound on the computationally intractable KL divergence between the two mixture distributions and has been determined experimentally to perform better in practice than simple bounds. 
In practice, in order to control the change of the high level and low level policies independently we decouple the constraints to be able to set different ϵ for the means (ϵ_μ), covariances (ϵ_Σ) and the categorical distribution (ϵ_α) in case of a mixture of Gaussian policy. 
To solve Equation (<ref>), we first employ Lagrangian relaxation to make it amenable to gradient based optimization and then perform a fixed number of gradient descent steps (using Adam <cit.>); a detailed overview can be found in Algorithm <ref> as well as with further information in the Appendix <ref>.



  
Policy Evaluation 
For data-efficient off-policy learning of Q̂ we experience sharing across tasks and switching between tasks within one episode for improved exploration by adapting the initial state distribution of each task based on other tasks <cit.>.

Formally, we assume access to a replay buffer containing data gathered from all tasks. 
For each trajectory snippet τ = { (s_0, a_0, R_0), …, (s_L, a_L, R_L) } we record the rewards for all tasks R_t = [r_i_1(s_t, a_t), …, r_i_|I|(s_t, a_t)] as a vector in the buffer. Using this data we define the retrace objective for learning Q̂, parameterized via ϕ, following <cit.> as

    min_ϕ L(ϕ) = ∑_i ∼ I𝔼_τ∼𝒟[ ( r_i(s_t, a_t) + 
    γ Q^ret(s_t+1, a_t+1, i) - Q̂_ϕ(s_t, a_t, i))^2 ],

where Q^ret is the L-step retrace target <cit.>, see the Appendix <ref> for details.






§ EXPERIMENTS

In the following sections, we investigate the effects of training hierarchical policies in single and multitask domains. In particular, we demonstrate that  can provide compelling benefits for multitask learning in real and simulated robotic manipulation tasks and significantly reduce platform interaction time. 
For the final experiment, a stacking task on a physical Sawyer robot arm,   achieves a dramatic performance improvement after a week of training compared to several strong baselines.
We further investigate  in a sequential transfer setting and find that when pre-trained skills (i.e. low-level components) are available  can provide additional improvements in data efficiency. 

Finally, we perform a number of ablations to emphasize the importance of trust-region constraints for the high-level controller and to understand the relative role of hierarchy in the single-task and multitask setting:
In the single-task case, using domains from the DeepMind Control Suite <cit.>, we first demonstrate that our hierarchy on its own can fail to improve performance and that for the model to exploit compositionality in this setting, additional incentives for component specialization are required. 



For all tasks and algorithms, we use a distributed actor-critic framework (similar to <cit.>) with flexible hardware assignment <cit.>. We perform critic and policy updates from a replay buffer, which is asynchronously filled by a set of actors. In all figures with error bars, we visualize mean and variance derived from 3 runs.
Additional details of task hyperparameters as well as results for ablations and the full set of tasks from the multitask domains are provided in the Appendix <ref>. [Additional details and the appendix can be found under <https://sites.google.com/corp/view/rhpo>]






 §.§ Simulated Multitask Experiments


We use three simulated multitask scenarios with the Kinova Jaco and Rethink Robotics Sawyer robot arms to test in a variety of conditions. The three scenarios each consist of tasks of different difficulties and vary in their overall complexity. The least difficult scenario is Pile1: Here, the seven tasks of interest range from simple reaching for a block over tasks like grasping it, 
to the final task of stacking the block on top of another block. 
The two more difficult scenarios are Pile2 and Cleanup2. Pile2 includes stacking with both blocks on top of the respective other block, resulting in a setting with 10 tasks. Cleanup2 includes harder tasks such as opening a box and placing blocks into this box, consisting of a total of 13 tasks. 
In addition to the experiments in simulation, which are executed with 5 actors in a distributed setting, we also investigate the Pile1 multitask domain (same rewards and setup) on a single, physical robot in Section <ref>. 

Our main comparison evaluates RHPO with hierarchical policies against SAC <cit.> with a flat, monolithic policy shared across all tasks which is provided with the additional task id as input (displayed as SAC-U-Monolithic) as well as policies with task dependent heads (displayed as SAC-U-Independent) following <cit.> – both using MPO as the optimizer. Furthermore, we compare against a re-implementation of SAC using SVG <cit.> as actor-critic based optimizer which uses the reparameterization trick (displayed as SAC-U[SVG]).  In order to compare with gradient-based hierarchical policy updates (such option critic <cit.>) as well as investigating the application of the proposed hierarchical model for other RL algorithms; we also use SVG (with continuous relaxation of the Categorical distribution <cit.>) instead of MPO to optimize the hierarchical model with results included in the Pile1 experiments (displayed as RHPO[SVG]) with additional results in Appendix <ref>. These comparisons furthermore strengthen our choice for critic-weighted likelihood instead of reparametrization gradient-based policy optimizer.

The main SAC baselines provide the two opposite, naive perspectives on transfer: by using the same monolithic policy across tasks we enable positive as well as negative interference and independent policies prevent policy-based transfer. After experimentally confirming the robustness of  with respect to the number of low-level sub-policies (see Appendix <ref>), we set M proportional to the number of tasks in each domain.



Figure <ref> demonstrates that  outperforms the monolithic as well as the independent baselines (based on SAC). For simple tasks such as the Pile1 domain, the difference is small, but as the number of tasks grows and the complexity of the domain increases (cf. Pile2 and Cleanup2), the advantage of composing learned behaviours across tasks becomes more significant. 
We further observe that using MPO instead of SVG <cit.> as policy optimizer results in an improvement for the baselines. This effect becomes more pronounced for the hierarchical policies.






 §.§ Physical Robot Experiments

For real-world experiments, data-efficiency is crucial. We perform all experiments in this section relying on a single robot (single actor) – demonstrating the benefits of  in the low data regime. The performed task is the real world version of the Pile1 task described in Section <ref>. Given the higher cost of experiment time, the robot experiments additionally emphasize the requirements for hyperparameter robust algorithms which is further investigated in Section <ref>.
 




The setup for the experiments consists of a Sawyer robot arm mounted on a table, equipped with a Robotiq 2F-85 parallel gripper. A basket of size 20cm^2 in front of the robot contains the three cubes. Three cameras on the basket track the cubes using fiducials (augmented reality tags).
As in simulation, the agent is provided with proprioception information (joint positions, velocities and torques), a wrist sensor's force and torque readings, as well as the cubes' poses – estimated via the fiducials. The agent's action is five dimensional and consists of the three Cartesian translational velocities, the angular velocity of the wrist around the vertical axis and the speed of the gripper's fingers.

Figure <ref> plots the learning progress on the real robot for four of the tasks, from simpler reach and lift tasks and the stack and final stack-and-leave task – which is the main task of interest. Plots for the learning progress of all tasks are given in the appendix <ref>. As can be observed, all methods manage to learn the reach task quickly (within about a few thousand episodes) but only  with a hierarchical policy is able to learn the stacking task (taking about 15 thousand episodes to obtain good stacking success), which takes about 8 days of training on the real robot with considerably slower progress for all baselines taking multiple weeks for completion.


To provide further insight into the learned representation we compute distributions for each component over the tasks which activate it, as well as distributions for each task over which components are being used. For each set of distributions, we determine the Battacharyya distance metric to determine the similarity between tasks and the similarity between components in Figure <ref> (right). The plots demonstrate how the components specialize, but also provide a way to investigate our tasks, showing e.g. that the first reach task is fairly independent and that the last four tasks are comparably similar regarding the high-level components applied for their solution.







 §.§ Sequential Transfer






 is well suited for sequential transfer learning as it allows to use pre-trained low-level components to solve new tasks.  

To investigate performance in adapting pre-trained multitask policies to novel tasks, we train agents to fulfill all but the final task in the Pile1 and Cleanup2 domains and subsequently evaluate training the models on the final task. 
We consider two settings for the final policy: we either introduce only a new high-level controller (Sequential-Only-HL) or both an additional shared component as well as a new high-level controller (Sequential).
Figure <ref> displays that in the sequential transfer setting, starting from a policy trained on a set of related tasks results in up to 5 times more data-efficiency in terms of actor episodes on the final task than training the same policy from scratch. We observe that the final task can be solved by only reusing low-level components from previous tasks if the final task is the composition of previous tasks. This is the case for the final task in Cleanup2 which can be completed by sequencing the previously learned components and in contrast to Pile1 where the final letting go of the block after stacking is not required for earlier tasks.      






 §.§ Simulated Single Task Experiments


We consider two high-dimensional tasks for continuous control: humanoid-run and humanoid-stand from <cit.> and  compare MPO with a flat Gaussian policy to  with a mixture of Gaussians with three components. 

Figure <ref> shows the results in terms of the number of episodes. 

When both the flat and hierarchical policies are initialized with means close to zero,  performs comparable to a flat policy and learns similar means and variances for all components as the model fails to decompose the learned behavior. If, however, the hierarchical policy is initialized with distinct means for different components (here, for the three components ranging for all dimensions from the minimum to maximum of the allowed action range, i.e. -1, 1), we observe significantly improved performance and component specialization.







 §.§ Performance Ablations

We perform a series of ablations based on the earlier introduced Pile1 domain, providing additional insights into benefits, shortcomings and relevant hyperparameters of .

First, we display the importance of choice of regularization in Figure <ref> with complete results in Appendix <ref>. We are able to demonstrate the effect of weakening the constraint by setting the epsilon value higher (here: to 1.). This setting prevents convergence of the policy to capable solutions and emphasizes the necessity of constraining the update steps. In addition, very small values can slow down convergence. However, in the present experiments a range of about 2 orders of magnitude results in good performance.




We additionally ablate over the number of data-generating actors in Figure <ref> to evaluate all approaches with respect to data rate and illustrate how  is particularly relevant at lower data rates such as given by real-world robotics applications (with results for all tasks in Appendix <ref>). Here,  always provides stronger final performance and learns significantly faster in one actor case as common for robot experiments. By running with multiple actors, we increase the rate of data generation such that in asynchronous settings, the speed of the learner becomes more important. Since training our hierarchical policies is computationally slightly more costly, the benefits become smaller for easier tasks[In asynchronous RL systems, the update rate of the learner can have a significant impact on the performance when evaluated over data generated. ].





Finally, we demonstrate the robustness of  with respect to the number of sub-policies in Figure <ref> (with complete results in Appendix <ref>) and connected simplicity of determining this hyperparameter which for all other experiments is simply set proportionally to the number of tasks.





§ RELATED WORK



Transfer learning, in particular in the multitask context, has long been part of machine learning (ML) for data-limited domains <cit.>. Commonly, it is not straightforward to train a single model jointly across different tasks as the solutions to tasks might not only interfere positively but also negatively <cit.>. 
Preventing this type of forgetting or negative transfer presents a challenge for biological <cit.> as well as artificial systems <cit.>. In the context of ML, a common scheme is the reduction of representational overlap  <cit.>.
<cit.> utilize neural networks to parametrize mixture models for representing multi-modal distributions thus mitigating shortcomings of non-hierarchical approaches. <cit.> demonstrate the benefits of hierarchical classification models to limit the impact of negative transfer.

Hierarchical approaches have a long history in the reinforcement learning literature <cit.>.
Prior work commonly benefits from combining hierarchy with additional inductive biases such as <cit.> which employ different rewards for different levels of the hierarchy rather than optimizing a single objective for the entire model as we do. 
Other works have shown the additional benefits for the stability of training and data-efficiency when sequences of high-level actions are given as guidance during optimization in a hierarchical setting <cit.>.
Instead of introducing additional training signals, we directly investigate the benefits of compositional hierarchy as provided structure for transfer between tasks.

Hierarchical models for probabilistic trajectory modelling have been used for the discovery of behavior abstractions as part of an end-to-end reinforcement learning paradigm <cit.> where the models act as learned inductive biases that induce the sharing of behavior across tasks. 
In a vein similar to the presented algorithm, <cit.> share a low-level controller across tasks but modulate the low-level behavior via a continuous embedding rather than picking from a small number of mixture components.
In related work  <cit.> learn hierarchical policies with continuous latent variables optimizing the entropy regularized objective.

Similar to our work, the options framework <cit.> supports behavior hierarchies, where the higher level chooses from a discrete set of sub-policies or “options” which commonly are run until a termination criterion is satisfied. The framework focuses on the notion of temporal abstraction. A number of works have proposed practical and scalable algorithms for learning option policies with reinforcement learning <cit.> or criteria for option induction <cit.>. 
Rather than the additional inductive bias of temporal abstraction, we focus on the investigation of composition as type of hierarchy in the context of single and multitask learning while demonstrating the strength of hierarchical composition to lie in domains with strong variation in the objectives - such as in multitask domains.
We additionally introduce a hierarchical extension of SVG <cit.>, to investigate similarities to work on the option critic <cit.>. 

With the use of KL regularization to different ends in RL, work related to  focuses on contextual bandits <cit.>. 
The algorithm builds on a 2-step EM like procedure to optimize linearly parametrized mixture policies. However, their algorithm has been used only with low dimensional policy representations, and in contextual bandit and other very short horizon settings.
Our approach is designed to be applicable to full RL problems in complex domains with long horizons and with high-capacity function approximators such as neural networks. This requires robust estimation of value function approximations, off-policy correction, and additional regularization for stable learning.




§ DISCUSSION


We introduce , a novel algorithm for robust training of hierarchical policies in multitask settings.   consistently outperforms competitive baselines which either handle tasks independently or implicitly share experience by reusing data across tasks. Especially for complex tasks or in a low data regime, as encountered in robotics applications, we strongly reduce the number of environment interactions and improve final performance as well as learning robustness and sensitivity to hyper-parameters. Our results show that the algorithm scales to complex, real-world domains and provides an important step towards the deployment of RL algorithms on robotic systems.

Algorithmically, our method highlights the importance of trust-region-like regularization for stable optimization of hierarchical policies. Furthermore, our update rules in combination with mixture policies and hindsight reward assignments enable training for any task and skill independent of the data source. This enables efficient learning of the hierarchical policies in an off-policy setting, which is important for data efficient learning.   

Conceptually, our results demonstrate that hierarchical policies can be an effective way of sharing skills or behavior components across tasks, both in multitask (Sections <ref>-<ref>) as well as in transfer settings (Section <ref>) and partially mitigate negative interference between tasks in the parallel multitask learning scenario. 
Furthermore, we find that their benefits are complementary to off-policy sharing of transition data across tasks (e.g. SAC-X <cit.>, HER <cit.>).
Valuable directions for future work include the direct extension to multilevel hierarchies and the identification of basis sets of behaviours which perform well on wide ranges of possible tasks given a known domain.


We believe that especially in domains with consistent agent embodiment and high costs for data generation learning tasks jointly and information sharing is imperative. Our results suggest that a system that is exposed to a rich set of tasks or experiences and has appropriate means for reusing knowledge can learn to solve non-trivial problems directly from interaction with its environment.  combines several ideas that we believe will be important: sharing data across tasks and skills across tasks with compositional policy representations, robust optimization, and efficient off-policy learning. Although we have found this particular combination of components to be very effective we believe it is just one instance of – and step towards – a spectrum of efficient learning architectures that will unlock further applications of RL both in simulation and, more importantly, on physical hardware.





§ ACKNOWLEDGMENTS

The authors would like to thank Michael Bloesch, Jonas Degrave, Joseph Modayil and Doina Precup for helpful discussion and relevant feedback for shaping our submission. 
As robotics (and AI research) is a team sport we'd additionally like to acknowledge the support of Francesco Romano, Murilo Martins, Stefano Salicetti, Tom Rothörl and Francesco Nori on the hardware and infrastructure side as well as many others of the DeepMind team.



plainnat





§ APPENDIX



 §.§ Additional Derivations 


In this section we explain the detailed derivations for training hierarchical policies parameterized as a mixture of Gaussians. 


  §.§.§ Obtaining Non-parametric Policies 

In each policy improvement step, to obtain non-parametric policies for a given state and task distribution, we solve the following program:


    max_q 𝔼_μ(s), i ∼ I[ 𝔼_q(a|s,i)[Q̂(s,a,i)] ] 
        s.t. 𝔼_μ(s), i ∼ I[ KL(q(·|s,i) , π(·|s,i,θ_t) ) ] < ϵ
        s.t. 𝔼_μ(s), i ∼ I[ 𝔼_q(a | s) [1 ] ] = 1.


To make the following derivations easier to follow we open up the expectations, writing them as integrals explicitly. For this purpose let us define the joint distribution over states s ∼μ(s) together with randomly sampled tasks i ∼ I as μ(s,i) = p(s | 𝒟) 𝒰(i ∈ I), where 𝒰 denotes the uniform distribution over possible tasks. This allows us to re-write the expectations that include the corresponding distributions, i.e. 𝔼_μ(s), i ∼ I[1] = 𝔼_μ(s, i)[1], but again, note that i here is not necessarily the task under which s was observed.
We can then write the Lagrangian equation corresponding to the above described program as


    L(q,   η,γ) = ∫μ(s,i)∫ q(a|s,i) Q̂(s,a,i)  a  s  i 
       +η(ϵ - ∫μ(s,i)∫ q(a|s,i)logq(a|s,i)/π(a|s,i,θ_t) a  s  i) 
       + γ(1 - ∬μ(s,i) q(a|s,i) a  s  i).

Next we maximize the Lagrangian L w.r.t the primal variable q. The derivative w.r.t q reads,


    ∂ qL(q,η,γ) =    Q̂(a,s,i) - ηlog q(a|s,i) 
       +ηlogπ(a|s,i,θ_t) - η - γ.


Setting it to zero and rearranging terms we obtain


    q(a|s,i) = π(a|s,i,θ_t)exp(Q̂(s,a,i)/η)exp(-η+γ/η).



However, the last exponential term is a normalization constant for q. Therefore we can write,


    exp(η+γ/η) = ∫π(a|s,i, θ_t)exp(Q(s,a,i)/η) a


    η+γ/η= log(∫π(a|s,i,θ_t)exp(Q(s,a,i)/η) a).


Now, to obtain the dual function g(η), we plug in the solution to the KL constraint term (second term) of the Lagrangian which yields 

    L(q,η,γ) = ∫μ(s,i)∫ q(a|s,i) Q(s,a,i)  a  s 
       +η(ϵ - ∫μ(s,i)∫ q(a|s,i)
                          logπ(a|s,i,θ_t)exp(Q(s,a,i)/η)exp(-η+γ/η)/π(a|s,i,θ_t) a  s  i) 
       + γ(1 - ∬μ(s,i) q(a|s,i) a  s  i).


After expanding and rearranging terms we get

    L(q,η,γ) = ∫μ(s,i)∫ q(a|s,i) Q(s,a,i)  a  s  i 
       
    - η∫μ(s,i)∫ q(a|s,i)[Q(s,a,i)/η + 
                          logπ(a|s,i;θ_t) - η+γ/η] a  s  i 
        + ηϵ
     +η∫μ(s,i)∫ q(a|s,i)logπ(a|s,i;θ_t) a  s  i 
        + γ(1 - ∬μ(s,i) q(a|s,i) a  s  i).


Most of the terms cancel out and after rearranging the terms we obtain

    L(q,η,γ) = ηϵ + η∫μ(s,i)η+γ/η s  i.


Note that we have already calculated the term inside the integral in Equation <ref>. By plugging in equation <ref> we obtain the dual function

    g(η) = ηϵ+η∫μ(s,i)log(∫π(a|s,i, θ_t)
                          exp(Q(s,a,i)/η) a) s  i
        ,

which we can minimize with respect to η based on samples from the replay buffer.



  §.§.§ Extended Update Rules For Fitting a Mixture of Gaussians 


After obtaining the non parametric policies, we fit a parametric policy to samples from said non-parametric policies – effectively employing using maximum likelihood estimation with additional regularization based on a distance function 𝒯, i.e,


    θ^(k+1)   =min_θ𝔼_s ∼𝒟, i ∼ I[ KL( q_k(· | s, i) π_θ(· | s, i) ) ] 
       = _θ𝔼_s ∼𝒟, i ∼ I, a ∼ q(· | s, i)[ -logπ_θ(a |s, i) ],   
       = _θ𝔼_s ∼𝒟, i ∼ I, a ∼ q(· | s, i)[ logπ_θ(a |s, i) ],   
       s.t. 𝔼_s ∼𝒟, i ∼ I[ 𝒯(π_θ_k(·|s, i) | π_θ(·|s, i)) ] < ϵ,


where 𝒯 is an arbitrary distance function to evaluate the change of the new policy with respect to a reference/old policy, and ϵ denotes the allowed change for the policy. 

To make the above objective amenable to gradient based optimization we employ Lagrangian Relaxation, yielding the following primal:


    max_θmin_α > 0 L(θ,α) = 𝔼_ s ∼𝒟,i ∼ I, a ∼ q(· | s, i)[ logπ_θ(a|s, i) ] + 
    α(ϵ - 𝔼_s ∼𝒟,i ∼ I[ 𝒯(π_θ_k(·|s, i) , π_θ(·|s, i))]).


We solve for θ by iterating the inner and outer optimization programs independently: We fix the parameters θ to their current value and optimize for the Lagrangian multipliers (inner minimization) and then we fix the Lagrangian multipliers to their current value and optimize for θ (outer maximization). In practice we found that it is effective to simply perform one gradient step each in inner and outer optimization for each sampled batch of data.


The optimization given above is general, i.e. it works for any general type of policy. As described in the main paper, we consider hierarchical policies of the form 

    π_θ(a | s, i) = ∑^M_o=1π^L_θ(a | s, o) π^H_θ(o | s, i).

In particular, in all experiments we made use of a mixture of Gaussians parametrization, where the high level policy π^H_θ is a categorical distribution over low level π^L_θ Gaussian policies, i.e,

    π_θ(a|s, i)    = π(a|{α_θ^j,μ_θ^j,Σ_θ^j}(s)_j=1...M) 
       =  ∑_j=1^M α^j_θ(s, i)𝒩(μ^j_θ(s),Σ^j_θ(s)) 
       ∀ s ∑_j=1^M α^j(s,i) = 1 , and,  α^j(s, i) > 0

where j denote the index of components and α is the high level policy π^H assigning probabilities to each mixture component for a state s given the task and the low level policies are all Gaussian. Here α^js are the probabilities for a categorical distribution over the components.
 

We also define the following distance function between old and new mixture of Gaussian policies

    𝒯(π_θ_k(·|s, i),π_θ(·|s, i)) = 𝒯_H(s, i) + 𝒯_L(s)



    𝒯_H(s,i) = KL(Cat({α_θ_k^j(s, i)}_j=1...M) Cat({α_θ^j(s, i)}_j=1...M))




    𝒯_L(s) = 1/M∑_j=1^MKL(𝒩(μ^j_θ_k(s),Σ^j_θ_k(s)) 𝒩(μ^j_θ(s),Σ^j_θ(s)))


where 𝒯_H evaluates the KL between categorical distributions and 𝒯_L corresponds to the average KL across Gaussian components, as also described in the main paper (c.f. Equation 5 in the main paper).

In order to bound the change of categorical distributions, means and covariances of the components independently – which makes it easy to control the convergence of the policy and which can prevent premature convergence as argued in <cit.> – we separate out the following three intermediate policies


    π_θ^Σ(a|s, i) = π(a|{α_θ_k^j,μ_θ_k^j,Σ_θ^j}(s, i)_j=1...M) 
    π_θ^μ(a|s, i) = π(a|{α_θ_k^j,μ_θ^j,Σ_θ_k^j}(s, i)_j=1...M) 
    π_θ^α(a|s, i) = π(a|{α_θ^j,μ_θ_k^j,Σ_θ_k^j}(s, i)_j=1...M)



Which yields the following final optimization program


    θ^(k+1)    = _θ𝔼_s ∼𝒟, i ∼ I, a ∼ q(· | s, i)[ 
       logπ_θ^μ(a|s, i) + logπ_θ^Σ(a|s, i) + logπ_θ^α(a|s, i)],   
       s.t. 𝔼_s ∼𝒟, i ∼ I[𝒯(π_θ_k(a|s, i) | π_θ^μ(a|s, i))] < ϵ_μ,
    
       s.t. 𝔼_s ∼𝒟, i ∼ I[𝒯(π_θ_k(a|s, i) | π_θ^Σ(a|s, i))] < ϵ_Σ,
    
       s.t. 𝔼_s ∼𝒟, i ∼ I[𝒯(π_θ_k(a|s, i) | π_θ^α(a|s, i))] < ϵ_α,


This decoupling allows us to set different ϵ values for the change of means, covariances and categorical probabilities, i.e., ϵ_μ , ϵ_Σ, ϵ_α. 
Different ϵ lead to different learning rates. We always set a much smaller epsilon for the covariance and categorical than for the mean. The intuition is that while we would like the distribution to converge quickly in the action space, we also want to keep the exploration both locally (via the covariance matrix) and globally (via the high level categorical distribution) to avoid premature convergence.   



 §.§ Algorithmic Details



  §.§.§ Pseudocode for the full procedure

We provide a pseudo-code listing of the full optimization procedure – and the asynchronous data gathering – performed by   in Algorithm <ref> and <ref>. The implementation relies on Sonnet <cit.> and TensorFlow <cit.>.









  §.§.§ Details on the policy improvement step 

As described in the main paper we consider the same setting as
scheduled auxiliary control setting (SAC-X) <cit.> to perform policy improvement (with uniform random switches between tasks every N steps within an episode, the SAC-U setting).

Given a replay buffer containing data gathered from all tasks, where for each trajectory snippet τ = { (s_0, a_0, R_0), …, (s_L, a_L, R_L) } we record the rewards for all tasks R_t = [r_i_1(s_t, a_t), …, r_i_|I|(s_t, a_t)] as a vector in the buffer, we define the retrace objective for learning Q̂, parameterized via ϕ, following <cit.> as

    min_ϕ L(ϕ) = ∑_i ∼ I𝔼_τ∼𝒟[ ( r_i(s_t, a_t) +  
       γ Q^ret(s_t+1, a_t+1, i) - Q̂_ϕ(s_t, a_t, i))^2 ], 
       with  Q^ret(s_t, a_t, i) = ∑_j=t^∞( γ^j-t∏_k=t^j c_k )[ δ_Q(s_j, s_j+1) ], 
       δ_Q(s_j, s_j+1) =   r_i(s_j, a_j) + 
       γ𝔼_π_θ_k(a | s_j+1, i),
      [ Q̂_ϕ'(s_j+1, ·, i; ϕ') ] - Q̂_ϕ'(s_j, a_j, i),

where the importance weights are defined as c_k = min(1, π_θ_k(a_k | s_k, i)/b(a_k | s_k)), with b(a_k | s_k) denoting an arbitrary behavior policy; in particular this will be the policy for the executed tasks during an episode as in <cit.>. Note that, in practice, we truncate the infinite sum after L steps, bootstrapping with Q̂. We further perform optimization of Equation (<ref>) via gradient descent and make use of a target network <cit.>, denoted with parameters ϕ', which we copy from ϕ after a couple of gradient steps.
We reiterate that, as the state-action value function Q̂ remains independent of the policy's structure, we are able to utilize any other off-the-shelf Q-learning algorithm such as TD(0) <cit.>.

Given that we utilize the same policy evaluation mechanism as SAC-U it is worth pausing here to identify the differences between SAC-U and our approach. The main difference is in the policy parameterization: SAC-U used a monolithic policy for each task π(a | s, i) (although a neural network with shared components, potentially leading to some implicit task transfer, was used). Furthermore, we perform policy optimization based on MPO instead of using stochastic value gradients (SVG <cit.>). We can thus recover a variant of plain SAC-U using MPO if we drop the hierarchical policy parameterization, which we employ in the single task experiments in the main paper.




  §.§.§ Network Architectures


To represent the Q-function in the multitask case we use the network architecture from SAC-X (see right sub-figure in Figure <ref>).
The proprioception of the robot, the features of the objects and the actions are fed together in a torso network.
At the input we use a fully connected first layer of 200 units, followed by a layer normalization operator, an optional tanh activation and another fully connected layer of 200 units with an ELU activation function.
The output of this torso network is shared by independent head networks for each of the tasks (or intentions, as they are called in the SAC-X paper).
Each head has two fully connected layers and outputs a Q-value for this task, given the input of the network. Using the task identifier we then can compute the Q value for a given sample by discrete selection of the according head output.




While we use the network architecture for the Q function for all multitask experiments, we investigate different architectures for the policy in this paper.
The original SAC-X policy architecture is shown in Figure <ref> (left sub-figure).
The main structure follows the same basic principle that we use in the Q function architecture. The only difference is that the heads compute the required parameters for the policy distribution we want to use (see subsection <ref>). This architecture is referenced as the independent heads (or task dependent heads).



The alternatives we investigate in this paper are the monolithic policy architecture (see Figure <ref>, left sub-figure) and the hierarchical policy architecture (see Figure <ref>, right sub-figure).
For the monolithic policy architecture we reduce the original policy architecture basically to one head and append the task-id as a one-hot encoded vector to the input. 
For the hierarchical architecture, we build on the same torso and create a set of networks parameterizing the Gaussians which are shared across tasks and a task-specific network to parameterize the categorical distribution for each task. The final mixture distribution is task-dependent for the high-level controller but task-independent for the low-level policies.




  §.§.§ Algorithm Hyperparameters



In this section we outline the details on the hyperparameters used for   and baselines in both single task and multitask experiments.
All experiments use feed-forward neural networks. We consider a flat policy represented by a Gaussian distribution and a hierarchical policy represented by a mixture of Gaussians distribution. The flat policy is given by a Gaussian distribution with a diagonal covariance matrix, i.e, 
π(a|s,θ) = 𝒩(μ , 
  Σ). The neural network outputs the mean μ=μ(s) and diagonal Cholesky factors A=A(s), such that Σ = AA^T. The diagonal factor A has positive diagonal elements enforced by the softplus transform A_ii←log(1 + exp(A_ii)) to ensure positive definiteness of the diagonal covariance matrix.
Mixture of Gaussian policy has a number of Gaussian components as well as a categorical distribution for selecting the components. The neural network outputs the Gaussian components based on the same setup described above for a single Gaussian and outputs the logits for representing the categorical distribution.
Tables <ref> show the hyperparameters we used for the single tasks experiments. We found layer normalization and a hyperbolic tangent (tanh) on the layer following the layer normalization are important for stability of the algorithms. For   the most important hyperparameters are the constraints in Step 1 and Step 2 of the algorithm.










 §.§ Additional Details on the SAC-U with SVG baseline

For the SAC-U baseline we used a re-implementation of the method from <cit.> using SVG <cit.> for optimizing the policy. Concretely we use the same basic network structure as for the "Monolithic" baseline with MPO and parameterize the
policy as 

    π_θ = 𝒩(μ_θ(s, i),σ^2_θ(s, i) I),

where I denotes the identity matrix and σ_θ(s, i) is computed from the network output via a softplus activation function. 

Together with entropy regularization, as described in <cit.> the policy can be optimized via gradient ascent, following the reparameterized gradient for a given states sampled from the replay:

    ∇_θ𝔼_π_θ(a | s, i)[Q̂(a, s, i)] + αH(π_θ(a | s, i)),

which can be computed, using the reparameterization trick, as 

    𝔼_ζ∼𝒩(0, I)[∇_θ g_θ(s, i, ζ) ∇_g Q(g_θ(s, i, ζ), s, i)] + 
    α∇_θH(π_θ(a | s, i)),

where g_θ(s, i, ζ) = μ_θ(s, i) + σ_θ() * ζ is now a deterministic function of a sample from the standard multivariate normal distribution. See e.g. <cit.> (for SVG) as well as <cit.> (for the reparameterization trick) for a detailed explanation.





 §.§ Details on the Experimental Setup 






  §.§.§ Simulation (Single- and Multitask)


For the simulation of the robot arm experiments the numerical simulator MuJoCo [MuJoCo: see www.mujoco.org] was used – using a model we identified from the real robot setup.

We run experiments of length 2 - 7 days for the simulation experiments (depending on the task) with access to 2-5 recent CPUs with 32 cores each (depending on the number of actors) and 2 recent NVIDIA GPUs for the learner. Computation for data buffering is negligible.





  §.§.§ Real Robot Multitask



Compared to simulation where the ground truth position of all objects is known, in the real robot setting, three cameras on the basket track the cube using fiducials (augmented reality tags).

For safety reasons, external forces are measured at the wrist and the episode is terminated if a threshold of 20N on any of the three principle axes is exceeded (this is handled as a terminal state with reward 0 for the agent), adding further to the difficulty of the task.

The real robot setup differs from the simulation in the reset behaviour between episodes, since objects need to be physically moved around when randomizing, which takes a considerable amount of time. To keep overhead small, object positions are randomized only every 25 episodes, using a hand-coded controller. Objects are also placed back in the basket if they were thrown out during the previous episode. Other than that, objects start in the same place as they were left in the previous episode. The robot's starting pose is randomized each episode, as in simulation.




 §.§ Task Descriptions





  §.§.§ Pile1





For this task we have a real setup and a MuJoCo simulation that are well aligned. It consists of a Sawyer robot arm mounted on a table and equipped with a Robotiq 2F-85 parallel gripper. In front of the robot there is a basket of size 20x20 cm which contains three cubes with an edge length of 5 cm (see Figure <ref>).

The agent is provided with proprioception information for the arm (joint positions, velocities and torques), and the tool center point position computed via forward kinematics. For the gripper, it receives the motor position and velocity, as well as a binary grasp flag. It also receives a wrist sensor's force and torque readings. Finally, it is provided with the cubes' poses as estimated via the fiducials, and the relative distances between the arm's tool center point and each object. At each time step, a history of two previous observations is provided to the agent, along with the last two joint control commands, in order to account for potential communication delays on the real robot. The observation space is detailed in Table <ref>.

The robot arm is controlled in Cartesian mode at 20Hz. The action space for the agent is 5-dimensional, as detailed in Table <ref>. The gripper movement is also restricted to a cubic volume above the basket using virtual walls.





For the Pile1 experiment we use 7 different task to learn, following the SAC-X principles. The first 6 tasks are seen as auxiliary tasks that help to learn the final task (STACK_AND_LEAVE(G, Y)) of stacking the green cube on top of the yellow cube.
Overview of the used tasks: 

    
  * REACH(G): stol(d(TCP, G), 0.02, 0.15): 

    Minimize the distance of the TCP to the green cube.
    
  * GRASP: 

    Activate grasp sensor of gripper ("inward grasp signal" of Robotiq gripper)
    
  * LIFT(G): slin(G, 0.03, 0.10) 

    Increase z coordinate of an object more than 3cm relative to the table.
    
  * PLACE_WIDE(G, Y): stol(d(G, Y + [0,0,0.05]), 0.01, 0.20)

    Bring green cube to a position 5cm above the yellow cube.
    
  * PLACE_NARROW(G, Y): stol(d(G, Y + [0,0,0.05]), 0.00, 0.01): 

    Like PLACE_WIDE(G, Y) but more precise.
    
  * STACK(G, Y): btol(d_xy(G, Y), 0.03) * btol(d_z(G, Y) + 0.05, 0.01) * (1 - GRASP) 

    Sparse binary reward for bringing the green cube on top of the yellow one (with 3cm tolerance horizontally and 1cm vertically) and disengaging the grasp sensor.
    
  * STACK_AND_LEAVE(G, Y): stol(d_z(TCP, G)+0.10, 0.03, 0.10) * STACK(G, Y) 

    Like STACK(G, Y), but needs to move the arm 10cm above the green cube.


Let d(o_i, o_j) be the distance between the reference of two objects (the reference of the cubes are the center of mass, TCP is the reference of the gripper), and let d_A be the distance only in the dimensions denoted by the set of axes A. We can define the reward function details by:


    stol(v, ϵ, r) =
    
      1    iff |v| < ϵ
    
      1 - tanh^2( atanh(√(0.95))/r |v|)    else



    slin(v, ϵ_min, ϵ_max) =
    
      0    iff v < ϵ_min
    
      1    iff v > ϵ_max
    v - ϵ_min/ϵ_max - ϵ_min   else



    btol(v, ϵ) =
    
      1    iff |v| < ϵ
    
      0    else




  §.§.§ Pile2





For the Pile2 task, taken from <cit.>, we use a different robot arm, control mode and task setup to emphasize that 's improvements are not restricted to cartesian control or a specific robot and that the approach also works for multiple external tasks.

Here, the agent controls a simulated Kinova Jaco robot arm, equipped with a Kinova KG-3 gripper. The robot faces a 40 x 40 cm basket that contains a red cube and a blue cube. Both cubes have an edge length of 5 cm (see Figure <ref>). The agent is provided with proprioceptive information for the arm and the fingers (joint positions and velocities) as well as the tool center point position (TCP) computed via forward kinematics. Further, the simulated gripper is equipped with a touch sensor for each of the three fingers, whose value is provided to the agent as well. Finally, the agent receives the cubes' poses, their translational and rotational velocities and the relative distances between the arm's tool center point and each object. Neither observation nor action history is used in the Pile2 experiments. The cubes are spawned at random on the table surface and the robot hand is initialized randomly above the table-top with a height offset of up to 20 cm above the table (minimum 10 cm). The observation space is detailed in Table <ref>.



The robot arm is controlled in raw joint velocity mode at 20 Hz. The action space is 9-dimensional as detailed in Table <ref>. There are no virtual walls and the robot's movement is solely restricted by the velocity limits and the objects in the scene.

Analogous to Pile1 and the SAC-X setup, we use 10 different task for Pile2. The first 8 tasks are seen as auxiliary tasks, that the agent uses to learn the main two tasks PILE_RED and PILE_BLUE, which represent stacking the red cube on the blue cube and stacking the blue cube on the red cube respectively. The tasks used in the experiment are:


    
  * REACH(R) = stol(d(TCP, R), 0.01, 0.25): 

    Minimize the distance of the TCP to the red cube.
    
  * REACH(B) = stol(d(TCP, B), 0.01, 0.25): 

    Minimize the distance of the TCP to the blue cube.
    
  * MOVE(R) = slin(| linvel(R) |, 0, 1): 

    Move the red cube.
    
  * MOVE(B) = slin(| linvel(B) |, 0, 1): 

    Move the blue cube.
    
  * LIFT(R) = btol(pos_z(R), 0.05) 

    Increase the z-coordinate of the red cube to more than 5cm relative to the table.
    
  * LIFT(B) = btol(pos_z(B), 0.05) 

    Increase the z-coordinate of the blue cube to more than 5cm relative to the table.
    
  * ABOVE_CLOSE(R, B) = above(R, B) * stol(d(R, B), 0.05, 0.2) 

    Bring the red cube to a position above of and close to the blue cube.
    
  * ABOVE_CLOSE(B, R) = above(B, R) * stol(d(R, B), 0.05, 0.2) 

    Bring the blue cube to a position above of and close to the red cube.
    
  * PILE(R): 

    Place the red cube on another object (touches the top). Only given when the cube doesn't touch the robot or the table.
    
  * PILE(B): 

    Place the blue cube on another object (touches the top). Only given when the cube doesn't touch the robot or the table.


The sparse reward above(A, B) is given by comparing the bounding boxes of the two objects A and B. If the bounding box of object A is completely above the highest point of object B's bounding box, above(A, B) is 1, otherwise above(A, B) is 0. 





  §.§.§ Clean-Up



The Clean-Up task is also taken from <cit.> and builds on the setup described for the Pile2 task. Besides the two cubes, the work-space contains an additional box with a moveable lid, that is always closed initially (see Figure <ref>). The agent's goal is to clean up the scene by placing the cubes inside the box. In addition to the observations used in the Pile2 task, the agent observes the lid's angle and it's angle velocity.



Analogous to Pile2 and the SAC-X setup, we use 13 different task for Clean-Up. The first 12 tasks are seen as auxiliary tasks, that the agent uses to learn the main task ALL_INSIDE_BOX. The tasks used in this experiments are:


    
  * REACH(R) = stol(d(TCP, R), 0.01, 0.25): 

    Minimize the distance of the TCP to the red cube.
    
  * REACH(B) = stol(d(TCP, B), 0.01, 0.25): 

    Minimize the distance of the TCP to the blue cube.
    
  * MOVE(R) = slin(| linvel(R) |, 0, 1): 

    Move the red cube.
    
  * MOVE(B) = slin(| linvel(B) |, 0, 1): 

    Move the blue cube.
    
  * NO_TOUCH = 1 - GRASP 

    Sparse binary reward, given when neither of the touch sensors is active.
    
  * LIFT(R) = btol(pos_z(R), 0.05) 

    Increase the z-coordinate of the red cube to more than 5cm relative to the table.
    
  * LIFT(B) = btol(pos_z(B), 0.05) 

    Increase the z-coordinate of the blue cube to more than 5cm relative to the table.
    
  * OPEN_BOX = slin(angle(lid), 0.01, 1.5) 

    Open the lid up to 85 degrees.
    
  * ABOVE_CLOSE(R, BOX) = above(R, BOX) * btol(|d(R, BOX)|, 0.2) 

    Bring the red cube to a position above of and close to the box.
    
  * ABOVE_CLOSE(B, BOX) = above(B, BOX) * btol(|d(B, BOX)|, 0.2) 

    Bring the blue cube to a position above of and close to the box.
    
  * INSIDE(R, BOX) = inside(R, BOX) 

    Place the red cube inside the box.
    
  * INSIDE(B, BOX) = inside(R, BOX) 

    Place the blue cube inside the box.
    
  * INSIDE(ALL, BOX) = INSIDE(R, BOX) * INSIDE(B, BOX) 

    Place the all cubes inside the box.


The sparse reward inside(A, BOX) is given by comparing the bounds of the object A and the box. If the bounding box of object A is completely within the box's bounds inside(A, BOX) is 1, otherwise inside(A, BOX) is 0.



































 §.§ Multitask Results 


































 §.§ Additional Multitask Ablations




  §.§.§ Importance of Regularization
 
Coordinating convergence progress in hierarchical models can be challenging but can be effectively moderated by the KL constraints. We perform an ablation study varying the strength of KL constraints on the high-level controller between prior and the current policy during training – demonstrating a range of possible degenerate behaviors.

As depicted in Figure <ref>, with a weak KL constraint, the high-level controller can converge too quickly leading to only a single sub-policy getting a gradient signal per step. In addition, the categorical distribution tends to change at a high rate, preventing successful convergence for the low-level policies. 
On the other hand, the low-level policies are missing task information to encourage decomposition as described in Section <ref>. This fact, in combination with strong KL constraints, can prevent specialization of the low-level policies as the categorical remains near static, finally leading to no or very slow convergence. As long as a reasonable constraint is picked (here a range of over 2 orders of magnitude), convergence is fast and the final policies obtain high quality for all tasks. We note that no tuning of the constraints is required across domains and the range of admissible constraints is quite broad.





  §.§.§ Impact of Data Rate
 
Evaluating in a distributed off-policy setting enables us to investigate the effect of different rates for data generation by controlling the number of actors.
Figure <ref> demonstrates how the different agents converge slower lower data rates (changing from 5 to 1 actor). These experiments are highly relevant for the application domain as the number of available physical robots for real-world experiments is typically highly limited.
To limit computational cost, we focus on the simplest domain from Section <ref>, Pile1, in this comparison.  










  §.§.§ Number of Component Policies
 





 §.§ Hierarchical Policies in Reparameterization Gradient-based RL
 
To test whether the benefits of a hierarchical policy transfer to a setting where a different algorithm is used to optimize the policy we performed additional experiments using SVG <cit.> in place of MPO. 
For this purpose we use the same hierarchical policy structure as for the MPO experiments but change the categorical to an implementation that enables reparameterization with the Gumbel-Softmax trick <cit.>. We then change the entropy regularization from Equation (<ref>) to a KL towards a target policy (as entropy regularization did not give stable learning in this setting) and use 

a regularizer equivalent to the distance function (per component KL's from Equation (<ref>)) – using a multiplier of 0.05 for the regularization multiplier was found to be the best setting via a coarse grid search. This is similar to previous work on hierarchical RL with SVG <cit.>.

This extension of SVG is conceptually similar to a single-step-option version of the option-critic <cit.>. Simplified, SVG is an off-policy actor-critic algorithm which builds on the reparametrisation instead of likelihood ratio trick (commonly leading to lower variance <cit.>). Since we do not build on temporally extended sub-policies, the algorithm simplifies to using a single critic (see Section <ref>).

The results of this experiment are depicted in Figure <ref>, as can be seen, for this simple domain results in mild improvements over standard SAC-U. 








