Using gpu-sim
Setup, commands, Python API and trace format.
5 min read
How to set up and run gpu-sim, and what its traces contain. What it is and how
it stays exact: Experimental GPU simulator.
Setup and commands#
gpu-sim/ is its own uv project (Python 3.12, warp-lang==1.18.0, numpy==2.5.4). It is
not the root pyproject.toml. No CUDA toolkit is needed, because Warp bundles NVRTC.
Rust is needed once, to build the oracle (The oracle: exact data from RocketSim).
just recipe | Command it runs | What it does |
|---|---|---|
just gpu-sync | uv sync --project gpu-sim | Creates the venv. For the torch benchmark variant, run uv sync --project gpu-sim --extra torch (torch 2.14.1+cu130) |
just gpu-cache | gpu-sim cache build | Builds the oracle, dumps arena geometry, builds the libm trig table, checks GPU f64 rounding, runs the bounds sweep |
just gpu-test | pytest gpu-sim/tests -q | 146 tests, about 20 s once kernels are cached |
just gpu-run <scenario> <out> | gpu-sim run <scenario> -o <out> | One scenario (ball and/or cars), one gpu-warp trace |
just gpu-batch [filter] | gpu-sim batch scenarios/ball/<filter>.json scenarios/advanced/a01-*.json scenarios/void/void-ball-drop.json scenarios/void/void-car-controls.json scenarios/car/car-air-*.json scenarios/car/car-fall-*.json scenarios/advanced/a02-flip-reset-setup.json gpu-sim/scenarios/*.json --out-dir gpu-sim/out/gpu --replicas 0,1,4095 | The suite (80 scenarios) as one batch, RocketSim references, compare, summary.{json,md} (with a car table) |
just gpu-validate | gpu-batch, then gpu-sim crosscheck --envs 16384 and gpu-sim car-crosscheck --envs 16384 --ticks 1200 | Suite plus random ball arenas and random free-flying cars checked bit for bit |
just gpu-bench <args> | gpu-sim bench <args> | Ball throughput benchmark |
just gpu-car-bench <args> | gpu-sim car-bench <args> | C1 car free-flight throughput (--cpu-baseline, --with-ball, --chunk 8) |
All commands take these options:
| Option | Default | Meaning |
|---|---|---|
--device | cuda:0 | Also cpu (Warp's LLVM backend) |
--trig | crt | crt, f64 or f32 (Floating point and the CPU libm) |
--candidate-order | bvh | bvh or index |
--max-manifolds | 8 | Manifold slots per env (K) |
--max-candidates | 306 | Triangle candidates per mesh query (MAX_CAND) |
--max-events | 32 | Event slots per env per tick (E) for run/batch traces. The Python API and bench default to 8 (sim.DEFAULT_E); see Bounds sized by the sweep |
--meshes | collision_meshes | Mesh folder |
batch also accepts --real-dir recordings, which compares each scenario against its
newest -r00 real-game capture as well.
Outputs. batch, bench and crosscheck write to gpu-sim/out/gpu/ by default
(gitignored; earlier runs wrote to the shared repo-root reports/gpu/ and were moved there).
run defaults to recordings/<id>.gpu-warp.jsonl, like physlab run.
Which physlab. batch and the tests use, in order: --physlab (it must exist; a
missing explicit path is an error, not a fallback), $PHYSLAB_EXE, a frozen copy at
gpu-sim/.cache/bin/physlab.exe (gitignored; present on this machine: sha256 465b832790b4d40f, the 06:52 build that all B1 round-2 and C1 results used; the current target/release build, 12:19, sha256 bb5d684d0ffa05c0, has not been run against the GPU suite), then
target/release/physlab.exe. The executable's sha256 is written to summary.json, and the
RocketSim reference cache in gpu-sim/.cache/ref/ is keyed by it as well as by scenario
hash and mesh fingerprint. The trace meta only says rocketsim 0.2.11, not which vendor
patches were compiled in, so without that key a stale reference could be reused silently.
Without any physlab, batch writes the GPU traces, prints a warning, compares nothing and
exits with code 2.
car-crosscheck and car-bench build gpusim-car-oracle on first use (Stage C1: car free flight; cargo needed)
and write to gpu-sim/out/gpu/car-crosscheck.json and car-bench.json.
Python API (gpusim.sim.BatchBallSim):
sim = BatchBallSim(n_envs, device="cuda:0", trig="crt") # loads/caches the arena geometry
sim.set_state(env_ids, pos_uu, vel_uu_s, angvel_rad_s, mode) # Ball::set_state + clear_persistent_manifolds; mode 1=soccar 0=the_void
sim.set_record_envs(ids) # optional: which envs step(record=True) writes to history
sim.step(n_ticks, record=False) # ONE kernel launch looping n_ticks
sim.get_state(); sim.events(); sim.history(); sim.diagnostics(); sim.torch_views() # torch_views: zero-copy (torch extra)Cars (gpusim.carsim.BatchCarSim, stage C1; one row per car, no interaction with the ball sim):
cars = BatchCarSim(n_cars, device="cuda:0", trig="crt")
cars.set_state(car_ids, pos_uu, vel_uu_s, angvel, boost, pyr=pyr) # or rot_cols=[m,3,3]; Car::set_state + airborne probe
cars.set_controls(axes, buttons, every=1) # axes [rows,N,5] throttle,steer,pitch,yaw,roll; buttons [rows,N] bit0 jump,1 boost,2 handbrake
cars.step(n_ticks, record=False) # ONE launch; row r drives ticks r*every..; the last row is held
cars.get_state(); cars.history(); cars.trace_quat()Trace format#
Traces follow crates/scenario-schema/src/trace.rs (schema 1). The runner name is
gpu-warp. Floats are written as the shortest round-trip decimal in serde_json's format
(tested by round-tripping every float back to the same f32 bits). NaN or ∞ aborts the run.
runner.details (all values are strings):
| Key | Example / meaning |
|---|---|
warp_version | 1.18.0 |
device | name=NVIDIA GeForce RTX 4070;alias=cuda:0;sm=sm_89;cuda_driver_api=13.4;cuda_toolkit_nvrtc=13.4;nvidia_driver=617.42 |
collision_mesh_hash | aa25f1f6fc230c7f, the same algorithm as sim_runner::collision_mesh_fingerprint (tested) |
mesh_body_order | mesh_0,mesh_1,mesh_10,…,mesh_15,mesh_2,…,mesh_9, the order RocketSim actually used, as reported by the oracle |
reference | rocketsim 0.2.11 + vendor patches (P1) |
fp_mode | nofma: fuse_fp=False, i.e. NVRTC --fmad=false |
trig_mode | crt / f64 / f32 |
trig_table | Table file (keyed by the ucrtbase.dll hash), exception counts, atan2=f64-rounded |
candidate_order | bvh / index |
geometry_source | oracle |
geometry_cache | .cache/arena-<fingerprint>-<oracle hash>.npz |
kernel_hash | sha256[:16] of all gpusim/*.py (so it also changes when only the CLI or runner changes; Warp's own module hash, e.g. gpusim.tick da9b949, identifies the compiled kernel) |
bounds | K=8;E=32;MAX_CAND=306 |
game_mode | Soccar / TheVoid |
batch_size, env_index | Where in the batch this scenario ran |
gpusim_version | 0.1.0 |
Car scenarios also write car_stage=C1-free-flight and c1_valid_until_tick (none, or
the first tick from which a car contact is possible, Stage C1: car free flight).
Cars in traces. Each sample has cars[] in the CarSample format with every gameplay
field RocketSim records:
rotation_quat_wxyzisQuat::from_mat3a(rot).normalize(), as in sim-runner;boost,on_ground,has_jumped,has_double_jumped,has_flipped,is_demoed;controls: the scenario's requested (unclamped) inputs for the step that produced the sample.
initial_state_requested and initial_state_actual are written as sim-runner writes them,
including the requested car's quaternion and the omitted boost when the scenario leaves
it unset. A scenario without a ball gets RocketSim's default ball, at rest at (0, 0, 93.15),
simulated and recorded with the same warning text physlab writes.
warnings lists:
the sim-runner warnings that apply (goal entered at tick N, the_void, truncated interval, no ball);
experimental GPU simulator (gpu-warp); see apps/web/src/content/docs/gpu/index.md;one line per active simplification (Simplifications register);
one line per bound that was hit, with its count;
for car scenarios:
C1 validity ends at tick N (<reason> at tick N-1), when it does.