Your JAX environments, at native speed.
ruxla compiles existing JAX environments to native code, unchanged. And it brings Rust environments back into JAX.
Background: 48 × 48 cells, the size of a Craftax level, each one an environment stepping.
Robots, games and driving, imported whole.
Three JAX environments with thousands of operations per step, running as native code. No Python, no XLA at run time.
- 1 core
- 2.0k steps/s
- 16 cores
- 24k steps/s
- 1 core
- 35 steps/s
- 16 cores
- 168 steps/s
- 1 core
- 106k steps/s
- 16 cores
- 909k steps/s
Import, don't rewrite.
Give ruxla the jaxpr of an environment you already have. It comes back as Rust, compiled ahead of time, on the same trajectories.
The same world, 228 times faster.
Both lanes run the same open-world survival game on one core, live, at their measured speeds.
An abstract Craftax: the agent gathers wood, builds a table and mines stone and ore until night falls and a new world is generated. Both lanes are shown 400 times slower than real time, so that the JAX lane moves at all; the counters run at the measured speeds.
A new Craftax world is generated only when an episode ends. Batched JAX code computes it on every step; ruxla's compiler turns it back into a branch.
16 CPU cores against an RTX 5090.
Environment steps per second as the batch grows. Up to about ten thousand environments, ruxla on 16 CPU cores is ahead of JAX on the GPU, by hundreds of times with a single environment.
Geometric mean of environment steps per second over the 58 environments of gymnax, Pgx and Jumanji measured at every batch size. ruxla runs the imported environments on an AMD Ryzen 9 9950X (one thread up to 64 environments, 16 beyond); JAX runs the originals on an NVIDIA RTX 5090 (solid) and on the same CPU (dashed). The GPU wins large batches of rigid-body physics.
Write it in Rust. Train it in JAX.
An environment written with ruxla becomes a JAX primitive that jit, vmap and grad treat like their own, on CPU or GPU.
Call it from PyTorch.
The JAX environment runs on the CPU cores. Your PyTorch agent stays on the GPU.
Craftax Classic ×3.4
Craftax ×3.0
envs = ruxla.compile_env("craftax:...").vec_env(num_envs=64) obs = torch.from_numpy(envs.reset()).cuda()
PPO (CleanRL) in PyTorch on an RTX 5090 with 64 environments, five seeds; JAX steps the same environments on the GPU and hands them over with DLPack. Lighter games gain 1.2–1.5×; an agent written in JAX trains fastest in a fused GPU loop.
Both directions, a few lines each.
// Rust (cargo add ruxla): write once, generic over the backend ruxla::env::export(&CartPole, "cartpole.ruxlapkg")?; # Python (pip install "ruxla[jax]"): use it inside JAX env = ruxla.load_env("cartpole.ruxlapkg") step = jax.jit(jax.vmap(env.step)) obs, state, reward, terminated, truncated, info = step(keys, state, actions)
# Python (pip install "ruxla[jax]", and cargo for the compiler): # export an existing JAX environment, compile it to native code, step it envs = ruxla.compile_env("gymnax:Breakout-MinAtar").vec_env(num_envs=64) obs = envs.reset() obs, reward, terminated, truncated, info = envs.step(actions) # Rust (cargo add --build ruxla-build): the same in a build script ruxla_build::compile_envs("envs");
Keep JAX. Run anywhere.
$ pip install ruxla $ cargo add ruxla