-
Notifications
You must be signed in to change notification settings - Fork 182
feature(tj): optimize AlphaZero with batch inference support #448
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
tAnGjIa520
wants to merge
5
commits into
opendilab:main
Choose a base branch
from
tAnGjIa520:alpha-batch
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
puyuan1996
requested changes
Dec 4, 2025
Document C++-Python env interaction as bottleneck and suggest C++ implementation.
- Convert all Chinese comments to English - Add parameter documentation for batch MCTS calls - Follow Google Style documentation standards
puyuan1996
reviewed
Dec 8, 2025
- Document C++-Python interaction bottleneck in current architecture - Note env_cpp_ification as future optimization direction - Mark get_next_action as non-batch version with reference to batch alternative
puyuan1996
reviewed
Dec 10, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR introduces a batch-optimized AlphaZero MCTS implementation in C++, achieving 2x
speedup compared to the standard sequential version.
Batch MCTS Inference: The core improvement is the get_next_actions_batch() function (line
207-415 in mcts_alphazero.cpp), which processes multiple game states simultaneously. Instead of running MCTS
simulations sequentially for each environment, we now:
(policy_value_func_batch), reducing GPU overhead
nodes that need expansion
_batch_expand_leaf_nodes() (line 162-205), minimizing individual network calls
selection, significantly reducing Python-C++ interface overhead
本 PR 引入了批量优化的 AlphaZero MCTS C++ 实现,相比标准顺序版本实现了 2 倍加速。
批量 MCTS 推理: 核心改进是 get_next_actions_batch() 函数(mcts_alphazero.cpp 第 207-415
行),可同时处理多个游戏状态。我们不再为每个环境顺序运行 MCTS 模拟,而是:
行)执行批量推理,最小化单独的网络调用