Monte-Carlo Tree Search as Regularized Policy Optimization

Jean-Bastien Grill, Florent Altché, Yunhao Tang, Thomas Hubert, Michal Valko, Ioannis Antonoglou, Rémi Munos

Introduction

Policy gradient is at the core of many state-of-the-art deep reinforcement learning (RL) algorithms. Among many successive improvements to the original algorithm (Sutton et al.,, 2000), regularized policy optimization encompasses a large family of such techniques. Among them trust region policy optimization is a prominent example (Schulman et al.,, 2015, 2017; Abdolmaleki et al.,, 2018; Song et al.,, 2019). These algorithmic enhancements have led to significant performance gains in various benchmark domains (Song et al.,, 2019).

As another successful RL framework, the AlphaZero family of algorithms (Silver et al.,, 2016; Silver et al., 2017b, ; Silver et al., 2017a, ; Schrittwieser et al.,, 2019) have obtained groundbreaking results on challenging domains by combining classical deep learning (He et al.,, 2016) and RL (Williams,, 1992) techniques with Monte-Carlo tree search (Kocsis and Szepesvári,, 2006). To search efficiently, the MCTS action selection criteria takes inspiration from bandits (Auer,, 2002). Interestingly, AlphaZero employs an alternative handcrafted heuristic to achieve super-human performance on board games (Silver et al.,, 2016). Recent MCTS-based MuZero (Schrittwieser et al.,, 2019) has also led to state-of-the-art results in the Atari benchmarks (Bellemare et al.,, 2013).

Our main contribution is connecting MCTS algorithms, in particular the highly-successful AlphaZero, with MPO, a state-of-the-art model-free policy-optimization algorithm (Abdolmaleki et al.,, 2018). Specifically, we show that the empirical visit distribution of actions in AlphaZero’s search procedure approximates the solution of a regularized policy-optimization objective. With this insight, our second contribution a modified version of AlphaZero that comes significant performance gains over the original algorithm, especially in cases where AlphaZero has been observed to fail, e.g., when per-search simulation budgets are low (Hamrick et al.,, 2020).

In Section 2, we briefly present MCTS with a focus on AlphaZero and provide a short summary of the model-free policy-optimization. In Section 3, we show that AlphaZero (and many other MCTS algorithms) computes approximate solutions to a family of regularized policy optimization problems. With this insight, Section 4 introduces a modified version of AlphaZero which leverages the benefits of the policy optimization formalism to improve upon the original algorithm. Finally, Section 5 shows that this modified algorithm outperforms AlphaZero on Atari games and continuous control tasks.

Background

We focus on the AlphaZero family, comprised of AlphaGo (Silver et al.,, 2016), AlphaGo Zero (Silver et al., 2017b, ), AlphaZero (Silver et al., 2017a, ), and MuZero (Schrittwieser et al.,, 2019), which are among the most successful algorithms in combining model-free and model-based RL. Although they make different assumptions, all of these methods share the same underlying search algorithm, which we refer to as AlphaZero for simplicity.

One of the main differences between AlphaZero and previous MCTS algorithms such as UCT (Kocsis and Szepesvári,, 2006) is the introduction of a learned prior πθ\pi_{\theta} and value function vθv_{\theta}. Additionally, AlphaZero’s search procedure applies the following action selection heuristic,

where cc is a numerical constant,Schrittwieser et al., (2019) uses a cc that has a slow-varying dependency on ∑bn(x,b)\sum_{b}n(x,b), which we omit here for simplicity, as it was the case of Silver et al., 2017a . n(x,a)n(x,a) is the number of times that action aa has been selected from state xx during search, and Q(x,a)Q(x,a) is an estimate of the Q-function for state-action pair (x,a)(x,a) computed from search statistics and using vθv_{\theta} for bootstrapping.

Intuitively, this selection criteria balances exploration and exploitation, by selecting the most promising actions (high Q-value Q(x,a)Q(x,a) and prior policy πθ(a∣x)\pi_{\theta}(a|x)) or actions that have rarely been explored (small visit count n(x,a)n(x,a)). We denote by NsimN_{\text{sim}} the simulation budget, i.e., the search is run with NsimN_{\text{sim}} simulations. A more detailed presentation of AlphaZero is in Appendix A; for a full description of the algorithm, refer to Silver et al., 2017a .

2 Policy optimization

Policy optimization aims at finding a globally optimal policy πθ\pi_{\theta}, generally using iterative updates. Each iteration updates the current policy πθ\pi_{\theta} by solving a local maximization problem of the form

Without regularizations, i.e., R=0\mathcal{R}=0, Equation 2 reduces to policy iteration (Sutton and Barto,, 1998). When πθ\pi_{\theta} is updated using a single gradient ascent step towards the solution of Equation 2, instead of using the solution directly, the above formulation reduces to (regularized) policy gradient (Sutton et al.,, 2000; Levine,, 2018).

MCTS as regularized policy optimization

In Section 2, we presented AlphaZero that relies on model-based planning. We also presented policy optimization, a framework that has achieved good performance in model-free RL. In this section, we establish our main claim namely that AlphaZero’s action selection criteria can be interpreted as approximating the solution to a regularized policy-optimization objective.

First, let us define the empirical visit distribution π^\hat{\pi} as

Note that in Equation 3, we consider an extra visit per action compared to the acting policy and distillation target in the original definition (Silver et al.,, 2016). This extra visit is introduced for convenience in the upcoming analysis (to avoid divisions by zero) and does not change the generality of our results.

We also define the multiplier λN\lambda_{N} as

where the shorthand notation nan_{a} is used for n(x,a)n(x,a), and N(x)≜∑bnbN(x)\triangleq\sum_{b}n_{b} denotes the number of visits to xx during search. With this notation, the action selection formula of Equation 1 can be written as selecting the action a⋆a^{\star} such that

2 A related regularized policy optimization problem

We now define πˉ\bar{\pi} as the solution to a regularized policy optimization problem; we will see in the next subsection that the visit distribution π^\hat{\pi} is a good approximation of πˉ\bar{\pi}.

Let πˉ\boldsymbol{\bar{\pi}} be the solution to the following objective

We can see from Equation 2 and Footnote 4 that πˉ\boldsymbol{\bar{\pi}} is the solution to a policy optimization problem where Q\mathcal{Q} is set to the search Q-values, and the regularization term R\mathcal{R} is a reversed KL-divergence weighted by factor λN\lambda_{N}.

In addition, note that πˉ\bar{\pi} is as a smooth version of the arg max⁡\operatorname*{arg\,max} associated to the search Q-values q\mathbf{q}. In fact, πˉ\bar{\pi} can be computed as (Section B.3 gives a detailed derivation of πˉ\bar{\pi})

3 AlphaZero as policy optimization

We now analyze the action selection formula of AlphaZero (Equation 1). Interestingly, we show that this formula, which was handcraftedNonetheless, this heuristic could be interpreted as loosely inspired by bandits (Rosin,, 2011), but was adapted to accommodate a prior term πθ\pi_{\theta}. independently of the policy optimization research, turns out to result in a distribution π^\hat{\pi} that closely relates to the policy optimization solution πˉ\bar{\pi}.

The main formal claim of this section that AlphaZero’s search policy π^\hat{\pi} tracks the exact solution πˉ\bar{\pi} of the regularized policy optimization problem of Footnote 4. We show that 1 and 2 support this claim from two complementary perspectives.

First, with Proposition 1, we show that π^\hat{\pi} approximately follows the gradient of the concave objective for which πˉ\bar{\pi} is the optimum.

with a⋆a^{\star} being the action realizing Equation 1 as defined in Equation 5 and \hat{\pi}=\mathopen{}\mathclose{{}\left(1+\mathbf{n}}\right)/\mathopen{}\mathclose{{}\left(|\mathcal{A}|+\sum_{b}n_{b}}\right) as defined in Equation 3, is a function of the count vector extended to real values.

The only thing that the search algorithm eventually influences through the tree search is the visit count distribution. If we could do an infinitesimally small update, then the greedy update maximizing Equation 8 would be in the direction of the partial derivative of Equation 9. However, as we are restricted by a discrete update, then increasing the visit count as in Proposition 1 makes π^\hat{\pi} track πˉ\bar{\pi}. Below, we further characterize the selected action a⋆a^{\star} and assume πθ>0.\pi_{\theta}>0.

The action a⋆a^{\star} realizing Equation 1 is such that

To acquire intuition from Proposition 2, note that once a⋆a^{\star} is selected, its count na⋆n_{a^{\star}} increases and so does the total count NN. As a result, π^(a⋆)\hat{\pi}(a^{\star}) increases (in the order of \mathcal{O}\mathopen{}\mathclose{{}\left(1/N}\right)) and further approximates πˉ(a⋆)\bar{\pi}(a^{\star}). As such, Proposition 2 shows that the action selection formula encourages the shape of π^\hat{\pi} to be close to that of πˉ\bar{\pi}, until in the limit the two distributions coincide.

Note that 1 and 2 are a special case of a more general result that we formally prove in Section D.1. In this particular case, the proof relies on noticing that

Then, since ∑aπ^(a)=∑aπˉ(a)\sum_{a}\hat{\pi}(a)=\sum_{a}\bar{\pi}(a) and π^>0\hat{\pi}>0 and πˉ>0\bar{\pi}>0, there exists at least one action for which 0<π^(a)≤πˉ(a)0<\hat{\pi}(a)\leq\bar{\pi}(a), i.e., 1/π^(a)−1/πˉ(a)≥01/\hat{\pi}(a)-1/\bar{\pi}(a)\geq 0.

To state a formal statement on π^\hat{\pi} approximating πˉ\bar{\pi}, in Section D.3 we expand the conclusion under the assumption that πˉ\bar{\pi} is a constant. In this case we can derive a bound for the convergence rate of these two distributions as NN increases over the search,

4 Generalization to common MCTS algorithms

Besides AlphaZero, UCT (Kocsis and Szepesvári,, 2006) is another heuristic with a selection criteria inspired by UCB, defined as

Contrary to AlphaZero, the standard UCT formula does not involve a prior policy. In this section, we consider a slightly modified version of UCT with a (learned) prior πθ\pi_{\theta}, as defined in Equation 14. By setting the prior πθ\pi_{\theta} to the uniform distribution, we recover the original UCT formula,

Using the same reasoning as in Section 3.3, we now show that this modified UCT formula also tracks the solution to a regularized policy optimization problem, thus generalizing our result to commonly used MCTS algorithms.

First, we introduce πˉUCT\bar{\pi}_{\text{UCT}}, which is tracked by the UCT visit distribution, as:

where D(x,y)≜2−2∑ixi⋅yi\displaystyle D(\boldsymbol{x},\boldsymbol{y})\triangleq 2-2\sum_{i}\sqrt{\boldsymbol{x}_{i}\cdot\boldsymbol{y}_{i}} is an ff-divergenceIn particular D(x,y)≥0,D(x,y)=0  ⟹  x=yD(x,y)\geq 0,D(x,y)=0\implies x=y and D(x,y)D(x,y) is jointly convex in xx and yy (Csiszár,, 1964; Liese and Vajda,, 2006).

To sum up, similar to the previous section, we show that UCT’s search policy π^UCT\hat{\pi}_{\text{UCT}} tracks the exact solution πˉUCT\bar{\pi}_{\text{UCT}} of the regularized policy optimization problem of Equation 15.

Algorithmic benefits

In Section 3, we introduced a distribution πˉ\bar{\pi} as the solution to a regularized policy optimization problem. We then showed that AlphaZero, along with general MCTS algorithms, select actions such that the empirical visit distribution π^\hat{\pi} actively approximates πˉ\bar{\pi}. Building on this insight, below we argue that πˉ\bar{\pi} is preferable to π^\hat{\pi}, and we propose three complementary algorithmic changes to AlphaZero.

MCTS algorithms produce Q-values as a by-product of the search procedure. However, MCTS does not directly use search Q-values to compute the policy, but instead uses the visit distribution π^\hat{\pi} (search Q-values implicitly influence π^\hat{\pi} by guiding the search). We postulate that this degrades the performance especially at low simulation budgets NsimN_{\text{sim}} for several reasons:

When a promising new (high-value) leaf is discovered, many additional simulations might be needed before this information is reflected in π^\hat{\pi}; since πˉ\bar{\pi} is directly computed from Q-values, this information is updated instantly.

By definition (Equation 3), π^\hat{\pi} is the ratio of two integers and has limited expressiveness when NsimN_{\text{sim}} is low, which might lead to a sub-optimal policy; πˉ\bar{\pi} does not have this constraint.

The prior πθ\pi_{\theta} is trained against the target π^\hat{\pi}, but the latter is only improved for actions that have been sampled at least once during search. Due to the deterministic action selection (Equation 1), this may be problematic for certain actions that would require a large simulation budget to be sampled even once.

The above downsides cause MCTS to be highly sensitive to simulation budgets NsimN_{\text{sim}}. When NsimN_{\text{sim}} is high relative to the branching factor of the tree search, i.e., number of actions, MCTS algorithms such as AlphaZero perform well. However, this performance drops significantly when NsimN_{\text{sim}} is low as showed by Hamrick et al., (2020); see also e.g., Figure 3.D. by Schrittwieser et al., (2019).

We illustrate the effect of simulation budgets in Figure 1, where xx-axis shows the budgets NsimN_{\text{sim}} and yy-axis shows the episodic performance of algorithms applying π^\hat{\pi} vs. πˉ\bar{\pi}; see the details of these algorithms in the following sections. We see that π^\hat{\pi} is highly sensitive to simulation budgets while πˉ\bar{\pi} performs consistently well across all budget values.

2 Proposed improvements to AlphaZero

We have pointed out potential issues due to π^\hat{\pi}. We now detail how to use πˉ\bar{\pi} as a replacement to resolve such issues.Recall that we have identified three issues. Each algorithmic variant below helps in addressing issue 1 and 2. Furthermore, the Learn variant helps address issue 3. Section B.3 shows how to compute πˉ\bar{\pi} in practice.

AlphaZero acts in the real environment by sampling actions according to a∼π^(⋅∣xroot)a\sim\hat{\pi}(\cdot|x_{\text{root}}). Instead, we propose to to sample actions sampling according to a∼πˉ(⋅∣xroot)a\sim\bar{\pi}(\cdot|x_{\text{root}}). We label this variant as Act.

Search: searching with π¯¯𝜋\bar{\pi}

During search, we propose to stochastically sample actions according to πˉ\bar{\pi} instead of the deterministic action selection rule of Equation 1. At each node xx in the tree, πˉ(⋅)\bar{\pi}(\cdot) is computed with Q-values and total visit counts at the node based on Footnote 4. We label this variant as Search.

Learn: learning with π¯¯𝜋\bar{\pi}

AlphaZero computes locally improved policy with tree search and distills such improved policy into πθ\pi_{\theta}. We propose to use πˉ\bar{\pi} as the target policy in place of π^\hat{\pi} to train our prior policy. As a result, the parameters are updated as

where xrootx_{\text{root}} is sampled from a prioritized replay buffer as in AlphaZero. We label this variant as Learn.

All: combining them all

We refer to the combination of these three independent variants as All. Appendix B provides additional implementation details.

Remark

Note that AlphaZero entangles search and learning, which is not desirable. For example, when the action selection formula changes, this impacts not only intermediate search results but also the root visit distribution π^(⋅∣xroot)\hat{\pi}(\cdot|x_{\text{root}}), which is also the learning target for πθ\pi_{\theta}. However, the Learn variant partially disentangles these components. Indeed, the new learning target is πˉ(⋅∣xroot)\bar{\pi}(\cdot|x_{\text{root}}) which is computed from search Q-values, rendering it less sensitive to e.g., the action selection formula.

3 Connections between AlphaZero and model-free policy optimization.

Next, we make the explicit link between proposed algorithmic variants and existing policy optimization algorithms. First, we provide two complementary interpretations.

For this interpretation, we treat Search as a blackbox, i.e., a subroutine that takes a root node xx and returns statistics such as search Q-values.

Recall that policy optimization (Equation 2) maximizes the objective ≈QπθTy\approx\mathcal{Q}_{\pi_{\theta}}^{\mathsf{\scriptscriptstyle T}}\mathbf{y} with the local policy y\mathbf{y}. There are many model-free methods for the estimation of Qπθ\mathcal{Q}_{\pi_{\theta}}, ranging from Monte-Carlo estimates of cumulative returns Qπθ≈∑t≥0γtrt\mathcal{Q}^{\pi_{\theta}}\approx\sum_{t\geq 0}\gamma^{t}r_{t} (Schulman et al.,, 2015, 2017) to using predictions from a Q-value critic Qπθ≈qθ\mathcal{Q}_{\pi_{\theta}}\approx\mathbf{q}_{\theta} trained with off-policy samples (Abdolmaleki et al.,, 2018; Song et al.,, 2019). When solving πˉ\bar{\pi} for the update (Equation 17), we can interpret Learn as a policy optimization algorithm using tree search to estimate Qπθ\mathcal{Q}_{\pi_{\theta}}. Indeed, Learn could be interpreted as building a Q-functionDuring search, because child nodes have fewer simulations than the root, the Q-function estimate at the root slightly under-estimates the acting policy Q-function. critic qθ\mathbf{q}_{\theta} with a tree-structured inductive bias. However, this inductive bias is not built-in a network architecture (Silver et al., 2017c, ; Farquhar et al.,, 2017; Oh et al.,, 2017; Guez et al.,, 2018), but constructed online by an algorithm, i.e., MCTS. Next, Learn computes the locally optimal policy πˉ\bar{\pi} to the regularized policy optimization objective and distills πˉ\bar{\pi} into πθ\pi_{\theta}. This is exactly the approach taken by MPO (Abdolmaleki et al.,, 2018).

Search as policy optimization

We now unpack the algorithmic procedure of the tree search, and show that it can also be interpreted as policy optimization.

During the forward simulation phase of Search, the action at each node xx is selected by sampling a∼πˉ(⋅∣x)a\sim\bar{\pi}(\cdot|x). As a result, the full imaginary trajectory is generated consistently according to policy πˉ\bar{\pi}. During backward updates, each encountered node xx receives a backup value from its child node, which is an exact estimate of Qπˉ(x,a)Q^{\bar{\pi}}(x,a). Finally, the local policy πˉ(⋅∣x)\bar{\pi}(\cdot|x) is updated by solving the constrained optimization problem of Footnote 4, leading to an improved policy over previous πˉ(⋅∣x)\bar{\pi}(\cdot|x). Overall, with NsimN_{\text{sim}} simulated trajectories, Search optimizes the root policy πˉ(⋅∣xroot)\bar{\pi}(\cdot|x_{\text{root}}) and root search Q-values, by carrying out NsimN_{\text{sim}} sequences of MPO-style updates across the entire tree.Note that there are several differences from typical model-free implementations of policy optimization: most notably, unlike a fully-parameterized policy, the tree search policy is tabular at each node. This also entails that the MPO-style distillation is exact. A highly related approach is to update local policies via policy gradients (Anthony et al.,, 2019).

By combining the above two interpretations, we see that the All variant is very similar to a full policy optimization algorithm. Specifically, on a high level, All carries out MPO updates with search Q-values. These search Q-values are also themselves obtained via MPO-style updates within the tree search. This paves the way to our major revelation stated next.

All can be interpreted as regularized policy optimization. Further, since π^\hat{\pi} approximates πˉ\bar{\pi}, AlphaZero and other MCTS algorithms can be interpreted as approximate regularized policy optimization.

Experiments

In this section, we aim to address several questions: (1) How sensitive are state-of-the-art hybrid algorithms such as AlphaZero to low simulation budgets and can the All variant provide a more robust alternative? (2) What changes among Act, Search, and Learn are most critical in this variant performance? (3) How does the performance of the All variant compare with AlphaZero in environments with large branching factors?

Throughout the experiments, we take MuZero (Schrittwieser et al.,, 2019) as the baseline algorithm. As a variant of AlphaZero, MuZero applies tree search in learned models instead of real environments, which makes it applicable to a wider range of problems. Since MuZero shares the same search procedure as AlphaGo, AlphaGo Zero, and AlphaZero, we expect the performance gains to be transferable to these algorithms. Note that the results below were obtained with a scaled-down version of MuZero, which is described in Section B.1.

Hyper-parameters

The hyper-parameters of the algorithms are tuned to achieve the maximum possible performance for baseline MuZero on the Ms Pacman level of the Atari suite (Bellemare et al.,, 2013), and are identical in all experiments with the exception of the number of simulations per step NsimN_{\text{sim}}.The number of actors is scaled linearly with NsimN_{\text{sim}} to maintain the same total number of generated frames per second. In particular, no further tuning was required for the Learn, Search, Act, and All variants, as was expected from the theoretical considerations of Section 3.

1 Search with low simulation budgets

Since AlphaZero solely relies on the π^\hat{\pi} for training targets, it may misbehave when simulation budgets NsimN_{\text{sim}} are low. On the other hand, our new algorithmic variants might perform better in this regime. To confirm these hypotheses, we compare the performance of MuZero and the All variant on the Ms Pacman level of the Atari suite at different levels of simulation budgets.

In Figure 2, we compare the episodic return of All vs. MuZero averaged over 8 seeds, with a simulation budget Nsim=5N_{\text{sim}}=5 and Nsim=50N_{\text{sim}}=50 for an action set of size ∣A∣≤18|\mathcal{A}|\leq 18; thus, we consider that Nsim=5N_{\text{sim}}=5 and Nsim=50N_{\text{sim}}=50 respectively correspond to a low and high simulation budgets relative to the number of actions. We make several observations: (1) At a relatively high simulation budget, Nsim=50N_{\text{sim}}=50, same as Schrittwieser et al., (2019), both MuZero and All exhibit reasonably close levels of performance; though All obtains marginally better performance than MuZero; (2) At low simulation budget, Nsim=5N_{\text{sim}}=5, though both algorithms suffer in performance relative to high budgets, All significantly outperforms MuZero both in terms of learning speed and asymptotic performance; (3) Figure 6 in Section C.1 shows that this behavior is consistently observed at intermediate simulation budgets, with the two algorithms starting to reach comparable levels of performance when Nsim≥24N_{\text{sim}}\geq 24 simulations. These observations confirm the intuitions from Section 3. (4) We provide results on a subset of Atari games in Figure 3, which show that the performance gains due to πˉ\bar{\pi} over π^\hat{\pi} are also observed in other levels than Ms Pacman; see Section C.2 for results on additional levels. This subset of levels are selected based on the experiment setup in Figure S1 of Schrittwieser et al., (2019). Importantly, note that the performance gains of All are consistently significant across selected levels, even at a higher simulation budget of Nsim=50N_{\text{sim}}=50.

2 Ablation study

To better understand which component of the All contributes the most to the performance gains, Figure 4 presents the results of an ablation study where we compare individual component Learn, Search, or Act.

The comparison is shown in Figure 4, we make several observations: (1) At Nsim=5N_{\text{sim}}=5 (Figure 4(a)), the main improvement comes from using the policy optimization solution πˉ\bar{\pi} as the learning target (Learn variant); using πˉ\bar{\pi} during search or acting leads to an additional marginal improvement; (2) Interestingly, we observe a different behavior at Nsim=50N_{\text{sim}}=50 (Figure 4(b)). In this case, using πˉ\bar{\pi} for learning or acting does not lead to a noticeable improvement. However, the superior performance of All is mostly due to sampling according to πˉ\bar{\pi} during search (Search).

The improved performance when using πˉ\bar{\pi} as the learning target (Learn) illustrates the theoretical considerations of Section 3: at low simulation budgets, the discretization noise in π^\hat{\pi} makes it a worse training target than πˉ\bar{\pi}, but this advantage vanishes when the number of simulations per step increases. As predicted by the theoretical results of Section 3, learning and acting using πˉ\bar{\pi} and π^\hat{\pi} becomes equivalent when the simulation budget increases.

On the other hand, we see a slight but significant improvement when sampling the next node according to πˉ\bar{\pi} during search (Search) regardless of the simulation budget. This could be explained by the fact that even at high simulations budget, the Search modification also affect deeper node that have less simulations.

3 Search with large action space – continuous control

The previous results confirm the intuitions presented in Sections 3 and 4; namely, the All variation greatly improves performance at low simulation budgets, and obtain marginally higher performance at high simulation budgets. Since simulation budgets are relative to the number of action, these improvements are critical in tasks with a high number of actions, where MuZero might require a prohibitively high simulation budgets; prior work (Dulac-Arnold et al.,, 2015; Metz et al.,, 2017; Van de Wiele et al.,, 2020) has already identified continuous control tasks as an interesting testbed.

We select high-dimensional environments from DeepMind Control Suite (Tassa et al.,, 2018). The observations are images and action space A=m\mathcal{A}=^{m} with mm dimensions. We apply an action discretization method similar to that of Tang and Agrawal, (2019). In short, for a continuous action space mm dimensions, each dimension is discretized into KK evenly spaced atomic actions. With proper parameterization of the policy network (see, e.g., Section B.2), we can reduce the effective branching factor to Km≪KmKm\ll K^{m}, though this still results in a much larger action space than Atari benchmarks. In Section C.2, we provide additional descriptions of the tasks.

Result

In Figure 5, we compare MuZero with the All variant on the CheetahRun environment of the DeepMind Control Suite (Tassa et al.,, 2018). We evaluate the performance at low (Nsim=4N_{\text{sim}}=4), medium (Nsim=12N_{\text{sim}}=12) and “high” (Nsim=50N_{\text{sim}}=50) simulation budgets, for an effective action space of size 30 (m=6m=6, K=5K=5). The horizontal line corresponds to the performance of model-free D4PG also trained on pixel observations (Barth-Maron et al.,, 2018), as reported in (Tassa et al.,, 2018). Section C.2 provides experimental results on additional tasks. We again observe that All outperforms the original MuZero at low simulation budgets and still achieves faster convergence to the same asymptotic performance with more simulations. Figure 1 compares the asymptotic performance of MuZero and All as a function of the simulation budget at 100k learner steps.

Conclusion

In this paper, we showed that the action selection formula used in MCTS algorithms, most notably AlphaZero, approximates the solution to a regularized policy optimization problem formulated with search Q-values. From this theoretical insight, we proposed variations of the original AlphaZero algorithm by explicitly using the exact policy optimization solution instead of the approximation. We show experimentally that these variants achieve much higher performance at low simulation budget, while also providing statistically significant improvements when this budget increases.

Our analysis on the behavior of model-based algorithms (i.e., MCTS) has made explicit connections to model-free algorithms. We hope that this sheds light on new ways of combining both paradigms and opens doors to future ideas and improvements.

Acknowledgements

The authors would like to thank Alaa Saade, Bernardo Avila Pires, Bilal Piot, Corentin Tallec, Daniel Guo, David Silver, Eugene Tarassov, Florian Strub, Jessica Hamrick, Julian Schrittwieser, Katrina McKinney, Mohammad Gheshlaghi Azar, Nathalie Beauguerlange, Pierre Ménard, Shantanu Thakoor, Théophane Weber, Thomas Mesnard, Toby Pohlen and the DeepMind team.

References

Appendix A Details on search for AlphaZero

Below we briefly present details of the search procedure for AlphaZero. Please refer to the original work (Silver et al., 2017a, ) for more comprehensive explanations.

As explained in the main text, the search procedure starts with a MDP state x0x_{0}, which is used as the root node of the tree. The rest of this tree is progressively built as more simulations are generated. In addition to Q-function Q(x,a)Q(x,a), prior πθ(x,a)\pi_{\theta}(x,a) and visit counts n(x,a)n(x,a), each node also maintains a reward R(x,a)=r(x,a)R(x,a)=r(x,a) and value V(x)V(x) estimate.

In each simulation, the search consists of several parts: Selection, Expansion and Backup, as below.

From the root node x0x_{0}, the search traverses the tree using the action selection formula of Equation 1 until a leaf node xlx_{l} is reached.

Expansion.

After a leaf node xlx_{l} is reached, the search selects an action from the leaf node, generates the corresponding child node xcx_{c} and appends it to the tree T\mathcal{T}. The statistics for the new node are then initialized to Q(xc,a)=min⁡x∈T,a′∈AQ(x,a′)Q(x_{c},a)=\min_{x\in\mathcal{T},a^{\prime}\in\mathcal{A}}Q(x,a^{\prime}) (pessimistic initialization), n(x,a)=0n(x,a)=0 for ∀a∈A\forall a\in\mathcal{A}.

Back-up.

The back-up consists of updating statistics of nodes encountered during the forward traversal. Statistics that need updating include the Q-function Q(x,a)Q(x,a), count n(x,a)n(x,a) and value V(x)V(x). The newly expanded node ncn_{c} updates its value V(x)V(x) to be either the Monte-Carlo estimation from random rollouts (e.g. board games) or a prediction of the value network (e.g. Atari games). For the other nodes encountered during the forward traversal, all other statistics are updated as follows:

where child(x,a)\text{child}(x,a) refers to the child node obtained by taking action aa from node xx.

Note that, in order to make search parameters agnostic to the scale of the numerical rewards (and, therefore, values), Q-function statistics Q(x,a)Q(x,a) are always normalized by statistics in the search tree before applying the action selection formula; in practice, Equation 1 uses the normalized Qz(x,a)Q_{z}(x,a) defined as:

Appendix B Implementation details

For ease of implementation and availability of computational resources, the experimental results from Section 5 were obtained with a scaled-down version of MuZero (Schrittwieser et al.,, 2019). In particular, our implementation uses smaller networks compared to the architecture described in Appendix F of (Schrittwieser et al.,, 2019): we use only 5 residual blocks with 128 hidden layers for the dynamics function, and the residual blocks in the representation functions have half the number of channels. Furthermore, we use a stack of only 4 past observations instead of 32. Additionally, some algorithmic refinements (such as those described in Appendix H of (Schrittwieser et al.,, 2019)) have not been implemented in the version that we use in this paper.

Our experimental results have been obtained using either 4 or 8 Tesla v100 GPUs for learning (compared to 8 third-generation Google Cloud TPUs (Google,, 2020) in the original MuZero paper, which are approximately equivalent to 64 v100 GPUs). Each learner GPU receives data from a separated, prioritized experience replay buffer (Horgan et al.,, 2018) storing the last 500000500000 transitions. Each of these buffers is filled by 512 dedicated CPU actorsFor 50 simulations per step; this number is scaled linearly as 12+10⋅Nsim12+10\cdot N_{\text{sim}} to maintain a constant total number of frames per second when varying NsimN_{\text{sim}}., each running a different environment instance. Finally, each actor receives updated parameters from the learner every 500 learner steps (corresponding to approximately 4 minutes of wall-clock time); because episodes can potentially last several minutes of wall-clock time, weights updating will usually occur within the duration of an episode. The total score at the end of an episode is associated to the version of the weights that were used to select the final action in the episode.

Hyperparameters choice generally follows those of (Schrittwieser et al.,, 2019), with the exception that we use the Adam optimizer with a constant learning rate of 0.0010.001.

B.2 Details on discretizing continuous action space

AlphaZero (Silver et al., 2017a, ) is designed for discrete action spaces. When applying this algorithm to continuous control, we use the method described in (Tang and Agrawal,, 2019) to discretize the action space. Although the idea is simple, discretizing continuous action space has proved empirically efficient (Andrychowicz et al.,, 2020; Tang and Agrawal,, 2019). We present the details below for completeness.

We consider a continuous action space A=m\mathcal{A}=^{m} with mm dimensions. Each dimension is discretized into K=5K=5 bins; specifically, the continuous action along each dimension is replaced by KK atomic categorical actions, evenly spaced between $.Thisleadstoatotalof. This leads to a total ofK^{m}actions,whichgrowsexponentiallyfast(e.g.actions, which grows exponentially fast (e.g.m=6leadstoaboutleads to about10^{4}jointactions).Toavoidthecurseofdimensionality,weassumethattheparameterizedpolicycanbefactorizedasjoint actions). To avoid the curse of dimensionality, we assume that the parameterized policy can be factorized as\pi_{\theta}(\mathbf{a}|x)=\Pi_{i=1}^{m}\pi_{\theta}^{(i)}(a_{i}|x),where, where\pi_{\theta}^{(i)}(a_{i}|x)isthemarginaldistributionfordimensionis the marginal distribution for dimensioni,,a_{i}\in\{1,2...K\}isthediscreteactionalongdimensionis the discrete action along dimensioniandand\mathbf{a}=[a_{1},a_{2}...a_{m}]$ is the joint action.

Modification to the search procedure

Though it is convenient to assume a factorized form of the parameterized policy (Andrychowicz et al.,, 2020; Tang and Agrawal,, 2019), it is not as straightforward to apply the same factorization assumption to the Q-function Q(x,a)Q(x,\mathbf{a}). A most naive way of applying the search procedure is to maintain a Q-table of size KmK^{m} with one entry for each joint action, which may not be tractable in practice. Instead, we maintain mm separate Q-tables each with KK entries Qi(x,ai)Q_{i}(x,a_{i}). We also maintain mm count tables n(x,ai)n(x,a_{i}) with KK entries for each dimension.

To make the presentation clear, we detail on how the search is applied. At each node of the search tree, we maintain mm tables each with KK entries as introduced above. The three core components of the tree search are modified as follows.

Selection. During forward action selection, the algorithm needs to select an action a\mathbf{a} at node xx. This joint action a\mathbf{a} has all its components aia_{i} selected independently, using the action selection formula applied to each dimension. To select action at dimension ii, we need the Q-table Qi(x,ai)Q_{i}(x,a_{i}), the prior πθ(i)(ai∣x)\pi_{\theta}^{(i)}(a_{i}|x) and count n(x,ai)n(x,a_{i}) for dimension ii.

Expansion. The expansion part does not change.

Back-up. During the value back-up, we update Q-tables of each dimension independently. At a node xx, given the downstream reward R(x,a)R(x,a) and child value V(child(x,a))V(\text{child}(x,\mathbf{a})), we generate the target update for each Q-table and count table as Q(x,ai)←R(x,a)+γV(child(x,a))Q(x,a_{i})\leftarrow R(x,a)+\gamma V(\text{child}(x,\mathbf{a})) and n(x,ai)←n(x,ai)+1n(x,a_{i})\leftarrow n(x,a_{i})+1.

The mm small Q-tables can be interpreted as maintaining the marginalized values of the joint Q-table. Indeed, let us denote by Q(x,a)Q(x,\mathbf{a}) the joint Q-table with KmK^{m} entries. At dimension ii, the Q-table Q(x,ai)Q(x,a_{i}) increments its values purely based on the choice of aia_{i}, regardless of actions in other dimension aj,j≠ia_{j},j\neq i. This implies that the Q-table Q(x,ai)Q(x,a_{i}) marginalizes the joint Q-table Q(x,a)Q(x,\mathbf{a}) via the visit count distribution.

Details on the learning

B.3 Practical computation of π¯¯𝜋\bar{\pi}

The vector πˉ\bar{\pi} is defined as the solution to a multi-dimensional optimization problem; however, we show that it can be computed easily by dichotomic search. We first restate the definition of πˉ\bar{\pi},

As ∑bπˉα[b]\sum_{b}\bar{\pi}_{\alpha}[b] is strictly decreasing on \alpha\in\mathopen{}\mathclose{{}\left(\alpha_{\text{min}},\alpha_{\text{max}}}\right), 4 guarantees that πˉ\bar{\pi} can be computed easily using dichotomic search over \mathopen{}\mathclose{{}\left(\alpha_{\text{min}},\alpha_{\text{max}}}\right).

The proof start the same as the one of Lemma 3 of Section D.1 setting f(x)=−log⁡(x)f(x)=-\log(x) to get

Then α\alpha is set such that ∑bπˉb=1\sum_{b}\bar{\pi}_{b}=1 and ∀b  πˉb≥0\forall b\;\bar{\pi}_{b}\geq 0. ∎

Proof of (ii).

Proof of (iii).

We combine this with the fact that ∑bπα[b]\sum_{b}\pi_{\alpha}[b] is a decreasing function of α\alpha for any α>max⁡bq[b]\alpha>\max_{b}q[b], and ∑bπα⋆[b]=1\sum_{b}\pi_{\alpha^{\star}}[b]=1. ∎

Appendix C Additional experimental results

Figure 6 presents a comparison of the score obtained by our MuZero implementation and the proposed All variant at different simulation budgets on the Ms. Pacman level; the results from Figure 2 are also included fore completeness. In this experiment, we used 8 seeds with 8 GPUs per seed and a batch size of 256 per GPU. We use the same set of hyper-parameters for MuZero and All; these parameters were tuned on MuZero. The solid line corresponds to the average score (solid line) and the 95% confidence interval (shaded area) over the 8 seeds, averaged for each seed over buckets of 2000 learner steps without additional smoothing. Interestingly, we observe that All provides improved performance at low simulation budgets while also reducing the dispersion between seeds.

Figure 7 presents a comparison of the score obtained by our MuZero implementation and the proposed All variant on six Atari games, using 6 seeds per game and a batch size of 512 per GPU and 8 GPUs; we use the same set of hyper-parameters as in the other experiments. Because the distribution of scores across seeds is skewed towards higher values, we represent dispersion between seeds using the min-max interval over the 6 seeds (shaded area) instead of using the standard deviation; the solid line represents the median score over the seeds.

C.2 Complements to Section 5.3

The DeepMind Control Suite environments (Tassa et al.,, 2018) are control tasks with continuous action space A=m\mathcal{A}=^{m}. These tasks all involve simulated robotic systems and the reward functions are designed so as to guide the system for accomplish e.g. locomotion tasks. Typically, these robotic systems have relatively low-dimensional sensory recordings which summarize the environment states. To make the tasks more challenging, for observations, we take the third-person camera of the robotic system and use the image recordings as observations to the RL agent. These images are of dimension 64×64×364\times 64\times 3.

Figures 9, 10, 11 and 12 present a comparison of MuZero and All on a subset of 4 of the medium-difficulty (Van de Wiele et al.,, 2020) DeepMind Control Suite (Tassa et al.,, 2018) tasks chosen for their relatively high-dimensional action space among these medium-difficulty problems (ndim=6n_{\text{dim}}=6). Figure 8 compare the score of MuZero and All after 100k learner steps on these four medium difficulty Control problems. These continuous control problems are cast to a discrete action formulation using the method presented in Section B.2; note that these experiments only use pixel renderings and not the underlying scalar states.

These curves present the median (solid line) and min-max interval (shaded area) computed over 3 seeds in the same settings as described in Section C.1. The hyper-parameters are the same as in the other experiments; no specific tuning was performed for the continuous control domain. The horizontal dashed line corresponds to the performance of the D4PG algorithm when trained on pixel observations only (Barth-Maron et al.,, 2018), as reported by (Tassa et al.,, 2018).

C.3 Complemantary experiments on comparison with PPO

Since we interpret the MCTS-based algorithms as regularized policy optimization algorithms, as a sanity check for the proposal’s performance gains, we compare it with state-of-the-art proximal policy optimization (PPO) (Schulman et al.,, 2017). Since PPO is a near on-policy optimization algorithm, whose gradient updates are purely based on on-policy data, we adopt a lighter network architecture to ensure its stability. Please refer to the public code base (Dhariwal et al.,, 2017) for a review of the neural network architecture and algorithmic details.

To assess the performance of PPO, we train with both state-based inputs and image-based inputs. State-based inputs are low-dimensional sensor data of the environment, which renders the input sequence strongly Markovian (Tassa et al.,, 2018). For image-based training, we adopt the same inputs as in the main paper. The performance is reported in Table 1 where each score is the evaluation performance of PPO after the convergence takes place. We observe that state-based PPO performs significantly better than image-based PPO, while in some cases it matches the performance of All. In general, image-based PPO significantly underperforms All.

Appendix D Derivations for Section 3

We start with a definition of the ff-divergence (Csiszár,, 1964).

(1) ∀x,y  D(x,y)≥0\forall x,y\;D(x,y)\geq 0 (2) D(x,y)=0  ⟺  x=yD(x,y)=0\iff x=y (3) D(x,y)D(x,y) is jointly convex in xx and yy.

We states four lemmas that we formally prove in Section D.2.

Where πθ\pi_{\theta} is assumed to be non zero. We now restate the definition of π^[a]≜na+1N+∣A∣\hat{\pi}[a]\triangleq\frac{n_{a}+1}{N+|\mathcal{A}|}.

Now we consider a more general definition of πˉ\bar{\pi} using any ff-divergence for some λf>0\lambda_{f}>0 and assume πθ>0\pi_{\theta}>0,

We also consider the following action selection formula based on ff-divergence DfD_{f}.

Applying Lemmas 2 and 4 with the appropriate function ff directly leads to 1, 2, and 3. In particular, we use

D.2 Proofs of Lemmas 1, 2, 3 and 4

For any action a∈Aa\in\mathcal{A} using basic differentiation rules we have

Proof of Lemma 2

where \beta=-\cfrac{\sum_{b\in\mathcal{A}}\mathopen{}\mathclose{{}\left[q_{b}-\lambda_{f}f^{\prime}\mathopen{}\mathclose{{}\left(\frac{\hat{\pi}(b)}{\pi_{\theta}(b)}}\right)}\right]}{\mathopen{}\mathclose{{}\left(|\mathcal{A}|+\sum_{c\in\mathcal{A}}n_{c}}\right)^{2}} is independent of aa. Also because 1∣A∣+∑c∈Anc>0\frac{1}{|\mathcal{A}|+\sum_{c\in\mathcal{A}}n_{c}}>0 then

Proof of Lemma 3

Proof of Lemma 4

Since ∑aπ^(a∣x)=∑aπˉ(a∣x)=1\sum_{a}\hat{\pi}(a|x)=\sum_{a}\bar{\pi}(a|x)=1, there exists at least an action a0a_{0} for which 0≤π^(a0∣x)≤πˉ(a0∣x)0\leq\hat{\pi}(a_{0}|x)\leq\bar{\pi}(a_{0}|x) then 0≤π^(a0∣x)πθ(a∣x)≤πˉ(a0∣x)πθ(a∣x)0\leq\frac{\hat{\pi}(a_{0}|x)}{\pi_{\theta}(a|x)}\leq\frac{\bar{\pi}(a_{0}|x)}{\pi_{\theta}(a|x)} as πθ(a∣x)>0\pi_{\theta}(a|x)>0. Because ff is convex then f′f^{\prime} is increasing and therefore

Finally we use again that f′f^{\prime} is increasing and πθ>0\pi_{\theta}>0 to conclude the proof

D.3 Tracking property in the constant π¯¯𝜋\bar{\pi} case

Let π\pi be some target distribution independent of the round t≥0t\geq 0. At each round t,t, starting from t=1,t=1, an action at∈Aa_{t}\in\mathcal{A} is selected and for any t≥0t\geq 0, we define

where for any action a∈Aa\in\mathcal{A}, nt(a)n_{t}(a) is the number of rounds the action aa has been selected,

Assume that for all rounds t≥1,t\geq 1, and for the chosen action at∈Aa_{t}\in\mathcal{A} we have

Before proving the proposition above, note that O(1/t)\mathcal{O}(1/t) is the best approximation w.r.t. t,t, since for any integer k≥0k\geq 0, taking π(a)=(12+k)/(∣A∣+t),\pi(a)=(\frac{1}{2}+k)/(|\mathcal{A}|+t), we have that for all n≥0,n\geq 0,

By induction on the round t,t, we prove that

At round t=1t=1, Equation 58 holds as for any action aa, nt(a)≥0n_{t}(a)\geq 0 therefore pt(a)≤1p_{t}(a)\leq 1. Now, let us assume that Equation 58 holds for some t≥1t\geq 1. We have that for all a,a,

Note that at each round, there is exactly one action chosen and therefore, ∑bnt(b)=t\sum_{b}n_{t}(b)=t. Furthermore, for a′≠at+1,a^{\prime}\neq a_{t+1}, we have that nt+1(a′)=nt(a′),n_{t+1}(a^{\prime})=n_{t}(a^{\prime}), since a′a^{\prime} has not been chosen at round t+1t+1. Therefore, for a′≠at+1,a^{\prime}\neq a_{t+1},

Now, for the chosen action, nt+1(at+1)=nt(at+1)+1n_{t+1}(a_{t+1})=n_{t}(a_{t+1})+1. Using our assumption stated in Equation 57, we have that

which concludes the induction. Next, we compute a lower bound. For any action a∈Aa\in\mathcal{A} and round t≥1,t\geq 1,

We have for any action a∈A,a\in\mathcal{A},

Since when ∣A∣=1,|\mathcal{A}|=1, then by definition, pt(a)=π(a)=1p_{t}(a)=\pi(a)=1 and for all rounds t≥1,t\geq 1, we get