Skip to content

perf(closed_loop): cache track anchors across evaluations - #341

Merged
HansRobo merged 1 commit into
perf/skip-interp-scan-noobjfrom
perf/interp-anchor-cache
Jul 31, 2026
Merged

perf(closed_loop): cache track anchors across evaluations#341
HansRobo merged 1 commit into
perf/skip-interp-scan-noobjfrom
perf/interp-anchor-cache

Conversation

@HansRobo

@HansRobo HansRobo commented Jul 30, 2026

Copy link
Copy Markdown
Member

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_trajectory and 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_validate from its second call onward. It does not help
run_all_sites_closed_loop.py, which starts a subprocess per (site, mode) and evaluates each
route 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_build timer nests timeline_load_*, so summing all timers exceeds elapsed.

Top of a 3-PR stack that reduces the cost of the same scan from different angles:

Merge 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 with
this one. Independent of #337 — no shared files.

@HansRobo HansRobo changed the title perf: track アンカーを評価をまたいでプロセス内キャッシュする (2回目以降 -23.4%) perf: track アンカーを評価をまたいでプロセス内キャッシュする(2回目以降 -4.7%) Jul 30, 2026
@HansRobo HansRobo changed the title perf: track アンカーを評価をまたいでプロセス内キャッシュする(2回目以降 -4.7%) perf(closed_loop): cache track anchors across evaluations Jul 31, 2026
@HansRobo
HansRobo marked this pull request as draft July 31, 2026 00:08
@HansRobo
HansRobo force-pushed the perf/interp-anchor-cache branch 3 times, most recently from 512f557 to aaf41a5 Compare July 31, 2026 00:55
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
HansRobo force-pushed the perf/interp-anchor-cache branch from aaf41a5 to 460ee3a Compare July 31, 2026 03:45
@HansRobo
HansRobo changed the base branch from tier4-main to perf/skip-interp-scan-noobj July 31, 2026 03:45
@HansRobo
HansRobo marked this pull request as ready for review July 31, 2026 04:11

@kosuke55 kosuke55 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@MasatoSaeki MasatoSaeki left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@HansRobo
HansRobo merged commit f75aa8e into tier4-main Jul 31, 2026
1 check passed
@HansRobo
HansRobo deleted the perf/interp-anchor-cache branch July 31, 2026 06:37
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.

3 participants