Gymnasium Vectorization
Use this sub-skill when a task needs multiple Gymnasium environments stepped as one batch: gymnasium.make_vec, SyncVectorEnv, AsyncVectorEnv, vector wrappers, batched observations/actions/rewards/masks/infos, autoreset modes, or vector multiprocessing troubleshooting.
Start Here
- Prefer
gymnasium.make_vec(env_id, num_envs=..., vectorization_mode="sync" | "async")for registered environments. - Use
envs.action_space.sample()or another action batch matchingenvs.action_space; useenvs.single_action_spaceonly to reason about one sub-environment. - Treat
rewards,terminations, andtruncationsas arrays of shape(num_envs,), not scalar booleans. - Check
envs.metadata["autoreset_mode"]before interpreting post-terminal observations or writing bootstrapping logic. - Use
gymnasium.wrappers.vectorwrappers around vector envs; pass single-env wrappers throughmake_vec(..., wrappers=[...])only when they should wrap each sub-environment before vectorization. - Always call
envs.close(), especially forAsyncVectorEnvworker processes.
Route by Task
| Task | Read |
| --- | --- |
| Create or step vector envs, choose sync vs async, handle batched outputs | references/vector-envs.md |
| Apply vector wrappers, transform batched spaces, use vector space utilities | references/vector-wrappers-and-spaces.md |
| Debug actions, masks, autoreset, multiprocessing, shared memory, render/video | references/troubleshooting.md |