Repository navigation
swarm: collect base NavStats on the vectorized fast path (PR3, first slice) - #84
Merged
Merged
Conversation
…slice) The base navigation stats were collected only on the pure-Python SdfNavigator path; the vectorized Swarm returned raw columns and aggregated nothing (design §1c). Make the Swarm collect per-vehicle base NavStats each episode and reduce to an EpisodeStats via the scorecard we already landed — reusing metrics.NavStats.update + scorecard.from_nav_stats verbatim, with ZERO change to the drive/physics. - Swarm(collect_stats=False, contact_radius_m=0.0): both opt-in and default-off, so the render / thousands-of-agents hot path and every existing parity test stay byte-identical (verified: test_swarm_matches_serial_navigators_to_float32 unchanged). - _collect_step(): the batched twin of SdfNavigator._metrics, folded once per tick after the drive and before parking (so the arriving tick counts once). Re-samples phi post-rollout at the CENTER (clearance_m=(phi-rr)/S, inside_building=phi<0) — NOT the rollout's discarded footprint minclr — for exact parity, and converts every metre field via n2w / /S (closing the normalized-vs-metres trap the C++ /sc seam hit). - episode_stats(): reduces the per-agent NavStats to an EpisodeStats via from_nav_stats, sourcing straights_m/arrival_times_s/veh_contacts/min_sep_m (the fields NavStats does not carry) from the run. - tests: exact parity vs N serial SdfNavigators (float32 tier), the episode_stats -> scorecard reduction, the default-off inert invariant, and pairwise contacts/min-sep. 18 passed locally (torch 2.12 via the cvcpkg .venv). Deferred (design DEFERRALS): the native sim_world path (needs a libcvc-side collector), retiring the squad_record/fog_record manifests, wiring into the eval/training loop, grl_snam_dbg harness.py recompute removal, and fully-vectorized accumulation for large N. A separate known parity gap (out of scope): the Python NavStats.update drops the first path segment while the C++ collector includes it — reconcile in a follow-up.
This was referenced Sep 22, 2026
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.
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.
The base navigation stats were collected only on the pure-Python
SdfNavigatorpath; the vectorizedSwarmreturned raw columns and aggregated nothing (design §1c). This makes theSwarmcollect per-vehicle baseNavStatseach episode and reduce to anEpisodeStatsvia the scorecard we already landed — reusingmetrics.NavStats.update+scorecard.from_nav_statsverbatim, with zero change to the drive/physics.What
Swarm(collect_stats=False, contact_radius_m=0.0)— opt-in, default-off, so the render / thousands-of-agents hot path and every existing parity test stay byte-identical (verified:test_swarm_matches_serial_navigators_to_float32unchanged)._collect_step()— the batched twin ofSdfNavigator._metrics, folded once per tick after the drive and before parking (arriving tick counts once). Re-samplesphipost-rollout at the center (clearance_m=(phi-rr)/S,inside_building=phi<0) — not the rollout's discarded footprintminclr— for exact parity, and converts every metre field vian2w//S(closing the normalized-vs-metres trap the C++/scseam hit).episode_stats()— reduces the per-agentNavStatsto anEpisodeStatsviafrom_nav_stats, sourcingstraights_m/arrival_times_s/veh_contacts/min_sep_mfrom the run.Tests (18 passed locally, torch 2.12 via the cvcpkg
.venv)SdfNavigators (float32 tier, the same drift band the position-parity test accepts) — the collector is a faithful vectorization of_metrics.episode_stats→aggregate_navcorpus reduction._sc_*state, drive path byte-identical,episode_statsraises).Reviewed adversarially across three lenses (parity correctness, test validity, safety/edge-cases); the collector logic was confirmed correct and the test-robustness findings (boundary-tick gating, path-ratio aggregate, penetration ±2) are folded in.
Deferred (design DEFERRALS — not this PR)
Native
sim_worldpath (needs a libcvc-side collector), retiring thesquad_record/fog_recordmanifests, wiring into the eval/training loop, the grl-snam-dbgharness.pyrecompute removal, and fully-vectorized accumulation for large N. Separately, a known parity gap (out of scope): PythonNavStats.updatedrops the first path segment while the C++ collector includes it — reconcile in a follow-up.