Training environment
The full reference: environment, tasks, learner, self-play and results.
119 min read
The complete reference for training: every convention, task field, reward term, flag, run and A/B table. For an overview, read Methodology first.
The page follows the order the pieces were built in:
| Part | Sections |
|---|---|
| Environment, single-agent tasks | Quick start to Curriculum |
| Environment, full matches | Match mode: observation, state setters, terminals, events, the Lucy-SKG reward table |
| Learner, single-agent tasks | Python learner: bindings, PPO, auxiliary tasks, curriculum results, first Lucy-SKG A/B tests |
| Learner, self-play matches | Self-play learner: opponent pool, evaluation and ratings, the 1 B-step 1v1 run, reward and ablation A/B tests |
| The paper, item by item | Lucy-SKG coverage: every technique of the paper, its status here and the evidence |
Commands to get started are on the Training overview. Conventions follow RLGym and Necto where they exist, so action indices and numbers compare with that ecosystem. Ideas from the Lucy-SKG paper are marked with its section number (§).
Quick start (Rust)#
use std::{path::Path, sync::Arc};
use rlenv::{BatchEnv, StepBuffers, Task};
rlenv::init_collision_meshes(Path::new("collision_meshes"))?; // once per process
let task = Arc::new(Task::load("tasks/ground-touch-v1.json")?);
let mut batch = BatchEnv::from_task(task, 1024, /*seed*/ 1, /*threads*/ None)?;
let mut buf = StepBuffers::new(batch.n_envs(), batch.obs_dim(), batch.num_components());
batch.reset(&mut buf.obs)?;
let actions = vec![rlenv::action::THROTTLE_BOOST_ACTION; batch.n_envs()];
batch.step(&actions, buf.as_out())?; // obs, reward, terminated, truncated, ...Collision meshes are proprietary and not in the repo (see README). Tests that
simulate skip themselves when collision_meshes/soccar is missing.
Environment conventions#
| Item | Convention |
|---|---|
| Arena | Soccar, standard meshes, ArenaMemWeightMode::Balanced; single-agent tasks: demolitions disabled, one Blue Octane. Match tasks: see Match mode |
| Units | uu, uu/s, rad/s; 120 Hz physics |
| Action repeat | tick_skip ticks per agent step (default 8 → 15 decisions/s, as RLGym and Necto) |
| Actions | 90-row discrete lookup table (below); controls persist across the step's ticks |
| Input latency | none: an action applies from the next tick. RLGym v2's RocketSimEngine defaults to rlbot_delay=True (each action one tick late, like RLBot). We don't, so that an exported episode is an ordinary scenario and replays bit-exactly. A bot deployed through RLBot sees one extra tick of latency. |
| Determinism | an episode is a pure function of (task file, seed, actions). BatchEnv results are bit-identical for any thread count (tested 1 vs 4 threads). |
| Reset | initial state drawn with fastrand::Rng::with_seed(seed) only; materialised BallInit/CarInit stored in EpisodeInit; pads reset; state applied with sim_runner::setup::apply_initial_state (the scenario runner's code path) |
Termination vs truncation#
PPO must bootstrap from V(s′) on truncation but not on termination, so they
are reported separately.
| Flag | When | Notes |
|---|---|---|
terminated | success or failure (including a timeout deadline) | The step stops at the first terminating tick; the remaining ticks of that step are not simulated. ticks_to_success is exact and the final state is the state at the event. Success wins if both happen on the same tick. |
truncated | max_steps = ceil(episode_seconds·120/tick_skip) agent steps reached, or the ball entered a goal | A goal is irrelevant for touch tasks; the real game would explode and reset the ball, so the episode cannot continue faithfully. It also stops the step at that tick and is counted in EpisodeStats::goal_scored. |
Success (kind: "touch"): any tick with a CarHitBall event for the
agent where the ball centre is at least min_ball_z_uu high and, if
require_car_airborne, the car is not on the ground (fewer than 3 wheels in
contact). Contacts always come from physics events, never distance
thresholds.
Success (kind: "drive_toward_ball", for turn-around mechanics): any
tick on which the car is on its wheels (3+ in contact), its horizontal
heading is within max_heading_error_rad of the horizontal direction to the
ball, and its velocity toward the ball is at least
min_speed_toward_ball_uu_s. The ball is only a target marker; both
parameters are required.
Failure (ball_hits_ground: true): a BallHitWorld event with contact
normal z > 0.7 and contact point z < 50 uu, i.e. the floor (walls and the
ceiling don't count). A ball resting on the floor fires this every tick, so
validation rejects ball_hits_ground when the ball can start below 120 uu.
Failure (timeout: true): a hard deadline, like a timed training pack
whose ball explodes. Without success by tick ceil(episode_seconds · 120)
the episode terminates with failure on that exact tick (no bootstrapping),
instead of being truncated at the next step boundary. The mechanics tasks
use it (Capabilities → Speed flips and half flips).
Action table#
Built by the exact loop of RLGym v2 LookupTableAction
(lookup_table_action.py:168-193), identical in Nexto and in the
NectoAction parser of .external/Necto/training (the released Necto model
has multi-discrete heads instead; see Necto and Nexto). Columns:
[throttle, steer, pitch, yaw, roll, jump, boost, handbrake]. Rows 0–23 are
ground actions (yaw = steer), 24–89 aerial (throttle = boost, steer = yaw).
The env also accepts control codes 90..2034 for bots with other action
spaces; policies only use the 90 rows.
| Index | Action |
|---|---|
| 8 | no-op |
| 16 | throttle |
| 18 | throttle + boost |
| 14 / 22 | throttle + boost, steer −1 / +1 |
| 0–5 | reverse |
| 56 | jump |
| 57 | jump + boost |
| 76 / 34 | pitch +1 (nose up) / −1 |
| 77 | pitch +1 + boost |
rlenv::action::table() returns all rows; tests pin row count (90), the
no-op, uniqueness and these indices.
Observation#
Single-agent tasks (match tasks: Observation layout).
Fixed size per task: 46 + 8·k floats with k = obs.action_stack
(default 5 → 86). Task::obs_names() / BatchEnv::obs_names() label every
index. Scales follow RLGym v2 DefaultObs: positions and velocities ÷ 2300,
angular velocities ÷ π, boost ÷ 100.
Agent frame: the agent always attacks +Y. For an Orange agent every
world vector (positions, velocities, angular velocities, the car's forward
and up axes) is rotated 180° about Z (x, y negated — RLGym's inversion,
physics_object.py:124-145); the initial-state distribution is mirrored the
same way, so an Orange episode looks exactly like the Blue one with the same
seed (tested). Only Blue is used for now.
| Indices | Features |
|---|---|
| 0–2, 3–5, 6–8 | ball position, velocity, angular velocity |
| 9–11 | car position |
| 12–14, 15–17 | car forward, up (unit vectors) |
| 18–20, 21–23 | car velocity, angular velocity |
| 24 | boost / 100 |
| 25–31 | on_ground, has_flip_or_jump (RocketSim CarState::has_flip_or_jump), has_jumped, has_double_jumped, has_flipped, is_flipping, is_supersonic (0/1) |
| 32–34, 35–37 | ball − car position, velocity (agent frame) |
| 38–40, 41–43 | ball − car position, velocity in the car frame (dot with forward, right, up) — small MLPs otherwise have to learn the rotation |
| 44 | car–ball distance / 2300 |
| 45 | fraction of the episode remaining (1 at reset, 0 at the time limit) |
| 46 … | previous k actions as their 8 control floats, most recent first, zeros before the first action (Lucy-SKG §4.3, appendix Table 2) |
on_ground at reset reflects the initial pose: the shared reset path
(sim_runner::setup::apply_initial_state) probes wheel contacts, so an
airborne spawn reads 0 from the first observation (and cannot ground-jump).
Reward components#
Every step yields one unweighted value per component; the reward is
Σ weightᵢ · componentᵢ. Components are the task's rewards keys (sorted by
name), then pot:<name> for each potentials key (sorted). Names and weights
are exposed (component_names(), component_weights()), per-step values in
reward_components, and per-episode sums in EpisodeStats::component_sums.
Log them separately (as Lucy-SKG does, §5), so reward hacking shows up: a weight of 0 keeps a
component logged without affecting training.
Event components (aggregated over the step's ticks):
| Name | Value |
|---|---|
success, failure | 1 on the step that terminates that way |
touch | single-agent tasks: 1 if an agent–ball contact onset happened (RocketSim emits CarHitBall every tick of a sustained contact; an onset is a contact tick after a tick without one). Match tasks: 1 if the agent touched the ball on any tick of the step (RLGym's ball_touched, see Match mode → Events) |
ball_height_at_touch | ball z / 2044 at the step's first onset, else 0 |
boost_used | boost spent this step / 100 (pickups not subtracted) |
time | 1 (use a negative weight for a time penalty) |
success_time_left | single-agent: on the success step, the seconds left before the time limit (ceil(episode_seconds · 120) ticks) at the exact success tick, else 0. Pays for every tick saved, which time and discounting can't resolve inside an 8-tick step |
dodge, flip_cancel, speed_flip, half_flip | 1 if the agent's car started a dodge, cancelled a flip, speed flipped or half flipped during the step (all task kinds; detectors below) |
Mechanic detectors (crates/rlenv/src/mechanics.rs, fed every tick
with the car state and the applied controls; read from RocketSim's flip
state, never from intent):
| Event | Rule |
|---|---|
| dodge | has_flipped turns on with a directional input; direction = RocketSim's dodge_dir (forward = −pitch, right = yaw + roll) |
| flip cancel | first tick of the dodge on which RocketSim scales its pitch torque down: still flipping, < 3 wheels down, pitch input with the sign of the flip's pitch torque, flip ≥ 0.041 s old |
| speed flip | the cancel of a dodge 12°–78° off straight ahead, at most 13 ticks after the dodge: the BakkesMod Speedflip Trainer's criteria (tynidev/SpeedFlipTrainer). Counted on the cancel tick |
| half flip | landing on the wheels after a cancelled backward dodge (forward share ≤ −0.5) with the heading turned more than 120°. Counted on the landing tick |
Episode stats (EpisodeStats, match AgentStats) also count dodges,
flip_cancels, speed_flips and half_flips, whatever the task's rewards.
Scripted examples of each, at 8-tick decisions, are tested to fire them and
near misses (a front flip, a cancel 16 ticks late, a cancelled back flip
without the air roll) not to (tests_mechanics.rs).
Utilities (functions of the state after the step; bounded, tested on random states):
| Name | Range | Formula (source) | ||
|---|---|---|---|---|
velocity_to_ball | [−1, 1] | dot(unit(ball − car), car_vel / 2300) (RLGym v1 VelocityPlayerToBallReward) | ||
distance_to_ball | (0, 1] | exp(−0.5·(d − 91.25)/2300), d floored at the ball radius (RLGym v1 LiuDistancePlayerToBallReward) | ||
face_ball | [−1, 1] | dot(forward, unit(ball − car)) (RLGym v1 FaceBallReward) | ||
car_height, ball_height | [0, 1] | z / 2044 | ||
user distance_to_ball {dispersion, density, subtract_ball_radius} | (0, 1] | exp(−0.5·d/(2300·w_dis))^(1/w_den) — Lucy-SKG §4.4 eq. 3. Larger dispersion spreads the curve, larger density makes it flatter. Defaults (1, 1, true) = the Liu distance. As printed, eq. 3 only depends on the product w_dis·w_den (exp(x)^(1/w_den) = exp(x/w_den)), so density is not a separate "concavity" control (tested). | ||
align_ball_to_goal | [−1, 1] | 0.5·(cos(ball − car, opp_back − car) + cos(ball − car, car − own_back)): RLGym v1 AlignBallGoal with offense = defense = 0.5 (Necto's alignment; RLGym's default 1, 1 gives [−2, 2], but Lucy-SKG §4.4 requires [−1, 1]). Lucy-SKG Table 1 a_b2g | ||
ball_to_goal_velocity | [−1, 1] | dot(unit(opp_back − ball), ball_vel / 6000) (RLGym v1 VelocityBallToGoalReward; Lucy-SKG Table 1 Φ_u_b2g) | ||
save_boost | [0, 1] | sqrt(boost / 100) (RLGym v1 SaveBoostReward; Lucy-SKG Table 1 Φ_boost) | ||
ang_vel | [0, 1] | ` | car angular velocity | / 5.5. Necto pays 0.005 of it per step (ang_vel_w`) because its bot stopped flipping early in training; not in Lucy-SKG |
touch_grass | {0, 1} | 1 while the car is on the ground below one ball radius. Necto charges 0.005 per step (touch_grass_w); not in Lucy-SKG | ||
user ball_goal_distance_difference {offense_weight, offense_dispersion, offense_density, defense_weight, defense_dispersion, defense_density, subtract_ball_radius} | [−w_def, w_off] | Lucy-SKG Table 1 Φ_dd_b2g: w_off·D(‖ball − opp_back‖) − w_def·D(‖ball − own_back‖) with D(d) = exp(−0.5·(d − ℓ)/(6000·w_dis))^(1/w_den), d − ℓ floored at 0, ℓ = goal depth 880 (+ ball radius 91.25 when subtract_ball_radius, the default). Weights 0..=1, everything else defaults to 1 | ||
user krc: [names…] | [−1, 1] | Kinesthetic Reward Combination, Lucy-SKG §4.4 eq. 2: `sgn·(Π | Rᵢ | )^(1/n)`, sgn = +1 only if every Rᵢ > 0, −1 otherwise, 0 if any Rᵢ = 0. Unlike a weighted sum, it is only high when all parts are (facing and near and approaching). |
opp_back / own_back are the backs of the nets the agent attacks /
defends, (0, ±6000, 321.39) (RLGym ORANGE_GOAL_BACK / BLUE_GOAL_BACK).
Every utility is computed in the world frame with the agent's attack
direction, so an Orange agent in the 180°-rotated state gets exactly the
Blue agent's value (tested for every utility of the Lucy-SKG tasks).
Potential-based shaping (Lucy-SKG §3.2)#
potentials maps utility names to weights; Φ(s) = Σⱼ wⱼ·Φⱼ(s). Each step
adds, per potential, F_j = γ_F·Φⱼ(s′) − Φⱼ(s) (component pot:<name>).
By Ng, Harada & Russell (1999) such shaping cannot change the optimal policy — it can't be "farmed" by circling near the ball, unlike dense per-step terms.
shaping_gamma= γ_F, default 1.0 as in the paper (they found small utility differences turned negative with γ_F < 1). The strictly policy-invariant choice is γ_F = the learner's γ. With γ_F = 1, γ < 1 and Φ(terminal) = 0, the discounted shaping return of an episode that terminates at T is−Φ(s₀) + (1 − γ)·Σ_{t=1}^{T−1} γ^{t−1}·Φ(s_t): a bonus of about(1 − γ)·Φper step spent in high-potential states, i.e. a mild incentive to linger there instead of terminating. Forpot:approach(weight 2, Φ ≤ 1) and γ = 0.989 that is ≤ 0.022 per step, comparable to thetimepenalty of 0.01, so A/B γ_F = γ if lingering shows up.Terminal handling:
Φ(s_terminal) := 0on termination (success/failure), which keeps invariance for episodic tasks — the agent "gives back" its accumulated potential when the episode ends, so with γ_F = 1 the episode's total shaping is exactly−Φ(s₀)(tested). On truncation the realΦ(s′)is used, because the learner bootstrapsV(s′)there.
The same task can run with dense per-step shaping (utilities in rewards) or
potential shaping (utilities in potentials); see the ground-touch variants.
Seeds and held-out evaluation#
| Namespace | Seeds | Used by |
|---|---|---|
| training | splitmix64(splitmix64(splitmix64(base) ⊕ env) ⊕ episode) with bit 63 cleared | BatchEnv::new(task, n, base, …), auto-resets; each env walks its own stream, independent of threading |
| evaluation | (eval.seed_base + i) | 2^63 (bit 63 set), i < eval.episodes | Task::eval_seeds() + BatchEnv::reset_with_seeds with auto-reset off |
The namespaces are disjoint, so training can never draw a held-out episode.
Evaluate with set_auto_reset(false), reset_with_seeds(&eval_seeds[..n]),
then step until all_done(); report success rate with a confidence interval
(e.g. Wilson), not mean reward.
Episode export → scenario → physlab run / view#
With recording on (Env::set_recording(true) / BatchEnv::set_recording(true)
before the episode starts), any episode exports to an ordinary validation
scenario: Env::episode_to_scenario(id) (current episode) or
BatchEnv::last_episode_scenario(i, id) (env i's last finished episode,
also after an auto-reset). The scenario contains the materialised initial
state, one ControlStep per agent step (duration_ticks = ticks actually
simulated, so the last step may be shorter), warmup_ticks = 0, a capture of
exactly the simulated ticks, and seed = the episode seed.
serde_json::to_writer_pretty(file, &scenario) # e.g. recordings/ground-touch-ep.json
physlab run recordings/ground-touch-ep.json # RocketSim trace
physlab view recordings/ground-touch-ep.rocketsim.jsonl # watch it in RLViserThe test exported_episodes_replay_bit_exactly_through_the_scenario_runner
replays 18 episodes (3 tasks × 6, in a reused arena, including car–ball
contacts and mid-step terminations) through sim_runner::run and requires
the final ball and car position, velocity, angular velocity and boost to be
bit-identical to the env's. This holds although the env uses Balanced
memory mode with demolitions disabled and a long-lived arena, while the
runner builds a fresh Heavy arena with default mutators: memory mode does
not change results, a single car cannot be demolished, and the arena RNG is
only consumed by add_car (overwritten by the teleport). Match tasks, with
several cars and demolitions, reseed the arena RNG to match the runner and
re-apply controls every tick; see
Export and replay of match episodes.
Task file format (tasks/<id>.json, task_schema_version: 1)#
Training tasks live in tasks/, not scenarios/ (physlab validate parses
scenarios/ as Scenarios). Unknown fields are rejected;
TaskSpec::validate collects every problem. A unit test loads and validates
every tasks/*.json and checks id = file stem.
| Field | Meaning |
|---|---|
id, description | slug, free text |
kind | "single_agent" (default) or "match" |
tick_skip | 1..=32, default 8 |
episode_seconds | truncation horizon (0, 3600]; the game timeout of a match |
obs.action_stack | 0..=16, default 5 |
obs.include_boost_pads, obs.max_team_size | match tasks only: pad cooldowns in the observation (default false), car slots per team (default team_size, ≤ 3) |
obs.game_info | match tasks only: the game info block (time_remaining_frac, score_diff), default true. Copied from Necto, which trained inside real matches where the clock and score carry across goals; here episodes end at the first goal, so the clock only says how long ago the episode started and the score is always level. false drops both |
match | match tasks only (required there): team_size 1..=3, no_touch_timeout_seconds (default 30), state_setters {setter: weight}, optional eval_state_setters, team_spirit τ and opponent_weight β (0..=1, default 0), optional setter_seconds {setter: seconds} (drills, see Terminals), action_delay_ticks (0 ≤ delay < tick_skip, default 0: input latency; a new action takes effect that many ticks into its step, the previous one holding until then; RLBot adds 1 tick). Match tasks have no initializer/success/failure. |
initializer.car (single-agent) | position_uu: [[lo,hi]×3], pitch_rad/yaw_rad/roll_rad: [lo,hi], linear_velocity_uu_s, angular_velocity_rad_s: [[lo,hi]×3], boost: [lo,hi] (0–100), optional forward_speed_uu_s: [lo,hi] (speed along the car's heading, added to the velocity box; negative = reversing; drawn last, so tasks without it keep their initial states) |
initializer.ball.placement | {"kind": "box", "position_uu": [[lo,hi]×3]} or {"kind": "near_car", "distance_uu": [lo,hi], "bearing_rad": [lo,hi], "z_uu": [lo,hi]} (horizontal distance from the car, bearing relative to its heading, positive = to the car's right, the same sense as positive yaw) |
initializer.ball.linear_velocity_uu_s, angular_velocity_rad_s | [[lo,hi]×3], world frame |
success (single-agent) | {"kind": "touch", "min_ball_z_uu": 0, "require_car_airborne": false} or {"kind": "drive_toward_ball", "min_speed_toward_ball_uu_s": v, "max_heading_error_rad": θ} |
failure | {"ball_hits_ground": false, "timeout": false} |
utilities | named distance_to_ball {…} / ball_goal_distance_difference {…} / krc […] definitions |
rewards | component → weight |
potentials | utility → weight |
shaping_gamma | γ_F, (0, 1], default 1 |
eval | {"seed_base": u64, "episodes": u32} |
notes | optional: free text per rewards / potentials / utilities entry (JSON has no comments; the Lucy-SKG tasks cite the paper for every entry). Keys must name an entry. |
All ranges are uniform [lo, hi] with finite lo ≤ hi. Sampled positions
must lie inside the field (100 uu from walls for the car, one ball radius for
the ball, conservative 45° corners); velocity boxes must respect RocketSim's
caps (car 2300 uu/s and 5.5 rad/s, ball 6000 uu/s and 6 rad/s) so nothing is
silently clamped. A car whose z range reaches below 120 uu must have zero
pitch_rad/roll_rad ranges, otherwise it could start inside the floor. Draws that violate bounds or put the ball within 200 uu of
the car are re-drawn (same RNG stream) up to 64 times; if that ever runs out,
EpisodeInit::fallback_used is set (a test checks the shipped tasks never get
there in 4000 draws each).
Curriculum: aerial interception#
Difficulty is expressed by separate task files rather than in-file schedules; graduate on held-out success rate, not reward.
| Task | Setup | Success / failure | Horizon |
|---|---|---|---|
ground-touch-v1 | car at rest (z 17, random yaw, x ±2500, y ±3500, boost 33–100); ball at rest on the floor 500–2500 uu away in any direction | any touch / — | 8 s |
ground-touch-dense-v1 | same initial states and eval seeds; dense shaping instead of potentials | same | 8 s |
ground-touch-nostack-v1 | same as ground-touch-v1 with action_stack: 1 | same | 8 s |
aerial-touch-easy-v1 | grounded car with 100 boost; ball 300–1000 uu ahead (±20°), z 300–700, rising 300–600 uu/s | airborne touch with ball ≥ 250 uu / ball reaches the floor | 4 s |
aerial-touch-v1 | boost 50–100; ball 600–1600 uu away in any direction, z 500–1200, rising 200–500 uu/s, ±250 uu/s sideways | same | 5 s |
Reward weights and their reasoning#
All tasks share the scale success = 10, so returns are comparable across the curriculum, and every shaping term is kept well below it:
time: −0.01per step: at most −1.2 over an 8 s episode — a nudge toward speed (discounting already does most of that).Potential variants:
pot:approachwith weight 2 onapproach = KRC(face_ball, distance_to_ball, velocity_to_ball). Its per-episode total is bounded by 2·|Φ| ≤ 2 and is exactly−2·Φ(s₀)on termination; it only redistributes credit in time.ground-touch-dense-v1:velocity_to_ball: 0.05,face_ball: 0.01per step. A fast approach earns ~0.5–1 in total, far below a touch; idling while facing the ball nets 0 against the time penalty. Unlike potentials these can in principle be farmed, which is what the A/B is meant to show.Aerial tasks add
failure: −2: without it, ending the episode early by letting the ball drop would dodge the time penalty.Zero-weight entries (
touch,velocity_to_ball,face_ball,distance_to_ball,car_height,ball_height_at_touch,boost_used, andpot:approachin the dense variant) are diagnostics only. Both ground-touch variants therefore log the identical component set.
These are starting points, not tuned values. Watch per-component logs for reward hacking.
The single-agent tasks use the paper's action stacking, potential-based shaping, parameterised distance and KRC; the full list of Lucy-SKG items, with their status and evidence, is in Lucy-SKG coverage.
Match mode#
Task kind "match" (crates/rlenv/src/match_env.rs): a full Soccar match
in one arena where every car is an agent. 1v1, 2v2 and 3v3
(match.team_size 1..=3) are supported; 1v1 and 2v2 are tested. Shipped
tasks: tasks/match-1v1-v1.json, tasks/match-2v2-v1.json (the full
Lucy-SKG reward table), the reward A/B baseline
tasks/match-1v1-simple-v1.json and the action-stack ablation
tasks/match-1v1-nostack-v1.json (match-1v1-v1 with action_stack: 0,
observation size 79). This section covers the environment and
its bindings; the self-play PPO learner is in
Self-play learner.
Agents, arena and batch rows#
| Item | Convention |
|---|---|
| Agents | 2·team_size Octanes, added and ordered blue-0.., orange-0..; agent i = arena car i = scenario car i |
| Arena | Soccar, Balanced, demolitions Normal (RocketSim's default; no team demos), the 34 boost pads active and reset to available at every episode start |
| Batch rows | per-agent arrays have n_rows = n_envs · n_agents rows, row env · n_agents + agent; BatchEnv::agent_env / agent_team (Python: env.agent_env, env.agent_team, 0 = Blue) give the mapping. Single-agent tasks are the special case n_agents = 1. |
| Per-env values | terminated, truncated, ep_length are the env's, repeated on each of its rows. Seeds (reset_with_seeds), done_mask and episode_seeds take one entry per env. |
| Per-agent values | observation, reward (after the team distribution), reward components (the agent's own, before it), ep_return; ep_success = the agent's team scored (won), ep_ticks_to_success = the goal tick for winners (−1 otherwise) |
| Auto-reset / final obs | as single-agent: when an env ends, every agent row of final_obs holds the end state and obs the next episode's first state |
| Episode stats | BatchEnv::last_match_stats(i) / Python last_episode_stats(i): seed, state_setter, length, end_reason (goal, timeout, no_touch_timeout), goal_team, goal_tick, scorer (the car with the last touch, if it is on the scoring team; None for own goals and untouched balls), and per agent: team, return, touches, shots, demolishes, demolished, boost collected, raw (pre-distribution) return, unweighted and weighted component sums; per team (teams, Blue then Orange): the means of those over its agents |
| Determinism | an episode is a pure function of (task, seed, actions); batch results are bit-identical for 1 and 4 threads (tested in Rust and Python) |
Observation layout#
Same scales and agent frame as single-agent tasks (positions and velocities
÷ 2300, angular velocities ÷ π, boost ÷ 100; Orange sees everything rotated
180° about Z, so both teams attack +Y. Tested: on a mirrored kickoff blue
agent k and orange agent k get identical observations; and for states
of every setter and team size 1–3 with boost pads on, agent i of a state
and agent (i + team_size) mod n of the state rotated 180° with the teams
swapped get the same observation (to 1e-4), and over the next 8 steps with
swapped actions the same observations, components and rewards (to 2e-3, the
mirrored physics drifting by float rounding); this covers velocities, spins,
tilted cars, other-car slots, the ball and pad cooldowns). obs.max_team_size
(default team_size, at most 3) fixes the number of car slots, so one
layout can serve several team sizes; a slot without a car is all zeros with
present = 0. Names: Task::obs_names() / env.info.obs_names (self_*,
ally<i>_*, opp<i>_*, ball_*, pad_<i>_timer, prev_action_<i>_<col>,
time_remaining_frac, score_diff); offsets: MatchObsLayout::offsets().
| Block | Size | Start (1v1) | Start (2v2) |
|---|---|---|---|
| self | 24 | 0 | 0 |
allies (max_team_size − 1 slots × 31) | 0 / 31 | — | 24 |
opponents (max_team_size slots × 31) | 31 / 62 | 24 | 55, 86 |
| ball | 22 | 55 | 117 |
boost pads (only with obs.include_boost_pads) | 34 | (77) | (139) |
action stack (8·k, k = 5) | 40 | 77 (111 with pads) | 139 (173 with pads) |
game info (none with obs.game_info: false) | 2 | 117 (151) | 179 (213) |
| total | 119 (153 with pads) | 181 (215 with pads) |
Self block (offset within the block):
| Offset | Feature |
|---|---|
| 0–2, 3–5, 6–8 | position, forward axis, up axis |
| 9–11, 12–14 | velocity, angular velocity |
| 15 | boost / 100 |
| 16–22 | on_ground, has_flip_or_jump, has_jumped, has_double_jumped, has_flipped, is_flipping, is_supersonic |
| 23 | demolished (Lucy-SKG §4.3: a demolished flag instead of demo/boost timers) |
Ally / opponent slot (allies and opponents each in arena order, the observer excluded):
| Offset | Feature |
|---|---|
| 0 | present (1 = a car fills this slot; stays 1 while that car is demolished) |
| 1–3, 4–6, 7–9 | position, forward, up |
| 10–12, 13–15 | velocity, angular velocity |
| 16 | boost / 100 |
| 17–20 | on_ground, has_flip_or_jump, is_supersonic, demolished (while demolished, RocketSim freezes the car's physics state, so its position and velocity are those at the demolition) |
| 21–23, 24–26 | position, velocity relative to the observer (agent frame) |
| 27–29 | relative position in the observer's car frame (forward, right, up) |
| 30 | distance to the observer / 2300 |
Ball block: position, velocity, angular velocity (0–8), ball − observer position and velocity (9–14), the same in the observer's car frame (15–20), distance (21) — the single-agent ball features.
Boost pads (off by default, as Lucy-SKG §4.3 drops pad objects): 34
cooldowns in seconds ÷ 10 (0 = available; RLGym v2 DefaultObs). Pad order
is RocketSim's (sorted by y, then x). For Orange, slot k holds pad
pad_mirror[k], the pad at slot k's position rotated 180°, so a slot
always means the same place in the agent's frame. The mirror map is built
from the arena's pad list (the pad nearest to (−x, −y, z)). Verified
against RocketSim's pad list: every mirrored pad matches within 1 uu, sizes
agree, the map is an involution and equals the reversal 33 − k (RLGym's
boost_pad_timers[::-1] trick holds here); the observation itself is
tested too.
Action stack: the agent's last k actions, as in single-agent tasks. Game
info: fraction of the game time remaining (1 at reset, 0 at the game
timeout) and the score difference from the agent's side, clipped to ±5 and
÷ 5 (Necto). Episodes end at the first goal, so the score difference is
always 0 for now; it is kept so the layout survives multi-goal episodes.
State setters (Lucy-SKG appendix §5, Necto training/state.py)#
match.state_setters is a weighted mixture (setter → weight, normalised);
match.eval_state_setters (optional) replaces it for held-out evaluation
seeds (bit 63 set), e.g. kickoffs only. The setter and the state are drawn
from fastrand::Rng::with_seed(seed); the materialised state (MatchInit:
setter, BallInit, one CarInit per agent) is what the env applies and
what exports replay. Invalid draws are re-drawn up to 64 times (tested: no
fallback in 2000 draws per setter and team size): a car closer than 100 uu
to walls or ceiling, a car inside the curved floor–wall or ceiling–wall
transitions (see below), the ball less than a radius inside the field,
car–ball < 200 uu, car–car < 250 uu.
Wall clearance (setters::car_clear_of_walls): the floor meets the walls
in a curved ramp, so a car origin 100 uu from a wall can start inside the
mesh. An upright car on the floor needs 270 uu from the side walls, 190 uu
from the back walls and 330 uu from the corner walls (along their normal);
a car in the air (any orientation, 120–1744 uu up) needs 190 / 170 / 240 uu;
no car starts above 1744 uu (the ceiling transitions need up to 430 uu of
clearance near the ceiling). Measured by teleporting an Octane toward each
wall and checking the first tick for a contact or a push, plus 10 uu. Before
this rule about 3 % of aerial and 0.5 % of random states started a car
inside a ramp (it was pushed out by up to 16 uu on the first tick); a test
now requires that no setter state has any car–world, car–car or car–ball
contact on its first tick. MatchEnv::reset_with_init starts an
episode from any explicit MatchInit.
| Setter | State |
|---|---|
kickoff | as RocketSim reset_to_random_kickoff: the 5 kickoff spots shuffled, blue car i on spot i, orange car i on the same spot rotated 180°, boost 33.3, ball at rest at the centre |
kickoff_like | kickoff plus jitter: ±400 uu x/y and ±0.4 rad yaw per car, boost 20–50, ball ±300 uu off centre |
random | Necto BetterRandom-like: ball x/y uniform within the BetterRandom limits (±3391, ±4415), z triangular(R, R, 2044 − R), velocity in a uniform direction with exponential speed (mean ≈ 869 uu/s, Necto's −6000 / ln 0.001 scale), spin up to 6 rad/s; each car at the ball plus a uniform direction × exponential distance (mean 1500 uu): below 120 uu it is put upright on the floor with a horizontal velocity, otherwise airborne with pitch triangular(±π/2) and roll triangular(±π); speed triangular(0, 0, 2300), boost 0–100; cars outside the field are re-drawn uniformly on the floor |
goalie | a random team defends: its first car near its own goal line (|x| ≤ 800, 4300–4900 uu from centre), facing up-field ±0.6 rad; the ball in that half flies at 1200–2500 uu/s (horizontal) toward a random point of the goal mouth, with the vertical speed that reaches it; other cars on the floor anywhere |
aerial | ball 600–1500 uu up with a small velocity; each team's first car 400–1500 uu (horizontally) from the point below it, facing it, boost 50–100; other cars on the floor anywhere |
The shipped tasks train on kickoff 0.2, kickoff-like 0.2, random 0.4, goalie 0.1, aerial 0.1 and evaluate on kickoffs only. Lucy-SKG (appendix §5) and Necto use replay states 0.7, random 0.15, kickoff 0.05, kickoff-like 0.05, goalie 0.05, i.e. without replays random 0.5 and 1/6 each for kickoff, kickoff-like and goalie. Ours is not that renormalisation: it gives kickoffs more weight (0.4 vs 0.33) and goalie states less (0.1 vs 0.17), and adds aerial states (not in the paper) as a stand-in for the high-ball situations that replay states supply. These are project choices, not paper values.
Not available: the replay-state setter (probability 0.7 in Lucy-SKG and
Necto), which samples states of real ranked games. It needs a replay
dataset (and a parser into MatchInits), which this project does not have.
State bank: starting from recorded states#
The bank setter starts an episode from an exact recorded mid-game state (plan
H3 and the reverse curriculum of track K).
Task fields:
match.state_setters: {"bank": w, ...}plusmatch.state_bank: {"path": "...", "mirror": true}. The path is relative to the working directory. A task that trains onbankmust also seteval_state_setters.File: JSON lines, one snapshot per line,
version: 1: the ball, every car's full RocketSim state (jump, flip, flip-reset and demo state and timers included), the action stack, boost pad cooldowns and the arena RNG. Each line may carry aweight.Sampling: the episode seed picks a snapshot by weight, then mirrors it (teams swapped) with probability ½. The clock and no-touch counter start at 0; works with
setter_seconds.Capture:
BatchEnv.snapshot(i),snapshots(indices), andepisode_snapshots(i, steps), which replays a recorded episode and returns snapshots at the given steps (for mining states before conceded goals).restore_snapshot(i, json)andset_state_bank(path)load them.Mining:
just mine <checkpoint> --out <bank>.jsonlplays the task's held-out seeds against Necto and Nexto and writes the states 2, 3, 4 and 5 s before every goal the checkpoint concedes (physlab_rl.mine_states;<bank>.jsonl.meta.jsonsays which game each line came from).tasks/match-1v1-flip-kickoff-bank-v1.jsontrains on such a bank.Exactness: a restored state continues bit-exactly, flips, flip resets, demolitions and pad cooldowns included (
crates/rlenv/src/tests_snapshot.rs), unless a body was in contact on the snapshot's last tick: RocketSim can't restore cached contact points, so such states can drift at rounding level (21 of 2,767 random-play snapshots).Episodes started from a snapshot can't be exported as scenarios; use
episode_snapshots.
Terminals (Lucy-SKG Table 4)#
| Flag | When | Notes |
|---|---|---|
terminated | a goal | the step stops at the scoring tick (the rest of the step is not simulated); potentials Φ(s′) := 0 |
truncated | game timeout: episode_seconds (300 s = 4500 steps in the shipped tasks, as Lucy-SKG) | bootstrap from V(final_obs) |
truncated | drill limit: match.setter_seconds {setter: seconds}, training episodes started from that setter only (held-out eval seeds and explicit initial states play the full game) | bootstrap from V(final_obs), so the drill is judged by the critic's value of where play has got to; observations still count down the full game |
truncated | no-touch timeout: no car–ball contact for match.no_touch_timeout_seconds (shipped match tasks: 45 s, Lucy-SKG Table 4; the field's default is 30 s, RLGym v2 / Necto) | checked at the end of each step; any contact tick (not only onsets) resets the timer, as RLGym v2's NoTouchTimeoutCondition |
Events (per agent, per step)#
Available as reward components (rewards keys; weight 0 = logged only) and
in the episode stats. The rules live in crates/rlenv/src/events.rs and are
unit-tested on synthetic tick data, and again end to end in the arena (goal,
touch + shot, demolition with respawn, big-pad pickup).
| Component | Value |
|---|---|
goal / concede | 1 on the step the agent's team scores / concedes (team events: every member gets them). Scoring team = the team attacking the goal the ball is in (ball y > 0 → Blue). |
touch | 1 if the agent was in contact with the ball on any tick of the step: RLGym's per-step ball_touched (v2: ball_touches > 0), which Lucy-SKG Table 1's 1_touch and Necto's touch rewards read. A sustained push or a ball resting on the roof pays every step it lasts. (Before the paper-fidelity review this was contact onsets only, which paid such a contact once.) |
shot | 1 if one of the agent's touch onsets (a CarHitBall tick after a tick without one) was a shot (below); onsets are also what the stats' touches counts |
demolish | cars this agent demolished: it is the bumper of the CarHitCar { is_demo: true } event of a car whose is_demoed turned on |
demolished | 1 if this agent's is_demoed turned on |
boost_pickup | boost gained from pads / 100: per CarPickupBoost, min(12 or 100, 100 − boost before the tick) |
touch_ball_to_goal_acceleration | on a step in which the agent touched the ball (as touch): ball_to_goal_velocity(s′) − ball_to_goal_velocity(s) over the agent step, in [−2, 2]; else 0 (Lucy-SKG Table 1) |
ball_height_at_touch, boost_used, time | as in single-agent tasks (boost_used counts consumption, not pickups) |
dodge, flip_cancel, speed_flip, half_flip | as in single-agent tasks, per car; AgentStats counts them too, and match evaluations report them per game for both teams |
success and failure exist only in single-agent tasks, and the match
events only in match tasks (validation rejects the others).
Shot — an approximation of the game's shot statistic, which RocketSim does
not have. At a touch onset, the ball (its state after that tick) is
extrapolated as a projectile — gravity 650 uu/s², no drag, no spin, no
bounces — to the opponent's goal-line plane y = ±5120. It is a shot if
the ball moves toward that goal, reaches the plane within 2 s, and its
centre is then inside the mouth: |x| < 892.755 and z < 642.775. A path
that dips below the floor counts as low (on target), so rolling and
bouncing shots count, a ball that would bounce up over the crossbar is
over-counted, and saves are ignored. Touches toward one's own goal are never
shots.
Rewards and team spirit#
Each agent gets the task's reward program over its own events and utilities (built-in utilities are per car and use the agent's attack direction; potentials are tracked per agent, Φ(s′) := 0 on termination). Then the reward distribution of Lucy-SKG Table 1 ("team spirit"):
R′ᵢ = (1 − τ)·Rᵢ + τ·mean(R over i's team) − β·mean(R over the opponents)
with τ = match.team_spirit and β = match.opponent_weight (both 0..=1,
default 0). The team mean includes agent i itself (the paper's R̄′_team,
and Necto). The paper writes the formula without β, i.e. β = 1, with
τ = 0.3; Necto uses τ = 0.6, β = 1. The returned reward is R′;
reward_components stay the agent's own unweighted values, so
reward = components · weights only when τ = β = 0 (tested with
hand-computed values and in 1v1 and 2v2 arenas).
β = 1 makes the reward exactly zero-sum (equal team sizes): the R′
of all agents sum to 0 every step, and a team's mean R′ is
mean(R_own) − mean(R_opp) (tested on every step of 1v1 and 2v2
episodes). Consequences, worth knowing when reading curves:
In 1v1, τ has no effect:
R′ = R − R_opp.Event weights act through their difference: a goal is worth
10 − (−3) = +13to every scorer and−13to every conceder. Concede −3 alone does not make defence cheap.Ball-only potentials (
ball_goal_distance_difference,ball_to_goal_velocity) are the same for all members of a team, so the team receivesF(Φ_own − Φ_opp). For the goal-distance difference that is[D₀.₆ + D₀.₄](‖ball − opp_back‖) − [D₀.₆ + D₀.₄](‖ball − own_back‖): the offensive/defensive dispersion asymmetry of Table 1 cancels out under β = 1; it only matters for β < 1.Per-car potentials become "mine minus the opponents'":
save_boost, for example, also pays for the opponent spending boost.Shaping stays potential-based:
R′is the shaping of the linear combinationΦ′ᵢ = (1 − τ)Φᵢ + τ·mean_team Φ − β·mean_opp Φ, which telescopes the same way. From a mirrored kickoffΦ′(s₀) = 0in 1v1, so with γ_F = 1 the episode's total shaping is exactly 0 there.
Per-component logging: the step result has every agent's unweighted
components (reward_components, rows = agents, env.agent_team gives the
team); weights are in env.info.reward_component_weights. Episode stats
(BatchEnv::last_match_stats(i), Python last_episode_stats(i)) add per
agent raw_return (before the distribution), component_sums and
weighted_component_sums, and per team (teams: Blue, Orange) the means
over its agents of return_mean, raw_return_mean, component_sums_mean
and weighted_component_sums_mean. The paper plots unweighted episode
means for the tested agent's team (§5); log Blue for that, plus per team.
The Lucy-SKG reward table (appendix Table 1)#
tasks/match-1v1-v1.json and tasks/match-2v2-v1.json (identical rewards)
implement the full Lucy-SKG table, checked against the PDF
(.external/2305.15801v1.pdf, appendix p. 4, Table 1; notation in
appendix §1.1). Each task entry has a notes string with its reference.
| Paper (Table 1) | Our component | Weight | Formula (ours) | Interpretation / deviation | ||
|---|---|---|---|---|---|---|
| Ball-to-Goal Distance Difference, offensive dispersion 0.6, defensive dispersion 0.4 | pot:ball_goal_distance_difference | 2 | D_off(‖ball − opp_back‖) − D_def(‖ball − own_back‖), D(d) = exp(−0.5·(d − ℓ)/(6000·w_dis))^(1/w_den), ℓ = 880 + 91.25 | The paper gives no w_off, w_def or densities: we use 1 (range [−1, 1]). Table 1 writes d − ℓ_goal; we also subtract the ball radius, like RLGym's LiuDistanceBallToGoalReward, because only that reproduces the paper's Figure 1 (0.549 and 0.811 at midfield for w_dis 0.7 and 2; tested). Targets are the backs of the nets (p_target, p_blue target). Under β = 1 the dispersion asymmetry cancels (above). | ||
| Ball-to-Goal Velocity | pot:ball_to_goal_velocity | 0.8 | dot(unit(opp_back − ball), ball_vel/6000) | As printed (= RLGym VelocityBallToGoalReward). | ||
| Save boost | pot:save_boost | 0.5 | sqrt(boost/100) | As printed. | ||
| Distance-weighted Alignment, dispersion 1.1 | pot:distance_weighted_alignment | 0.6 | KRC(a_b2g, d_p2b) = `sgn· | a_b2g·d_p2b | ^(1/2), d_p2b=distance_to_ball {dispersion 1.1}` | a_b2g = align_ball_to_goal with 0.5/0.5 weights so it stays in [−1, 1] (the paper requires that range, §4.4; RLGym's default gives [−2, 2]). The dispersion applies to d_p2b, the only distance in it (appendix §1.1). d_p2b subtracts the ball radius (RLGym Liu distance). |
| Offensive Potential, density 1.1 | pot:offensive_potential | 1 | KRC(a_b2g, d_p2b, u_p2b), d_p2b = distance_to_ball {density 1.1}, u_p2b = velocity_to_ball | Table 1 leaves this row's "Type" cell blank; its formula is written Φ_op like the other potentials and §5.2 discusses it with Distance-weighted Alignment, so it is a potential here. Eq. 3 as printed makes density 1.1 identical to dispersion 1.1, so both KRCs use the same distance curve. | ||
| Goal | goal | 10 | 1 when the agent's team scores | Team-level, as Necto (whose goal_w = 10 is paid to every home-team member): the paper's Figure 2 (appendix p. 3) draws Lucy-SKG's Goal as inherited from Necto's. | ||
| Concede | concede | −3 | 1 when it concedes | — | ||
| Shot | shot | 1.5 | 1 for a touch onset predicted on target | RocketSim has no shot stat; ballistic approximation (above). | ||
| Touch Ball-to-Goal Acceleration | touch_ball_to_goal_acceleration | 0.25 | 1_touch·(r_u_b2g(s′) − r_u_b2g(s)) over the agent step | Δ over each 8-tick step with a contact (RLGym-step granularity, as t − 1 → t in the paper), range [−2, 2]. | ||
| Touch | touch | 0.05 | 1 per step with any contact | 1_touch = RLGym's per-step ball_touched (any contact tick), not only contact onsets. | ||
| Demolish | demolish | 2 | number of cars demolished this step | — | ||
| Demolished | demolished | −2 | 1 when demolished | — | ||
| Team spirit | match.team_spirit, match.opponent_weight | 0.3, 1 | R′ᵢ = (1 − τ)Rᵢ + τ·R̄_team − β·R̄_opp | β = 1 is the paper's formula; zero-sum (above). | ||
| γ of the shaping function F | shaping_gamma | 1 | F = γ_F·Φ(s′) − Φ(s) | The paper sets it to 1 (appendix §1.1); Φ(terminal) := 0 on a goal only (truncations use the real Φ(s′)). |
Logged at weight 0 (diagnostics, and the same component set as the A/B
baseline): boost_pickup, boost_used, ball_height_at_touch, and the
dense (per-step) values of ball_goal_distance_difference,
ball_to_goal_velocity, save_boost, align_ball_to_goal,
distance_to_ball, velocity_to_ball, distance_weighted_alignment and
offensive_potential.
Not adopted from the paper: the "Save" reward that Figure 2 shows flowing into Lucy-SKG is not in Table 1 (we follow the table), and RocketSim has no save statistic. The auxiliary-task ablation rewards (Table 1, lower half) belong to the paper's MLP ablations, not to Lucy-SKG.
Terminal potentials. A goal terminates, so every agent's potential is
"given back" on the scoring step (F = −Φ(s)). For the team that scores,
pot:ball_goal_distance_difference is then about −2 (the ball was at its
target), for the conceders about +2; the sum over an episode is
−Φ(s₀) whatever happened (tested on 1v1 and 2v2 episodes: per agent and
potential, Σ F = Φ(s_T) − Φ(s₀), with Φ(s_T) = 0 after goals). Shaping
only moves credit in time; goals and events decide the return. The paper
does not say how it handles Φ at the goal. Necto's reward (the code
Lucy-SKG builds on) pays plain differences Φ(s′) − Φ(s) and keeps
Φ(s_T), which adds Φ(s_T) − Φ(s₀) to each episode and so rewards scoring
"from a good position" a little more. Zeroing Φ(s_T) is the Ng et al.
choice that keeps the optimal policy unchanged; it is the project's
documented choice (shaping_gamma section above), not a paper value.
A/B baseline: match-1v1-simple-v1#
Same states, terminals, events, team spirit and eval seeds as
match-1v1-v1, but a plain linear reward without KRCs or potentials:
every step pays 0.02·ball_goal_distance_difference +
0.008·ball_to_goal_velocity + 0.005·save_boost +
0.006·align_ball_to_goal + 0.005·distance_to_ball +
0.005·velocity_to_ball (1 % of the matching Lucy potential weight; the
Offensive Potential's weight split between its distance and velocity
parts, Distance-weighted Alignment's going to the alignment), plus the
same events. The KRCs and all pot: terms are logged at weight 0, so both
tasks log the identical component set (tested). Dense terms can be farmed
in principle (e.g. idling near the ball), but under β = 1 a symmetric
opponent cancels most of that; these weights are starting points, not
tuned values.
Scripted baselines#
rlenv::scripted (BatchEnv::scripted_actions(policy, out), Python
env.scripted_actions("ball_chaser") → int64 (n_rows,)) returns an index
into the 90-action table for every row, computed from each car's own
world state, so any subset of agents (e.g. env.agent_team == 1) can be
scripted cheaply and mixed with policy actions:
| Policy | Behaviour |
|---|---|
ball_chaser | on the ground: full throttle steering toward the ball (dead zone 0.15 rad), handbrake for turns sharper than 2 rad, boost when facing it (within 0.3 rad), more than 1000 uu away and not supersonic, jump when the ball is within 400 uu horizontally and 250–700 uu high; in the air: pitch/yaw the nose toward the ball, boost when facing it and it is above. Demolished cars idle. |
idle | action 8 (no-op) |
random | uniform, from splitmix64(batch seed, call counter, row): reproducible for a batch seed and call sequence, independent of threads |
Tested: two ball chasers touch the ball on every tested held-out kickoff; ball-chaser/random mixes stay thread-count independent.
Community bots: Necto and Nexto#
physlab_rl.rlgym_bots runs the two RLGym community bots as opponents
inside the batched env, next to the scripted ones. Both were trained in the
real game with RLGym v1 and released for RLBot. Necto (v1) is "around
Diamond" and won the 2022 RLBot championship; Nexto (v2) is "approximately
Grand Champion 1" in 1v1, per their README. They are the strong anchors the
ball chaser is not.
| Piece | How |
|---|---|
| Models | The TorchScript files of the local checkout, .external/Necto/rlbot-support/{Necto,Nexto}/*-model.pt (Rolv-Arild/Necto @ 2e6ed7d, CC BY-NC-SA 4.0), loaded from there and never copied into the repo. They are traces with CPU constants, so they always run on the CPU. Without the checkout the bots are unavailable and their tests skip. |
| State | BatchEnv.raw_state(): per env, the world state in game units, not inverted (crates/rlenv/src/raw.rs): ball (9), pad availability and cooldowns (2 × 34), then per car team, position, forward, up, velocity, angular velocity, boost, on_ground, has_flip_or_jump, has_jumped, has_double_jumped, has_flipped, is_demoed, demo_respawn_timer (24). Names: env.raw_state_names; pad positions: env.boost_pads(). |
| Observations | Vectorised ports of the RLBot builders (necto_obs.py, nexto_obs.py): attention inputs (q, kv, mask) with one entity per car, the ball and the 34 pads, for every controlled car in one batch. Tested against the original builder code, run literally per car on rlgym_compat stand-ins, in 1v1 and 2v2 over 60 steps (equal to float32 rounding: Nexto's original round-trips the rotation through a quaternion). Pads are matched to the bots' BOOST_LOCATIONS by position. |
| Actions | Nexto's 90 logits index our table (tested equal), so its actions go to the env unchanged. Necto has five multi-discrete heads (throttle, steer, jump, boost, handbrake). Its control vectors (pitch = throttle, roll = steer while drifting) are not table rows, so they go to the env as control codes (below). |
| Action choice | As the RLBot agents' beta: 1 = argmax (deployed default), 0.5 = sample from the policy, 0 = uniform, −1 = worst. necto:<beta> / nexto:<beta> select another value. Nexto samples (β = 0.5) during the kickoff pause, its default stochastic_kickoffs; here the pause is "ball untouched on the centre spot". |
Control codes. BatchEnv.step accepts indices 90..2034 besides the
90 table rows: every control vector with analog values in {−1, 0, 1} and
buttons in {0, 1} (3⁵ · 2³ = 1944 codes, rlenv::action::control_code,
Python rlgym_bots.control_codes, env_action_table()). Learned policies
keep the 90-action space. Recording, export and the action-stack
observation read the control floats, so a code behaves exactly like the
table row it encodes (tested bit for bit).
Deviations from the RLBot bots, all because the env steps in decisions of
tick_skip ticks:
Actions apply from the next tick for the whole step, as for our policies (RLGym v1 training semantics). Under RLBot, Necto acts on the decision tick and Nexto six ticks after it.
No hardcoded kickoffs. The RLBot wrappers can play a scripted speed flip with 4-tick control changes: off by default for Necto, on for Nexto. Here the policies play their own kickoffs.
Necto's RLBot builder updates its demo and pad timer features on every tick; here they advance
tick_skiptimes per decision, from the decision-time state. Those features are quirky in the original (demo timers cycle whether or not a car is demolished; pad timers run for available pads) and are reproduced as they are.has_flipis RocketSim'shas_flip_or_jump: the in-game flag that RLGym v1 training used, notrlgym_compat'snot double_jumpedapproximation.
Sanity check (1v1, all 256 held-out kickoffs, the bots' default argmax): Nexto beats Necto 207/0/49 (0.809 [0.756, 0.852]), Nexto beats the ball chaser 254/0/2, and Necto beats it 256/0/0. That ordering matches their published strength. In 2v2 (128 kickoffs) Nexto beats Necto 114/0/14.
Export and replay of match episodes#
Recording and export work as for single-agent tasks
(BatchEnv::last_episode_scenario, MatchEnv::episode_to_scenario, Python
export_episode_scenario): the scenario contains every car (agent order),
one ControlStep per run of identical consecutive actions per car, a
capture of exactly the simulated ticks, and seed = the episode seed. Two
details make demolitions replay exactly:
Arena RNG. RocketSim draws a demolished car's respawn spot from the arena RNG. At every episode start the env reseeds it to the state the scenario runner reaches after adding the cars to an arena seeded with the episode seed (one respawn-spot draw per
add_car).Controls are re-applied every tick. A respawn resets the car's controls in the middle of a step; the env, like the runner (and RLGym's engine), sets every car's controls before each tick, so the agent's action holds after the respawn. (Found by the replay test: without it the respawned car idled for the rest of the step in the env only.)
exported_match_episodes_replay_bit_exactly_including_demolitions replays
12 episodes (1v1 and 2v2, a reused arena, ball-chaser and random actions,
one forced demolition per team size) through sim_runner::run and requires
bit-identical final ball and car states (in the current run: 3 demolitions,
3 respawns, 2 goals). physlab run and physlab view handle multi-car
traces:
physlab run recordings/match-ep.json # 2- or 4-car trace
physlab view recordings/match-ep.rocketsim.jsonlPython#
from physlab_rl import BatchEnv
env = BatchEnv("tasks/match-2v2-v1.json", n_envs=1024, seed=1)
env.n_envs, env.n_agents, env.n_rows # 1024, 4, 4096
env.agent_env, env.agent_team # uint32 / uint8 (n_rows,), read-only
obs = env.observe() # float32 (n_rows, 181)
a = policy(obs) # one action per row
orange = env.agent_team == 1
a[orange] = env.scripted_actions("ball_chaser")[orange]
r = env.step(a) # every field has n_rows rowsThroughput: Benchmarks §3 (at 28 threads ≈ 2.3 M agent steps/s for 1v1 and ≈ 2.6–2.8 M for 2v2, random actions, before Python).
Raw state and community bots (Necto and Nexto):
from physlab_rl.rlgym_bots import BotSpec, RLGymBot
raw = env.raw_state() # float32 (n_envs, 9 + 68 + 24 * n_agents)
bot = RLGymBot(BotSpec("nexto"), env, rows=np.flatnonzero(orange))
a[orange] = bot.act(env.raw_state()) # env action indices (Necto: control codes >= 90)Python learner#
The single-agent learner: PyO3 bindings for rlenv
(crates/rlenv-py), a PyTorch PPO learner (python/physlab_rl), held-out
evaluation with confidence intervals, reproducible checkpoints and run
manifests, plus A/B tests of the Lucy-SKG ideas.
Setup#
uv sync # .venv: free-threaded Python 3.15t, numpy, torch, pytest, maturin
# + builds crates/rlenv-py (profile release-lto) as physlab_rl._native
uv run pytest # python/tests (simulating tests skip without collision meshes)
just py-sync / just py-testFirst
uv sync: ~3 GB of torch/CUDA wheels (20–40 s with a warm uv cache) plus the extension build. With the workspace'srelease-ltoartefacts already built (e.g. byjust bench-lto) the extension links in ~20 s; from scratch, fat LTO of RocketSim takes a few minutes.uv run …rebuilds the extension automatically when any Rust source it is built from changes ([tool.uv] cache-keysinpyproject.toml). While other crates are mid-edit, runuv run --no-sync …to keep using the already-built extension.The extension uses pyo3's stable ABI (
abi3-py315), socargo build,cargo clippy --workspaceandcargo test --workspaceneed no Python environment. Python is not part ofjust ci(the torch download is ~3 GB).There is one venv,
.venv, on free-threaded Python (3.15t, no GIL; set in.python-version). The extension builds there as a version-specific module (free-threaded builds have no stable ABI), and the GIL stays off with everything training imports (the run manifest recordsenvironment.gil_enabled).--compile/--torch-compileneed Triton, which has no free-threaded Windows build, so they are refused there.just bench-python <checkpoint>compares training throughput against the GIL build (3.15) in a throwaway uv environment.torch is temporarily a pinned nightly: the stable release's Python 3.15 Windows wheels crash on tensor work off the main thread, which the overlapped update does.
pyproject.tomlsays what to undo once a fixed stable release is out.Windows console: set
PYTHONUTF8=1if you print non-ASCII.
Python API#
import numpy as np
from physlab_rl import BatchEnv
env = BatchEnv("tasks/ground-touch-v1.json", n_envs=4096, seed=1) # threads=None: all cores
obs = env.observe() # float32 (n, obs_dim); construction started episode 0
r = env.step(np.full(env.n_envs, 18)) # int actions 0..89 -> StepResult (named tuple)
r.obs, r.reward, r.terminated, r.truncated, r.final_obs, r.reward_components
r.ep_return, r.ep_length, r.ep_success, r.ep_ticks_to_success # valid where r.done
env.info # task_id, task_json (canonical), obs_names, tick_skip, max_steps,
# reward_component_names / _weights, eval_seeds
env.set_auto_reset(False); env.set_recording(True)
env.reset_with_seeds(env.info.eval_seeds[:env.n_envs])
env.export_episode_scenario(0, "recordings/ep.json") # then: physlab run recordings/ep.json| Item | Choice |
|---|---|
| Native class | physlab_rl._native.BatchEnv(task_path, n_envs, seed, threads=None, meshes_dir="collision_meshes"); physlab_rl.BatchEnv wraps it with dtype and shape checks (for a wrong numpy dtype the native error is the unhelpful 'ndarray' object is not an instance of 'ndarray') |
| GIL | released (Python::detach) for construction, reset and step |
| Buffers | outputs are written into Rust buffers preallocated at construction, then copied into fresh numpy arrays (≈ 0.7 MB per step at 1024 envs). Measured ≈ 1.44 M agent steps/s through Python with constant actions at 1024 envs / 28 threads, close to the bare Rust batch. Fresh arrays avoid aliasing bugs from views that the next step overwrites. |
| dtypes | obs, final_obs, reward, components, ep_return float32; actions int64 (the wrapper accepts any integer array or a list); terminated, truncated, ep_success bool (views of uint8); ep_length uint32; ep_ticks_to_success int64 (−1 = none); seeds uint64 |
| Errors | bad actions, shapes, seeds, unknown scripted policy → ValueError (every bad entry listed); bad env index → IndexError; missing task file or write failure → OSError; invalid task → ValueError; meshes or recording problems → RuntimeError |
| Match tasks | one row per agent: env.n_rows = n_envs · n_agents, actions and every StepResult field have n_rows rows; env.agent_env, env.agent_team, env.task_kind, env.team_size, env.scripted_actions(policy); see Match mode |
Learner (physlab_rl.ppo, physlab_rl.train)#
CleanRL-style PPO for the 90-way categorical policy.
| Item | Default | Why |
|---|---|---|
| Networks | separate actor and critic MLPs, 2×256, ReLU, orthogonal init (√2 hidden, 0.01 policy head, 1 value head) | observations are ≤ 86 floats already scaled to O(1); ReLU as in rlgym-ppo; separate nets keep value-loss gradients out of the policy trunk (the trunk is shared only with the optional RP and SR heads, as in the paper); small enough that inference stays cheap at 4096 envs |
| Batch | 4096 envs × 32 steps = 131 072 steps per update, 8 minibatches × 4 epochs | 1024 × 64 with 4 minibatches gave only 16 gradient steps per 65 k samples (KL ≈ 1e-3, slow learning); 4096 envs amortise the per-step Python/GPU overhead |
| Optimiser | Adam, lr 3e-4, ε 1e-5, linear anneal to 0 (--no-anneal-lr), grad-norm clip 0.5 | CleanRL defaults |
| PPO | clip 0.2, value clipping off (--clip-vloss), entropy 0.01, vf 0.5, per-minibatch advantage normalisation, optional --target-kl | standard |
| GAE | λ = 0.95 | standard |
| γ | from a half-life (Lucy-SKG appendix Table 6): γ = exp(ln 0.5 / (120/tick_skip · half_life_s)); default half_life = clamp(0.375 · episode_seconds, 1.5 s, 4 s): 3 s (γ = 0.98472) for the 8 s ground tasks, 1.5 s (γ = 0.96967) for aerial-easy, 1.875 s (γ = 0.97566) for aerial; --gamma or --gamma-half-life-s override; printed and stored in the manifest | the horizon should match how long the task's credit assignment needs, not a generic 0.99 |
| Truncation | on truncated & ~terminated the stored reward gets + γ·V(final_obs); termination adds nothing; both end the GAE recursion | bootstrapping at time limits (and goals), following the env's terminated/truncated split. Caveat: the observation includes the remaining episode time, and for these tasks no reward is possible after the time limit or a goal, so by Pardo et al. (2018) treating those ends as terminal would be the stricter choice; V(final_obs) at remaining time 0 is an extrapolation the critic is never trained on (its effect on the reported runs was not measured) |
| Reward scaling | on (--no-reward-scaling): rewards ÷ running std of the discounted return, never shifted | as rlgym-ppo's standardize_returns; keeps value targets O(1) |
| Obs normalisation | off (--obs-norm) | the env already scales observations |
| Speed options | TF32, fused Adam, pinned staging and the batched truncation bootstrap on; bf16, CUDA graphs, torch.compile and overlapped updates opt-in | see Learner speed: the defaults change nothing but float rounding; the opt-in ones change numerics or (overlap) the data's policy lag and wait for a training A/B |
| Determinism | seeded Python, numpy, torch and CUDA RNGs and a seeded sampling generator; --torch-deterministic also forces deterministic CUDA kernels | the env is bit-deterministic; GPU kernels are the only remaining source of run-to-run noise |
Reward-prediction auxiliary task (Lucy-SKG §4.5, --aux-reward-prediction,
off by default): the last --aux-seq-len 20 observations pass through the
actor trunk, then LSTM(32) → linear → 3 logits predicting the sign class of
the immediate (raw, unscaled) reward: negative, |r| ≤ --aux-zero-band 0.007,
or positive; cross-entropy weighted by --aux-weight 1.0, computed on
--aux-batch-size 4096 sequences per minibatch. Sequences come from the
rollout buffer plus the last 19 observations of the previous rollout; every
entry from an earlier episode is zeroed (left zero-padding) using a per-env
episode counter that advances on terminated | truncated, so auto-resets
never leak across episodes (tested by
test_reward_prediction_sequences_are_zero_padded_before_the_episode_start).
Logged: ppo/aux_loss, ppo/aux_acc and the class balance ppo/aux_class_*.
The paper picks the zero band to balance the classes ("computed through
rollout data analysis", appendix §5: ±0.009 for the full game, ±0.005 in
the ablations). With the fixed 0.007 on the single-agent tasks the
near-zero class is only 4–14 % of samples (the −0.01 time penalty puts most
steps outside the band). --aux-zero-band auto (the default for match
tasks, see Defaults) does what the paper
describes: after the first rollout it picks, among 1001 quantiles of the
learner rows' |r|, the band whose three classes have the highest entropy
(ppo.calibrate_zero_band), and keeps it fixed for the run. The value is
logged as ppo/aux_zero_band, printed, and stored in the checkpoints'
config.aux_zero_band and in summary.json. On match-1v1-v1 it came out
at 0.0154, with classes 0.333 / 0.333 / 0.333 on the first rollout.
State-representation auxiliary task (Lucy-SKG §4.5, appendix §2 item 2,
--aux-state-representation, off by default): an autoencoder on the actor
trunk's output. Encoder FC 128 → 32 → 16, decoder mirrored (32 → 128), then
FC 512 and an output layer, with batch norm and ReLU between layers. It
reconstructs the observation without the action stack: the paper
reconstructs "the key/value objects only", i.e. everything but the previous
actions (appendix §5), and ppo.sr_columns drops the prev_action_*
features. Loss: smooth L1 (Huber, δ = 1) with weight --aux-sr-weight 1.0
(the paper's λ_SR = 1), on the first --aux-batch-size samples of each
minibatch. Like RP it trains the actor trunk only (appendix §5: "auxiliary
tasks were employed for the actor only"); the critic is untouched (tested).
Logged: ppo/aux_sr_loss. The paper's final agent, Lucy-SKG, uses both
tasks (λ_SR = λ_RP = 1); Lucy-Gamma is the same agent without them.
--aux-reward-prediction --aux-state-representation is that
configuration. On 1v1 matches RP, attached to the whole actor trunk as
here, made training fail (entropy collapse) and SR was neutral; see
Lucy-SKG ablations.
Commands#
just train tasks/ground-touch-v1.json --total-steps 10_000_000 --seed 1
just train tasks/aerial-touch-easy-v1.json --init-checkpoint runs/<ground-run>/best.pt --total-steps 300_000_000
just eval runs/<id>/best.pt "" --export 5 # all held-out seeds, argmax + sampled; export 5 episodes
cargo run --release --bin physlab -- run runs/<id>/eval_scenarios/<scenario>.json
cargo run --release --bin physlab -- view recordings/<scenario>.rocketsim.jsonl
just runs-table runs/ab-ground # Markdown table of finished runsUseful flags: --eval-every N (updates between held-out evals; default 10),
--eval-minutes M (also eval after M wall minutes since the last one; given
alone, it replaces --eval-every),
--eval-episodes N, --target-eval-success 0.95 (stop early),
--init-checkpoint (weights + obs normaliser, plus the return-scaler
statistics when the checkpoint's task id equals the new task's — a new
curriculum stage starts with a fresh scaler; architecture changes such as
adding the RP head load with strict=False and are listed in the manifest),
--init-optimizer (also Adam state, only when the architectures match),
--env-threads, --device, --run-name, --cpu-placement (on Windows
with a hybrid CPU: fast, the default, turns off power throttling and keeps
the Python threads on performance cores, about 28% more samples per second
than leaving it to Windows with os; p-only puts the whole process on
performance cores and is slower, since the env step loses the efficiency
cores). Create an empty
runs/<run_id>/STOP file to end a run cleanly after the current update
(final eval, checkpoint and summary are still written).
Run directory (runs/<run_id>/, gitignored)#
run_id = <YYYYmmdd-HHMMSS>-<task>-s<seed>[-<run-name>].
| File | Contents |
|---|---|
manifest.json | immutable (written before training, then made read-only; --resume only appends to its resumes list): run id, command line, git revision ("uncommitted" when git rev-parse HEAD fails) and dirty flag, SHA-256 over every crates/**/*.rs, Cargo.toml, Cargo.lock, pyproject.toml, python/physlab_rl/**/*.py and the vendored RocketSim sources (CRLF-normalised), RocketSim version (from Cargo.lock), task id, path, canonical-JSON SHA-256 and the JSON itself, every CLI hyperparameter, derived values (γ and its source, half-life, batch sizes, parameter count, component weights), seeds, parent checkpoint (path, SHA-256, missing/unexpected keys), Python/numpy/torch/CUDA/cuDNN versions, GPU name, capability and driver (nvidia-smi), CPU count, platform, UTC start time |
metrics.jsonl | one JSON object per line, x-axis global_step (agent steps summed over envs). kind: "train", every update: sps, sps_update, time/env_s, time/inference_s, time/update_s, time/other_s, lr, and the learner-speed breakdown time/cycle_s, time/h2d_s, time/act_launch_s, time/d2h_wait_s, time/bookkeeping_s, time/update_wait_s; over a rolling window of the last 4096 training episodes (--stats-window): train/success_rate, train/return_mean, train/length_mean, train/terminated_frac, train/ticks_to_success_mean, and per component ep_comp/<name> (unweighted per-episode sum) and ep_comp_weighted/<name>; step_comp/<name> (per-step mean), reward/step_mean, reward/return_scale; ppo/pg_loss, ppo/v_loss, ppo/entropy, ppo/approx_kl, ppo/clipfrac, ppo/explained_variance, ppo/adv_mean, ppo/adv_std, ppo/value_mean, ppo/return_mean, ppo/epochs, ppo/aux_*, ppo/approx_kl_first_mb (KL of the first minibatch before any step: the rollout-vs-update log-prob mismatch), ppo/minibatches, ppo/minibatch_size (with --overlap-update also ppo/update, the update the ppo/* values come from, and ppo/behaviour_kl, the KL between the stale behaviour policy and the update's start). kind: "eval": eval/success_rate, eval/ci95_lo, eval/ci95_hi, eval/mean_ticks_to_success, eval/mean_return, eval/mean_length, eval/wall_s. kind: "sysload" (every --sysload-every seconds): machine load, see Tracing, profiling and machine load |
checkpoints/step_<n>.pt | saved at every held-out eval: model, optimiser, obs normaliser and return scaler state, model config, all hyperparameters, task (id, path, JSON), RNG states (Python, numpy, torch CPU and CUDA), and the resume state |
checkpoints/resume.pt | the rolling resumable checkpoint (same contents), rewritten every --checkpoint-minutes and on a save/stop request |
best.pt, final.pt | copies of the best-eval and the last checkpoint |
summary.json | status (completed, stopped = paused and resumable, interrupted), stop reason, steps, wall time, mean SPS, γ, final held-out eval (success, Wilson CI, ticks-to-success, component sums), best eval, steps to 50/80/90 % held-out success, eval curve, how to resume |
control, control.ack | a pending save/stop request and the answer to the last one |
eval/<ckpt>.<task>.json, eval_scenarios/*.json | written by physlab_rl.evaluate |
The learning telemetry above is file-based on purpose: learning curves, checkpoints and run metadata belong in durable run artifacts, which a trace backend doesn't replace. Execution telemetry (throughput, phase timings, PPO health) is also exported as OpenTelemetry metrics, and on request as spans and NVTX ranges (Tracing, profiling and machine load).
Held-out evaluation uses all of the task's eval seeds (bit 63 set, never
drawn in training), one env per episode, auto-reset off and argmax actions;
the success rate is reported with a Wilson 95 % interval
(physlab_rl.stats). evaluate.py also runs a sampled (stochastic,
seeded) pass. Evaluating a checkpoint twice gives identical per-episode
results (tested).
Environment state is not checkpointed (RocketSim arenas can't be
serialised): --init-checkpoint carries over the policy, the obs
normaliser, the return scaler (same task only, or any task with
--keep-return-scaler, for a small reward change to the same game) and, with --init-optimizer,
Adam state, but it is a warm start of a new run: episodes, the step
counter, the LR schedule and the RNG streams restart. To continue the same
run, use --resume (next section).
Pausing and resuming a run#
A running training can be told to save or to stop, and a stopped (or killed) run continues in place:
just train-save runs/selfplay/<id> --wait # resumable checkpoint now, training goes on
just train-stop runs/selfplay/<id> --wait # save and exit cleanly (status "stopped")
just train-resume runs/selfplay/<id> # continue the run where it stopped
just train-resume runs/selfplay/<id> --total-steps 2_000_000_000 # ... and extend ittrain-save / train-stop (python -m physlab_rl.train_ctl RUN_DIR save|stop)
write the request to RUN_DIR/control; the training reads it before each
update, acts after that update, removes the file, answers in
RUN_DIR/control.ack and logs a kind: "control" row. --wait blocks
until the answer. Ctrl+C, SIGTERM and Ctrl+Break do the same as stop
(a second Ctrl+C aborts). A stop skips the final eval; the STOP file
still ends a run for good (final eval, final.pt).
--resume RUN_DIR loads the run's newest checkpoint with resume state
(checkpoints/resume.pt or an eval's checkpoints/step_<n>.pt) and reuses
the run's own arguments. Only --total-steps, --env-threads,
--pipeline-rollout / --no-pipeline-rollout, --quiet,
--checkpoint-minutes, --cpu-placement, --eval-every, --eval-minutes
and the tracing and load options may be given; any other flag is an error (warm-start
a new run with --init-checkpoint to change settings). Restored: step and
update counters, model, optimiser, obs normaliser, return scaler, RNG states
and sampling generators, the LR and kickstarting schedules (they follow the
step counter), the opponent pool, ratings, earlier evaluated checkpoints,
evaluation history and best score, adaptive setter scores and weights, the
rolling train/* window, and wall time. metrics.jsonl keeps its rows up
to the checkpoint (the old file is kept as metrics.jsonl.bak-<UTC>),
pool snapshots past it are deleted, later step_<n>.pt files are renamed
*.bak-<UTC>, and manifest.json gets an entry in its resumes list.
Not restored: environment state. Episodes in progress restart, from new
training seeds derived from the seed and the step. A process that is killed
hard (Task Manager, Stop-Process, power loss) cannot save anything: it
loses the training since its last resumable checkpoint, at most
--checkpoint-minutes (default 10; 0 turns the rolling checkpoint off).
Runs from before --resume existed have no resume state and can only be
warm-started.
Selection bias. best.pt and --target-eval-success both select on the
same held-out seeds they are scored on, so a best-checkpoint score (and the
final score of a run stopped by the target) is optimistically biased; quote
final.pt of a fixed-length run as the unbiased number.
Early train/* stats are biased. Every env starts its first episode at
the same time, so until the first time-limit wave (max_steps agent steps)
only the episodes that ended early — mostly quick successes — are in the
window: train/success_rate reads ≈ 1.0 in the first few updates while
held-out success is near 0. Trust eval/* there.
Results (2026-10-15, i7-14700K 28 threads, RTX 4070 shared with a running Rocket League)#
All numbers are held-out: the task's 256 eval seeds, argmax actions, Wilson
95 % CI. Default learner settings throughout (4096 envs × 32 steps,
potential shaping, action stack 5, no RP head), seed 1, each stage
initialised from the previous stage's best.pt. Runs live in runs/t1/.
| Stage | Task | Steps | Wall | SPS | Steps to 50 / 80 / 90 / 95 % | Final held-out success [95 % CI] | Mean time to touch |
|---|---|---|---|---|---|---|---|
| 0 | ground-touch-v1 (from scratch) | 19.9 M | 1.2 min | 278 k | 2.6 / 2.6 / 3.3 / 3.3 M | 256/256 = 1.000 [0.985, 1.000] | 1.55 s |
| 1 | aerial-touch-easy-v1 | 87.7 M (process killed once flat, before the STOP file existed: no summary.json; success from evaluate on best.pt) | 4.7 min | 309 k | 15.7 / 18.4 / 18.4 / 21.0 M | 256/256 = 1.000 [0.985, 1.000] | 1.14 s |
| 2 | aerial-touch-v1 | 499.9 M | 27.1 min | 308 k | 5.2 / 18.4 / 138.9 / 191.4 M | 246/256 = 0.961 [0.930, 0.979] (best checkpoint 247/256 = 0.965) | 1.50 s |
Learning curves (held-out success vs. steps):
Stage 0: 0.50 at 2.0 M, 1.00 from 4.6 M on.
Stage 1: 0 at 2.6–13.1 M (zero-shot from the ground policy: 0/256), then 0.93 at 18.4 M and 1.00 from 39 M on. The ground policy's entropy had dropped to ≈ 2.1 nats; touches per episode rose 0 → 0.9 over 12 M steps before the first airborne successes.
Stage 2: zero-shot from stage 1: 80/256 = 0.31. 0.47 at 2.6 M, 0.81 at 18 M, 0.88 at 79 M, 0.92 at 149 M, 0.96 at 249 M, then flat to 500 M. Remaining failures concentrate on balls behind the car (|bearing| > 135°: 70 % success, vs 100 % within ±90°) and low, slowly rising balls (ball z < 700 uu: 81 %; vertical speed < 300 uu/s: 84 %), i.e. the cases with the least time to turn around before the ball lands; some may be infeasible.
Throughput: env ≈ 0.09 s, policy inference + bookkeeping ≈ 0.09 s, PPO update ≈ 0.24 s per 131 k-step update; the learner, not the simulator, is the bottleneck.
Exported held-out episodes (evaluate --export) of the stage-1 and stage-2
policies replay through cargo run --release --bin physlab -- run: the trace
ends on the env's success tick and its car_hit_ball events match the env
exactly (e.g. ticks 183, 162, 192 for three aerial-touch-v1 seeds; car 190–710
uu up, on_ground: false).
Behaviour worth knowing. On some aerial-touch-v1 seeds the policy first
pops the ball up with a grounded touch (ball ≈ 140 uu) and then takes an
airborne touch just above the 250 uu success threshold (e.g. seed
2^63 + 3000000: grounded contact at tick 242, success at 289 uu at tick
299). It satisfies the task as written; raise min_ball_z_uu or fail on a
grounded touch if that is not what "aerial interception" should mean.
Lucy-SKG A/B experiments#
Ground touch (runs/ab-ground/): same seeds 1–3, 8 M steps each, eval
every 262 k steps, default learner. "Steps to 80 %" is the first eval at or
above 0.8.
| Variant | Steps to 80 % (mean ± sd, 3 seeds) | Final success (mean) | Mean ticks to success | SPS |
|---|---|---|---|---|
ground-touch-v1: potential shaping (KRC), stack 5 | 2.97 M ± 0.61 M | 0.990 | 196 | 219 k |
ground-touch-dense-v1: dense per-step shaping | 3.41 M ± 0.69 M | 1.000 | 195 | 210 k |
ground-touch-nostack-v1: action stack 1 | 2.80 M ± 0.40 M | 0.997 | 197 | 218 k |
ground-touch-v1 + --aux-reward-prediction | 3.32 M ± 0.55 M | 1.000 | 205 | 93 k |
Every variant reached 80 % in 2.4–4.2 M steps and ~100 % by 8 M steps; the differences are smaller than the seed-to-seed spread (and than the 262 k-step eval granularity), so ground touch cannot distinguish them. The one clear effect is cost: the RP head runs the trunk over 20× more inputs and an LSTM, cutting throughput 2.3×, so per wall-clock second it is slower. The task is too easy to reveal the paper's benefits, which were measured over 10⁸–10⁹-step self-play games.
RP auxiliary task on aerial-touch-easy (runs/ab-aerial-easy/): a
harder test, since this stage needs ~10 M steps of exploration before the
first successes. Both arms start from the same stage-0 ground-touch
checkpoint, seeds 1–2, 50 M steps, eval every 655 k steps.
| Variant | Steps to 50 % | Steps to 80 % | Steps to 90 % | Final success | Mean ticks to success | SPS | Wall |
|---|---|---|---|---|---|---|---|
| baseline, seed 1 | 10.5 M | 12.5 M | 13.8 M | 1.000 | 117 | 302 k | 2.8 min |
| baseline, seed 2 | 11.1 M | 13.8 M | 14.4 M | 1.000 | 119 | 298 k | 2.8 min |
--aux-reward-prediction, seed 1 | 9.8 M | 13.8 M | 15.1 M | 1.000 | 126 | 108 k | 7.7 min |
--aux-reward-prediction, seed 2 | 11.8 M | 15.7 M | 18.4 M | 1.000 | 153 | 99 k | 8.4 min |
With the RP head, 80 % came at 14.8 M ± 1.4 M steps vs 13.1 M ± 0.9 M without, and the final policies were slower to touch (140 vs 118 ticks). With two seeds per arm this is weak evidence, if anything against the head on this task, and it costs 2.8× wall time. No sample-efficiency gain like the paper's (§4.5) showed up at this scale.
Decision for the curriculum: keep the paper-faithful environment defaults (potential shaping, action stack 5) — they were never worse — and leave the RP head off by default (no measurable sample-efficiency gain on either task, 2.3–2.8× wall time). These are hypotheses that need harder tasks and more seeds before anyone concludes they help or not.
Known limitations#
One seed per curriculum stage; the A/B uses 2–3 seeds. Differences of a few hundred thousand steps are noise.
GPU kernels are not forced deterministic by default, so re-running the same seed can diverge slightly (
--torch-deterministicfixes kernels at a speed cost); evaluation of a given checkpoint is exactly reproducible.Env state isn't checkpointed:
--resumeand--init-checkpointrestart episodes.The policy is a feed-forward MLP over one observation plus the action stack; no recurrence (the RP LSTM is only an auxiliary head).
Actions apply on the next tick (no RLBot one-tick delay, see above), so a deployed bot sees one extra tick of latency.
The curriculum stages are separate runs rather than a mixed-difficulty schedule. (Match tasks train with the self-play learner below.)
metrics.jsonlis the only sink for learning curves (no TensorBoard); OpenTelemetry carries a few dozen execution metrics.time/inference_sincludes per-step Python bookkeeping (buffer writes, episode statistics), not only the forward pass.
Self-play learner#
physlab_rl.train trains match tasks (kind: "match") with one shared
policy for every car (self-play), against a pool of frozen past versions,
and rates every evaluated checkpoint on an Elo scale. Code:
python/physlab_rl/train.py (loop), selfplay.py (opponent pool, batched
frozen-policy inference), ratings.py (match results, ratings),
evaluate.py (match evaluation CLI), league.py (post-hoc round robin
over a run's checkpoints), ppo.py (streams, masked update).
Tests: python/tests/test_selfplay.py.
Commands#
just train-match # 1v1, 600 M agent steps (~25–30 min), runs/selfplay/<run_id>/
just train-match tasks/match-2v2-v1.json --total-steps 1_000_000_000
just train-match tasks/match-1v1-v1.json --aux-state-representation # + the SR aux task (RP: see the ablations first)
just train-match tasks/match-1v1-v1.json --net large
just eval-match runs/selfplay/<id>/final.pt # vs ball_chaser + the run's 3 previous checkpoints (standalone: prev:K = the last K)
just eval-match runs/selfplay/<id>/final.pt --opponents ball_chaser idle prev:5 other-run/final.pt
just eval-bots runs/selfplay/<id>/final.pt # vs ball_chaser, Necto and Nexto
just eval-match runs/selfplay/<id>/final.pt --export 2 # write the first 2 games as scenarios
just eval-match runs/selfplay/<id>/final.pt --ratings runs/selfplay/<id>/ratings.json # add the games, refit
just league-match runs/selfplay/<id> --every 10 # round robin of every 10th checkpoint (+ the last) -> <id>/league/ratings.json--export K writes the first K games to <run>/eval_scenarios/ as scenarios.
just view --live <scenario> re-simulates one and streams it to RLViser; the
Command Center lists them with a "Replay in
RLViser" button.
Drills: setter weights, adaptive setters, kickstarting#
Flags for steering what a match run practises (python/physlab_rl/drills.py,
tests in python/tests/test_drills.py). None of them changes the reward.
--setter-weights kickoff=0.3,random=0.4,...replaces the task'smatch.state_settersfor training episodes. Eval seeds keepeval_state_setters.--adaptive-settersre-weights the setters every--adaptive-setters-everyupdates (default 10), after prioritized level replay: each setter's score is the mean positive advantage of the learner's samples from its episodes (smoothed,--adaptive-setters-ema0.1); setters are weighted by rank ((1/rank)^(1/T),--adaptive-setters-temp0.3), mixed with the base weights (--adaptive-setters-mix0.5) and floored (--adaptive-setters-floor0.05), so none is ever dropped.--kickstart-teacher <specialist>.ptadds a cross entropy toward a single-agent specialist's action distribution (Schmitt et al. 2018) on episodes from--kickstart-setters(defaultkickoff,kickoff_like) until the first touch. The env builds the teacher's own observation of each car (BatchEnv.teacher_obs): the car in its own frame, its action history, and the teacher task's clock from the episode start. The teacher must share the action stack andtick_skip. After--kickstart-start-step(0) the coefficient rises linearly to--kickstart-coef(1) over--kickstart-warmup-steps(10 M), then fades linearly to 0 over--kickstart-decay-steps(400 M). Without the warm-up, a trained student's first updates moved the policy so far that the PPO ratios blew up (approx KL about 10¹⁵ for two updates).--kickstart-min-ball-dist(0) stops the teacher while the car is within that many uu of the ball, so a teacher trained to reach the ball fast guides the approach and the student learns the contact itself.Logged per update:
setter/<name>/sample_frac(share of learner samples; kickoff drills cut at 5 s make this much lower than the episode weight),setter/<name>/adv_pos,setter/<name>/weight,kickstart/coef, andppo/kick_loss,ppo/kick_kl(KL from the teacher on its samples),ppo/kick_agree(top actions agree),ppo/kick_frac(share of samples the teacher applies to).
Agent streams#
Every agent row (
n_envs · n_agents, env-major, Blue first) is its own sample stream: the rollout buffer's columns are rows, so GAE, the truncation bootstrap (add_truncation_bootstrap:+ γ·V(final_obs)from the agent's own final observation, learner rows only) and the RP auxiliary sequences (--aux-reward-prediction, per-row episode counter) are all per agent.RolloutBuffer.validmarks learner transitions. Rows driven by a frozen opponent stay in the(T, rows)grid but are excluded from the update (minibatches are drawn from valid entries only, and so are the diagnostics). A row's controller changes only when its env's episode ends, so GAE over the full grid never mixes the two: the episode end cuts the recursion (tested with NaN- and 1e6-poisoned frozen entries).Blue is always the learner. Per env episode Orange is: a frozen pool snapshot with probability
--opponent-past-prob 0.2(Necto'spast_prob = .2,.external/Necto/training/worker.py:64; falls back to self-play while the pool is empty), the scriptedball_chaserwith--opponent-scripted-prob(default 0), otherwise the learner itself (both cars are then learning streams).--opponent-bot-frac F(default 0) sets aside the firstFof the envs, where Orange is always an RLGym bot (--opponent-bot, defaultnecto). Those envs are never resampled. The bot runs on the CPU (about 14 ms per step at 512 envs, so 25 % of the envs roughly halves throughput), and its per-car state resets when its env's episode ends. Training stats for those episodes are logged asvs_bot/*. Held-out evaluation uses the same bot, so keep another anchor (Nexto, the league) to tell real progress from exploiting one opponent.Rewards are the env's (Lucy-SKG team spirit included). Frozen and scripted rows feed nothing: the running return-std scaler (
--reward-scaling) and the observation normaliser (--obs-norm) update their statistics from learner rows only.python/tests/test_selfplay.py::test_the_training_loop_keeps_every_row_aligned_and_opponents_outinstruments a tiny run (3 s games, 2 s no-touch timeout, pool and scripted opponents) and checks the rollout buffer against what the env saw at every update: observations, actions, log-probs and values per row, raw rewards, done flags,γ·V(final_obs)exactly on truncated learner rows, the valid mask (Blue + learner Orange, constant within an episode), the ball chaser's actions on scripted rows, RP sequences (the row's own episode only, across rollout boundaries), the loggedstep_comp/*andep_comp/{blue,orange}/*, and that the bank runs the snapshot weights rather than the live model.
Opponent pool#
A snapshot (actor + critic + obs normaliser, frozen) is taken every
--pool-snapshot-every 10_000_000agent steps, written to<run>/pool/step_<n>.pt(a light checkpoint without optimiser state, loadable byevaluate) and indexed in<run>/pool.json(name, step, path, sampling probability).At most
--pool-size 20snapshots; the oldest is evicted (its file is deleted, but the policy stays loaded until no env plays it any more).Sampling is latest-weighted: weight
--pool-recency-decay 0.9to the power of the snapshot's age (0 = newest). How Necto's framework (rocket_learn, not in our references) chooses past versions is unverified; recency is our choice.Inference is grouped by policy:
PolicyBankstacks the actor weights of every loaded snapshot of one architecture and runs them all with onebaddbmmper layer and onemultinomial, whatever the pool size; all row indices go to the GPU in one copy between steps (a pageable host-to-device copy waits for queued GPU work). Measured with 6 snapshots in play: one forward pass per policy, each with its own index upload and host copy, cost 0.50 s of inference per 131 k-step update; the bank costs 0.16 s (no pool: 0.11 s).
Exploiters, PFSP, budget checkpoints and plasticity#
Options added for the superhuman plan. Each is off by default except the plasticity metrics; with them off, training is bit-identical to before.
--opponent-fixed CKPT: exploiter training (plan A3). Every Orange car is this frozen checkpoint: no self-play games, no pool snapshots. It can't be combined with scripted or bot opponents. In-run evaluations add it aseval/fixed/*, and the manifest records its path and sha256; a resume refuses a changed file.--pool-sampling pfspwith--pfsp-weighting hard|var: each pool snapshot is sampled with weight (1−p)² or p(1−p), after AlphaStar's PFSP. p is the learner's smoothed training score against that snapshot: win 1, draw ½, a prior of 0.5 worth 2 games, about the last 200 games. Every weight is at least 0.01. Logged aspool/pfsp_*; per-snapshot results go inpool.json.--budget-checkpoints [--budget-first-step 250_000_000]: full checkpointscheckpoints/budget_<B>.ptat 250 M, 500 M, 1 B, … agent steps and at the end, never removed.Compute accounting:
compute/flop,compute/train_s(rollout and update time only) andcompute/learner_stepsinmetrics.jsonl; totals insummary.json. The FLOP formula, about 20 FLOP per weight per learner step at 3 epochs, is inmanifest.derived.compute.--plasticity-every 200(0 = off):plasticity/<actor|critic>/l<k>/{dead_frac,srank}, the share of ReLU units never active on 4,096 recent observations and the effective rank of each layer's features (Kumar et al. 2021, δ = 0.01). It costs about 0.5% of training time at M.
Warm starts#
--init-checkpoint <run>/final.pt on a match task also carries the
source run's self-play state over (--no-init-selfplay-state starts
fresh): its pool snapshots (from <run>/pool.json, files in
<run>/pool/) and then the starting policy itself seed the opponent pool,
so past-version opponents are there from the first episode rather than
after the first snapshot; the starting policy is the first prev
evaluation opponent; and the source's ratings.json records are merged
into the new table. Source players are renamed <source run id>/step_<n>
(the new run's step counter restarts at 0, so plain step_<n> names would
collide); the scripted bots keep their names, and the idle reference is
not replayed when its games came with the merge. The manifest records what
was carried over (derived.init.selfplay_state). The new run's
pool.json lists the seeded snapshots with their paths in the source run.
Defaults and their sources#
Flags left unset take the task kind's defaults (MATCH_DEFAULTS /
SINGLE_AGENT_DEFAULTS in train.py; recorded in the manifest's
derived.defaults_source). Explicit flags always win.
| Item | Match default | Single-agent | Source |
|---|---|---|---|
| Rows × steps per update | 4096 agent rows (4096 // n_agents envs: 2048 for 1v1, 1024 for 2v2) × 32 = 131 072 agent steps (learner share ≈ 80–100 %) | 4096 envs × 32 | between the rlgym-ppo guide's 100 k batch and Lucy-SKG's 320 k rollout (appendix §1.1); same update size as the single-agent learner |
| Minibatches × epochs | 8 (≈ 15 k samples) × 3 | 8 × 4 | Lucy-SKG: minibatch 4000 (appendix §1.1), 10 epochs in the ablations (appendix Table 6); rlgym-ppo guide: 50 k × 2. Project choice, untuned |
| Learning rate | 2e-4, constant (--anneal-lr to anneal) | 3e-4, annealed | Lucy-SKG 1e-4 (appendix §1.1; 5e-5 in Table 6) and rlgym-ppo 1e-4, both with larger batches; 2e-4 is an untuned project choice. Self-play has no natural end, so no annealing by default |
| Entropy coefficient | 0.01 | 0.01 | Lucy-SKG ablations (Table 6), Necto, rlgym-ppo (Lucy-SKG's full run used 0) |
| Value coefficient | 0.5 | 0.5 | Lucy-SKG appendix §1.1 (1.0 in Table 6) |
| Clip | 0.2 | 0.2 | Lucy-SKG appendix §1.1 |
| GAE λ | 0.95 | 0.95 | not given by Lucy-SKG; rlgym-ppo's default (unverified) |
| γ | half-life 5 s for 1v1 (γ = 0.99080), 10 s for 2v2/3v3 (γ = 0.99539) | clamp(0.375·episode_s, 1.5, 4) s | Lucy-SKG §5.1 (1v1 ablations: 5 s) and appendix §1.1 (2v2: 10 s, "greedy enough to make goals as early as possible but also farsighted") |
| Network | --net medium: separate actor and critic MLPs 512-512-256, ReLU (0.93 M parameters for 1v1) | small: 256-256 | widths of Lucy-SKG's MLP baseline (appendix §2: shared 512-unit layers, 256-unit branches); --net large = rlgym-ppo's [2048, 2048, 1024, 1024]; --hidden for anything else. Lucy-SKG's own network is Necto's perceiver (§4.2), not adopted (see coverage) |
| Reward scaling | on (÷ running return std) | on | rlgym-ppo standardize_returns |
| Auxiliary tasks | off (--aux-reward-prediction, --aux-state-representation); RP zero band auto (calibrated on the first rollout) | off; RP zero band 0.007 | Lucy-SKG §4.5, appendix §2 and §5 (the paper's final agent uses both, λ = 1). Off by default: on 1v1 matches RP collapsed the policy (entropy 3.0 → 1.3 nats, head to head 0.002) and SR was neutral at 1.8× the update time (ablations) |
| TF32 matmuls | on (--no-tf32) | on | ≈ 20 % faster PPO update on the RTX 4070 (0.49 → 0.41 s per update, medium net; Learner performance) |
| Learner speed path | on CUDA: --amp bf16 --cuda-graphs --cuda-graph-act --overlap-update (decoupled correction); off without CUDA; each can be turned off (--amp off, --no-cuda-graphs, --no-cuda-graph-act, --no-overlap-update) | off (opt-in) | 2.2× agent steps/s while training and 2.3–3.0× less wall time to 0.8 vs ball_chaser in a 2-seed, 20-minute A/B (Learner performance); single-agent tasks had no training A/B |
| Opponents | past 0.2, scripted 0, pool 20, a snapshot every 10 M steps, decay 0.9 | — | Necto past_prob; the rest is a project choice |
| Evaluation | every 160 updates (21 M steps; 40 before the fast learner path became the default: an evaluation costs ≈ 10 s, about 40 fast updates), 128 kickoff seeds per opponent, sampled actions, vs ball_chaser + 5 earlier evaluated checkpoints 1, 2, 4, 8 and 16 evaluations back (--eval-prev 5 --eval-prev-spacing geometric; recent = the last K, the behaviour before 2026-10-15) | every 10 updates, all seeds, argmax | Lucy-SKG §5.3 evaluates with independent single-goal matches; the geometric spacing is ours (see "Main run" below for why) |
The paper's own values (appendix §5: 320 k-step rollouts, minibatch 4000,
lr 1e-4, entropy 0, value coefficient 0.5) are one flag set away:
--n-steps 80 --num-minibatches 80 --lr 1e-4 --ent-coef 0 gives 4096 rows ×
80 = 327 680 steps per update in 80 minibatches of ≈ 3700–4100 learner samples (untested here). What
was not adopted from the paper, and why, is in
Lucy-SKG coverage. An earlier bfloat16 test (autocast
in the update only, bf16 heads, fp32 rollouts) halved the update time but
the critic's explained variance read ≈ 0.4 instead of ≈ 0.75 after 2.5 M
steps (19 updates); --amp bf16 now runs the rollout in bf16 too and keeps
the heads in fp32, and is part of the default fast path for match tasks
since the wall-clock A/B in
Learner performance.
Match results, evaluation and ratings#
One evaluation match = one episode from a held-out kickoff seed (
eval_state_setters: {kickoff: 1}): a single-goal game, like the paper's "300 independent single-goal (i.e. first scorer wins)" matches (Lucy-SKG §5.3). From the evaluated (Blue) side, win = the episode terminated on Blue's goal, loss = on Orange's (own goals count for the team the ball went in against), draw = truncated (5 min or the 45 s no-touch timeout).score = (wins + draws/2) / episodes; goals for and against per episode equal the win and loss rates. Reported with Wilson 95 % intervals (win_ci95;score_ci95applies Wilson to the fractional count, slightly conservative), plus mean length, touches (contact onsets) per car-minute for both sides, shots and demos per episode, end reasons and Blue's per-component reward sums.The evaluated policy always plays Blue. Kickoffs are mirror-symmetric and each side sees itself attacking +Y, so the sides are equivalent up to the float drift of mirrored physics.
Actions are sampled (seeded, so an evaluation is reproducible). With argmax actions on both sides, a deterministic env plays the same game for every seed with the same kickoff position (5 in 1v1), so 128 "episodes" would be about 5 distinct games and the confidence interval meaningless.
--eval-deterministic(train) and--modes deterministic(evaluate) exist for inspection.All opponents run in one batched env (
n_opponents × n_seedsenvs; enviplays opponenti // n_seeds); frozen policies go through thePolicyBank.Policies from tasks with another observation layout (e.g. the
match-1v1-nostack-v1ablation, which has no action stack) can play:evaluatereads the evaluation task's observation by feature name (evaluate.adapt_to_layout: the first actor and critic layers get zero weights for features the policy never saw). Every feature the policy was trained on must exist in the task, so a stacked policy can play in the stacked task against an unstacked one, but not the other way round. Checked: the unstacked 1v1 policy evaluated inmatch-1v1-v1plays the identical 256 games (outcomes and lengths) as in its own task.Ratings (
ratings.json, andkind: "rating"rows inmetrics.jsonl): Bradley–Terry maximum likelihood on the Elo scale (P(a beats b) = 1/(1 + 10^((R_b − R_a)/400)), a draw is half a win, one virtual draw per played pair so perfect records stay finite), refitted over all recorded games at every evaluation (sequential K-factor updates would depend on the evaluation order). The scriptedball_chaseris the anchor at 1000. At the first evaluation the scriptedidlebot also plays the ball chaser once (--eval-reference) as a reference point.Which earlier checkpoints an evaluation plays decides what the ratings can see (
prev_eval_indicesinselfplay.py). With--eval-prev-spacing recentevery game links checkpoints a few million steps apart; their scores sit near 0.5 even while the policy improves, and a slow drift in the ball-chaser score then dominates the fit. In the 90-minute main run below (which usedrecent, K = 3) the in-run ratings peaked at 115 M steps and drifted down, although the 524 M-step checkpoint beat the 115 M one 0.83 and the 419 M one 0.64. The default is thereforegeometric(1, 2, 4, 8, 16 evaluations back), so long-range games enter the fit. Weights of checkpoints the next evaluation does not need are released and reloaded fromcheckpoints/when picked again.The ball chaser is a weak anchor. From kickoffs it often scores own goals: an idle car scores 0.42 against it (54 W / 74 L over 128 episodes), and a random policy about the same. Beating it more than half of the time is a low bar; ratings against past checkpoints and the touch rate are the more informative curves early on.
Necto and Nexto are the strong anchors.
--eval-bots(defaultnecto nexto) adds them to every match evaluation; they play Orange with their deployed argmax actions (Necto and Nexto). At the first evaluation each bot also plays the ball chaser and the other bot once, so the fit can separate them; a weak policy loses every game to both and could not. With the local checkout missing they are skipped with a warning. Standalone:just eval-bots <checkpoint>, ornecto,nextoandnexto:<beta>in--opponents. On a warm start their ratings records keep their names, like the scripted bots.
Logging (match tasks)#
Per update (kind: "train"), in addition to the single-agent keys:
| Key | Meaning |
|---|---|
time/env_s, time/inference_s, time/opponent_launch_s, time/update_s | env stepping; all policy inference including the single host copy and per-step bookkeeping; host time spent launching frozen-opponent passes and scripted actions (their GPU time is inside inference_s); PPO update |
learner_steps, selfplay/learner_frac, selfplay/opponent_rows_frac, selfplay/pool_size | learner transitions so far; share of this update's samples that were trained on; share driven by frozen or scripted opponents; pool size |
match/episode_length_s, match/goal_frac | over the episode window: mean episode length; share of episodes ending in a goal (the rest are timeouts) |
match/{touch_steps,shots,demos,goals}_per_car_minute and _per_car_episode | over learner rows (Blue, plus Orange in self-play envs). touch_steps counts steps with any ball contact (the touch component), not contact onsets |
selfplay/blue_{win,draw,loss}_rate, vs_pool/…, vs_scripted/… | Blue's outcomes by opponent kind (self-play is ≈ symmetric; vs_pool shows whether the learner beats its past) |
ep_comp/blue/<c>, ep_comp_weighted/blue/<c>, ep_comp/orange/<c>, ep_comp_weighted/orange/<c> | per-episode unweighted and weighted sums of every reward component (all Lucy-SKG terms) for Blue (the paper's logging side, appendix §1.1) and for Orange in self-play envs; ep_comp/<c> = all learner rows |
Per evaluation (kind: "eval"): eval/ball_chaser/<k>, eval/necto/<k>
and eval/nexto/<k> (--eval-bots; nexto:0.5 is logged as
eval/nexto_0_5/<k>), and eval/prev_<i>/<k> (prev_1 = the most recent earlier checkpoint, prev_i
the i-th nearest one picked by --eval-prev-spacing; its name is in
eval/prev_<i>/opponent) for
score, win_rate, draw_rate, loss_rate, their CIs, mean_length_s,
touches_per_car_minute, opp_touches_per_car_minute,
shots_per_episode, demos_per_episode and opponent;
eval/prev_mean_score; eval/success_rate (= the score vs ball_chaser,
the generic key behind best.pt and --target-eval-success); at the first
evaluation eval/reference/<a>_vs_<b>_score for the reference games. Each
is followed by a kind: "rating" row with every player's rating
(rating/current, rating/ball_chaser, rating/necto, rating/nexto).
Run directory additions: pool/, pool.json, ratings.json,
eval/<ckpt>.<task>.match.json (from evaluate), eval_scenarios/.
summary.json holds the final evaluation per opponent, the
ratings, the best score vs ball_chaser and the eval curve.
Watching runs live#
The local Command Center shows every run live: what it trains, headline numbers, charts of any logged metric (overlaying up to two other runs), checkpoints, ratings, standalone evaluations and exported games.
Smoke run (2026-10-15, i7-14700K 28 threads, RTX 4070 shared with a running Rocket League)#
runs/selfplay/smoke-1v1-s1/: tasks/match-1v1-v1.json (full Lucy-SKG
reward), every learner default, seed 1, --total-steps 115_000_000:
114.95 M agent steps in 12.2 min (156 k agent steps/s including
evaluations). One seed and a short run: this shows the plumbing works and
the policy learns, not a tuned result.
Throughput per 131 k-step update (mean of updates 101–877): env 0.102 s
(15 %), policy inference + bookkeeping 0.165 s (25 %; 0.016 s of it is host
time launching the frozen opponents), PPO update 0.395 s (60 %) → 198 k
agent steps/s while training; each evaluation (128 episodes against each
of ball_chaser and the 3 previous checkpoints, one batched env) took
≈ 7 s, ≈ 21 % of the wall time at --eval-every 40. 92.6 % of the samples were learner transitions.
Held-out evaluation during training (128 kickoff seeds, sampled actions;
rating = the final refit in ratings.json, ball chaser = 1000, idle =
946 from 54 W / 74 L):
| Agent steps | vs ball_chaser W/D/L | Score [95 % CI] | Touches per car-minute | Mean length | Rating |
|---|---|---|---|---|---|
| 5.2 M | 50/0/78 | 0.391 [0.310, 0.477] | 0.1 | 33.6 s | 777 |
| 21.0 M | 55/3/70 | 0.441 [0.358, 0.528] | 0.9 | 57.6 s | 786 |
| 31.5 M | 72/4/52 | 0.578 [0.492, 0.660] | 5.5 | 64.8 s | 1073 |
| 41.9 M | 90/0/38 | 0.703 [0.619, 0.775] | 13.5 | 59.9 s | 1280 |
| 57.7 M | 111/0/17 | 0.867 [0.798, 0.915] | 20.2 | 44.0 s | 1444 |
| 78.6 M | 122/0/6 | 0.953 [0.902, 0.978] | 33.9 | 41.0 s | 1587 |
| 115.0 M | 124/0/4 | 0.969 [0.922, 0.988] | 39.8 | 30.1 s | 1693 |
Ratings rise monotonically from 21 M steps on. Against the three previous evaluated checkpoints (5.2 M steps apart) the score was 0.93–1.00 at 26 M and 31 M steps, then shrank: 0.52–0.87 against the most recent one from 37 M to 73 M, 0.48–0.62 from 78 M on; 2 of the 60 comparisons were below 0.5. Training curves (episode window): touch steps per car-minute 0.2 (5 M) → 1.2 (21 M) → 8.7 (31 M) → 29 (42 M) → 56 (115 M); shots per car-minute 0 → 3.4; episodes ending in a goal 18 % → 100 %; entropy 4.50 → 2.94 nats; Blue's win rate against pool snapshots 0.93 at 42 M, 0.71 at 115 M. Blue's weighted per-episode reward at the end: goal +5.4, concede −1.4, shot +3.0, touch +1.6, touch ball-to-goal acceleration +0.18, potentials −0.7 in total.
Standalone evaluation of final.pt on all 256 held-out seeds
(just eval-match runs/selfplay/smoke-1v1-s1/final.pt --opponents ball_chaser idle prev:3 --export 2):
| Opponent | W/D/L | Score [95 % CI] | Our / their touches per car-minute |
|---|---|---|---|
ball_chaser | 249/0/7 | 0.973 [0.945, 0.987] | 40.2 / 11.5 |
idle | 255/0/1 | 0.996 [0.978, 0.999] | 51.9 / 0.1 |
step_99614720 | 150/1/105 | 0.588 [0.527, 0.646] | 47.7 / 42.9 |
step_104857600 | 137/1/118 | 0.537 [0.476, 0.597] | 45.9 / 37.7 |
step_110100480 | 139/3/114 | 0.549 [0.488, 0.609] | 49.4 / 47.2 |
The two exported episodes (vs ball_chaser, seeds 2^63 + 3000000 and
+ 3000001) replay through physlab run: the 2-car traces end on the
env's goal ticks (2638 and 1083) with the ball in Orange's net. The
policy's play has not been watched in RLViser.
After the learner review (learner-only return/observation statistics, no
reward aliasing, warm-start state), runs/selfplay/review-smoke-1v1-s2/
(seed 2, every default, --total-steps 50_000_000): 49.9 M agent steps in
5.2 min (159 k agent steps/s including evaluations). Score vs ball_chaser
0.41 at 5.2 M steps (touches per car-minute 0.2), 0.61 at 41.9 M (8.4), and
0.72 [0.64, 0.79] at the end (18.5, rating 1468); against the three
previous checkpoints 0.98 / 0.85 / 0.66 at the end. Touches took off about
5 M steps later than in the seed-1 run above; with one run per seed, that
is not evidence of a regression. A 5.2 M-step warm start from its
final.pt (review-warmstart-1v1-s2/, seed 3) began with the 5 carried-over
snapshots in the pool (learner share 0.905 from the first update) and
scored 0.875 vs ball_chaser and 0.77 vs its starting checkpoint.
Main run (2026-10-15, i7-14700K 28 threads, RTX 4070 12 GB shared with a running Rocket League)#
runs/selfplay/main-1v1-s11/: tasks/match-1v1-v1.json (the full
Lucy-SKG reward table from appendix Table 1, with potential shaping per
§3.2), every learner default of the time (medium net, lr 2e-4 constant,
3 epochs × 8 minibatches, half-life 5 s per Lucy-SKG §5.1, past-version
probability 0.2, no RP head), seed 11, --eval-every 80 (every 10.5 M
steps). It was stopped with the STOP file at the 90-minute budget. The
in-run evaluation used the default of the time, --eval-prev 3 with
recent spacing (see "Ratings" below).
python -m physlab_rl.train --task tasks/match-1v1-v1.json --total-steps 1_500_000_000 \
--eval-every 80 --seed 11 --run-dir runs/selfplay/main-1v1-s11 # STOP file at 90 min
python -m physlab_rl.league runs/selfplay/main-1v1-s11 --every 10 --episodes 128
python -m physlab_rl.evaluate runs/selfplay/main-1v1-s11/final.pt --opponents ball_chaser idle \
runs/selfplay/main-1v1-s11/checkpoints/step_{104857600,524288000,838860800,943718400}.pt \
--export 11.024 B agent steps in 90.0 min, 189.6 k agent steps/s including evaluations. The 98 evaluations took 4.3 s each, 7.7 % of the wall time. Per 131 k-step update (mean of updates 101–7809): env 0.095 s, inference and bookkeeping 0.157 s (0.013 s of it launching frozen opponents), PPO update 0.383 s. That is 207 k agent steps/s while training. 90.3 % of the samples (925 M) were learner transitions.
There were no restarts, because the first 20 minutes showed nothing pathological:
None of the 7809 update rows has a NaN or infinite value.
Entropy fell from 4.50 to 2.84 nats and did not collapse.
Approx-KL stayed at 0.004–0.005 throughout.
The potential terms' per-episode sum stayed flat at about −0.7. That is expected for γ_F = 1 shaping: the sum telescopes to Φ(end) − Φ(start), so the potentials cannot be farmed.
The in-run ratings went flat mid-run. That turned out to be a measurement problem, not a learning one; see "Ratings" below.
Training curves: a rolling window over the last 4096 learner episodes. Rates are per car-minute; reward columns are Blue's weighted per-episode sums.
| Steps | Wall (min) | Ep. length (s) | Goal frac | Touch steps / min | Shots / min | Demos / min | Entropy | Approx KL | Value loss | Expl. var. | Return scale | Blue vs pool win | Goal | Concede | Shot | Touch | Touch b2g acc | Potentials |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 10 M | 0.8 | 44.5 | 0.19 | 0.3 | 0.00 | 0.00 | 4.15 | 0.0038 | 0.106 | 0.80 | 0.78 | 0.40 | 0.96 | −0.30 | 0.00 | 0.01 | 0.00 | −0.31 |
| 31 M | 2.7 | 108.9 | 0.91 | 5.5 | 0.13 | 0.00 | 3.52 | 0.0045 | 0.253 | 0.85 | 0.92 | 0.72 | 5.03 | −1.21 | 0.36 | 0.50 | 0.08 | −0.69 |
| 52 M | 4.6 | 29.6 | 1.00 | 24.8 | 2.15 | 0.01 | 3.17 | 0.0051 | 0.426 | 0.85 | 1.48 | 0.84 | 5.47 | −1.36 | 1.66 | 0.63 | 0.13 | −0.72 |
| 105 M | 9.2 | 25.6 | 1.00 | 46.6 | 3.99 | 0.02 | 3.04 | 0.0043 | 0.289 | 0.86 | 2.12 | 0.73 | 5.40 | −1.38 | 2.66 | 1.01 | 0.13 | −0.75 |
| 210 M | 18.4 | 26.4 | 1.00 | 62.4 | 5.15 | 0.04 | 2.87 | 0.0048 | 0.247 | 0.87 | 2.49 | 0.61 | 5.18 | −1.43 | 3.45 | 1.37 | 0.13 | −0.76 |
| 419 M | 36.7 | 25.0 | 1.00 | 62.7 | 7.50 | 0.05 | 2.96 | 0.0046 | 0.226 | 0.91 | 2.93 | 0.55 | 5.12 | −1.46 | 4.73 | 1.31 | 0.12 | −0.71 |
| 629 M | 54.9 | 24.5 | 1.00 | 61.2 | 7.93 | 0.07 | 2.87 | 0.0041 | 0.186 | 0.90 | 3.25 | 0.50 | 5.06 | −1.48 | 4.98 | 1.26 | 0.12 | −0.75 |
| 839 M | 73.3 | 23.1 | 1.00 | 57.7 | 9.22 | 0.08 | 2.92 | 0.0042 | 0.164 | 0.93 | 3.49 | 0.53 | 4.94 | −1.51 | 5.20 | 1.11 | 0.12 | −0.72 |
| 1024 M | 89.9 | 23.4 | 1.00 | 59.3 | 10.13 | 0.10 | 2.84 | 0.0045 | 0.169 | 0.93 | 3.69 | 0.48 | 4.98 | −1.50 | 6.26 | 1.18 | 0.12 | −0.70 |
Touches took off at 25–35 M steps and levelled off at about 60 touch steps per car-minute by 200 M.
After that, the visible changes are more shots (4.0 to 10.1 per car-minute between 105 M and 1024 M) and a falling value loss.
Blue's win rate against pool snapshots falls to about 0.5, as expected. The pool holds the last 20 snapshots (at most 200 M steps old), which are close in strength late in the run.
In-run evaluation (128 held-out kickoffs per opponent, sampled actions). "In-run" is the rating fitted at that evaluation; "Refit" is the fit over all of the run's games at the end; "League" is the post-hoc league below, nearest member:
| Steps | vs ball_chaser W/D/L | Score [95 % CI] | Touches / car-min (opp) | Mean length | vs prev 1/2/3 | Rating in-run | Refit | League |
|---|---|---|---|---|---|---|---|---|
| 10.5 M | 56/0/72 | 0.438 [0.355, 0.524] | 0.3 (30.8) | 36.5 s | – | 957 | 723 | 830 |
| 31.5 M | 60/2/66 | 0.477 [0.392, 0.563] | 1.4 (29.2) | 54.3 s | 1.00/0.99 | 1186 | 980 | |
| 52.4 M | 105/0/23 | 0.820 [0.745, 0.877] | 12.3 (18.0) | 47.8 s | 0.87/0.98/1.00 | 1511 | 1336 | |
| 104.9 M | 124/0/4 | 0.969 [0.922, 0.988] | 39.7 (10.6) | 31.3 s | 0.54/0.65/0.64 | 1693 | 1528 | 1322 (115 M) |
| 209.7 M | 118/0/10 | 0.922 [0.862, 0.957] | 45.3 (10.3) | 23.9 s | 0.51/0.56/0.59 | 1627 | 1491 | 1407 (220 M) |
| 419.4 M | 111/0/17 | 0.867 [0.798, 0.915] | 51.2 (9.8) | 19.9 s | 0.53/0.46/0.56 | 1416 | 1410 | 1477 (430 M) |
| 629.1 M | 121/0/7 | 0.945 [0.891, 0.973] | 49.8 (8.8) | 16.9 s | 0.41/0.43/0.58 | 1445 | 1459 | 1596 (640 M) |
| 838.9 M | 123/0/5 | 0.961 [0.912, 0.983] | 55.7 (7.2) | 15.0 s | 0.52/0.49/0.61 | 1542 | 1520 | 1650 (849 M) |
| 1023.5 M | 123/0/5 | 0.961 [0.912, 0.983] | 63.2 (8.3) | 16.3 s | 0.50/0.49/0.58 | 1558 | 1558 | 1669 |
The score vs ball_chaser first reached 0.5 at 41.9 M steps, 0.8 at 52.4 M and 0.9 at 73.4 M; the best in-run score was 0.992. After 105 M it stayed between 0.86 and 0.99: mean 0.94 from 105 to 300 M, 0.91 from 300 to 600 M, 0.95 after 600 M.
Ratings. Neither the in-run ratings nor the end-of-run refit show steady progress:
The in-run rating peaked at 1726 (126 M steps), drifted down to about 1400 by 400–500 M, and recovered to 1558.
The refit over all in-run games is not monotone either: 1528 at 105 M, 1410 at 419 M, 1558 at the end.
The policy did not get worse. The in-run games link each checkpoint only to the previous three, 10.5 M steps apart. After 105 M those scores averaged 0.51–0.53, with 59–70 % of them above 0.5: too close to 0.5 to carry the progress. The fit therefore followed the ball-chaser scores, which moved between 0.87 and 0.99 regardless of strength. A standalone check of the 524 M checkpoint (256 seeds) scored 0.83 against the 115 M checkpoint, 0.73 against 220 M, 0.67 against 325 M and 0.64 against 419 M.
Two changes came out of this: --eval-prev-spacing geometric, now the
default with --eval-prev 5, and the new physlab_rl.league module.
The post-hoc league has 11 checkpoints about 105 M steps apart. Each plays the ball chaser and every earlier member, 128 kickoffs per pairing, 7040 games in all. Its ratings, oldest first: 830, 1322, 1407, 1466, 1477, 1544, 1596, 1609, 1650, 1646, 1669. They rise all the way except one −4 step (849 to 954 M), which is inside the noise. Head to head, the final checkpoint scores 0.90 against the 115 M one, 0.65 against 534 M and 0.56 against 954 M (but 0.46 against 744 M; 128 games per pairing are noisy).
Final standalone evaluation of final.pt
(= checkpoints/step_1023541248.pt, the highest league rating): all 256
held-out kickoff seeds, sampled actions. Results are in
runs/selfplay/main-1v1-s11/eval/final.match-1v1-v1.match.json.
| Opponent | W/D/L | Win rate [95 % CI] | Score [95 % CI] | Mean length | Our / their touches per car-min |
|---|---|---|---|---|---|
ball_chaser | 241/0/15 | 0.941 [0.906, 0.964] | 0.941 [0.906, 0.964] | 15.5 s | 55.6 / 7.5 |
idle | 255/1/0 | 0.996 [0.978, 0.999] | 0.998 [0.982, 1.000] | 9.9 s | 57.9 / 0.2 |
step_104857600 | 243/0/13 | 0.949 | 0.949 [0.915, 0.970] | 23.5 s | 68.6 / 22.5 |
step_524288000 | 163/2/91 | 0.637 | 0.641 [0.580, 0.697] | 29.6 s | 55.5 / 41.0 |
step_838860800 | 151/1/104 | 0.590 | 0.592 [0.531, 0.650] | 35.9 s | 49.5 / 42.5 |
step_943718400 | 137/1/118 | 0.535 | 0.537 [0.476, 0.597] | 33.7 s | 54.0 / 42.6 |
The self-play learner's exit criteria are met. The win rate vs ball_chaser is 0.941 with a 95 % lower bound of 0.906, above 0.5. The rating increases over checkpoints in the league above; the in-run ratings alone would not have shown it.
The exported episode is the first eval seed vs ball_chaser
(2^63 + 3000000, a kickoff):
runs/selfplay/main-1v1-s11/eval_scenarios/match-1v1-v1-step-1023541248-vs-ball-chaser-seed-9223372036857775808.json.
physlab runreplays it to a 2-car trace that ends on the env's goal tick 1653 (13.8 s), with the ball at y = 5219 uu in Orange's net. Blue scored, with 21 touches to Orange's 2 and 2 shots.Nobody has watched the policy in RLViser yet.
Caveats:
One seed and one 90-minute run, with untuned hyperparameters. The GPU was shared with Rocket League throughout.
The ball chaser is a weak anchor: the 10.5 M checkpoint, which barely touches the ball, still scores 0.44 against it. "Beats ball_chaser" mostly shows that the policy plays at all.
The league ratings are relative to this run's own checkpoints.
The final policy lost 15/256 to the ball chaser, slightly more than the 105 M checkpoint did (4/128). Self-play does not optimise against that bot.
Every evaluation episode is a single-goal game from a kickoff, so these results say nothing yet about full 5-minute matches, or about play against humans or other bots.
Reward A/B: match-1v1-v1 vs match-1v1-simple-v1 (2026-10-15)#
runs/selfplay/ab/: the two tasks differ only in the reward.
match-1v1-simple-v1 pays the same utilities densely at 1 % of the Lucy
potential weights, with no KRC and no potentials. Events, team spirit,
initial states and eval seeds are the same. Both arms used seed 21,
120 M agent steps and every default (now with geometric eval opponents).
The two runs shared the machine concurrently (--env-threads 12
each): 16.3 min and 123 k agent steps/s each.
| Agent steps | Lucy-SKG: score vs ball_chaser [95 % CI] | eval touches / car-min | train touch steps / car-min | Simple: score vs ball_chaser [95 % CI] | eval touches / car-min | train touch steps / car-min |
|---|---|---|---|---|---|---|
| 21 M | 0.434 [0.351, 0.520] | 0.4 | 1.0 | 0.434 [0.351, 0.520] | 0.3 | 0.3 |
| 31.5 M | 0.516 [0.430, 0.600] | 1.6 | 3.2 | 0.367 [0.289, 0.453] | 0.3 | 0.5 |
| 41.9 M | 0.656 [0.570, 0.733] | 7.0 | 15.0 | 0.422 [0.340, 0.508] | 0.4 | 1.1 |
| 52.4 M | 0.812 [0.736, 0.871] | 12.9 | 23.8 | 0.445 [0.362, 0.532] | 0.7 | 1.5 |
| 62.9 M | 0.828 [0.753, 0.884] | 19.1 | 29.7 | 0.465 [0.381, 0.551] | 1.2 | 2.9 |
| 83.9 M | 0.938 [0.882, 0.968] | 30.5 | 39.1 | 0.703 [0.619, 0.775] | 5.3 | 9.2 |
| 104.9 M | 0.961 [0.912, 0.983] | 35.3 | 44.3 | 0.805 [0.728, 0.864] | 9.1 | 15.2 |
| 119.9 M | 0.938 [0.882, 0.968] | 37.3 | 50.1 | 0.820 [0.745, 0.877] | 14.3 | 19.9 |
Steps to a score of 0.5 / 0.8 / 0.9 vs ball_chaser: Lucy-SKG 31.5 / 52.4 / 78.6 M; simple 73.4 / 104.9 M / not reached.
Final checkpoints on all 256 seeds: Lucy-SKG 251/0/5 = 0.980 [0.955, 0.992] vs ball_chaser; simple 225/0/31 = 0.879 [0.833, 0.913].
Head to head (final vs final, 256 seeds each way): Lucy-SKG as Blue won 195/0/61 = 0.762 [0.706, 0.810]. Simple as Blue won 54/0/202 = 0.211 [0.165, 0.265], so Lucy-SKG scored 0.789 from that side.
In this one-seed comparison, the Lucy-SKG reward brought the touch takeoff about 40 M steps earlier, and at equal steps its policy beats the simple one about 4 games in 5.
Caveats:
One seed per arm. In the smoke runs, touch takeoff varied by about 5 M steps between seeds; this gap is about 40 M, so it is likely but not certainly real.
The simple arm's dense weights (1 % of the potential weights) are one arbitrary choice. A better-scaled dense reward might close the gap.
The two runs shared the machine, so their SPS (123 k each) is not comparable with the main run's.
120 M steps is early in training: the main run kept improving up to 1 B steps.
Lucy-SKG ablations on 1v1: aux tasks and action stacking (2026-10-15)#
runs/selfplay/ab/: the paper's ablation ladder (§5.4) on our 1v1 task.
Lucy-SKG = Lucy-Gamma + the RP and SR auxiliary tasks; Lucy-Alpha =
Lucy-Beta without the action stack. The baseline is the Lucy-reward arm of
the reward A/B above (match-1v1-v1-s21: Lucy reward, action stack 5, no
auxiliary tasks, i.e. Lucy-Gamma's ingredients). Every arm uses seed 21,
every learner default and --env-threads 12, and ran next to one other
training run on the shared machine; wall times are only roughly
comparable. In-run scores are from 128 held-out kickoffs; "final" rows use
all 256.
| Arm | Run | Steps | Wall | Steps to 0.5 / 0.8 / 0.9 vs ball_chaser | Entropy at the end (nats) | Final vs ball_chaser [95 % CI] | Head to head vs the baseline |
|---|---|---|---|---|---|---|---|
| Baseline: Lucy reward, stack 5, no aux | match-1v1-v1-s21 | 120 M | 16.3 min | 31.5 / 52.4 / 78.6 M | 2.95 | 251/0/5 = 0.980 [0.955, 0.992] | — |
No action stack (match-1v1-nostack-v1) | match-1v1-nostack-v1-s21 | 120 M | 16.6 min | 41.9 / 52.4 / 57.7 M | 2.95 | 250/0/6 = 0.977 [0.950, 0.989] | baseline as Blue 125/1/130: the unstacked policy scores 0.510 [0.449, 0.570] |
RP + SR (--aux-reward-prediction --aux-state-representation) | match-1v1-v1-aux-s21 | 120 M | 32.6 min | 57.7 M / – / – | 1.28 | 138/4/114 = 0.547 [0.486, 0.607] | aux as Blue 1/0/255; baseline as Blue 255/0/1: the aux policy scores 0.002–0.004 |
| SR only | match-1v1-v1-sr-s21 | 72 M | 14.1 min | 31.5 / 47.2 M / – (0.891 at 72 M) | 3.12 | 240/0/16 = 0.938 [0.901, 0.961] | vs the baseline's 73.4 M-step checkpoint (227/0/29 = 0.887 vs ball_chaser): SR as Blue 0.537 [0.476, 0.597], baseline as Blue 0.477, so SR scores 0.52–0.54 |
| RP only | match-1v1-v1-rp-s21 | 72 M | 22.4 min | 52.4 M / – / – | 1.53 | 121/4/131 = 0.480 [0.420, 0.542] | RP as Blue vs the baseline's 73.4 M-step checkpoint: 0/1/255, 0.002 |
The RP auxiliary task, as configured here, wrecks 1v1 training. With RP on, the policy's entropy falls from ≈ 3.3 to 1.1–1.5 nats once touches start (40–60 M steps), while the baseline stays at ≈ 3.0. The policy then settles on a narrow strategy that barely touches the ball from kickoffs: 1.4 touches per car-minute in the final evaluation (RP only) against 24 for the baseline at the same step count, and a score against the ball chaser close to an idle car's (0.42). RP alone reproduces the failure, and SR alone does not, so RP is the cause. Both RP runs calibrated the same zero band (0.0154, classes 1/3 each) and the head reached 70–73 % accuracy.
Why, probably: our RP head reads the policy's whole actor trunk (its last hidden layer feeds both the policy head and the RP LSTM), 20 observations per sample, with λ_RP = 1 and one shared gradient-norm clip. The paper attaches RP through its own cross-attention layer to the actor's preprocessing MLPs only (app. §2), so the policy's final features are not shared. Untested remedies: a smaller
--aux-weight, or attaching the head to the first trunk layers only. Until one is shown to work, leave--aux-reward-predictionoff for match tasks (it is off by default, andtrain.pyprints a warning when it is turned on for a match task). On the single-agent tasks it was harmless but no faster (see Lucy-SKG A/B experiments).SR is neutral. It reached 0.8 vs ball_chaser 5 M steps earlier than the baseline and plays it about even at equal steps (0.52–0.54 head to head, inside the noise), for 1.8× the update time (0.78 s vs 0.44 s per update, both measured next to another run; RP: 1.78 s).
Action stacking made no measurable difference at 120 M steps of 1v1: equal final scores vs ball_chaser and an even head to head (the unstacked policy played in the stacked task through
adapt_to_layout; a stacked policy cannot play in the unstacked task, so only one direction exists). The paper's Lucy-Beta beat Lucy-Alpha 300–4 in 2v2 after 1 B steps, with a perceiver and a reduced observation; our MLP observation already has every car's velocities and flip state.Caveats. One seed per arm. In the reward A/B the touch take-off moved by about 5 M steps between seeds; the RP effect (a 0.002 head-to-head score) is far outside that, the stacking and SR effects are not. 72 M and 120 M steps are early compared with the paper's 1 B.
Learner speed (2026-10-15)#
The goal is less wall-clock time to a given skill, not just more steps
per second: a change that raises steps/s but needs proportionally more
steps is no win. Every option is a flag recorded in the manifest
(derived.learner, plus the GPU's nvidia-smi state at the start in
derived.gpu_at_start). Options that cannot change what is learned
beyond float rounding are on by default; options that change numerics or
learning dynamics are opt-in until a training A/B (2 seeds per arm,
wall time to 0.5/0.8/0.9 vs ball_chaser) decides.
| Flag | Default | What it does | Changes the math? |
|---|---|---|---|
--tf32 | on | TF32 matmuls (existing) | rounding |
--fused-adam | on (CUDA) | Adam as one fused kernel instead of ~10 multi-tensor kernels | rounding only (the update differs from foreach Adam by ≈ 0.2 % relative after 24 steps) |
--pin-memory | on (CUDA) | page-locked host staging: the env writes each step's observations straight into one of two pinned buffers, whose upload is asynchronous; actions come back through a reused pinned buffer | no (bit-identical) |
--deferred-bootstrap | on | the truncation bootstrap γ·V(final_obs) for the whole rollout in one critic pass after it, instead of a small pass (+ 2 synchronous uploads) on every step that truncated an episode | rounding (another batch shape) |
| (always) | — | in-place ReLU; the update's ~17 float() reads replaced by one device-to-host copy; release_unused via np.unique; cheaper per-step component sums for logging | no (bit-identical) |
--amp bf16 | off | torch.autocast to bfloat16 for the forward passes of the rollout and the update (same precision on both sides, so the PPO ratio starts at 1); the policy and value heads, log_softmax, the RP LSTM and every loss stay fp32; no GradScaler (bf16). --no-amp-critic keeps the whole critic fp32 | yes |
--cuda-graphs | off | each PPO minibatch step (forward, backward, grad clip, fused capturable Adam) replayed as a CUDA graph. Minibatches are padded to multiples of --graph-bucket 512 with weight-0 entries (masked means, so the loss equals the unpadded minibatch's) and, unlike the eager loop, cover every learner sample (the eager loop drops the last n_valid mod n_mb); 1–3 graphs per run (one per padded size). No extra dependency | rounding, and minibatch composition |
--cuda-graph-act | off | each rollout step's GPU work as one CUDA graph replay: the learner's forward pass over every row (opponent rows are computed and ignored), the frozen pool opponents' stacked forward passes (each policy's rows padded to a multiple of 32; one graph per padded size, captured on first use), sampling, the scatter of the opponents' actions and the writes of observation, action, log-prob and value into the rollout buffer. With --amp bf16 the trunks run on bf16 copies of their weights (refreshed each rollout) instead of under autocast: the same values, fewer kernels | the sampling stream differs (not bit-identical to eager); same distributions |
--overlap-update | off | the PPO update runs on a worker thread and its own CUDA stream while the next rollout collects with a copy of the previous weights (two rollout buffers, high-priority rollout stream). Data is one update stale. --overlap-correction decoupled (default) uses the decoupled PPO objective (Hilton et al. 2021): one extra forward pass computes the log-probs of the weights at the update's start (the proximal policy), the ratio and its clip are taken against those, and the behaviour policy enters only as an importance weight π_prox/π_behaviour truncated at 2. none = classic PPO on the stale data (do not use, see the smoke runs). Logged: ppo/behaviour_kl, ppo/update. Evaluations, pool snapshots, STOP, save/stop requests, the rolling checkpoint and the last update wait for the running update, so checkpoints never hold half-updated weights | yes: one-update policy lag, decoupled objective |
--pipeline-rollout | off (match tasks on CUDA: on) | the training envs in two halves (same seeds, same rows): one half's env step runs on a worker thread while the loop finishes the other half's previous step and computes its next actions, so CPU stepping overlaps inference and bookkeeping. time/env_s is then the loop's wait for the env, time/env_step_s the steps' own time. Compare with just bench-pipeline | no: every row gets the trajectory the serial rollout would give it for the same actions; action sampling draws in another order, and --obs-norm statistics are updated per half |
| (always) | — | the env writes its step outputs into reused arrays (one row of rollout-sized host arrays per step) instead of ten new arrays; the env sums the learner rows' rewards and components and each ended episode's components itself; return scaling, done flags, valid masks, the truncation bootstrap and the episode statistics are done once per rollout, from those arrays; sampling uses torch.multinomial's own algorithm without its input checks | rounding only (return-scale moments; the samples are bit-identical) |
--compile MODE | off | torch.compile of the minibatch loss (forward + backward). Inductor modes (default, reduce-overhead, max-autotune-no-cudagraphs) need Triton: on Windows uv sync --extra compile (installs triton-windows 3.8, the build matching torch 2.14; bundles ptxas and TinyCC, no CUDA toolkit or MSVC). cudagraphs and aot_eager need nothing. The minibatch dimension is marked dynamic, so the changing learner share compiles one graph, not one per size | rounding |
--torch-compile | off | (existing) compile model.act; measured slower than eager | rounding |
--update-epochs, --num-minibatches, --minibatch-size N | 3, 8, — | --minibatch-size (new) sets minibatches of ≈ N learner samples (n_valid // N of them) instead of a fixed count | yes |
Measurement tools:
python -m physlab_rl.bench_learner(just bench-learner): runstrain.pyfor--warmup+--updatesupdates per flag set ("arm"), each in its own process, sequentially and interleaved over--repeats, and prints medians of the per-update phases frommetrics.jsonl(time/cycle_s,time/env_s,time/h2d_s,time/act_launch_s,time/d2h_wait_s,time/bookkeeping_s,time/update_s,time/update_wait_s), withnvidia-smirecorded before each run.--synthetictimes the update alone on a random rollout.train.py --profile-updates START:COUNTwrites atorch.profilertrace (<run>/profile/trace.json, Chrome format) and akey_averages.txttable for those updates.
Measured (match-1v1, default net and batch, shared GPU)#
runs/perf/bench-20261015-134010 (bench_learner --updates 30 --warmup 8
--repeats 2, arms interleaved; medians in ms per update of 131 072 agent
steps; Rocket League running, nvidia-smi 43–45 % utilisation and 4.8 GB
before every run; the two repeats agree within 1 %). "Rollout" is
everything but env and the update (time/inference_s).
| Arm (flags) | Cycle | Env | Rollout (h2d / launch / wait / book) | Update | Steps/s | vs legacy |
|---|---|---|---|---|---|---|
legacy (--no-fused-adam --no-pin-memory --no-deferred-bootstrap: results bit-identical to the learner before this work, which was not re-timed; it keeps the always-on host savings) | 632 | 98 | 125 (37 / 33 / 16 / 44) | 409 | 207 k | 1.00× |
| default (fused Adam, pinned staging, deferred bootstrap) | 598 | 97 | 94 (17 / 34 / 15 / 28) | 408 | 219 k | 1.06× |
--cuda-graphs | 564 | 99 | 93 | 371 | 233 k | 1.12× |
--amp bf16 | 451 | 99 | 106 (17 / 49 / 12 / 28) | 246 | 291 k | 1.40× |
--amp bf16 --cuda-graphs | 411 | 99 | 104 | 209 | 319 k | 1.54× |
--amp bf16 --cuda-graphs --cuda-graph-act | 369 | 96 | 64 (16 / 4 / 16 / 28) | 209 | 355 k | 1.71× |
… --minibatch-size 4096 (29 Adam steps per epoch) | 419 | 96 | 65 | 261 | 313 k | 1.51× |
… --overlap-update --overlap-correction none | 231 | 95 | 125 (16 / 4 / 76 / 30) | 228 (hidden) | 567 k | 2.73× |
… --overlap-update --overlap-correction none --update-epochs 2 | 210 | 96 | 106 | 154 (hidden) | 624 k | 3.01× |
--cuda-graphs --cuda-graph-act --overlap-update --overlap-correction none (fp32) | 400 | 96 | 179 | 401, of which 116 waited | 328 k | 1.58× |
--amp bf16 --cuda-graphs --cuda-graph-act --overlap-update (decoupled; bench-20261015-140336, same conditions) | 239 | 94 | 128 (16 / 4 / 79 / 29) | 241 (hidden; 4.5 waited) | 549 k | 2.65× |
(The overlap rows with none were measured before the decoupled
correction existed; it adds ≈ 13 ms of update time, which with overlap
makes the update, not the rollout, the slower side.)
With overlap the cycle is ≈ max(rollout, update): in bf16 both are
≈ 0.22 s, so the rollout waits on the GPU longer (d2h_wait 16 → 76 ms:
its small kernels queue behind the update's) and the update never makes
the rollout wait; in fp32 the update (0.40 s) is the bottleneck. Further
gains therefore need both sides faster. Evaluations are not included
(--eval-every 0); at the match defaults (every 40 updates, ball_chaser +
5 previous checkpoints) they cost ≈ 10 s each, about as long as
the 40 updates between them take on the fast path (≈ 9.5 s) — raise
--eval-every (or evaluate asynchronously, not implemented) with it.
Findings:
bf16 is the biggest single step (update 0.41 → 0.25 s); a CUDA graph on top saves another ≈ 15 % of the update. Without bf16 the graph gains little: the fp32 update is compute-bound. Larger minibatches do not make the update faster (it is flat from ≈ 16 k samples up; synthetic bench); fewer epochs cut it in proportion.
The rollout became the next bottleneck. With the update at ≈ 0.2 s, ≈ 50 ms per update was spent launching the learner's forward passes (~1.5 ms per step under autocast) —
--cuda-graph-actmakes that 4 ms.Overlap hides the update behind the next rollout: the cycle becomes ≈ max(rollout, update) instead of their sum. On Windows,
CUDAGraph.replayholds the GIL while it blocks on a full launch queue, which stalled the rollout thread by milliseconds per step; the engine now waits on an event after every minibatch step in this mode (UpdateEngine.sync_each_step), which releases the GIL.torch.compilebrings nothing over CUDA graphs + bf16 here (synthetic update:default/bf16 0.18 s vs graphs/bf16 0.19 s; 16–29 s compile on the first update), so it is opt-in and its dependency an optional extra. Inductor warns that the 4070 has too few SMs (46) for GEMM autotuning.Pinned staging matters less than its reputation (a pageable 2 MB copy is ≈ 0.15 ms); what it saves is mostly the synchronisation of the small per-step copies (h2d 44 → 18 ms per update).
Smoke runs: learning per step (seed 11, one run each)#
Same seed and evaluation settings as the
main run
(--eval-every 80 --eval-prev 3, 128 kickoffs vs ball_chaser, Rocket
League running); "train s" is wall time minus evaluation time. Runs in
runs/perf/.
| Run | Flags | Score vs ball_chaser at 31 / 42 / 52 / 63 M steps | Touches per car-minute (train) at 31 / 42 M | Train s to 52 M / 63 M |
|---|---|---|---|---|
main run (runs/selfplay/main-1v1-s11) | the learner before this work | 0.48 / 0.62 / 0.82 / 0.85 | 5.6 / 15.3 | 252 / 302 |
smoke-gact-s11 | --amp bf16 --cuda-graphs --cuda-graph-act | 0.54 / 0.67 / 0.72 / 0.92 | 7.6 / 28.9 | 161 / 194 |
smoke-ovl-dec-s11 | … --overlap-update (decoupled) | 0.57 / 0.65 / 0.82 / 0.91 | 11.6 / 23.8 | 109 / 131 |
smoke-fast-s11 | … --overlap-update --overlap-correction none (classic PPO on one-update-stale data) | 0.42 / 0.44 / 0.47 / 0.43 (0.49 at 105 M) | 0.4 / 0.7 (take-off only at ≈ 90 M) | 105 / 126 |
bf16 + CUDA graphs learned like the main run per step (touch take-off at the same ≈ 30 M steps, explained variance 0.77–0.85 vs 0.78–0.87;
ppo/approx_kl_first_mbexactly 0: rollout and update agree bit for bit in bf16). The earlier explained-variance worry did not show.Overlap needs the decoupled objective. With classic PPO on the one-update-stale data the clip is centred on the behaviour policy while the update starts from newer weights; each update then moved the policy far (in-update KL 0.03–0.09, clip fraction 0.2–0.47, against 0.005 / 0.05 normally), the KL between consecutive policies grew to 0.14, and learning stalled for ≈ 60 M steps. With the decoupled objective the behaviour policy is ≈ 0.006 KL from the update's start (one normal update), the clip fraction is the usual 0.05 and the curve matches the main run's per step.
Wall time to 0.8 vs ball_chaser: 252 s → 109 s of training (2.3×) on this seed, for the full fast set. One seed per arm; the reward A/B saw the touch take-off move by ≈ 5 M steps between seeds, so the per-step equality is "no visible regression", not a proof.
Not yet verified: multi-seed A/Bs of bf16 and of overlap; fewer epochs or other minibatch sizes (only timed); runs longer than 105 M steps; 2v2. Absolute timings were taken with Rocket League using ≈ 45 % of the GPU and ≈ 4.8 GB.
Tracing, profiling and machine load#
Three tools answer "where does an update's time go, and is the GPU kept busy". None of them changes
what is trained, so --resume accepts them too.
Phases. One helper (physlab_rl.tracing.phase) names each part of an update once, and it becomes
an OpenTelemetry span (with tracing on) and an NVTX range (with --nvtx):
| Phase | Where | Spans |
|---|---|---|
training.run | the whole run; attributes physlab.task, physlab.run_id | a trace of its own |
training.update | one update (rollout, update, logging, evaluation); attributes update, physlab.detail, global step, sps | one trace per update, linked to the run |
training.rollout, training.gae | collecting the rollout; bootstrap + GAE | every update |
training.ppo_update | the PPO update; with --overlap-update on the update thread, a child of the update that started it that runs on into the next one | every update |
training.update_wait | the loop waiting for the overlapped update (linked to its training.ppo_update) | every update |
training.evaluate, checkpoint.save | evaluations; checkpoint writes (physlab.checkpoint: full, light, resume) | when they happen |
policy.inference_batch, env.step, rollout.bookkeeping, env.step_wait, env.teacher_obs | one rollout step: acting, the env step (on the worker thread with --pipeline-rollout), statistics and buffer stores, the wait for the worker | every --trace-detail-every (50) updates |
rlenv.prepare_actions, rlenv.step, rlenv.outputs (and rlenv.reset, rlenv.observe, ...) | the Rust env inside env.step; rlenv.step carries envs, threads and busy_s (summed worker time: busy_s / (duration · threads) is the rayon pool's utilisation) | with the per-step spans |
A long run has ~10⁵ updates, so each update is its own small trace instead of one giant run trace.
Spans are never per car, tick or episode. The Rust spans are tracing spans in crates/rlenv; the
extension records them per calling thread only while per-step spans are on and Python re-emits them
as children of the env.step span, so there is one exporter and one trace.
Traces in Grafana. A local backend runs in Docker (otel/compose.yaml, the grafana/otel-lgtm
image: an OpenTelemetry Collector, Tempo, Prometheus, Loki and Grafana in one container):
just otel-up # Grafana on http://localhost:3000, OTLP on 4317 (gRPC) / 4318 (HTTP)
just train-match tasks/match-1v1-v1.json --trace
just otel-down # add --volumes to delete the stored tracesIn Grafana: Explore → Tempo → Search, service physlab-train, span name training.update, or
TraceQL such as {name="training.update" && span.physlab.detail=true} for the detailed updates.
| Setting | Effect |
|---|---|
--trace / --no-trace | turns spans on or off; by default they are on only when OTEL_EXPORTER_OTLP_TRACES_ENDPOINT is set |
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT | full URL (OTLP/HTTP protobuf) |
OTEL_EXPORTER_OTLP_ENDPOINT | base URL with --trace; /v1/traces is appended. Default http://localhost:4318/v1/traces |
--trace-detail-every N | per-step spans in every Nth update (0 = never) |
OTEL_SDK_DISABLED=true | no spans (and no metrics) |
Metrics keep going to the Command Center. Export failures never stop training: the first one is printed, later ones are dropped. With tracing off a phase costs about 0.2 µs; with it on, the per-update spans are a handful and the detailed updates add ~200 spans each.
Nsight Systems. just profile-nsys [checkpoint] [-- train flags] forks a short training from
a checkpoint (default runs/selfplay/main10b-1v1-s18/final.pt, --init-optimizer --eval-every 0)
under nsys profile with NVTX ranges on, and captures only updates 11–30 (train.py --nsys-capture
START:COUNT brackets them with cudaProfilerStart/Stop for --capture-range=cudaProfilerApi),
tracing CUDA, NVTX and the GIL. It writes runs/perf/nsys/<name>.nsys-rep (open it in the Nsight
Systems GUI) and nsys stats CSVs next to it. nsys comes from $NSYS, else the newest default
install, else PATH. CPU sampling and context switches need administrator rights and are not
traced. Options: --warmup, --updates, --name, --trace (nsys's -t); e.g. just profile-nsys
runs/selfplay/<id>/final.pt --updates 30 -- --pipeline-rollout.
Machine load. A background sampler (physlab_rl.sysload, --sysload, on by default) measures
how much of the machine the run and everything else use. Every --sysload-every (30) seconds the
run writes a kind: "sysload" row with the means since the previous one, and prints a line when
other processes used more than 20 % of the CPUs or of the GPU:
| Key | Meaning |
|---|---|
sys/cpu_total_pct, sys/cpu_ours_pct, sys/cpu_other_pct | CPU use in % of all logical CPUs: the machine, this process tree, everything else (sampled every --sysload-cpu-interval 2 s) |
sys/gpu_util_pct | GPU utilisation (nvidia-smi) |
sys/gpu_ours_pct, sys/gpu_other_pct | per-process GPU use (Windows GPU Engine counters, as in Task Manager: each process's busiest engine), summed over this process tree and over the others (sampled every --sysload-gpu-interval 60 s, with the top processes; a read takes a few seconds) |
sys/top_cpu_other, sys/top_gpu_other | the three busiest other processes, {name: %} |
The numeric keys are also exported as physlab.system.cpu.utilization and
physlab.system.gpu.utilization (fractions, attribute process = all, ours or other).
just bench-learner samples the load of each run itself and prints cpu_oth, gpu_oth and
gpu_own next to sps, with a warning (and ! in the summary) for a run during which other
processes used more than --load-warn-pct (10) % of the CPUs or the GPU: its timings are suspect.
Measured (2026-10-16, match-1v1 fork of main10b-1v1-s18, default fast learner)#
Overhead (just bench-learner, 2 repeats of 40 updates per arm; two identical "off" arms differed
by 1 %): spans on with per-step detail every 10 updates 747k sps vs 750k–758k off; --sysload
(train's own sampler) 767k vs 777k off. A phase with tracing and NVTX off costs 0.1 µs.
The Nsight timeline (runs/perf/nsys/main10b-default.nsys-rep, 20 updates of ~190 ms):
The GPU is busy 48 % of each update. The PPO update (~95 ms, overlapped) keeps it 84 % busy and finishes halfway through the next rollout; after that the GPU only runs the per-step forward passes and waits.
The rollout (~185 ms) is the critical path, all on the main thread: per step 2.9 ms in
env.step(of whichrlenv.step2.0 ms at 72 % rayon utilisation andrlenv.outputs, the copy into fresh numpy arrays, 0.66 ms), 1.5 ms inpolicy.inference_batch(~37 kernel launches and ~14 copies per step) and 1.3 ms inrollout.bookkeeping. The main thread holds the GIL ~45 % of the time; the update thread mostly waits incudaEventSynchronize.--pipeline-rollouthides the env step (the loop's env wait drops from 93 to 1 ms per update) but doubles the per-call Python work, so it gains only 6 % (716k vs 675k sps under the profiler).
Rollout step (2026-10-16)#
Same benchmark as above (just bench-learner --task tasks/match-1v1-flip-kickoff-v1.json --warmup 20
--updates 440 --repeats 4 --common="--init-checkpoint runs/selfplay/main10b-1v1-s18/final.pt
--init-optimizer"), medians in ms per update, each change on top of the previous ones:
| Change | Cycle | Env | h2d / launch / wait / book | Update (overlapped) | Steps/s |
|---|---|---|---|---|---|
| before | 155.3 | 72.1 | 11.5 / 19.4 / 18.6 / 27.3 | 96.9 | 844 k |
| env writes into reused arrays (observations into pinned memory) | 140.7 | 59.5 | 7.3 / 18.5 / 20.1 / 29.5 | 93.7 | 932 k |
| one graph per rollout step, bookkeeping once per rollout | 128.2 | 58.9 | 1.4 / 2.7 / 40.7 / 19.3 | 97.5 | 1022 k |
| sampling without input checks, bf16 weight copies, cheaper controller updates | 120.7 | 58.7 | 2.2 / 2.4 / 34.7 / 17.1 | 93.2 | 1086 k |
--pipeline-rollout (now the default) | 112.7 | 3.7 (step 66.2) | 6.0 / 5.7 / 58.0 / 31.5 | 100.4 | 1163 k |
The env's own step got ≈ 2 % faster with smaller work-stealing leaves (32 per thread instead of 4); most of the env gain is the output copy that is gone.
With the act step in one graph, launching costs ≈ 0.1 ms per step; what remains is the GPU's latency: the step's kernels share the GPU with the overlapped update, so
d2h_waitgrew while everything else shrank. A higher priority for the rollout stream (0, -1 or the maximum -3 against the update's 0) made no difference (128.9 / 128.8 / 128.6 ms).Pipelining now pays: the per-half Python work is small enough that the other half's env step hides behind it.
Nsight (just profile-nsys, final defaults, 20 updates): the GPU is busy 63 % of the time
(48 % before). Per update the rollout takes ≈ 112 ms and the overlapped update ≈ 102 ms, so the
update is close to becoming the bottleneck. The main thread is the rollout's critical path: per
half-step ≈ 1.2 ms in policy.inference_batch (mostly waiting for the act graph, 0.3 ms alone and
0.7–0.85 ms beside the update) and 0.44 ms of bookkeeping, while the worker's 1.0 ms env step
overlaps them. Next candidates: fewer kernels in the act graph (values computed once after the
rollout; bf16 opponents), waiting for the actions on the env worker instead of the main thread,
a faster update, and the ≈ 8 ms of serial work at each rollout's end (rollout.finish,
training.gae).
Known limitations (self-play)#
One seed per configuration: the 90-minute main run (1.02 B steps, the paper's order of magnitude of 10⁹) and one-seed, 120 M-step reward, auxiliary-task and action-stack A/B tests. The defaults (learning rate, epochs, pool cadence) are untuned; whether constant lr 2e-4 keeps improving past 1 B steps is untested.
Only 1v1 has been trained.
match-2v2-v1(the paper's setting) runs and is tested, but no 2v2 policy has been trained or evaluated.just train-matchandjust traintake the task as their first argument:just train-match tasks/match-1v1-v1.json --aux-reward-prediction, notjust train-match --aux-reward-prediction.The ball chaser is a weak anchor (see above); ratings are relative to the evaluated checkpoints of one run, and Elo intervals are not reported. In-run ratings with
--eval-prev-spacing geometrichave only been checked on the 120 M-step A/B runs;physlab_rl.leagueis the more direct measure of long-range progress.Blue is always the learner in training and the evaluated side in evaluation (both sides see the same mirrored observation layout).
The pool samples by recency, not by rating; pool snapshots are not rated unless they are also evaluation checkpoints.
Environment state is not checkpointed:
--resumecontinues a run but its episodes restart;--init-checkpointis a warm start of a new run (step counter, RNG streams and episodes restart) that carries the self-play state over (see "Warm starts" above).
Lucy-SKG coverage#
Every technique or design element that Lucy-SKG (arXiv 2305.15801v1,
.external/2305.15801v1.pdf; "§" = main paper, "app." = appendix)
proposes or uses, and what this project does with it. This is the one
authoritative list; the sections above give the details.
Status: implemented (with tests); A/B-tested (implemented and
compared against a variant without it, results linked); partly
(implemented with a documented deviation); not adopted (with the
reason). "Env" files are in crates/rlenv/src/, learner files in
python/physlab_rl/.
Reward design#
| Paper item | Status | Where | Evidence, deviation or reason |
|---|---|---|---|
Potential-based shaping F = γ_F·Φ(s′) − Φ(s) (§3.2, after Ng et al. 1999) | A/B-tested | env reward.rs (potentials, pot:<name> components), task field potentials | Telescoping tested on synthetic states and real 1v1/2v2 episodes (potential_shaping_telescopes_and_zeroes_the_terminal_potential, lucy_potential_shaping_telescopes_over_match_episodes). A/B: ground touch, potential vs dense: no difference (Lucy-SKG A/B experiments); 1v1 matches, the Lucy reward (potentials + KRCs) vs a dense linear reward: score 0.8 vs ball_chaser at 52 M vs 105 M steps, final head to head 0.76 (Reward A/B) |
| γ_F = 1 (app. §1.1) | implemented | task field shaping_gamma (default 1) | Φ(terminal) := 0 on termination is our choice; the paper does not say (see Terminal potentials) |
| R and Φ as weighted linear combinations of components (§3.2) | implemented | task fields rewards, potentials | — |
| Kinesthetic Reward Combination, eq. 2 (§4.4) | A/B-tested | env reward.rs::krc, task utilities.<name>.krc | Sign rule tested (krc_follows_lucy_skg_sign_rule, lucy_krcs_are_negative_unless_every_part_is_positive). A/B only as part of the whole Lucy reward (row above); KRC alone was not isolated |
| Weighted KRC (powers per component, §4.4) | not adopted | — | The paper leaves it as future work |
| Parameterised distance, eq. 3 (dispersion, density; §4.4, Figure 1) | implemented | env reward.rs::parameterised_distance, utilities.<name>.distance_to_ball / ball_goal_distance_difference | Figure 1's 0.549 / 0.811 reproduced (ball_goal_distance_difference_matches_hand_computed_values). As printed, density and dispersion are one parameter (density_and_dispersion_are_interchangeable_in_eq_3_as_printed); implemented as printed |
| Table 1 shaping terms: Ball-to-Goal Distance Difference (2; dispersion 0.6 / 0.4), Ball-to-Goal Velocity (0.8), Save Boost (0.5), Distance-weighted Alignment (0.6, KRC), Offensive Potential (1, KRC) (app. Table 1) | implemented | tasks/match-1v1-v1.json, tasks/match-2v2-v1.json | Independent float64 recomputation pinned in lucy_potential_matches_an_independent_computation; mirror symmetry tested. Interpretations (ball radius subtracted, Align Ball-to-Goal with 0.5/0.5 weights, unspecified goal-distance weights = 1) in the reward table |
| Table 1 events: Goal 10, Concede −3, Shot 1.5, Touch 0.05, Demolish 2, Demolished −2 | partly | env events.rs, match_env.rs | All per agent and tested end to end. Shot is a ballistic approximation (RocketSim has no shot statistic) |
| Touch Ball-to-Goal Acceleration 0.25, replacing Necto's Touch Ball Acceleration (§4.1, §4.4) | implemented | component touch_ball_to_goal_acceleration | Checked against values recomputed from observations (touch_ball_to_goal_acceleration_is_the_ball_to_goal_velocity_change_on_touch_steps) |
| Team spirit τ = 0.3 with the opponent mean subtracted (Table 1, §4.4) | implemented | env match_env.rs::distribute_team_spirit; task match.team_spirit, match.opponent_weight | Hand-computed values and exact zero-sum tested; consequences (τ inert in 1v1, goal worth ±13) in Rewards and team spirit |
| "Save" reward (app. Figure 2 only) | not adopted | — | Not in Table 1, and RocketSim has no save statistic |
| Auxiliary-ablation reward set (Table 1, lower half) | not adopted | — | It belongs to the paper's MLP auxiliary-task ablations, not to Lucy-SKG |
| Reward analysis library: arena contour plots and replay-to-reward parsing (§4.1, app. §4) | not adopted | — | Tooling, not part of training. Our substitutes: hand-computed unit tests for every utility and per-component logging. Replay parsing needs a replay dataset, which we do not have. A contour plotter would help future reward design (open gap) |
| Unweighted per-component episode logging, Blue team only (§5, app. §5) | implemented | train.py (ep_comp/blue/*, ep_comp_weighted/blue/*) | Orange (self-play envs) and weighted sums are logged too; every training env feeds the window, not one "logger" instance |
Observation and actions#
| Paper item | Status | Where | Evidence, deviation or reason |
|---|---|---|---|
| Previous-action stacking, k = 5, query features only (§4.3, app. Table 2) | A/B-tested | task obs.action_stack (default 5); env obs.rs | Ordering and reset tested (action_history_is_most_recent_first_and_zero_initialised, action_stacks_are_per_row_and_restart_with_every_episode). A/B: ground touch k = 5 vs 1: no difference; 1v1 matches k = 5 vs 0: no difference (final 0.980 vs 0.977 against ball_chaser, head to head 0.51 for the unstacked policy; ablations) |
| No boost-pad objects (§4.3) | implemented | task obs.include_boost_pads (default false) | Pads are available as an option (mirrored for Orange, tested) |
| Demolished flag instead of demolition/boost timers (§4.3, app. Table 2) | implemented | env obs.rs (self offset 23, slot offset 20) | Tested for every cross-team pair in 2v2 |
| Table 2 features: relative position and velocity, forward and up vectors, angular velocity, boost, on-ground, has-flip, player/ball flags | partly | env obs.rs, Observation layout | A superset: we add car-frame relative vectors, distances, jump/flip state and game info. The paper reduced the observation to save memory and doubled its game FPS; our simulator is not the bottleneck, so we did not reduce ours |
| Perceiver input triplet: latent query, key/value objects, key padding mask (§4.3, app. §1.2) | partly | env obs.rs | A flat, fixed MLP layout instead; each car slot has a present flag (the padding mask's role) and obs.max_team_size lets one layout serve several team sizes |
| Keyboard-mouse action parser, 5 binary/ternary outputs (app. §1.3) | not adopted | env action.rs | We use the 90-row lookup table of RLGym / Necto's current code / Nexto, so action indices match that ecosystem. The paper's March 2022 Necto parser is not in our references |
| Frame skip 8 (app. §5) | implemented | task tick_skip (default 8) | — |
| Graph observation with a parameterised object-to-object adjacency (app. §7) | not adopted | — | Future work in the paper |
Learner and network#
| Paper item | Status | Where | Evidence, deviation or reason |
|---|---|---|---|
| PPO (§4.2) | implemented | ppo.py | CleanRL-style; tests in python/tests/test_ppo.py, test_selfplay.py |
| Reward-prediction auxiliary task: 20 observations, LSTM 32, FC, 3 sign classes, cross-entropy, λ_RP = 1, on the actor (§4.5, app. §2 item 1) | A/B-tested | ppo.py (--aux-reward-prediction) | Sequences never cross episode starts (tested, also across rollouts and agent rows). A/B: ground touch and aerial-easy: no gain, 2.3–2.8× wall time (Lucy-SKG A/B experiments); 1v1 matches: harmful as configured here: entropy collapse, final head to head 0.002 against the run without it; RP alone reproduces it (ablations). Probable cause: it shares the whole actor trunk, while the paper attaches it to the preprocessing layers only. Off by default; a warning is printed for match tasks |
| RP zero band chosen by rollout analysis to balance the classes (app. §5: ±0.009; ±0.005 in the ablations) | implemented | ppo.calibrate_zero_band, --aux-zero-band auto (match default) | Maximum class entropy over quantiles of |r|, from the first rollout; tested on symmetric and skewed rewards. On match-1v1-v1: 0.0154, classes 1/3 each |
| State-representation auxiliary task: autoencoder 128-32-16 + mirrored decoder + FC 512, batch norm + ReLU, smooth L1, λ_SR = 1, key/value features only, on the actor (§4.5, app. §2 item 2, app. §5) | A/B-tested | ppo.py (--aux-state-representation) | Layer widths, target columns (no action stack) and actor-only gradients tested. A/B on 1v1: SR alone is neutral (0.8 vs ball_chaser at 47 M vs 52 M steps, head to head 0.52–0.54 at 72 M steps), for 1.8× the update time; with RP the run fails because of RP (ablations) |
| Auxiliary heads attached through their own 4-head cross-attention layer (app. §2) | not adopted | — | We have no attention network; the heads attach to the MLP actor trunk, like the paper's MLP-baseline ablations (app. §2, Figure 3b) |
| Necto's perceiver actor and critic: 128-unit preprocessing MLPs, 2 transformer encoder layers with 4-head cross-attention, layer norm (§4.2, app. §2) | not adopted | ppo.py uses separate MLPs (--net small/medium/large) | The paper took this network from Necto to compare with Necto, not as one of its contributions. Our observation has a fixed size, and the batched frozen-opponent inference (selfplay.PolicyBank) stacks MLP weights. Variable team sizes in one network would need it (open gap) |
| MLP baseline: shared 512-unit layers, 3-layer 256-unit actor and critic branches (app. §2) | partly | --net medium (512-512-256) | Same widths, but separate actor and critic networks (no shared layers) |
| Hyperparameters (app. §5): rollout 320 k, minibatch 4000, clip 0.2, Adam lr 1e-4, entropy 0, value coefficient 0.5 | partly | train.py MATCH_DEFAULTS | Clip 0.2, Adam and value coefficient 0.5 as the paper; our rollout 131 k, minibatches of ≈ 15 k, lr 2e-4, entropy 0.01, 3 epochs are untuned choices (the paper does not give its full-run epoch count). The paper's set is --n-steps 80 --num-minibatches 80 --lr 1e-4 --ent-coef 0 (untested) |
| γ from a half-life: 10 s for 2v2, 5 s for the 1v1 ablations (app. §5, §5.1, Table 6) | implemented | ppo.gamma_from_half_life; match defaults | γ = 0.99539 (2v2), 0.99080 (1v1), tested |
| Auxiliary-ablation hyperparameters: 10 epochs, lr 5e-5, entropy 0.01, value coefficient 1 (app. Table 6) | not adopted | — | They belong to the 500 M-step MLP ablations; available as flags |
| Device-alternating PPO: model on the CPU for rollouts, on the GPU for updates (app. §5) | not adopted | — | It saves transfers in RLGym's multi-process setup. Our env is batched in-process and inference is one GPU pass over all agent rows |
Training setup#
| Paper item | Status | Where | Evidence, deviation or reason |
|---|---|---|---|
| Self-play with a shared policy (2v2, 10–20 game instances; app. §5) | implemented | train.py, selfplay.py | Every car is a sample stream; 1v1 trained for 1.02 B steps (Main run); 2v2 supported but not trained yet. We add Necto's frozen past-version opponents (probability 0.2), which the paper does not mention |
| State-setter mixture: replays 0.7, random 0.15, kickoff 0.05, kickoff-like 0.05, goalie 0.05 (app. §5) | partly | env setters.rs, task match.state_setters | Kickoff, kickoff-like, random (Necto BetterRandom-like) and goalie implemented and tested. No replay states: needs a replay dataset and parser (open gap). Our weights 0.2 / 0.2 / 0.4 / 0.1 + aerial 0.1 are a project choice |
| Terminal conditions: 5 min of play, 45 s without a touch, a goal (app. Table 4) | implemented | env match_env.rs; shipped match tasks | Goal terminates; the timeouts truncate (bootstrapped). The 1v1 ablations' 1000-step limit (app. §5.1) was not used: our 1v1 task keeps Table 4 |
| RLGym patched so velocities are not zeroed for velocity rewards (app. §5) | not needed | — | We read RocketSim's state directly |
Evaluation#
| Paper item | Status | Where | Evidence, deviation or reason |
|---|---|---|---|
| Independent single-goal head-to-head matches (300 per pairing; §5.3, app. §6.1) | implemented | evaluate.py, ratings.py, league.py | One held-out kickoff per game (128 in training, 256 standalone), win/draw/loss with Wilson 95 % intervals, Elo-scale ratings and a league. Policies trained on another observation layout can play by feature name (evaluate.adapt_to_layout, tested) |
| "Win %" = share of the series during which Team 1 led the cumulative score (§5.3 Table 1, app. Table 7) | not adopted | — | It depends on the game order and has no confidence interval; we report the score with a Wilson interval |
| Opponents Necto and Nexto, evaluated through RLBot in the real game (§5.3, app. §3) | partly | rlgym_bots.py, evaluate.py, train.py --eval-bots | In the simulator, not through RLBot: their released models play inside our env with ported observation builders (Necto and Nexto), at every in-training evaluation and in just eval-bots. The real-game route isn't built yet |
| Ablation ladder Lucy-SKG / Gamma (no aux) / Beta (Necto reward) / Alpha (no stacking) and Necto-Reward (§5.4) | partly | runs under runs/selfplay/ab/ | Reproduced on 1v1, one seed each: aux tasks on/off, Lucy reward vs a dense linear reward (not Necto's), action stack 5 vs 0. See Reward A/B and Lucy-SKG ablations. Necto itself is not available |
| About 1 B training steps (§5.3) | implemented | Main run | 1.02 B agent steps of 1v1 in 90 minutes on one machine |