Skip to content

feat: Implement zero-copy AsyncVectorEnv via shared memory for parallel execution#1550

Open
shivansh023023 wants to merge 1 commit into
google-deepmind:masterfrom
shivansh023023:feature-async-vector-env
Open

feat: Implement zero-copy AsyncVectorEnv via shared memory for parallel execution#1550
shivansh023023 wants to merge 1 commit into
google-deepmind:masterfrom
shivansh023023:feature-async-vector-env

Conversation

@shivansh023023

Copy link
Copy Markdown
Contributor

Pull Request: feat: Implement zero-copy AsyncVectorEnv using shared memory

Description

This PR introduces AsyncVectorEnv to open_spiel/python/vector_env.py, enabling true parallel execution of environments across multiple CPU cores.

Key Architectural Details

  • Zero-Copy Shared Memory: To avoid severe Inter-Process Communication (IPC) pickling bottlenecks when transmitting large observation tensors (e.g., in Chess or Backgammon), this implementation utilizes multiprocessing.sharedctypes.RawArray.
  • Direct Memory Writing: Worker processes instantiate the C++ environments natively and write time_step.observations["info_state"] directly into pre-allocated shared NumPy views.
  • Lightweight Pipes: The multiprocessing.Pipe is strictly reserved for small control payloads (rewards, done flags, step types), completely eliminating the need to serialize massive multi-dimensional arrays.
  • Performance: In a 16-worker benchmark on chess running 1,000 steps, this shared memory architecture achieved a ~2.87x speedup over the synchronous SyncVectorEnv, fully bypassing the IPC overhead that typically throttles complex state transmission.

@lanctot

lanctot commented May 30, 2026

Copy link
Copy Markdown
Collaborator

Thanks!

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