Skip to content

Self-play tuning - #350

Merged
alejandromarcu merged 5 commits into
mainfrom
tune
Mar 6, 2026
Merged

Self-play tuning#350
alejandromarcu merged 5 commits into
mainfrom
tune

Conversation

@alejandromarcu

@alejandromarcu alejandromarcu commented Mar 4, 2026

Copy link
Copy Markdown
Collaborator

This new script allows to run self-play with different configurations of num_workers and parallel_games to figure out which combination is faster for the specific training in that hardware.
Mostly done by Claude!

For example:

% python src/tune_selfplay.py ../experiments/B5W2/cucu-01.yaml --workers 2,4,6 --games 8,12,16 --duration "1 minute"(.venv) 

================================================================================
BENCHMARK RESULTS
================================================================================
        nw         pg     rounds  tot games    avg round t        games/s
-------------------------------------------------------------------------
         6         12         12        144          24.50          2.939
         6         16          6         96          36.27          2.647
         4         16          8        128          26.10          2.452
         6          8         12         96          20.65          2.325
         4         12          8         96          23.12          2.076
         4          8         12         96          16.08          1.990
         2         16          4         64          26.44          1.210
         2         12          5         60          21.08          1.139
         2          8          6         48          16.68          0.959

It can also be used to tune the rust self play:

python src/tune_selfplay.py ../experiments/B5W2/cucu-01.yaml --workers 2,4,6,8 --games 1 --duration "30 seconds" --extra-overrides self_play.program=rust

================================================================================
BENCHMARK RESULTS
================================================================================
        nw         pg     rounds  tot games    avg round t        games/s
-------------------------------------------------------------------------
         8          1         81         81           3.06          2.611
         6          1         75         75           2.44          2.458
         4          1         71         71           1.76          2.279
         2          1         52         52           1.15          1.738

Comment on lines -35 to -55
)
runs_dir = args.runs_dir if args.runs_dir is not None else str(Path(__file__).parent.parent)

config = load_config_and_setup_run(args.config_file, runs_dir, overrides=args.overrides)

use_rust = config.self_play.program == "rust"
if use_rust:
# Apply default Rust binary path if not specified in config
if config.self_play.rust_selfplay_binary is None:
config.self_play.rust_selfplay_binary = str(
Path(__file__).parent.parent
/ "rust"
/ "target"
/ "release"
/ "selfplay"
)
rust_binary = config.self_play.rust_selfplay_binary
if not Path(rust_binary).exists():
print(f"ERROR: Rust self-play binary not found at {rust_binary}")
print(
"Build it with: cd deep_quoridor/rust && cargo build --release --features binary --bin selfplay"
)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I moved this to load_config_and_setup_run for clarity

Comment thread deep_quoridor/src/tune_selfplay.py Outdated
parser.add_argument("--games", type=str, help="Comma-separated parallel_games values")
parser.add_argument("--duration", type=str, default="2 minutes", help="Duration per combo (default: '2 minutes')")
parser.add_argument("--runs-dir", type=str, default=None, help="Directory for runs")
parser.add_argument("--extra-overrides", nargs="*", default=[], help="Additional config overrides for train_v2.py")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

isn't this the same as -o? Shouldn't it also be -o for consistency?

@adamantivm

Copy link
Copy Markdown
Collaborator

Can you include the YAML you used to test in this PR, as you show in the description? It will be handy for experiments in the future, when we trace back to this and want to reproduce your test run.

I have that and one more obersvation, then LGTM

@alejandromarcu
alejandromarcu merged commit dc831dc into main Mar 6, 2026
4 of 5 checks passed
@alejandromarcu
alejandromarcu deleted the tune branch March 6, 2026 19:34
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.

2 participants