Skip to content

Fix: Move RNAD/NFSP agent creation outside game loop#1

Merged
gsmithline merged 1 commit into
mainfrom
fix-rnad-agent-reinitialization
Jan 16, 2026
Merged

Fix: Move RNAD/NFSP agent creation outside game loop#1
gsmithline merged 1 commit into
mainfrom
fix-rnad-agent-reinitialization

Conversation

@gsmithline

Copy link
Copy Markdown
Owner

Summary

  • Fixed performance bug where RNAD/NFSP agents were being re-instantiated on every game iteration
  • Agents are now created once before the game loop and reused

Problem

The RNaDAgentWrapper and NFSPAgentWrapper were created inside the for gi in range(games) loop in pyspiel_runner.py. This caused:

  • JAX/Haiku model re-initialization on every game
  • Repeated JIT compilation overhead
  • 50 games × 2 agents = 100 model loads instead of 2

On GitHub Actions (AMD EPYC CPUs), JAX compilation is slow, causing runs to take hours instead of minutes.

Solution

Move agent instantiation before the game loop so models are loaded once and reused.

Test plan

  • Tested locally with docker compose - games progress smoothly
  • RNAD models now load only once at startup
  • Rebuild Docker image and retest on GitHub Actions

🤖 Generated with Claude Code

Previously, RNaDAgentWrapper and NFSPAgentWrapper were instantiated
inside the `for gi in range(games)` loop, causing model re-initialization
on every game. This triggered repeated JAX/Haiku compilation, which is
extremely slow on certain CPUs (e.g., GitHub Actions AMD EPYC runners).

With 50 games, this meant 100 model loads instead of 2, causing runs
that should take minutes to take hours.

The fix moves agent creation before the loop so models are loaded once
and reused across all games.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@gsmithline gsmithline merged commit 1062acf into main Jan 16, 2026
1 check 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.

1 participant