Principle:Farama Foundation Gymnasium Vectorized Environment Creation
| Knowledge Sources | |
|---|---|
| Domains | Reinforcement_Learning, Parallelism |
| Last Updated | 2026-02-15 03:00 GMT |
Overview
A parallelization pattern that runs multiple copies of an environment simultaneously, enabling batched observation collection and action execution for accelerated training.
Description
Vectorized Environment Creation instantiates multiple copies of the same environment and exposes them through a unified batched interface. Instead of interacting with one environment at a time, the agent sends a batch of actions and receives a batch of observations, rewards, and done flags.
Two execution modes exist:
- Synchronous (SyncVectorEnv): Environments run sequentially in the same process. Simple and debuggable.
- Asynchronous (AsyncVectorEnv): Environments run in separate processes via multiprocessing. Uses shared memory for zero-copy observation transfer.
Vectorization accelerates training by:
- Collecting diverse experience in parallel
- Amortizing neural network inference cost across batches
- Enabling GPU-efficient batched forward passes
Usage
Use vectorized environments when training deep RL agents (A2C, PPO, etc.) that benefit from batched experience collection. Synchronous mode is preferred for debugging and simple environments. Asynchronous mode is preferred for computationally expensive environments.
Theoretical Basis
Batched data collection with parallel environments:
This provides transitions per step call, improving sample efficiency per wall-clock time by a factor of approximately (for async mode with costly environments).