Skip to content

feat: parallel processing - #15

Merged
kstruempf merged 9 commits into
mainfrom
feat/parallel-processing
Jun 30, 2025
Merged

feat: parallel processing#15
kstruempf merged 9 commits into
mainfrom
feat/parallel-processing

Conversation

@kstruempf

@kstruempf kstruempf commented Jun 30, 2025

Copy link
Copy Markdown
Owner

Implements #7

@kstruempf
kstruempf requested a review from Copilot June 30, 2025 07:00

This comment was marked as outdated.

@kstruempf
kstruempf requested a review from Copilot June 30, 2025 07:11

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces parallel processing support for the Monte Carlo Tree Search (MCTS) algorithm by adding a new method, search_parallel, and updating tests and documentation accordingly.

  • Added search_parallel functionality for parallel rollouts.
  • Updated tests to verify parallel processing behavior and error handling for unsupported configurations.
  • Updated README to include instructions on using parallel processing.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
tests/test_mcts.py Adds new tests for parallel search and NotImplementedError case
mcts/searcher/mcts.py Implements search_parallel and related multiprocessing changes
README.md Documents the parallel processing feature
Comments suppressed due to low confidence (1)

mcts/searcher/mcts.py:69

  • [nitpick] Consider renaming the method 'all_child_have_at_least_one_visit' to something more grammatically clear such as 'all_children_visited' to improve readability.
    def all_child_have_at_least_one_visit(self,) -> bool:

Comment thread mcts/searcher/mcts.py Outdated
import math
import random
import time
import copy

Copilot AI Jun 30, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 'copy' module is imported but not used. Removing unused imports can improve code clarity and maintainability.

Suggested change
import copy

Copilot uses AI. Check for mistakes.
Comment thread mcts/searcher/mcts.py Outdated
Comment on lines +167 to +182
#processes.append(Process(target=self.execute_rollout_parallel,args=(index,root_shared,return_dict)))

for p in processes: p.start()

for p in processes: p.join()

for index, reward in return_dict.items():
#for index, rez in return_dict.items():
self.backpropagate(input_nodes[index], reward)
#node, reward = rez
#self.backpropagate(node, reward)

best_child = self.get_best_child(self.root, 0)
#best_child = self.get_best_child(root_shared, 0)
action = (action for action, node in self.root.children.items() if node is best_child).__next__()
#action = (action for action, node in root_shared.children.items() if node is best_child).__next__()

Copilot AI Jun 30, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider removing commented-out alternative code to reduce clutter and make the current implementation clearer.

Suggested change
#processes.append(Process(target=self.execute_rollout_parallel,args=(index,root_shared,return_dict)))
for p in processes: p.start()
for p in processes: p.join()
for index, reward in return_dict.items():
#for index, rez in return_dict.items():
self.backpropagate(input_nodes[index], reward)
#node, reward = rez
#self.backpropagate(node, reward)
best_child = self.get_best_child(self.root, 0)
#best_child = self.get_best_child(root_shared, 0)
action = (action for action, node in self.root.children.items() if node is best_child).__next__()
#action = (action for action, node in root_shared.children.items() if node is best_child).__next__()
for p in processes: p.start()
for p in processes: p.join()
for index, reward in return_dict.items():
self.backpropagate(input_nodes[index], reward)
best_child = self.get_best_child(self.root, 0)
action = (action for action, node in self.root.children.items() if node is best_child).__next__()

Copilot uses AI. Check for mistakes.
@kstruempf
kstruempf merged commit ff4ec32 into main Jun 30, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants