Skip to content

nav: a golden for the per-step energy books, for GRL-SNAM's torch twin - #849

Merged
transfix merged 1 commit into
masterfrom
feat/nav-energy-books-golden
Oct 28, 2026
Merged

transfix merged 1 commit into
masterfrom
feat/nav-energy-books-golden

Conversation

@transfix

Copy link
Copy Markdown
Owner

Adds NavPotential.BooksGolden and src/cvc/tests/data/nav_energy_books_golden.json. This is the golden that GRL-SNAM's torch twin of the per-step energy books (#832) is held to: book_step, energy_residual_bound, and the books integrate_surrogate_material fills.

It is a separate file, so nav_potential_golden.json and GRL-SNAM's test_nav_potential_parity.py are untouched. CVC_NAV_ENERGY_BOOKS_GOLDEN_WRITE=1 rewrites it.

Sections:

  • bound: energy_residual_bound on a sweep, with mass and kappa_H varied (double).
  • clamp: a diff::surr_step rollout whose vmax clamp cuts every step, on ClampWorkClosesTheBooks' wall. Each step is booked as that test books it. The golden stores the states, book_step's arguments and its books (double), so the twin's book_step can be checked exactly.
  • sharp: the material surrogate with a port force and the sharp check, covering every book rollout_energy has. Agent 2 stops early, so its frozen steps book zero.
  • unlogged: the same rollout at dt 0.002 under a strong port force. With W_port booked, every step closes within the bound; with it left out, every step alarms.

The material sections use a linear patch, whose gradient channels are its values' gradients. On NavPotential.Golden's curved patch, each step books the gap between the force and -grad U, which is work of order dt. At dt 0.002 that gap alone nearly fills the bound (|r_E|/bound 0.9965), so it would hide the integrator's own residual. NavPotential.Golden's surrogate setup moves into a shared fixture; its golden is unchanged and still passes.

Tolerance: 1e-6 relative.

  • States, potentials and kinetic energies: relative to max(1, |x|), as NavPotential.Golden.
  • Books: relative to max(|x|, the step's bound).

Measured (MSVC 14.44 Release; nav_potential_test 16 -> 17 tests, all pass):

  • clamp: |r_E|/bound <= 0.375 and |r_E - r_hat_E|/bound <= 1.1e-3, with W_clamp > 0 at every step;
  • sharp (dt 0.05): |r_E|/bound <= 0.48 and |r_E - r_hat_E|/bound <= 1.0e-2;
  • unlogged: |r_E|/bound <= 0.35 when booked; smallest |r_E + W_port|/bound is 6.6.

NavPotential.BooksGolden writes or checks tests/data/nav_energy_books_golden.json
(CVC_NAV_ENERGY_BOOKS_GOLDEN_WRITE=1), the values GRL-SNAM's torch twin of
book_step, energy_residual_bound and the material surrogate's books is held to:

- bound: energy_residual_bound on a sweep, mass and kappa_H included (double).
- clamp: a diff::surr_step rollout whose vmax clamp cuts every step, booked per
  step as ClampWorkClosesTheBooks books it: the states, book_step's arguments
  and its books (double).
- sharp: the material surrogate with a port force and the sharp check, every
  book rollout_energy has; agent 2 stops early, so its frozen steps book zero.
- unlogged: the same rollout at dt 0.002 under a strong port force: booked,
  every step closes within the bound; left out, every step alarms.

The material sections use a linear patch, whose gradient channels are its
values' gradients. On NavPotential.Golden's curved patch a step books the gap
between the force and -grad U, work of order dt, which nearly fills the bound
at dt 0.002. NavPotential.Golden's surrogate setup moves into a shared fixture,
and its golden is unchanged.

The build reproduces the file to 1e-6 relative: of max(1, |x|) for states,
potentials and kinetic energies (as NavPotential.Golden), and of max(|x|, the
step's bound) for the books. Measured: clamp |r_E - r_hat_E|/bound <= 1.1e-3;
sharp <= 1.0e-2 at dt 0.05; unlogged, smallest |r_E + W_port|/bound 6.6.
@transfix
transfix enabled auto-merge (squash) October 28, 2026 00:30
@transfix
transfix merged commit 6918707 into master Oct 28, 2026
17 of 24 checks passed
transfix added a commit to CVC-Lab/GRL-SNAM that referenced this pull request Oct 28, 2026
…he sharp check (#139)

The torch twin of libcvc's per-step energy books for the navigator's
point-mass surrogate (the white paper's Eq. 38; transfix/libcvc#832), held
to libcvc's nav_energy_books_golden.json (transfix/libcvc#849).

- nav_potential.book_step (StepBooks) and energy_residual_bound: libcvc's
  book_step, with the cheap bound and, given vHv, the sharp check r_hat_E.
- nav_potential.material_energy: U and the material surrogate's conservative
  force in any dtype, libcvc's detail::material_energy<double>.
- integrate_surrogate_material: energy={"books": True} (or "sharp": True)
  also fills kinetic, w_damp, w_port, w_clamp, w_cross, residual, bound
  (and residual_sharp), float64 and detached, booked from the rollout's
  state in float64 as libcvc does. The rollout's outputs are unchanged.

tests/test_nav_energy_books_parity.py: book_step and the bound bit for bit
on libcvc's arguments (DOUBLE tier); the clamped surr_step rollout's books
to 2e-5 of the step's bound (measured 1.1e-6), and the material surrogate's
to 1e-5 (measured 8.3e-8) (FLOAT tier); the unlogged port raises the alarm
at every step, as in libcvc; r_E is second order, and the sharp check meets
r_E on a quadratic potential.
transfix added a commit that referenced this pull request Oct 28, 2026
The project version and the cvcpkg recipe family move to 3.7.2. Every recipe is at cvc_revision 1
already, so none restarts.

3.7.2 carries the dynamic plants on the terrain and in a Jolt world, and the four-wheel plant
(#869): --plant dynamic and dynamic4w drive the ground, collide with the
buildings and each other, and book the collisions. It also carries dyn_4w's port-Hamiltonian form
(#850), dyn_bike's wheel-frame front slip (#852), the books goldens for GRL-SNAM's twins (#848,
#849), pycvc's drive telemetry (#857) and keep-alives (#864), the macOS SDK's openssl (#846), and
the state_exec scheduler and evaluator work (#842, #843, #844, #861, #863).
@transfix
transfix deleted the feat/nav-energy-books-golden branch October 29, 2026 20:52
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