ruxla
JAX → Rust → JAX

Your JAX environments, at native speed.

ruxla compiles existing JAX environments to native code, unchanged. And it brings Rust environments back into JAX.

11.2×faster than JAX on one CPU core
228×faster on Craftax
238JAX environments, no rewrite
What ruxla doesone IR, two directions
ruxla IR JAX's primitives and rules JAX environment gymnax · Pgx · Jumanji Craftax · Brax · Waymax IMPORT optimize emit Rust COMPILE Native code compiled by rustc no Python, no XLA Rust environment an API like jax.numpy generic over a backend TRACE vmap · grad lower to XLA EXPORT Inside JAX one primitive under jit · vmap · grad ruxla IR JAX's primitives and rules JAX envgymnax · PgxCraftax · Brax IMPORT optimize emit Rust COMPILE Native coderustcno Python Rust envjax.numpy-likeany backend TRACE vmap · grad lower to XLA EXPORT Inside JAXone primitivejit · vmap · grad

Background: 48 × 48 cells, the size of a Craftax level, each one an environment stepping.

Brax / MJX · Waymax · Craftax

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.

Brax / MJXA Go2 backflip: MJX physics and a trained policy, in closed loop.
1 core
2.0k steps/s
16 cores
24k steps/s
Waymax128 road users on a recorded scene. 6× JAX
1 core
35 steps/s
16 cores
168 steps/s
CraftaxNine generated levels, mobs, crafting. 228× JAX
1 core
106k steps/s
16 cores
909k steps/s
JAX → native

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.

5–11×faster than JAX on the CPU, across 71 environments
env.py · JAX def step(key, state, action): state = move(state, action) done = is_over(state) state = jnp.where(done, reset(key), state) return obs(state), ... ① jax.make_jaxpr(env.step) ruxla IR jaxpr · 128 primitives fused gather mul add select_nif / else scatterin place ② branch fuse in place env.rs · generated fn step(s: &mut State, a, key) { if done(s) { *s = reset(key); } else { move_in_place(s, a); } } ③ rustc → native ✓ matches JAX
Craftax · one CPU core

The same world, 228 times faster.

Both lanes run the same open-world survival game on one core, live, at their measured speeds.

JAXXLA on one core
0468 steps/sworld 1
ruxlaimported, native
0106,500 steps/sworld 1

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.

228×

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.

CPU vs GPU

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.

ruxla on the CPU is faster
environments1
ruxla, 16 CPU cores–
JAX, RTX 5090–
faster–

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.

Rust → JAX

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.

1.0×the speed of the same environment written in JAX
1.5×faster on the CPU, when Rust lets you use a better algorithm
cartpole.rs · Rust fn step_env<B: Backend>( &self, s: &State<B>, a, ) -> Transition<B, ..> { let x = s.x + DT * s.v; ... trace · B = Trace .ruxlapkg reset · step · default_params pkg JAX program env = ruxla.load_env(pkg) f = jax.jit(jax.vmap(env.step)) g = jax.grad(loss) jit vmap grad compiled by XLA ruxla_call ∂ backward CPU GPU
JAX env → PyTorch agent

Call it from PyTorch.

The JAX environment runs on the CPU cores. Your PyTorch agent stays on the GPU.

3×sooner to the target return on Craftax
CPU · 16 cores Craftax · ruxla.VecEnv GPU · PyTorch PPO agent · CleanRL observations actions
time to the target return0 s

Craftax Classic ×3.4

ruxla
24 s
JAX on GPU
81 s

Craftax ×3.0

ruxla
14 s
JAX on GPU
42 s
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.

gymnax 25Pgx 20Jumanji 26CraftaxWaymaxBrax MJXMuJoCo PlaygroundNAVIX 83XLand-MiniGrid 44JaxMARL 24
Code

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)

Keep JAX. Run anywhere.

$ pip install ruxla
$ cargo add ruxla