Repository navigation
nav: train through the dynamic vehicle, with checkpoint selection on Jolt reach (P8b) - #717
Merged
Merged
Conversation
…the dynamic vehicle (P8b) coef_trainer drives bike_control into dyn_plant (dyn_bike_step / dyn_bike_step_bwd) when train_config::rollout is dynamic. loss_and_grad carries the vehicle's further state (vy, r, delta, a) through optional x / x_out, and train() keeps it across windows. train_config::dyn is the vehicle; a dynamic run without one whose wheelbase is veh_L throws. nav_plant::dyn_bike_params_at(desc, wheelbase) builds it from a vehicle_desc: the trainer's city reads as a RoboRacer at about 0.108 normalized units per metre. The CUDA trainer refuses the dynamic rollout for now. Gradcheck dir_rel 2.3e-2; the horizon loss falls; a policy trained at 5e-5 keeps 71.9% reach; an lr sweep is in docs/NAV_TRAINING.md.
…ynamic vehicle (P8b) integrate_dynamic_material drives integrate_bicycle_material's controller (force law, pure pursuit, governors, d_cap) into diff::dyn_plant in place of the kinematic update; arc length and cumulative risk follow the dynamic path. Its VJP joins the plant's dual-number VJP to the bicycle's hand-written controller reverse, which gains a controller-only mode (the kinematic default adds 0, so its sums are unchanged). multi_start_penalty_dynamic runs L_multi on it. material_loss_config::dynamic is the vehicle; L_vel compares the rear axle's world velocity. Gradchecks: rollout VJP on 40 coefficients (worst 1.5e-2, directional 3e-6 at eps 1e-3), L_multi worst 4.8e-4, the full loss-to-weights chain dir_rel 7.0e-4 over 64 weights.
…icy against the point-mass one NavPlantConvergence.DynamicTrainedPolicyAgainstPointMassOnJolt trains both alike on the city and drives each on Jolt RoboRacers (the city as a RoboRacer's, its blocks static boxes) over 20 paired seeds, with a paired-bootstrap 95% CI. At lr 2e-4 / 300 steps the dynamic-trained policy reaches 44.0% against 35.0% (+9.0, CI [+6.7, +11.4]), but both fall below the untrained seed's 51.7%; at 5e-5 / 150 they tie (+0.4, CI [-1.8, +2.8]). Recorded in NAV_TRAINING.md and the roadmap.
coef_trainer::train(scene, verbose, fitness) scores the untrained policy, every train_config::checkpoint_every steps and the last, and ends on the best, so it never ends below where it started by that score (checkpoints(), selected_step()). cvc::physics::reach_on_plant (nav_eval.h) is that score on the physics plant: a coef_train scene's blocks as static boxes, read at a vehicle's scale, `agents` vehicles driven through a nav_plant per seed. The P8b gate test now uses it. It repeats exactly (single-threaded, cross-platform determinism) but is chaotic: passing veh_L's 0.035f instead of 0.035 moves a seed's reach by up to 0.1, so the tests pin the exact scale. NavPlantConvergence.CheckpointSelectionOnJoltReach: at lr 2e-4 / 300 steps, selected every 30 steps on 8 validation seeds, held out over the gate's 20 seeds the dynamic-trained policy reaches 52.7% and the point-mass-trained one 50.1% (+2.6, CI [+0.3, +4.7]); the seed 51.7% (dynamic - seed +1.0, CI [-1.2, +3.4]). With 4 validation seeds: +3.8 [+0.9, +6.7] and +1.3 [-0.6, +3.3]. Recorded in NAV_TRAINING.md and the roadmap.
…oint sweep (P8b)
plant_reach_options::threads (0 = the hardware's threads) runs seeds at once, each in its own
world, sim_world and plant with its agents on the worker's thread. NavPlant.
ReachOnPlantIsRepeatable checks that parallel scores equal serial ones; 8 validation seeds now
score in about the time of one, so a 31-checkpoint selection run takes about 9 minutes.
The next P8b lever, lower peak rates with denser checkpoints (8 validation seeds, 31
checkpoints, held out on the gate's 20 seeds; the seed reaches 51.7%):
1e-4 / 300 steps / every 10: dynamic 53.5%, point mass 51.1%; +2.4 [+0.3, +4.4], dynamic -
seed +1.9 [-0.8, +4.4]
5e-5 / 600 / every 20: 50.5% vs 48.9%; +1.7 [-1.2, +4.5], -1.1 [-4.0, +1.6]
2e-4 / 150 / every 5: 51.7% vs 50.5%; +1.1 [-0.8, +3.0], +0.0 [-1.9, +2.1]
No setting beats the seed outside the CI. At the lower rates validation reach stays flat and
denser checkpoints mostly add selection noise, so the next levers act on the signal: more
validation seeds, or Jolt reach as the training signal. Recorded in NAV_TRAINING.md and the
roadmap.
transfix
force-pushed
the
feat/dyn-rollout
branch
from
October 19, 2026 15:21
4f73c8a to
b881988
Compare
…s (fixes macOS) DynBike.KinematicLimitFollowsBikeStep failed on macOS (#717's CI, and master since #714): its 32 routes come from sample_starts_goals, whose uniform_int_distribution differs by standard library, and under the controller (dyn_bike_step) the worst agent parted by 1.3 against 0.017 here. Over 40 sets of routes, 0 to 11 of 32 agents part by more than 0.2 rr in closed loop (the controller amplifies the plant's small differences along some routes), while the median gap is at most 0.0081 and the median end-distance difference at most 0.41%. The closed loop is now gated by those medians (0.1 rr, 2%) and its worst agent reported; the open-loop gate, at most 0.0151 over the 40 sets, moves from 0.1 rr to 0.2 rr.
StateSessionStatusTest.StatusReportsPumpCycles joined a session with pump_interval_ms = 5, slept a fixed 50ms and then expected pump_cycles > 0. On 2026-10-19 it failed on recipe / windows-2022 / Release of #717 (job 118144550758), a PR that does not touch state: state_session_status_test.cpp(53): error: Expected: (s.pump_cycles) > (0u), actual: 0 vs 0 [ FAILED ] StateSessionStatusTest.StatusReportsPumpCycles (1002 ms) The assertion fired ~220ms after [ RUN ], and stop() then took another ~560ms to join the pump thread: under ctest -j load the pump thread had not finished its first cycle. Nothing is wrong with the pump; the window is just too short to guarantee one scheduling slice. Poll session->status().pump_cycles until it is > 0, with a 5s steady_clock deadline, the same remedy cc45c55 applied to ConflictAutoPublish. The common case still leaves within a few milliseconds, and a timeout now says the pump completed no cycle in 5s. The file's other tests do not depend on wall-clock timing: StatusReportsRunning and the accessor tests read state set before join() returns, StatusReportsLocalSequence drives pump_all() itself, WaitForDataTimeoutReturns asserts nothing about the result, and ConflictAutoPublish already polls (cc45c55). Verified on Windows (MSVC 19.38, Release, deps from a local cvcpkg prefix), on a box already at 100% CPU from other work, running 16 copies of the test binary at once: * old test: 1 failure in 16 x 50 runs, the same "actual: 0 vs 0"; * new test: 0 failures in 16 x 50 + 16 x 150 runs (3200); median 30ms, p99 114ms, max 419ms per test including stop(); * full suite 8/8, and ctest -R StateSessionStatusTest -j 8 --repeat until-fail:5 passes. (cherry picked from commit 4933281)
This was referenced Oct 19, 2026
transfix
added a commit
that referenced
this pull request
Nov 11, 2026
…every standard library (#1118) * nav: scatter_free picks the same cells on every standard library NavSimWorldAgents.EachPolicyDrivesItsOwnAgents failed on package-macos with pd.pos[2] == po.pos[2] == -5.26315784. scatter_free drew its cells with std::uniform_int_distribution, whose mapping each standard library picks for itself. libstdc++ and MSVC both use Lemire's multiply-and-reject on a 32-bit draw, so they agree. libc++ masks the low ceil(log2 n) bits and rejects. With seed 11, libc++ gave agent 1 a start and a goal in one column (45), so it drove straight along -y and its x stayed at -5.2631578 under both policies. Only y differed. #1095 loosened the check to the whole world's positions, which hid the different scene rather than fixing it. - sim_world.cpp: pick_below writes out Lemire's mapping, so a seed is one scene on every platform: the one Linux and Windows always drew. Their worlds are unchanged bit for bit; macOS and wasm (libc++) now draw them too. The colours stay std::uniform_real_distribution: it takes one draw on each library, so the picks after it stay in step. - nav_sim_world_test: ScatterFreePicksTheSameCellsOnEveryStandardLibrary pins seed 11's cells on an open field. - nav_sim_world_agents_test: the policies must drive agents 1 and 3 to different points, not merely to different whole worlds. A point, not one coordinate, since an agent driving along a column keeps its x. * nav: sample_starts_goals and from_occupancy's groups are the same on every standard library The rest of cvc::nav's seeded draws, written out the way #1114 wrote out scatter_free's. - detail/seeded_draw.h: pick_below (#1114's Lemire multiply and reject, moved out of sim_world.cpp and shared) and seeded_shuffle. - training_scene::sample_starts_goals: its three picks (goals anywhere, starts with a clearance, local goals) are pick_below. libstdc++ and MSVC map a 32-bit draw this way already, so Linux and Windows draw the routes they always drew; macOS and wasm (libc++, low bits and reject) now draw them too. - sim_world::from_occupancy, clustered: the k-means centres come from seeded_shuffle instead of std::shuffle. The three libraries all shuffle differently: libstdc++ takes two swaps from one Lemire draw while n * n fits in 32 bits, MSVC's std::shuffle maps each draw by its remainder (its older _Rng_from_urng, not uniform_int_distribution's Lemire), and libc++ swaps from the other end. seeded_shuffle is libstdc++'s written out, so Linux keeps its groups and Windows, macOS and wasm change: on the pinned field (twelve agents, three groups) MSVC's shuffle gave 34 of 40 seeds other groups. Checked against the libraries themselves with one program built by MSVC 19.44, g++ 13.2 (libstdc++) and em++ 21 (libc++, run under node): pick_below matches uniform_int_distribution<int> on libstdc++ and MSVC for every case (230000 picks, n from 1 to INT_MAX, the draw streams in step), seeded_shuffle matches libstdc++'s std::shuffle for every case (n up to 70001), and the written-out draws hash the same under all three. Tests: - NavCoefTrain.StartsAndGoalsAreTheSameOnEveryStandardLibrary pins seed 7's cells in each of the three ways on a 40 x 30 field with a wall. libc++'s own draw began {19, 4, 31, 13}. The clearance and the goal range sit at least 0.019 from every cell's square-root distance, so rounding moves no cell in or out. - NavSimWorld.ClusteredGroupsAreTheSameOnEveryStandardLibrary pins seed 20's groups of twelve; each agent is at least 15% nearer (squared) its own centre than the next at every step. - NavSimWorld.SeededShuffleIsTheSameOnEveryStandardLibrary pins odd, even and past-paired lengths. The gates loosened because macOS drew other routes: - DynBike.KinematicLimitFollowsBikeStep: the open-loop gap is gated at 0.1 rr again (#717 had moved it to 0.2 rr because each library drew other routes). It is 0.0107 on these routes, the same with the test compiled /fp:contract /arch:AVX2, which contracts its arithmetic to about 1260 fused multiply-adds as clang does on arm64. The closed-loop worst agent stays reported, not gated: on these same routes it parts by 1.80 normally and by 0.017 with the fused arithmetic, while the medians barely move (0.00045 / 0.17% against 0.00032 / 0.13%). - DiffExtForce / DiffExtRollout and the four-wheel ext checks keep their switch filter and quotas: the shared draws still put one to five cases on a switch, and the quotas were set over 100 swept seeds, not per library. Their comments, and NAV_TRAINING.md, no longer say the draws differ by library. Windows (MSVC, RelWithDebInfo): nav_sim_world 7/7, nav_sim_world_agents 17/17, nav_coef_train 31/31, nav_dyn_bike 23/23, nav_dyn_4w 23/23, nav_potential 17/17, nav 64/64. Every pre-existing test's output is identical to the base commit's, number for number. * ci: room_calls.cpp's process-wide objects on the writable-data scan's allowlist #1122 (room-call) added src/cvc/ariadne/conference/room_calls.cpp to libcvc. Its CI ran on a base from before #1107, so the scan never saw it, and every PR based on master now fails the package-linux scan step on its seven objects: the per-app client map clients() and its mutex, the once-per-app list in register_room_call_intrinsics and its mutex, and the message counter g_messages (like room_lane.cpp's g_lane_messages).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
P8b of the vehicle-physics plan: both trainers train through the dynamic vehicle from P8a (#714), with its gate on the Jolt plant and checkpoint selection on Jolt reach (Joe: "start P8b, rollout_kind::dynamic in the trainers", then "start checkpoint selection on Jolt reach for P8b", then "start the next P8b lever, lower lr with denser checkpoints").
coef_train:
rollout_kind::dynamicbike_controldrivesdyn_plant(dyn_bike_step/dyn_bike_step_bwd) whentrain_config::rolloutisdynamic.loss_and_gradcarries the vehicle's further state(vy, r, delta, a)through optionalx/x_out, andtrain()keeps it across windows.train_config::dynis the vehicle. A dynamic run without one whose wheelbase isveh_Lthrows.nav_plant::dyn_bike_params_at(desc, wheelbase)builds it from avehicle_desc: the trainer's city reads as a RoboRacer at about 0.108 normalized units per metre.material_train:
material_integrator::dynamicintegrate_dynamic_materialdrives the bicycle material controller (force law, pure pursuit, governors,d_cap) intodyn_plantin place of the kinematic update. Arc length and cumulative risk follow the dynamic path.multi_start_penalty_dynamicrunsL_multion it.L_velcompares the rear axle's world velocity.L_multiworst 4.8e-4, the full loss-to-weights chain dir_rel 7.0e-4 over 64 weights.Checkpoint selection on the physics plant
coef_trainer::train(scene, verbose, fitness)scores the untrained policy, everytrain_config::checkpoint_everysteps and the last, and ends on the best, so it never ends below where it started by that score (checkpoints(),selected_step()).cvc::physics::reach_on_plant(inc/cvc/physics/nav_eval.h, needs Jolt) is that score: the scene's blocks as static boxes, read at a vehicle's scale,agentsvehicles driven through anav_plantper seed, seeds in parallel.NavPlant.ReachOnPlantIsRepeatable), but it is chaotic: passing veh_L's0.035finstead of0.035moves a seed's reach by up to 0.1. The tests pin the exact scale and validate on 8 seeds.The gate (Jolt RoboRacers in the city, 20 held-out paired seeds x 48 agents x 400 ticks, paired bootstrap)
Two policies trained alike, one on the point-mass surrogate and one on the dynamic vehicle (a RoboRacer at about 0.108 per metre). The untrained seed reaches 51.7%.
docs/NAV_TRAINING.md.Local (Windows, cvcpkg prefix): 361/361 nav/physics/plant ctest cases outside the heavy suites. The heavy runs are
NavPlantConvergence.DynamicTrainedPolicyAgainstPointMassOnJoltandNavPlantConvergence.CheckpointSelectionOnJoltReach(P8B_GATE_*,P8B_SELECT_*override them).Not in this PR