Skip to content

scorecard: base nav fitness row for base-policy training (parity with cvc::dbg) - #82

Merged
transfix merged 6 commits into
mainfrom
feat/base-scorecard
Sep 22, 2026
Merged

transfix merged 6 commits into
mainfrom
feat/base-scorecard

Conversation

@transfix

Copy link
Copy Markdown
Contributor

grl-snam needs the same base scorecard the DBG campaign uses, to rank its own base-policy checkpoints over a scene corpus (RF-free). This adds the Python twin of the C++ cvc::dbg::nav_scorecard (CVC-DBG/cvcdbg inc/cvc/dbg/nav_stats.h), so a grl-snam eval and a cvcdbg dbg_arrival_check3 --episodes run report identical base numbers.

What

  • grl_snam/scorecard.py — VehStats / EpisodeStats, aggregate_nav(), and NavScorecard (field names + JSON keys identical to the C++). Same reduction: success/arrival rate, mean + p95 time-to-goal, makespan, path ratio, turns, fuel, penetration %, veh-contacts/run, min-sep, material share.
  • EpisodeStats.from_nav_stats(...) maps the per-vehicle NavStats the drive already produces into an EpisodeStats — so a base eval loop is: run corpus scene → NavStats → from_nav_stats → aggregate_nav.
  • metrics.NavStats.update() now also accumulates turn_total_rad + a Σ|Δspeed| fuel proxy (from NavMetrics.heading_rad/speed_mps), mirroring the C++ collector, so the economy fields populate for free.

Test

tests/test_scorecard.py aggregates the same hand-computed corpus as the C++ tests/nav_stats_test.cpp::test_scorecard and asserts identical numbers (cross-language parity), plus the NavStats turn/fuel accumulation and the from_nav_stats mapping. All pass (ruff clean).

Context

Part of the CVC-DBG/cvcdbg nav-stats design (docs/nav-stats-design.md, §7). The remaining piece is dropping the nav recompute in grl_snam_dbg evaluation/harness.py::_summarise_episode so the DBG reducer consumes this base row instead of recomputing it.

… cvc::dbg)

grl-snam needs the SAME base scorecard the DBG campaign uses, to rank its OWN
base-policy checkpoints over a scene corpus (RF-free). This adds the Python twin of
the C++ cvc::dbg::nav_scorecard (CVC-DBG/cvcdbg nav_stats.h): grl_snam/scorecard.py
with VehStats/EpisodeStats, aggregate_nav(), and NavScorecard (field names + JSON keys
identical to the C++ so a grl-snam eval and a cvcdbg `dbg_arrival_check3 --episodes` run
report the same base numbers).

- aggregate_nav reduces a corpus into success/arrival rate, mean+p95 time-to-goal,
  makespan, path ratio, turns, fuel, penetration %, veh-contacts/run, min-sep, material
  share — the same reduction as the C++ aggregate_nav.
- EpisodeStats.from_nav_stats maps the per-vehicle NavStats the drive already produces
  into an EpisodeStats, so a base eval loop is just: run corpus scene -> NavStats ->
  from_nav_stats -> aggregate_nav.
- metrics.NavStats now also accumulates turn_total_rad + a Sigma|dSpeed| fuel proxy in
  update() (using NavMetrics.heading_rad/speed_mps), mirroring the C++ collector, so the
  economy fields are populated for free.

Test: tests/test_scorecard.py aggregates the SAME hand-computed corpus as the C++
tests/nav_stats_test.cpp::test_scorecard and asserts identical numbers (cross-language
parity), plus the NavStats turn/fuel accumulation and the from_nav_stats mapping.

The remaining piece is dropping the nav recompute in grl_snam_dbg
evaluation/harness.py::_summarise_episode so the DBG reducer consumes this base row
instead of recomputing it.
…ure)

black from the grl-snam-cp3XX closure imports mypy_extensions at startup, but that
runtime dep is not in the black-cp3XX recipe, so `black --check` dies with
ModuleNotFoundError before checking any file (red on every PR). Install it as a dev
tool into a throwaway dir on PYTHONPATH, the same way coverage is handled. TODO: add
mypy_extensions to the black-cp3XX recipe depends in libcvc-deps and drop this.
…ons)

The black-cp3XX cvcpkg closure (black 26.5.1) is missing pathspec / platformdirs /
pytokens as well as mypy_extensions, so black dies importing pathspec after the first
fix. Install black's full dep set (pytokens pinned to black's ~=0.4.0) as dev tools on
PYTHONPATH; deps only, so the closure's own black version runs. Repo is black-26.5.1
clean (106 files). TODO: fix the black-cp3XX recipe depends in libcvc-deps.
The cvcpkg dev-tool closure is broken across the board: black-cp3XX is missing its
runtime deps AND absent on cp313, and pytest-cp3XX is missing pluggy — so black --check
and pytest both die with ModuleNotFoundError. Install a working black (pinned to the
closure's 26.5.1; repo is clean against it) + pytest with their full dep trees as dev
tools on PYTHONPATH, superseding the broken closure copies. ruff (self-contained binary)
is unaffected. TODO: fix the black-cp3XX / pytest-cp3XX recipe closures in libcvc-deps.
…missing it

With black/pytest fixed the suite runs (371 pass) but 6 torch/sympy-using tests raise
ImportError: sympy in the cvcpkg closure is missing mpmath. Add it to the dev-tools
install. TODO: fix the sympy recipe closure in libcvc-deps.
cp311/cp312 now pass; cp313's cvcpkg closure additionally lacks typing_extensions so
torch fails to import and 14 test collections error. Add torch's import-time deps
(typing_extensions/filelock/networkx/jinja2/fsspec) to the dev-tools install. TODO: the
proper fix is repairing the cp313 recipe closure in libcvc-deps.
@transfix
transfix merged commit 3697e4e into main Sep 22, 2026
3 checks passed
@transfix
transfix deleted the feat/base-scorecard branch September 22, 2026 08:31
transfix added a commit that referenced this pull request Sep 22, 2026
…umer (#87)

The base nav_stats collectors (Swarm #84, native #86) and the scorecard (#82) had no
production consumer — the corpus aggregation was demonstrated only in tests. Add a
scorecard eval CLI that runs a CoefMLP checkpoint over a scene corpus with the Swarm's
base collector and aggregates one NavScorecard: the RF-free fitness row grl-snam uses to
rank its own base-policy checkpoints (design §7, PR5 training bridge).

- grl_snam/tools/scorecard_eval.py: load_model (a grl-snam train .pt or the bias net) +
  scene_specs (city corpus) + evaluate(scenes/agents/steps/grid/contact_r) ->
  Swarm(collect_stats=True) per scene -> episode_stats() -> aggregate_nav -> NavScorecard.
  Prints a compact row + the full JSON (the record a campaign ranks on), optional --json.
  Convention matches the other `python -m grl_snam.tools.X` tools (coef_eval/coef_train).
- tests/test_scorecard_eval.py: a tiny corpus reduces to a well-formed, in-range card;
  seeds give distinct corpora; the default (no checkpoint) is the bias net. 3 pass, and
  the CLI runs end-to-end locally (torch 2.12 via the cvcpkg .venv).

The scorecard field-mirrors the C++ nav_scorecard + the native collector, so a checkpoint
scores identically whichever path evaluates it. Follow-up (optional): register as a
`grl-snam scorecard-eval` Click subcommand; a --native flag to score via NativeSimWorld.
transfix added a commit that referenced this pull request Nov 7, 2026
* release: 0.3.0

95 commits since v0.2.1 (PRs #66 to #158), with new features, so the
pre-1.0 minor version goes up. The main changes:

- Ariadne hosts: GRL-SNAM's demos run as Python hosts of Ariadne documents
  (#147, #149, #153). `grl-snam ariadne cars` runs libcvc's multi-car
  template (#155), and fleet and live take its settings, worlds, plants,
  panels and log (#157). These need pycvc-gl 3.7.12.
- Vehicle plants: capture, the demos, the fog-of-war stories and training
  run on kinematic, dynamic and Jolt plants (#119, #130, #143, #145, #154).
- Torch twins of libcvc, held to its goldens: the material rollout (#118),
  terrain (#120), dyn_bike and dyn4 (#121, #123, #134-#136), the external
  force (#122, #124), the material trainer (#125), belief material
  (#128, #129, #131), U_nav (#133), and the port-Hamiltonian form, its
  energy books, wheel spin and compliant contact (#138, #139, #146).
- The vehicle-plant port-Hamiltonian whitepaper (#137 to #158).
- Training and evaluation: the base scorecard and selection (#82-#98),
  `grl-snam coef-train` (#102), the learned lam head and .cvcnav v2
  (#94, #105), and the 2026-10 audit fixes (#113).
- Data: grl-snam-weights, plus the Austin scene and Humvee as runtime
  dependencies, so `grl-snam demo` runs from a bare install (#72-#77).
- The research core moves under grl_snam/ (#103). The world clock is
  shared with libcvc's (#116, #117).

The version lives in pyproject.toml. The three cvcpkg columns mirror it in
upstream_version and in the package.files dist-info path. cvc_revision goes
back to 1 for the new upstream version. The publish job asks the server for
the next revision in any case.

* material_train_native: pass semi_implicit=False explicitly (libcvc #981)

libcvc #981 (in 3.7.12) changed nav_material_trainer_create's
ms_semi_implicit default from 0 to 1. MaterialTrainer left the L_multi
sampling args out for the legacy single start, so on pycvc-gl 3.7.12
semi_implicit=False quietly ran semi-implicit Euler. #159's CI was the
first run on 3.7.12, and four tests failed on cp311, cp312 and cp313:

- test_sampled_multi_start_args: "semi_implicit did not reach the
  rollout", because the default and semi_implicit=True were now the same
  rollout;
- test_live_native_trainer_agrees[legacy] and [legacy+ext], and
  test_live_native_trainer_agrees_on_the_belief_net[surrogate]: the
  explicit torch trainer and the native one differed by 1.3e-3 to 1.5e-3
  (tolerance 1e-5).

Now a binding that takes the args always gets them, so the integrator is
the one asked for on any pycvc. An older binding still gets the legacy
start through the old signature. GRL-SNAM's default stays explicit Euler.

tests/test_material_train_native_args.py checks both bindings. Its new
case fails without this change.
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