Skip to content

nav: semi-implicit Euler by default in the geometry rollout, with the integrator A/B - #981

Merged
transfix merged 3 commits into
masterfrom
feat/nav-semi-implicit
Nov 6, 2026
Merged

transfix merged 3 commits into
masterfrom
feat/nav-semi-implicit

Conversation

@transfix

@transfix transfix commented Nov 2, 2026 •

Copy link
Copy Markdown
Owner

What

Semi-implicit (symplectic) Euler is now the default in the navigator's geometry rollout. Explicit Euler stays an option.

  • integrate_surrogate_v2 / multi_start_penalty (L_multi). geom_rollout_params::semi_implicit and multi_start_params::semi_implicit default to true. The velocity updates first, then the position steps with the new velocity. false is explicit Euler, as before.
  • pycvc. nav_material_trainer_create(..., ms_semi_implicit=1) is the new default; 0 is explicit.
  • Every other navigator point-mass path was already semi-implicit, so nothing else changes:
    • the coefficient trainer's surr_step (rollout_kind::surrogate, CPU and CUDA);
    • integrate_surrogate_material (CPU and CUDA);
    • GRL-SNAM's sdf_rollout and surrogate_robust.py.
  • No path uses a wasm-specific integrator. The wasm builds compile the same sources.
  • Goldens. None in libcvc change. gen_nav_geom_multistart_golden.py's cases name their integrator, so they hold. The material-trainer goldens that GRL-SNAM commits record semi_implicit in their config, and its torch twin reads it from there. Regenerated with this branch, they would say 1. GRL-SNAM's committed copies (0) stay valid.

Explicit Euler gains energy at every step of a conservative orbit, by w^2 dt^2 on a harmonic mode. The energy books' sharp check alarms on it (NavPotential.ExplicitEulerRaisesTheAlarm). This is the integrator a reviewer of the GRL-SNAM vehicle pH whitepaper objected to.

The A/B

What it answers. The A/B answers the reviewer's question with evidence: which integrator should the navigator use? It is not about protecting deployed coefficients, because none were ever trained under explicit Euler.

What was trained before. No trained policy depended on explicit Euler:

  • The shipped coefficient policy (grl-snam-weights' coef_sdf.cvcnav, a CoefMLP) was trained through sdf_rollout, which is semi-implicit.
  • Explicit Euler only ever reached the material trainer's L_multi, which has no production caller and no trained weights in either repo.

What the A/B tests instead. The integrator inside the coefficient policy's own training. train_config::point_mass (CPU only) selects it:

  • semi_implicit, the default and unchanged;
  • explicit_euler;
  • a Strang split, dropped in the second commit (below).

NavPlantConvergence.PointMassIntegratorAB (CVC_NAV_INTEGRATOR_AB=1) runs it:

  • Training. 10 training seeds per arm on city_scene(96) (n 128, horizon 28, window 7), the city GRL-SNAM's coef_train.py trains on.
  • Evaluation. Every policy, plus the untrained one, drives Jolt RoboRacers over 20 seeds × 48 agents × 400 ticks.
  • Statistics. Each arm minus semi-implicit, with a paired bootstrap 95% CI that resamples training seeds and evaluation seeds.
Training Arm Reach Building hits / agent Contact s / agent Path m / agent Closest approach m
untrained 52.2% 7.23 0.036 44.0 3.17
lr 5e-5, 150 steps (the P8b gate's) semi-implicit 51.3% 7.36 0.034 43.8 3.17
explicit − semi +1.0 [+0.1, +1.9] +0.32 [+0.21, +0.45] +0.005 [+0.003, +0.008] +2.1 [+1.4, +2.7] +0.02 [+0.01, +0.03]
Strang − semi +0.6 [−0.2, +1.4] +0.00 [−0.12, +0.13] +0.001 [−0.002, +0.003] +0.0 [−0.5, +0.5] +0.01 [−0.01, +0.02]
lr 1e-4, 300 steps semi-implicit 46.1% 5.37 0.052 48.4 3.47
explicit − semi −7.3 [−10.1, −4.7] −2.32 [−3.31, −1.42] −0.006 [−0.009, −0.002] −4.3 [−5.4, −3.2] +0.17 [+0.11, +0.25]
Strang − semi +0.8 [−1.6, +3.3] +0.22 [−0.86, +1.35] +0.003 [−0.001, +0.007] +1.0 [−0.5, +2.4] +0.01 [−0.07, +0.08]
lr 2e-4, 300 steps semi-implicit 22.3% 3.11 0.028 30.8 4.53
explicit − semi −4.7 [−8.4, −1.6] −0.08 [−0.16, +0.01] −0.006 [−0.011, −0.002] −4.6 [−7.8, −2.0] +0.29 [+0.06, +0.55]
Strang − semi +3.0 [−1.0, +7.4] +0.14 [+0.06, +0.21] +0.002 [−0.003, +0.008] +3.1 [−0.2, +6.7] −0.26 [−0.51, −0.01]

The books' sharp check on each arm's point-mass steps, driven by its trained policies:

  • 96 agents × 60 steps per training seed.
  • Only steps outside every barrier are booked (U is exactly the goal spring there), with a cheap bound above 1e-5.
  • The ratio is (r_E − r_hat_E) / bound, with book_step's semi-implicit r_hat_E. Strang keeps its own books: exact damping and clamps, a cross term for the clamp before the drift, and r_hat_E = 0.
Training Arm Steps booked Largest |ratio| Steps alarming (|ratio| > 0.1) Of those, gaining energy
lr 5e-5 semi-implicit 24,657 4.0e-4 0
explicit 25,097 0.996 19.4% 93.5%
Strang 24,821 5.8e-3 0
lr 1e-4 semi-implicit 26,237 1.2e-3 0
explicit 20,475 1.000 15.6% 87.1%
Strang 25,946 5.6e-3 0
lr 2e-4 semi-implicit 12,745 1.2e-3 0
explicit 12,438 1.000 13.9% 78.2%
Strang 13,290 5.5e-3 0

L_multi itself, on nav_geom_rollout_grad_test's penetrating batch: semi-implicit's penalty is 8% lower than explicit's on the legacy start (2.050 against 2.230) and 15% lower on sampled starts (2.453 against 2.898).

Reading it:

  • At the gate's training the arms barely differ. Explicit-trained policies get a point more reach but drive 5% further and hit buildings 4% more.
  • When training moves the policy, explicit Euler costs 4.7 to 7.3 points of reach.
  • The explicit-Euler alarm fires on 14–19% of booked steps, not on every step.
    • Under these policies the point mass is heavily damped and near its terminal velocity, where explicit Euler's gain dt^2 g.(g + gamma v) vanishes.
    • The accelerating steps alarm, and 78–94% of those gained energy.
  • Strang (velocity Verlet with the damping and the speed clamp split out) doesn't earn its place, so the second commit drops it.
    • Its reach never differs from semi-implicit's outside the CI.
    • At lr 2e-4 it hits buildings more and passes closer to them.
    • It costs two force evaluations a step, and its books need their own cross term.
    • b2349e10 keeps the arm, its gradcheck and its books (AB_ARMS=semi,explicit,strang).
  • Two Strang fixes made along the way:
    • Its drift now uses the clamped velocity. A barrier's kick otherwise carried agents any distance in one step: the window loss doubled and the gradient grew 300×.
    • Its books gained the clamp's cross term hdt/2 g.(v_b − v_k), the counterpart of semi-implicit's W_cross.

Nowhere did fully implicit Euler look like what was needed, so it isn't here.

GRL-SNAM

grl_snam/material_train_native.py leaves the integrator out on MaterialTrainer's legacy start (semi_implicit=False with the default frac_range), so with a pycvc carrying this change that start runs semi-implicit natively.

  • The torch twin keeps its explicit default.
  • tests/test_material_train_native.py::test_sampled_multi_start_args asserts loss(semi_implicit=True) != loss() (its semi_one != legacy). That will fail once GRL-SNAM's CI picks up a pycvc release with this change.
  • The fix is GRL-SNAM's: pass the flag whenever the binding takes it, and flip both trainers' default. It isn't in this PR. The guide's integrator note goes to GRL-SNAM separately.

Local

MSVC 14.44 Release, deps from the local cvcpkg prefix. Rerun 2026-11-06 with master (8f468c18) merged in (1ca5b97d), after master's required recipe checks moved to ubuntu-22.04; the C++ suites pass as below, with NavPlant.* at 20/20 (#1011 added one):

Suite Result
nav_geom_rollout_grad_test 16/16
nav_potential_test 17/17
nav_material_train_test 18/18
nav_material_bike_rollout_test 12/12
nav_material_test 33/33
nav_material_ext_test 11/11
nav_coef_train_test (NavCoefTrain.*, NavCoefMlp.*) 27/27
nav_plant_test (NavPlant.*) 19/19
The A/B (NavPlantConvergence.PointMassIntegratorAB) as above
pycvc test_pycvc_nav_train.py 8/8

New tests:

  • NavGeomRolloutGrad.SemiImplicitIsTheDefault
  • NavMaterialTrain.FullChainGradcheckExplicitMultiStart
  • NavCoefTrain.ExplicitEulerGradcheckMatchesFiniteDifference: dir_rel 6.5e-4
  • NavCoefTrain.PointMassIntegratorsDiffer

The CUDA trainer refuses point_mass values other than the default. It isn't built locally; CI covers it.

…or A/B harness

integrate_surrogate_v2 / multi_start_penalty (L_multi) defaulted to
explicit Euler, following the material fork's surrogate_robust.py. Every
other point-mass rollout here was already semi-implicit: GRL-SNAM's own
surrogate_robust.py (since f5a015f) and sdf_rollout,
integrate_surrogate_material (CPU and CUDA), and the coefficient trainer's
surr_step. Explicit Euler gains energy at every step of a conservative orbit
(NavPotential.ExplicitEulerRaisesTheAlarm).

- geom_rollout_params::semi_implicit and multi_start_params::semi_implicit
  default to true; explicit Euler stays an option (false).
- pycvc's nav_material_trainer_create(ms_semi_implicit) defaults to 1.
- Tests that meant the explicit order now say so (legacy(false)); new
  NavGeomRolloutGrad.SemiImplicitIsTheDefault and
  NavMaterialTrain.FullChainGradcheckExplicitMultiStart.
- docs/NAV_MATERIAL.md: the new default.

The A/B: train_config::point_mass (CPU only; the CUDA trainer refuses all
but the default) selects the coefficient trainer's point-mass integrator:
semi_implicit (the default, unchanged), explicit_euler, or strang (velocity
Verlet with the damping and the speed clamp split out). Each has its own
backward and gradcheck. NavPlantConvergence.PointMassIntegratorAB
(CVC_NAV_INTEGRATOR_AB=1) trains on the city under each arm and drives the
policies on Jolt RoboRacers over 20 paired seeds, and books each arm's
point-mass steps under its trained policies.
…ING.md

The A/B (10 training seeds per arm on the city; Jolt RoboRacers over 20
paired seeds; 95% CIs over both): against semi-implicit, a policy trained on
explicit Euler loses 7.3 [4.7, 10.1] points of reach at lr 1e-4 and 4.7
[1.6, 8.4] at 2e-4. At the gate's lr 5e-5 it drives 5% further and hits
buildings 4% more, for +1.0 [+0.1, +1.9] points. On its booked steps the
sharp check alarms 14-19% of the time, and 78-94% of those steps gained
energy. Semi-implicit never alarms (worst ratio 1.2e-3).

The Strang split never differs from semi-implicit in reach outside the CI.
At lr 2e-4 it hits buildings more (+0.14 [+0.06, +0.21]) and comes closer
to them. It costs two force evaluations a step, and its books need a cross
term of their own. It does not earn its place: point_mass_integrator keeps
semi_implicit (the default) and explicit_euler (the A/B's control). The
previous commit has the Strang arm, its gradcheck and its books.
transfix added a commit to CVC-Lab/GRL-SNAM that referenced this pull request Nov 2, 2026
…#981) (#144)

The guide's integrator note said cvc::nav's integrate_surrogate_v2 runs
explicit Euler by default. transfix/libcvc#981 makes semi-implicit Euler the
default there, in multi_start_params and in pycvc's
nav_material_trainer_create(ms_semi_implicit=1); explicit stays an option.

The note now says so, and says what changes for MaterialTrainer here: its
legacy start leaves the integrator argument out, so with such a pycvc it runs
semi-implicit natively while the torch twin keeps its explicit default. Only
this note changes; the guide's PDF is not re-rendered (it was last rendered
on Oct 2, before #115 and #140 edited the Markdown).
@transfix
transfix enabled auto-merge (squash) November 6, 2026 21:03
@transfix
transfix merged commit 45cb239 into master Nov 6, 2026
13 of 28 checks passed
@transfix
transfix deleted the feat/nav-semi-implicit branch November 6, 2026 21:50
transfix added a commit that referenced this pull request Nov 7, 2026
Bumps the project version and every recipe's upstream_version from 3.7.11 to 3.7.12. The v3.7.12 tag on this commit is the first release with the multi-car controller template (pycvc_gl.cars, #1031 #1035 #1040), the hidden-subtree fix in cvcGL (#1037), the discrete-gradient dyn_bike step (#978), semi-implicit Euler by default in the nav rollout (#981), the implicit contact damper (#1004, #1038), and generated_world's roads and water (#1032, #1034).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant