---
title: 'Stable-Envs: GPU Native Rendering & Simulations'
url: https://www.emergentmind.com/topics/stable-envs
type: topic
---

# Stable-Envs: GPU Native Rendering & Simulations

Stable-envs is an open-source library for fast, reproducible, batched simulation and GPU-native rendering of reinforcement-learning and world-model environments. It separates simulator state evolution from image generation, enabling RGB observations to be rendered on demand directly on GPUs while preserving explicit state access, deterministic replay, and controllable visual variations. Version 1 supports 80 environments across multiple simulation families and CPU/GPU backends, and reports end-to-end world-model training speedups of up to $1.33\times$ without meaningful degradation in downstream planning performance [2611.23151].

## 1. Design objectives and conceptual model

Pixel-based world-model training requires processing large quantities of high-dimensional image data. A representative dataset containing 20,000 trajectories of 200 steps at $224\times224$ resolution and one byte per pixel contains approximately 200 GB of image data. Conventional workflows either store image frames, decode compressed videos during training, or render images on the CPU and transfer them to the GPU.

Stable-envs instead emphasizes a state-first representation:

$$
\text{state trajectory}\longrightarrow\text{on-demand RGB rendering}.
$$

The library exposes low-dimensional simulator states and renders observations only when required. This design reduces the need to store image trajectories, avoids large CPU-to-GPU image transfers, permits arbitrary rendering resolutions, and allows visual properties to change without modifying the underlying physical trajectory.

The architecture separates dynamics from rendering. Conceptually, an environment implements a state transition,

$$
s_{t+1}=f(s_t,a_t;\xi_t),
$$

and a rendering function,

$$
o_t=R(s_t;\theta),
$$

where $s_t$ is simulator state, $a_t$ is an action, $\xi_t$ represents stochastic information when present, $o_t$ is an RGB observation, and $\theta$ contains visual or rendering parameters. The same physical state can therefore produce multiple image observations under different rendering configurations.

This factorization is relevant to world-model evaluation because it distinguishes physical variation from perceptual variation. A trajectory can remain physically identical while its colors, appearance, resolution, or other visual properties change.

## 2. Library architecture and environment coverage

Stable-envs provides a common interface over heterogeneous simulation systems. Individual environment classes retain their native simulation logic, while the library supplies common mechanisms for batched environment creation, physics stepping, rendering, state access and restoration, visual variations, CPU/GPU execution, deterministic seeding, and evaluation.

An environment may represent $B$ independent instances. Actions can be supplied either individually or as temporal chunks:

- single action tensor: $[B,A]$;
- action sequence: $[B,T,A]$.

A representative interface is:

```python
import stable_envs as snv

env = snv.PushT(num_envs=256, device="cuda")
env.reset(seed=0)

actions = env.action_space.sample()

with_frames = env.step(actions, frames=slice(None))
no_frames = env.step(actions, frames=None)
```

The `frames` argument decouples physics from rendering. `frames=slice(None)` requests rendered observations, whereas `frames=None` performs physics without rendering. Rendering can also be invoked independently:

```python
frames = env.render()
```

This supports stepping and rendering at every time step, stepping without rendering, rendering only selected states, saving states for later rendering, and generating multiple visual variants from a shared physical trajectory.

The reported 80 environments are distributed across 11 families:

| Family | Source or backend | Classes |
|---|---|---:|
| Classic control | Gymnasium | 5 |
| DM Control | `dm_control`, MuJoCo | 17 |
| Fetch | Gymnasium Robotics, MuJoCo | 12 |
| OGBench | OGBench, MuJoCo | 27 |
| Navigation | stable-worldmodel | 5 |
| PushT | `gym-pusht`, Pymunk | 2 |
| Roadster | stable-envs, MuJoCo | 5 |
| MiniWorld | MiniWorld | 1 |
| PyFlyt | PyBullet | 1 |
| MS-Human | MS-Human-700, MuJoCo | 1 |
| Craftax | Craftax, JAX | 4 |

The supported environments span classic control, navigation, manipulation, locomotion, MuJoCo tasks, Pymunk tasks, PyBullet, JAX-based simulation, and other environment families. Stable-envs does not impose a single underlying physical model; instead, it standardizes interaction, batching, state handling, and rendering across heterogeneous backends.

CPU execution uses vectorized simulation code or multiple worker processes. GPU execution includes MuJoCo Warp, MJX, custom PyTorch kernels, and GPU rendering through MuJoCo Warp and `nvdiffrast`. The library is intended as a lightweight research-oriented alternative to systems tied to a particular simulator or GPU renderer, although the paper does not claim feature parity with robotics simulators such as Isaac Lab or ManiSkill3.

## 3. GPU-native rendering and batched execution

A conventional pixel-based pipeline can be represented as:

$$
\text{CPU simulation}\rightarrow\text{CPU rendering}\rightarrow\text{CPU image tensor}\rightarrow\text{GPU transfer}\rightarrow\text{world-model training}.
$$

Stable-envs targets the alternative:

$$
\text{GPU state/physics}\rightarrow\text{GPU rendering}\rightarrow\text{GPU image tensor}\rightarrow\text{world-model training}.
$$

The motivation is that image tensors are substantially larger than physical states. Rendering directly on the GPU reduces memory traffic and permits rendered observations and model computation to remain on the same device.

The rendering implementation uses several optimizations:

1. **Batched rendering**: multiple environments and states are rendered together.
2. **Custom GPU kernels**: rendering work is parallelized over environments and pixels.
3. **Static-scene reuse**: static scenery can be rendered once for a configuration and reused while moving bodies are drawn for individual states.
4. **On-demand rendering**: frames are generated only when requested.
5. **Backend-specific GPU rasterization**: MuJoCo Warp and `nvdiffrast` provide GPU rendering for supported configurations.

The paper reports standalone rendering speedups from $1.4\times$ to $24.1\times$ over the reference implementation when multiple prerecorded states are rendered in parallel. The maximum detailed result is $24.1\times$ for TwoRoom at GPU batch size $B=128$. The largest advantages generally occur at high batch sizes; at small batch sizes, GPU launch and synchronization overhead can make GPU physics slower than the CPU-oriented reference.

For physics-only execution, the reported GPU speedup reaches $7.55\times$ for Cube at $B=128$, while the largest combined physics-and-rendering speedup is $14.4\times$ for PushT at the same batch size. Performance is environment- and batch-dependent, and GPU execution is not uniformly faster at $B=1$.

The benchmark was conducted on an NVIDIA L40S with an AMD EPYC 9354 CPU using eight pinned CPU cores. Images had resolution $224\times224$, and batch sizes were $B\in\{1,16,128\}$. Timing used warm-up followed by multiple timing windows, with median throughput reported.

## 4. Controllable visual variations

Stable-envs treats visual parameters as controllable factors that can be modified independently of simulator state. For example:

```python
env = snv.PushT(num_envs=256, device="cuda")
env.reset(seed=0)

before = env.render()[0]

env.set_variation({
    "block.color": [230, 80, 60]
})

after = env.render()[0]
```

The physical state remains unchanged while the T-block’s RGB color changes. Conceptually,

$$
\text{physics}=f(s_t,a_t),
$$

and

$$
\text{appearance}=R(s_t;\theta).
$$

The parameter $\theta$ can include visual factors such as color and other rendering properties. This enables color randomization, controlled visual-domain shifts, multiple image observations from one physical trajectory, rendering at different resolutions, and evaluation under explicitly specified visual conditions.

A dataset can consequently store simulator states, actions, rewards or task metadata, seeds, and variation parameters rather than permanently storing all image frames. Images can later be reconstructed using

$$
o_t=R(s_t;\theta_t,r_t),
$$

where $\theta_t$ controls appearance and $r_t$ controls resolution.

The separation between state and appearance supports experiments that distinguish physical generalization from perceptual generalization. A world model can be trained on one appearance distribution and evaluated on another while holding simulator dynamics fixed. The supplied results do not include a dedicated quantitative ablation isolating each variation type, and the paper does not provide a complete enumeration of all supported variation fields or their sampling distributions.

## 5. Determinism, state restoration, and correctness

Reproducibility is a central design objective. Stable-envs supports explicit seeding, complete simulator-state access, exact state saving and restoration, deterministic replay from a seeded state and action sequence, batched evaluation, and visual variation independent of physical state.

Given environment class $E$, initial state $s_0$, and action sequence $a_0,\ldots,a_{T-1}$,

$$
s_{t+1}=f_E(s_t,a_t).
$$

When all required deterministic and stochastic variables are included in the saved state, replaying the same sequence reproduces the same trajectory. Rendering can then vary independently:

$$
o_t^{(\theta)}=R_E(s_t;\theta).
$$

Thus two image sequences may differ despite identical physical trajectories:

$$
s_{0:T}^{(1)}=s_{0:T}^{(2)},\qquad
\theta^{(1)}\neq\theta^{(2)}
\Longrightarrow
o_{0:T}^{(1)}\neq o_{0:T}^{(2)}.
$$

Dynamics were validated against source environments by initializing both systems from the same seeded state and applying the same 20 actions. The maximum reported dynamics errors were:

| Environment | Maximum dynamics error |
|---|---:|
| TwoRoom | 0 |
| PushT | $4\times10^{-13}$ |
| Reacher | 0 |
| Cube | 0 |

Rendering parity was evaluated by rendering identical underlying states in stable-envs and the reference stable-worldmodel implementation and computing pixel-space mean squared error at $224\times224$ resolution. TwoRoom and PushT were effectively exact. Cube was exact or nearly exact on GPU, while Reacher exhibited the largest discrepancy, with GPU mean MSE $2.16$ and maximum MSE $2.75$ on the $0$–$255$ pixel scale. These differences were characterized as visually negligible.

The reported evidence supports numerical parity for the tested environments and configurations. It does not establish bitwise reproducibility across all hardware, simulator versions, rendering backends, or environment classes.

## 6. World-model training and evaluation

Stable-envs was evaluated with LeWM, an 18-million-parameter world model trained in bfloat16 with batch size 128 on one NVIDIA L40S. Frames were rendered online, and throughput was measured in optimizer steps per second after warm-up.

| Environment | stable-worldmodel | stable-envs | Model only |
|---|---:|---:|---:|
| TwoRoom | 5.29 steps/s | 6.15 steps/s | 6.78 steps/s |
| PushT | 4.58 | 6.09 | 6.77 |
| Reacher | 4.06 | 5.05 | 6.78 |
| Cube | 3.56 | 4.29 | 6.78 |

The corresponding stable-envs speedups over stable-worldmodel were approximately $1.16\times$ for TwoRoom, $1.33\times$ for PushT, $1.24\times$ for Reacher, and $1.21\times$ for Cube. The maximum reported end-to-end training speedup was therefore $1.33\times$.

The fraction of wall time spent in the model-training step increased under stable-envs:

| Environment | stable-worldmodel | stable-envs |
|---|---:|---:|
| TwoRoom | 78.2% | 86.3% |
| PushT | 71.8% | 86.2% |
| Reacher | 57.9% | 72.3% |
| Cube | 52.3% | 62.2% |

The time required to reach 1,000 optimizer steps decreased from 234 to 211 seconds for TwoRoom, from 252 to 221 seconds for PushT, from 301 to 250 seconds for Reacher, and from 330 to 291 seconds for Cube.

Downstream planning performance remained similar:

| Environment | Source environment | stable-envs |
|---|---:|---:|
| TwoRoom | 88.7% | 88.0% |
| PushT | 94.0% | 93.3% |
| Reacher | 80.0% | 79.3% |
| Cube | 74.0% | 71.3% |

Stable-envs was slightly lower in each listed case, with differences of 0.7, 0.7, 0.7, and 2.7 percentage points, respectively. No statistical significance test was reported. The results therefore support faster training without a reported meaningful loss in planning performance for these experiments, but do not establish universal performance equivalence.

## 7. Applications, limitations, and relation to environment standardization

Stable-envs is intended for pixel-based world-model training, simulation-based reinforcement learning, batched online data collection, offline trajectory generation, reproducible planning evaluation, visual-domain randomization, studies of visual versus physical generalization, large-scale benchmark generation, storage-efficient simulator-state datasets, and GPU-based model-training pipelines.

Its principal combination is:

$$
\text{batched physics}
+
\text{GPU-native rendering}
+
\text{explicit simulator state}
+
\text{controlled visual variation}
+
\text{reproducible replay}.
$$

This distinguishes stable-envs from environment standardization systems that primarily unify APIs and dataset collection. For example, stable-worldmodel provides a common `World` abstraction, standardized data collection, explicit factors of variation, and online and offline evaluation protocols across heterogeneous environments [2602.08968]. Stable-envs instead concentrates on batched simulation, state-level reproducibility, and GPU-native image generation, while supporting several existing environment families and backends.

The principal limitations are:

- **Batch-size dependence**: GPU physics can be slower at small batch sizes because launch and synchronization overhead dominate.
- **Environment dependence**: rendering and combined-execution speedups vary substantially across TwoRoom, PushT, Reacher, and Cube.
- **Evaluation coverage**: although 80 environments are supported, detailed speed and correctness tables focus on four environments.
- **Incomplete variation specification**: the paper demonstrates parameters such as `"block.color"` but does not enumerate all variation fields, distributions, or constraints.
- **Unreported memory measurements**: the paper motivates reduced image storage and data movement but does not provide numerical GPU-memory savings, dataset-size comparisons, or measured bandwidth reductions.
- **Limited determinism evidence**: state and dynamics parity are reported, but no cross-device bitwise reproducibility table is provided.
- **No factorial optimization ablation**: the individual contributions of batching, custom kernels, static-scene reuse, and GPU rendering are not isolated experimentally.
- **Narrow quantitative baselines**: detailed numerical comparisons are primarily against stable-worldmodel rather than a comprehensive set of simulation frameworks.
- **Backend heterogeneity**: support for MuJoCo, Pymunk, PyBullet, JAX/Craftax, MJX, MuJoCo Warp, and custom kernels entails differences in capability and performance.
- **Rendering nonidentity**: Reacher and CPU Cube exhibit nonzero pixel differences relative to reference implementations, even though they are described as visually negligible.

Stable-envs therefore defines a stable environment not as an unchanging simulator, but as a reproducible and controllable computational substrate: physical trajectories can be batched and restored, observations can be rendered on demand, appearance can be varied independently, and evaluation can be repeated under explicitly recorded configurations. Its reported results establish substantial rendering and training-throughput gains in the tested settings while preserving close dynamics and rendering agreement with reference environments.

Source: https://www.emergentmind.com/topics/stable-envs