Skip to content
opendilabPublic

Latest commit

 

History

309 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LightZero

LightZero

Twitter PyPI PyPI - Python Version Loc Comments

Code Test Badge Creation Package Release

GitHub Org's stars GitHub stars GitHub forks GitHub commit activity GitHub issues GitHub pulls Contributors GitHub license discord badge

Last updated December 3, 2026 · LightZero v0.3.0

LightZero is a lightweight, efficient, and easy-to-understand open-source algorithm toolkit that combines Monte Carlo Tree Search (MCTS) and Deep Reinforcement Learning (RL).

English | 简体中文 (Simplified Chinese) | Documentation | Environment Zoo | LightZero Paper | UniZero Paper | ReZero Paper | 🔥ScaleZero Paper

News

  • [2026.12] Fixed known bugs affecting long-run UniZero Atari training performance and added parallel search within MCTS trees.
  • [2026.02] 🔥 The ScaleZero paper has been accepted as a conference paper at ICLR 2026: One Model for All Tasks: Leveraging Efficient World Models in Multi-Task Planning.
  • [2025.08] The ReZero paper has been accepted by the CoRL 2025 RemembeRL workshop.
  • [2025.06] The UniZero paper has been accepted by Transactions on Machine Learning Research (TMLR 2025).
  • [2023.09] The LightZero paper has been accepted as a Spotlight Presentation at the NeurIPS 2023 Datasets and Benchmarks Track.
  • [2023.04] LightZero v0.0.1 was officially released.

🔍 Background

The integration of Monte Carlo Tree Search and Deep Reinforcement Learning, exemplified by AlphaZero and MuZero, has achieved unprecedented performance levels in various games, including Go and Atari. This advanced methodology has also made significant strides in scientific domains like protein structure prediction and the search for matrix multiplication algorithms. The following is an overview of the historical evolution of the Monte Carlo Tree Search algorithm series: pipeline

🎨 Overview

LightZero is an open-source algorithm toolkit that combines Monte Carlo Tree Search (MCTS) and Reinforcement Learning (RL) for PyTorch. It supports a range of MCTS-based RL algorithms and applications, offering several key advantages:

  • Lightweight.
  • Efficient.
  • Easy-to-understand.

For further details, see Features, Framework Structure, and Integrated Algorithms.

LightZero aims to promote the standardization of the MCTS+RL algorithm family to accelerate related research and applications. The repository includes published benchmark results and example configurations. Benchmarks · Environment Zoo

Outline

💥 Features

Lightweight. LightZero integrates multiple MCTS algorithm families behind shared training and evaluation components. Algorithms · Environments

Efficient. C++ tree search works with PyTorch model inference. UniZero can batch edge predictions within a tree during Atari search.

Easy to understand. Tutorials and source configurations show how each example connects the environment, policy, and search. Documentation · Paper notes

🧩 Framework Structure

Image Description 2

The above picture is the framework pipeline of LightZero. We briefly introduce the three core modules below:

Model: Model is used to define the network structure, including the __init__ function for initializing the network structure and the forward function for computing the network's forward propagation.

Policy: Policy defines the way the network is updated and interacts with the environment, including three processes: the learning process, the collecting process, and the evaluation process.

MCTS: MCTS defines the structure of the Monte Carlo search tree and the way it interacts with the Policy. The implementation of MCTS includes two languages: Python and C++, implemented in ptree and ctree, respectively.

For the file structure of LightZero, please refer to lightzero_file_structure.

🎁 Integrated Algorithms

Family Implementations Example configuration
AlphaZero AlphaZero · Sampled AlphaZero · Gumbel AlphaZero Gomoku
MuZero MuZero · Sampled MuZero · Stochastic MuZero · Gumbel MuZero CartPole · 2048
EfficientZero EfficientZero · Sampled EfficientZero Atari · MuJoCo
ReZero ReZero reanalysis with MuZero or EfficientZero Atari
UniZero UniZero · Sampled UniZero · UniZero + PPO Atari · DeepMind Control
PriorZero World-model planning with language or vision-language model priors Jericho · LunarLander

Browse the available environments, action spaces, and setup guides in the Environment Zoo.

⚙️ Installation

Use Python 3.11 or 3.12 with a C++ compiler and Python development headers. The Linux training CI covers Gymnasium with NumPy 1.26 and 2.x. Compatibility matrix

Install from the current source tree.

git clone https://github.com/opendilab/LightZero.git
cd LightZero
python -m pip install -e .

Additional simulators and text environments may require separate dependencies. Environment setup guides

Installation with Docker

From the checkout, start a Python 3.11 container with the source mounted.

docker run --rm -it -v "$PWD:/workspace" -w /workspace python:3.11-bookworm bash

Inside the container, install and run an example.

apt-get update && apt-get install -y g++ git swig
python -m pip install -e .
python -m zoo.classic_control.cartpole.config.cartpole_muzero_config

🚀 Quick Start

Run these examples from the repository root.

Task Command
CartPole with MuZero python -m zoo.classic_control.cartpole.config.cartpole_muzero_config
Pong with MuZero python -m zoo.atari.config.atari_muzero_segment_config --env ALE/Pong-v5
Tic-Tac-Toe with MuZero python -m zoo.board_games.tictactoe.config.tictactoe_muzero_bot_mode_config
Pong with UniZero python -m zoo.atari.config.atari_unizero_segment_config --env ALE/Pong-v5

The Atari UniZero entry also supports MsPacman, checkpoint resume, and optional batched search.

Experimental Async Segment Training

With Ray installed, use --async-pipeline to run collection and evaluation in separate actors. The learner and replay buffer run in the driver.

python -m zoo.atari.config.atari_muzero_segment_async_config --env ALE/Pong-v5 --async-pipeline

A July 2026 Pong MuZero comparison with two collector actors collected 809.5k versus 499.8k environment steps in the same 6.2-hour window. The guide covers the protocol and the UniZero variant. Async Segment Pipeline · 中文说明

📚 Documentation

The LightZero documentation can be found here. It contains tutorials and the API reference.

For those interested in customizing environments and algorithms, we provide relevant guides:

Should you have any questions, feel free to contact us for support.

📊 Benchmark

Click to expand
  • These AlphaZero and MuZero curves show bot-mode training on Tic-Tac-Toe and Gomoku. Tic-Tac-Toe · Gomoku

Tic-Tac-Toe bot-mode benchmark Gomoku bot-mode benchmark

pong_main qbert_main mspacman_main mspacman_sez_K

"Factored Policy" indicates that the agent learns a policy network that outputs a categorical distribution. After manual discretization, the dimensions of the action space for the five environments are 11, 49 (7^2), 256 (4^4), 64 (4^3), and 4096 (4^6), respectively. On the other hand, "Gaussian Policy" refers to the agent learning a policy network that directly outputs parameters (mu and sigma) for a Gaussian distribution.

pendulum_main pendulum_sez_K lunarlander_main

bipedalwalker_main hopper_main walker2d_main

  • These Gumbel MuZero and MuZero benchmarks compare simulation budgets on Pong, MsPacman, Gomoku, and LunarLander. Atari wrapper · Gomoku · LunarLander

pong_gmz_ns mspacman_gmz_ns gomoku_bot-mode_gmz_ns lunarlander_gmz_ns

2048_stochasticmz_mz mspacman_gmz_ns

keycorridors3r3_exploration fourrooms_exploration

📝 Awesome-MCTS Notes

Paper Notes

The following are the detailed paper notes (in Chinese) of the above algorithms:

Click to collapse

You can also refer to the relevant Zhihu column (in Chinese): In-depth Analysis of MCTS+RL Frontier Theories and Applications.

Algo. Overview

Awesome-MCTS Papers

Here is a collection of research papers about Monte Carlo Tree Search.

Classic & Foundational Papers

Click to expand

LightZero Implemented series

AlphaGo series

MuZero series

MCTS Analysis

MCTS Application

Recent Research & Emerging Applications

Click to expand

ICML

ICLR

NeurIPS

Other Conference or Journal

💬 Feedback and Contribution

🌏 Citation

@article{niu2024lightzero,
  title={LightZero: A Unified Benchmark for Monte Carlo Tree Search in General Sequential Decision Scenarios},
  author={Niu, Yazhe and Pu, Yuan and Yang, Zhenjie and Li, Xueyan and Zhou, Tong and Ren, Jiyuan and Hu, Shuai and Li, Hongsheng and Liu, Yu},
  journal={Advances in Neural Information Processing Systems},
  volume={36},
  year={2024}
}

@article{puunizero,
  title={UniZero: Generalized and Efficient Planning with Scalable Latent World Models},
  author={Pu, Yuan and Niu, Yazhe and Yang, Zhenjie and Ren, Jiyuan and Li, Hongsheng and Liu, Yu},
  journal={Transactions on Machine Learning Research}
}

@article{xuan2024rezero,
  title={ReZero: Boosting MCTS-based Algorithms by Backward-view and Entire-buffer Reanalyze},
  author={Xuan, Chunyu and Niu, Yazhe and Pu, Yuan and Hu, Shuai and Liu, Yu and Yang, Jing},
  journal={arXiv preprint arXiv:2404.16364},
  year={2024}
}

@article{pu2025one,
  title={One Model for All Tasks: Leveraging Efficient World Models in Multi-Task Planning},
  author={Pu, Yuan and Niu, Yazhe and Tang, Jia and Xiong, Junyu and Hu, Shuai and Li, Hongsheng},
  journal={arXiv preprint arXiv:2509.07945},
  year={2025}
}

💓 Acknowledgments

This project has been developed partially based on the following pioneering works on GitHub repositories. We express our profound gratitude for these foundational resources:

We would like to extend our special thanks to the following contributors @PaParaZz1, @karroyan, @nighood, @jayyoung0802, @timothijoe, @TuTuHuss, @HarryXuancy, @puyuan1996, @HansBug for their valuable contributions and support to this algorithm library.

Thanks to all who contributed to this project:

🏷️ License

All code within this repository is under Apache License 2.0.

(Back to top)

Releases

Packages

Used by

Contributors

Languages