Roadmap
Goals, design choices, stages and risks.
18 min read
Status#
Stages are named by what they add: B for the ball, C for cars, E for the RL environment. Each one is defined in Staged milestones.
B1 (ball + arena) was built and validated on 2026-10-15. Measured results are in Results and validation.
Suite: all 41 B1 scenarios are bit-exact against RocketSim (20,100 of 20,100 ticks, events included) with
--trig crt. A follow-up review added 10 GPU-owned edge cases: 51 scenarios, 29,865 of 29,865 samples.Random arenas: 16,384 random arenas per workload are bit-identical after 1,200 ticks.
Throughput with contact: about equal to RocketSim on 28 CPU threads (74 vs 74 M env-ticks/s), measured on a GPU shared with a running game client.
C1 (car free flight) was built and validated on 2026-10-15 (Stage C1: car free flight, C1: car free flight, C1 car free flight validation). The exit criteria (Staged milestones) are met with zero error.
Scenarios: inside the conservative contact-free window, all 29 car scenarios are bit-identical to RocketSim: 3,871 of 3,871 car-ticks, flags and boost included, with sample lines byte-identical to physlab's.
Random cars: 16,384 of 16,384 random cars with random inputs match bit for bit after 1,200 ticks, and 65,536 of 65,536 after 2,400 ticks.
Throughput: about 0.95 G car-ticks/s against 53 M on 28 CPU threads (~18×).
Not modelled: car contacts of any kind; they are C2+ work.
The design text (this page, Design spec and Alternatives considered) is unchanged except for marked B1 corrections and later notes. Its numbers come from the scratch probes and name their sources.
Scope: an optional research track. It builds on the CPU simulator after that has been measured against the real game, and is not a requirement for the rest of the project. The expected speedup comes from many batched environments whose state stays on the GPU, not from compiling the CPU loops for the GPU one to one. Results: Results and validation; usage: Using gpu-sim. This page covers goals, backend, architecture, the staged plan and the risks.
This is an experimental simulator that steps many independent Rocket League arenas in
parallel on the GPU. It is checked against RocketSim (the CPU reference, rocketsim
=0.2.11 plus the vendored patches in vendor/rocketsim/PATCHES.md), and through
RocketSim against the real game. It uses the project's own scenario files, trace
format and physlab compare / report tooling.
Goals and non-goals#
Goals#
Many independent environments. The target is 10⁴–10⁶ arenas per batch, each advanced by the same tick function. The goal is not one fast match.
Measured agreement with RocketSim. The simulator runs the same
scenarios/**.jsonfiles. Its traces use the same JSONL format, sophyslab comparereports per-horizon errors, first-divergence ticks and contact-tick agreement without any changes.Honest error accounting. Every simplification is named in the code, listed in The roadmap's register, and written into each trace's
meta.warnings. No approximation is ever silent.Order of work: ball and arena first, then car integration, then interactions (Staged milestones).
Resident data. State stays on the GPU, and the learner gets observations with no copy (Integration with the PyTorch learner). The aim is end-to-end environment steps per second, not isolated kernel speed.
Non-goals#
Bit-exactness with the CPU is not a requirement. Arithmetic order, fused multiply-add, solver ordering and math libraries can all differ between CPU and GPU, and floating-point arithmetic is not associative. What training needs is the same physical behaviour, above all the same discrete events such as contacts. Bit-exactness is still used as a diagnostic. Where the plane-only ball path can match bit for bit (Floating point and determinism), any non-zero difference points to a porting bug rather than float noise. That is a much sharper test than a tolerance.
Replacing RocketSim as the reference. RocketSim stays the reference, and the real game is the final judge.
Fixing RocketSim's known gaps toward the real game (see Sim vs real differences). The GPU simulator first reproduces RocketSim, including its flaws. A deliberate fidelity change would be a named, switchable patch that is measured against real-game traces, in the same way as the vendored P1.
Shipping proprietary geometry. Meshes are read from
collision_meshes/at run time. Derived caches go only ingpu-sim/.cache/, which is gitignored.Other game modes (Hoops, Dropshot, Heatseeker, Snowday) and mutators beyond the defaults. The only modes are
soccarandthe_void.
Backend choice: NVIDIA Warp 1.18.0, in a separate uv project#
Choice: custom kernels written in NVIDIA Warp 1.18.0 (warp-lang), running on
Python 3.12 in gpu-sim/. It is a standalone uv project with its own .venv; it is
not the root pyproject.toml.
Evidence comes from a scratch probe (not kept), run on an RTX 4070 12 GB with driver 617.42 and no CUDA toolkit installed:
| Requirement | Warp result |
|---|---|
| Works without a CUDA toolkit | Yes. NVRTC is bundled in warp.dll; only nvcuda.dll comes from the driver. A first kernel compile takes 0.5–1.1 s, and later runs load from the cache in about 11 ms |
| Batched integration throughput | 12.1–12.6 G body-ticks/s at 1M bodies (memory-bound, state fits in the 36 MB L2). 3.9 G at 4M. Same as a hand-written cudarc kernel (12.0 G) |
| Arena mesh queries | wp.Mesh BVH over the 8,020 Soccar triangles. All 16 mesh hashes match RocketSim's. Distance error vs a brute-force float64 reference ≤ 5e-4 uu |
| Sphere-vs-mesh throughput (toy physics) | 471 M ball-ticks/s at 65k envs with a closest-point query; 190 M/s for "all triangles in the AABB, each tested exactly", the query B1 needs. Near walls this drops to 65 M/s |
| Per-launch latency | About 17–27 µs for any launch that queries the mesh. It only pays off from about 64k envs, so ticks are looped inside one kernel launch (Per-tick kernel pipeline) |
| Zero-copy to PyTorch | wp.to_torch / wp.from_torch share pointers (5–9 µs wrap cost) and can share a stream through wp.stream_from_torch (torch 2.14.1+cu130) |
| Control over float contraction | Module option fuse_fp=False makes NVRTC compile with --fmad=false (checked in warp/native/warp.cu). Precise division and square root stay on unless fast_math |
Architecture overview#
scenarios/*.json ──► gpusim.scenario (parse + content_hash) ─┐
collision_meshes/soccar/*.cmf ──► gpusim.arena ──────────────┤ (CPU, once)
vendor/rocketsim (copy) ──► tools/oracle (Rust) ──► .cache/ │ edge info, BVH leaf rank
▼
BatchBallSim(n_envs, device) [state SoA arrays on device]
│ set_state(env_ids, pos, vel, angvel)
│ step(n_ticks, record=False) ── one kernel launch: for t in range(n_ticks): tick()
│ get_state() / torch views / events
▼
gpusim.trace (JSONL, runner "gpu-warp") ──► physlab compare / report (unchanged)One thread per environment. Everything inside one arena runs serially in its thread, in exactly RocketSim's order. Arenas never write to each other, so there are no atomics and no reductions across arenas.
Tick loop inside the kernel.
step(n)is one launch that loopsntimes. This hides the 17–27 µs launch latency the probe measured. In record mode the same loop writes each tick into preallocated history arrays.Megakernel first, split later. B1 uses one fused kernel. Branch divergence between flying and touching balls is measured (Performance methodology). Splitting into a uniform integrate kernel plus a compacted contact kernel is an optimisation stage, not a B1 requirement.
Performance methodology#
Workload
ball-random:N balls with uniform positions inside the Soccar box (margin 200 uu), |v| ≤ 3,000 uu/s in random directions and |ω| ≤ 6;
1,200 ticks, no resets;
initial states from a seeded generator, saved to
.npyso the CPU oracle runs the same states.Also
ball-floor(resting and rolling, so contact every tick) andball-flight(the_void, no contact), which bracket the cost.
GPU numbers:
envs × ticks / wall time, for N ∈ {1k, 4k, 16k, 64k, 256k, 1M}: after warm-up, measured with
wp.synchronizearoundstep(n), median of 5 runs;separately: compile time, cache-load time, setup (mesh upload, cache) and peak GPU memory;
the contact-active fraction per tick and the overflow counters.
Transfer costs, measured separately:
(a) step only;
(b) step + writing obs into a torch tensor through a zero-copy view on the same stream;
(c) step +
.numpy()readback every 8 ticks (agent-step cadence);(d) record mode + JSONL writing. Trace writing is a validation path, never a throughput claim.
CPU baseline on the same machine and the same states:
oracle
cpu-bench(RocketSim ball-only arenas,Balancedmemory mode), 1 and 28 threads;for reference, Benchmarks reports 5.03 M ticks/s on one thread (ball only), and 14.9–16.0 M ticks/s on 28 threads for the 1v0 batched env;
ball-only multi-thread numbers are measured by the oracle and must not be extrapolated.
Report: a table of GPU vs CPU-1T vs CPU-28T, with power (
nvidia-smi --query-gpu=power.draw) and the conditions (other GPU load present or not; the Bullet3 runs showed 2–4× noise from a shared GPU).Expectation, stated in advance:
Ball-only is cheap on the CPU too. The probe's toy kernel (190 M/s at 65k with exact AABB queries) is an upper bound.
With manifolds and the solver, a 2–10× gain over the 28-thread CPU is plausible.
The real case for a GPU is cars (1v1 is about 4× costlier than ball-only on the CPU) and keeping the learner's data on the device.
B1 is gated on fidelity. Its throughput result is input to the go/no-go decision before C2 (Staged milestones), not a pass/fail.
Integration with the PyTorch learner#
Ownership: the learner owns the torch tensors (obs
[N, D], actions, rewards, dones). gpusim wraps them withwp.from_torch(no copy) and launches onwp.stream_from_torch(torch.cuda.current_stream()). Physics, observation building, reward terms and auto-reset all run on the device, so nothing goes to the host in the rollout loop.Interface target: the same shape as the CPU env in
python/physlab_rl/env.py(reset,step(actions),obs_names), returning device tensors. The same task JSON (tasks/*.json) defines observation and reward layout, so a policy can be evaluated on the CPU env and in the real game without remapping. This is an E-stage item after C2; B1 only exposesBatchBallSim.torch_views().Validation of the env layer: the same seeds and actions are replayed on the CPU BatchEnv and the GPU env, and obs and rewards are compared per step. The transfer test is a policy trained on GPU physics, evaluated on CPU RocketSim, then in the real game.
Dependencies:
torchis an optional extra of gpu-sim (cu130wheel index, as in the probe), so the core simulator and its tests do not need torch.
Staged milestones#
Each stage ends with its suite in just gpu-batch, a results section in
Results and validation, and an explicit decision (continue / change approach / stop).
B1 — Ball + arena (prototype)#
Scope:
ball-only Soccar and the_void;
full RocketSim ball semantics: clamp, quantise (P1), damping, the plane and mesh contact paths, persistent manifolds, internal-edge correction, the ball-only solver, integration and events;
oracle tooling, trace export, batch runner, benchmark.
Exit:
Metrics and tolerances acceptance for all 41 ball scenarios (37 + 3 a01 + 1 void; +10 GPU-owned edge cases since the follow-up review);
determinism checks pass;
benchmark table published.
Go/no-go: if the mesh path cannot reach the acceptance limits after the oracle manifold diff (L2), stop and write up why before any car work.
B2 — Ball performance (optional)#
Divergence measurements, and possibly a split integrate/contact kernel with compaction, CUDA graphs and an SDF early-out as a gate only (never for contact geometry).
Exit: ≥ 1.5× over B1 at 256k envs with bit-identical traces.
C1 — Car free flight#
Scope:
per-car state machine: jump hold, double jump, flip impulse and torque, z-damp, pitch lock, flip cancel, stale
flip_rel_torque, boost, air throttle, air control withstate.ang_veldamping;quantisation;
free-flight integration with persistent quaternion;
the conservative contact-free "safe box" predicate. Outside it the sample is marked invalid, never simulated wrongly.
Validation:
car-air-* (6 scenarios) and a02-flip-reset-setup (verify it stays contact-free);
new gpu-sim-only C1 scenarios (z = 1500: jump-and-flip in each direction, boost in air, flip cancel, a stale-torque case), stored under
gpu-sim/scenarios/with RocketSim traces as reference;the safe-box predicate is itself checked against RocketSim contact events.
Exit:
position error ≤ 0.05 uu at 120 ticks;
orientation error ≤ 1e-4 rad, ω error ≤ 2e-4 rad/s;
jump, flip and boost flags identical every tick.
Status: done, 2026-10-15 (Stage C1: car free flight, C1 car free flight validation). Every exit criterion is met with zero error: car states are bit-identical to RocketSim inside the C1 window.
Validation:
the 6
car-air-*, thevoid-car-controlsfixture, 14 newgpu-sim/scenarios/gpu-car-*scenarios (dodges in every direction and speed branch, flip cancel, deadzoned dodge, boost latch and run-out, overspeed, two cars, Soccar with and without a ball, warmup/every_n);the contact-free prefixes of the 7
car-fall-*scenarios anda02-flip-reset-setup;random-state crosschecks against a new public-API oracle,
gpusim-car-oracle.
Corrections to this plan:
a02-flip-reset-setupis not C1 for 120 ticks. The car reaches the ball at tick 85 (the predicate ends the window at tick 39).The quaternion is not persistent. It is re-derived from the matrix every tick, as for the ball.
The safe box's floor is 195 uu, not 110. It must also clear the boost-pad pickup cylinders (
max_pad_z168 uu).The predicate is checked against RocketSim's first divergence. In every scenario where it fires, it fires before that divergence; this is tested.
Throughput: about 0.95 G car-ticks/s from 65k cars up, ~18× RocketSim on 28 threads for one-car TheVoid arenas (C1: car free flight). That is free flight only.
Go/no-go for C2: go. C1 removes no risk from C2/C3 (wheel rays, suspension and friction impulses, then box–mesh contacts and the solver), which is where the throughput question is decided.
C2 — Car on flat ground#
Scope:
4 wheel raycasts against the floor plane only;
suspension, extra pushback, friction curves, the throttle/brake/handbrake logic, sticky force, auto-roll and jump re-arm;
the order "all suspension impulses, then all friction impulses".
Validation:
car-throttle-, car-steer-, car-powerslide-, car-boost-, car-jump-, car-fall-wheels-;
a02 jump-flip scenarios through take-off.
Exit:
on_groundand landing ticks identical;jump-tick timing exact;
position ≤ 1 uu at 120 and ≤ 5 uu at 240 (driving scenarios accumulate);
error growth characterised.
Go/no-go: end-to-end throughput with the E1 env (1 car + ball, flat ground only) vs the CPU BatchEnv (2.0 M agent steps/s on 28 threads). Continue only if the GPU is clearly ahead (≥ 3×) including the learner.
C3 — Car vs arena mesh#
Scope:
wheel rays against the mesh BVH (
wp.mesh_query_ray, flipping the triangle normal towards the ray origin, edge tolerance −1e-4);hitbox against planes (support point, manifolds);
hitbox against mesh: either an exact port of
box_triangle_sat.rs(1,188 lines), or a named approximation (closest-point or SDF probes on box features) with measured error;the car–world solver path with warm starting;
world_contact_normal, auto-flip (including the UE16 sine-table sign rule), wall driving and turtle.
Exit:
per-tick wheel contact counts match on ≥ 99% of ticks for wall and ramp scenarios (new gpu-sim scenarios plus the car-fall-* side, roof and nose cases);
position ≤ 5 uu at 120;
every non-matching tick class is explained.
C4 — Car–ball#
Scope:
sphere vs car OBB (analytic, with margin);
friction 2.0, restitution 0;
the shared solver island (car, ball and world rows in Bullet order, one thread per arena);
the RocketSim extra hit impulse (start-of-tick state copies,
can_accelevery other tick, z_scale, the extra-impulse curve);wheels hitting the ball (dynamic hit,
ground_stick);CarHitBallevents.
Validation: cb01–cb03 and a01 scenarios with a car.
Exit:
touch-onset ticks identical;
post-hit ball velocity within 1% or 10 uu/s;
position ≤ 1 uu at 30 ticks after the hit.
C5 — Car–car#
Scope:
box–box detection (ODE-style SAT plus clipping, up to 4 points), friction 0.09 and restitution 0.1;
bump and demo logic (cooldown, cones, supersonic demo rule,
vel_impulse_cacheapplied after integration);demoed-car freeze and respawn with the wyrand RNG;
the cross-car pre-tick order hazard.
Validation: cc01–cc02 plus new multi-car scenarios.
Exit:
bump and demo ticks and
is_demoidentical;respawn positions identical given the seed;
position ≤ 5 uu at 60 after the contact.
E1 — RL environment (after C2, extended after each later stage)#
A torch-native batched env with the task-JSON obs/reward layout, on-device auto-reset and seeded resets.
Exit:
obs and rewards match the CPU BatchEnv per step for replayed actions, within the tolerances of the physics stage it relies on;
a policy trained on the GPU env reaches comparable evaluation scores on the CPU env;
the end-to-end training throughput table.
Risks#
| Risk | Why | Mitigation |
|---|---|---|
| The mesh path has not been run against data (retired: it is bit-exact on all 51 B1 scenarios) | The ball spec's sphere–triangle test, edge correction, sort_cached_points and BVH order come from reading code only | Oracle (exact preprocessing plus manifold dumps); mesh scenarios that isolate one feature each (ramp sweeps, the 10/11 seam, goal translation in a01) |
| Seam and edge contacts (the D2 residue: 11 of 18,900 real-game ramp steps, mostly at seams) | Seams between meshes and between mesh and plane get no edge correction; averaged normals at seams are sensitive to which points survive | Port the manifold logic in full; report contact-tick agreement and post-bounce velocity at seams explicitly |
| Quantisation amplifies ulps | A 1-ulp difference before a 0.01 uu or 1e-4 rad/s grid step becomes a whole step | Bit-exact target on planes; error reported in grid units, not just uu |
| f32 differences | NVRTC code generation, trig, as i32 saturation | fuse_fp=False, hand-ordered helpers, trig modes, L0 unit tests |
| Divergence and memory on the GPU | Contacting envs run 10× longer; manifolds cost about 1 KB per env | Measure; B2 split kernels; size K from data |
| Warp version drift | Code generation or BVH behaviour changes | Pin warp-lang==1.18.0; record version and kernel hash; re-run the suite on any bump |
| Car stages are much harder | Box–triangle SAT, the multi-body solver, wheel rays on meshes, RNG | Go/no-go gates after B1 and C2; named approximations allowed only with measured error |
| The GPU is shared with Rocket League or training | Benchmark noise (2–4× in the Bullet3 runs) | Record GPU utilisation before and after; median of repeats; flag contaminated runs |
| Proprietary data leaks into git | Caches hold derived geometry | Everything derived lives in gpu-sim/.cache/ (gitignored); tests read from collision_meshes/ only |
Open questions#
Answered in B1: it is trig after all. The cause of the 1-ulp self-correcting transient on
ball-roll-x-slow-long(21 of 1,200 ticks; also 10 of 1,200 ticks onball-roll-diag-slow-long) is the Windows UCRTcosf, which is not correctly rounded. At tick 782,cosf(0x3bfe9f29)returns0x3f7ffe05where the correctly rounded result is0x3f7ffe06, and the quaternion first differs there.The earlier "not trig" test compared two correctly rounded implementations, never UCRT itself.
The oracle's lockstep manifold and rotation dump located it, and replaying the integration with each sin/cos variant confirmed it.
Fixed by
--trig crt(Floating point and the CPU libm).
Answered in B1: exact static visit order in RocketSim's grid broadphase (S1). It is the ordered per-cell
static_handleslist, dumped by the oracle and replayed on the GPU.Whether ball-world results are identical with cars present (split rows for all points, all rows solved). This matters for C4. Partly answered in C1: for a resting ball and a ball in the void, the ball-only GPU path matched RocketSim's general path bit for bit in all 15 Soccar car scenarios (S10). Bouncing or rolling balls with cars present are untested.
Whether the 1e-4 rad/s ω grid (P1) also holds for cars in the real game (
vendor/rocketsim/PATCHES.mdsays it may become ball-only).Answered in B1: the worst case for triangle candidates and simultaneous manifolds.
A sweep over 29.1M points on a 20 uu grid found at most 153 candidates per mesh query (p99.9 = 70) and at most 4 open gates, 2 of them meshes.
The bounds were therefore set to MAX_CAND = 306 and K = 8.
The 41-scenario suite and the crosscheck had 0 overflows.
The event bound E was not swept. A follow-up review measured up to 16 events per tick in a scenario and up to 93 in random states, so traces now use E = 32 (Bounds sized by the sweep).
New after B1: ball-only throughput.
With contacts, the B1 megakernel is on par with 28 CPU threads (74 vs 74 M env-ticks/s for ball-random; 55 vs 47 for ball-floor).
With better CPU load balancing (more chunks than threads), the CPU reaches 75–82 M on ball-random (follow-up review).
Without contacts (the_void) it is 8.6× faster (1.29 G vs 0.15 G).
These were measured on a GPU shared with a running game client.
Whether splitting the kernel (B2) closes the gap is open. It feeds the C2 go/no-go.
New after C1: Warp's scalar unary minus drops the sign of zero. In Warp 1.18,
-xgives +0 for x = +0; Rust gives −0. It surfaced as-0.0vs0.0in a tick-0 quaternion.wpmath.neg()(x·−1) is used inquat_muland in the car code. The B1 contact and solver code still has a few scalar negations. They have never produced a difference.