perf(closed_loop): cache track anchors across evaluations - #341
Merged
Conversation
HansRobo
marked this pull request as draft
July 31, 2026 00:08
HansRobo
force-pushed
the
perf/interp-anchor-cache
branch
3 times, most recently
from
July 31, 2026 00:55
512f557 to
aaf41a5
Compare
The per-track interpolation anchors depend only on the recorded route, not on the model or the epoch, yet the training loop rebuilds them at every checkpoint. The scan is ~12% of a rollout. Cached in-process, keyed by route paths and sidecar directory -- the same pattern as the existing per-map caches. 4.15 MiB for a 2-route site, and the number of routes a process sees is the manifest size, so the cache is unbounded. Full workload on one H100: -4.7% from the second evaluation onward. This helps train.py::closed_loop_validate from its second call; it does not help run_all_sites_closed_loop.py, which starts a subprocess per (site, mode). Output identical. 7 tests, mutation-verified.
HansRobo
force-pushed
the
perf/interp-anchor-cache
branch
from
July 31, 2026 03:45
aaf41a5 to
460ee3a
Compare
HansRobo
marked this pull request as ready for review
July 31, 2026 04:11
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.
Problem
The per-track interpolation anchors are a function of the recorded route alone — not of the model
or the epoch. The training loop evaluates the same routes at every checkpoint and rebuilds them
every time. The scan is ~12% of a rollout.
Fix
Cache them in-process, keyed by route paths and sidecar directory. Same pattern as the existing
per-map caches in
eval_cl_trajectoryand the pooled worker.Memory is 4.15 MiB for a 2-route site (9,488 frames, 4,734 tracks), so the cache is unbounded:
the number of routes a process sees is the manifest size, not a function of steps.
Result
Full workload, 1xH100, exclusive node: -4.7% from the second evaluation onward
(difference-in-differences against a no-cache arm, which cancels the per-arm offset).
Output is identical.
Scope
This helps
train.py::closed_loop_validatefrom its second call onward. It does not helprun_all_sites_closed_loop.py, which starts a subprocess per (site, mode) and evaluates eachroute once. This is a per-evaluation stage saving, not "training gets N% faster".
Tests
7 tests, mutation-verified — including that the sidecar path is part of the key (dropping it
fails the test, because the same npz read with a different sidecar yields different track IDs).
Note
The added
interp_buildtimer neststimeline_load_*, so summing all timers exceeds elapsed.Top of a 3-PR stack that reduces the cost of the same scan from different angles:
tier4-mainMerge bottom-up; review this PR's own commit only. Each PR's % figure was measured standalone
against
tier4-main, not as an increment within the stack — #333 and #340 partly overlap withthis one. Independent of #337 — no shared files.