Fast and Reproducible Environments with Controllable Variations

stable-envs is a library of batched simulation environments that keep the full simulator state, so you can restore any step exactly and render images from it later, on CPU or GPU.

Store the state, replay or branch from any step, and draw frames from it later. 80 environment classes in 11 families share the same API. Policies, datasets and training live in stable-worldmodel, which builds on stable-envs.

Install

uv add stable-envs
pip install stable-envs

The core install runs CartPole, Acrobot and most navigation classes. Install lists the extras for the other families.

Example

import torch
import stable_envs as snv

with snv.CartPole(num_envs=8, device="cpu") as env:
    env.reset(seed=0)
    actions = torch.randint(0, 2, (8, 10, 1))  # (B, T, A): ten steps for each environment
    out = env.step(actions, frames=None)  # step without rendering
    print(out["states"].batch_size)  # torch.Size([8, 10])
    frames = env.render(out["states"][:, 4])  # render the state after five steps
    print(frames.shape, frames.dtype)  # torch.Size([8, 400, 600, 3]) torch.uint8

step returns the state after every step, and render draws a batch of frames from any of them.

Next steps

If you want to Read
run your first environment Quickstart
install the extras for a family, or set up a GPU Install
store states in a dataset and render them while you train Store states, render later
randomize colors, lighting or physics across a batch Randomize appearance and physics
write an environment of your own Write your own environment
find an environment and see what it looks like Environments
look up a function or class API