Repository navigation
Description
Overview
Census option O1 of the ci-timing-fast-tests epic (timings/unit_import_census_2026-09.md §6), widened by one finding. Library CI is compile-bound: lib-tests.yml restores no JAX and no numba cache (ten of PyAutoArray's 25 slowest CI tests are 24.8 s of a 101 s leg cold-numba, ≤ 0.02 s warm; a persistent JAX cache halves the local suite 43 → 21 s). The census also says smoke-tests.yml "has both since phase 7" — it does not: #211 cached the JAX compile cache and the datasets; NUMBA_CACHE_DIR=/tmp/numba_cache is set and nothing restores or saves it, so every smoke run compiles numba cold (the cold-numba term phase 8 found inflating three user-workspace scripts 4–6×).
One premise checked before planning: numba stamps every cache entry with the source file's (st_mtime, st_size) (numba/core/caching.py, _SourceFileBackedLocatorMixin.get_source_stamp) and stores it under NUMBA_CACHE_DIR/<parentdir>_<sha1(abs dirname)>. A fresh clone or a fresh pip install gives every source file a new mtime, so a restored numba cache would miss every entry unless the mtimes are normalised. The plan sets each .py file's mtime to a function of its content hash, so the stamp becomes a content fingerprint: identical content hits, changed content misses, and the prefix restore-keys fallback is safe.
Plan
- Give
lib-tests.yml'sunittestjob the JAX compile cachesmoke-tests.ymlalready has, plus a numba cache, with the same discipline (restore/save, run-id-suffixed accumulating keys, epoch salt, every new stepcontinue-on-error, pytest command byte-identical apart from env). - Add the numba cache to
smoke-tests.ymlbeside the JAX one, and a "stamp source mtimes from content" step in both workflows so numba's stamps survive a fresh checkout. - Extend the
cache_state.jsonsidecar with anumbasection;lib-tests.ymlwrites one too (jax + numba) intotest-results/so it rides the existingunit-timings-<py>artifact. - Ingest:
smoke_timingsreadsnumba;unit_timingsreads the sidecar and carriescacheon every leg; the record (timings/scripts,timings/unit) stores it; the drift rules never compare two known but different cache states (unit rows compare on the combined jax+numba state); the board brackets it. - Wiring tests for both workflows; a dated correction note appended to the census §5.3.
- Hot-vs-cold is read back from the record after the next daily runs, not claimed here. Cache scoping: a PR-branch save is invisible to
main, so the firstmainrun after merge misses and seeds.
Detailed implementation plan
Affected Repositories
- PyAutoHeart (primary, only)
Branch Survey
| Repository | Current Branch | Dirty? |
|---|---|---|
| ./pyautoheart | main | clean |
Suggested branch: feature/lib-tests-compile-caches
Implementation Steps
.github/workflows/lib-tests.yml(unittestjob only;unittest-nojaxstays unchanged — its wiring test asserts that):- job-level
env: PYAUTO_CACHE_EPOCH: "1". - After the
Installstep:Resolve cache keys(idkeys,continue-on-error):jaxlibversion ornojax;chain= sha256 (16 hex) overgit rev-parse HEADof the repo under test and its deps;pyfull=python -c 'import sys; print(sys.version.split()[0])'(the site-packages path carries the patch version, so it is part of what a numba path hashes to). Restore the JAX compile cache(actions/cache/restore@v4, idjax-cache, path${{ github.workspace }}/.pyauto_jax_cache, keypyauto-jax-${{ runner.os }}-py${{ matrix.python-version }}-jaxlib<jaxlib>-e<epoch>-${{ github.run_id }}, one prefixrestore-keysline without the run id).Restore the numba cache(actions/cache/restore@v4, idnumba-cache, path${{ github.workspace }}/.numba_cache, keypyauto-numba-${{ runner.os }}-py<pyfull>-e<epoch>-${{ github.run_id }}, one prefix fallback). Not keyed on the chain SHAs: the content-stamped mtimes below make a stale entry a miss, never a wrong answer, and a numba version bump invalidates the index on its own.Stamp source mtimes from content(continue-on-error): a Python heredoc that, for every.pyunder each cloned repo dir (${{ steps.map.outputs.deps }}+ repo) and under the installed PyAuto packages'importlib.util.find_spec(<pkg>).submodule_search_locations(no import of the package), setsmtime = 1_000_000_000 + int.from_bytes(sha1(content)[:4], "big")viaos.utime. Roots reach the script throughenv:, never interpolated into the heredoc.Measure the caches before the run(idcache-before) —du -sm+ file count for both paths, as in smoke-tests.Run tests: addJAX_COMPILATION_CACHE_DIR: ${{ github.workspace }}/.pyauto_jax_cacheandNUMBA_CACHE_DIR: ${{ github.workspace }}/.numba_cacheto the step env (add anenv:block; therun:text is unchanged).Record cache state(idcache-state,if: always(),continue-on-error): writes${{ steps.map.outputs.repo }}/test-results/cache_state.jsonwithschema cache_state/1,epoch, andjax+numbasections of the same shape as smoke's (restored_key,hit,exact, sizes/entries before/after); emitsjax_changed/numba_changedoutputs. Every input viaenv:.Save the JAX compile cache/Save the numba cache(actions/cache/save@v4,if: always() && steps.cache-state.outputs.<x>_changed == 'true',continue-on-error, same path/key as the restores). Both save on red too: a compile-cache entry is complete or absent.- The existing upload step already globs
test-results/, so the sidecar rides the artifact with no upload change.
- job-level
.github/workflows/smoke-tests.yml:Restore the numba cache(idnumba-cache, path${{ github.workspace }}/.numba_cache, key as above usingsteps.keys.outputs.pyfull, which theResolve cache keysstep gains) after the dataset restore;Stamp source mtimes from contentover the installed PyAuto packages (site-packages — the smoke install ispip install ./<lib>, not PYTHONPATH) placed before the runner;Measure the caches before the rungains the numba path; the runner step'sNUMBA_CACHE_DIRmoves from/tmp/numba_cacheto${{ github.workspace }}/.numba_cache(Prepare cache dirskeeps making/tmp/matplotlib);Record cache stategains anumbasection andnumba_changed;Save the numba cacheafter the JAX save,if: always() && … numba_changed == 'true'. The runner command stays byte-identical.heart/checks/smoke_timings.py:parse_cache_statereads anumbasection when present →hit/miss, absent →unknown(older sidecars predate it; unlikejax/datasets, absence is not evidence of a miss);cache_viewand_cache_pair(inheart/timings.py) carrynumba.classify_driftunchanged (scripts compare onjax, the compile term for scripts).heart/checks/unit_timings.py:read_downloaded_legalso reads the sidecar viasmoke_timings.read_cache_stateintometa["cache"];build_sidecarlegs carrycache;aggregaterepos[]carriescacheandclassify_test_driftreceivescache=unit_cache_state(cache)where the combined state ishitwhen jax and numba are bothhit,misswhen bothmiss, elseunknown(a mixed or unknown leg compares normally);record_prev_rowsrows carrycache_state. Schema docstrings updated.heart/timings.py:unit_lines_from_rollupwrites"cache": {"jax", "numba"}per line (unknownon both for older rollups);previous_unit_rowshandscache_stateto the drift rule; scripts lines gainnumbain theircacheblock; module docstring /timings/README.mdschema examples updated.heart/dashboard.py: the scripts per-repo bracket becomes[jax cache hit, numba hit]only when numba is known, else exactly[jax cache hit]as today;_unit_suite_detailsgains the same bracket when the leg's cache is known.- Tests: extend
tests/test_lib_tests_wiring.py(epoch salt, key shapes with one prefix fallback each, step order install → keys → restores → stamp → before → tests → record → upload → saves, non-fatality of every new step, pytestrun:text unchanged, env keys named, sidecar schema string matches the check, nojax job unchanged); extendtests/test_smoke_tests_wiring.pyfor the numba restore/save/stamp steps and the runner env; unit tests for thenumbasection parse (present/absent/older sidecar),unit_cache_state, the unit leg carryingcache, the record line carrying it, the unit drift rule refusing two known different states, and both dashboard brackets. Fake names only. timings/unit_import_census_2026-09.md§5.3: append a dated note thatsmoke-tests.ymlcached JAX + datasets only, and that this PR adds the numba cache to both workflows (the census's verdict is a record; do not rewrite it).- Validate:
python3 -m pytest -q -n autoin PyAutoHeart; then a dispatched run is not possible from here (the workflows are consumed@main), so hot-vs-cold lands intimings/unit/<repo>.jsonlandtimings/scripts/<repo>.jsonlwith the daily runs after merge and is read back, not claimed.
Key Files
.github/workflows/lib-tests.yml— the six libraries' reusableTestsgate.github/workflows/smoke-tests.yml— the eleven workspaces' reusable smoke gateheart/checks/smoke_timings.py,heart/checks/unit_timings.py— the two ingestersheart/timings.py— the durable recordheart/dashboard.py— the board rendertests/test_lib_tests_wiring.py,tests/test_smoke_tests_wiring.py,tests/test_unit_timings.py,tests/test_smoke_timings.py,tests/test_timings.py,tests/test_dashboard.pytimings/unit_import_census_2026-09.md,timings/README.md
Original Prompt
Click to expand starting prompt
PyAutoMind draft/feature/pyautoheart/lib_tests_compile_caches_numba_smoke.md (moves to active/ with this issue). Census option O1 widened: JAX + numba caches for lib-tests.yml, a numba cache for smoke-tests.yml, cache state on every unit and script timing row, a dated census correction, honest measurement from the record after merge. Guard: settings and caches only; the closed jax-compile-time arc's verdict is honoured exactly; --xla_cpu_multi_thread_eigen=false stays wherever it is set.
Activity
Jammy2211 commentedon Sep 7, 2026
Shipped
Merged in #217 (
af03c75).lib-tests.ymlnow restores and saves a JAX compile cache and a numba cache withsmoke-tests.yml's discipline;smoke-tests.ymlgains the numba cache it never had; both stamp source mtimes from content so numba's(mtime, size)entry stamps survive a fresh checkout; thecache_state.jsonsidecar carriesnumbaand rides the unit-timings artifact; unit and script timing rows record the cache state and the drift rules never compare two known but different states. Tests 893 → 924.What to watch: the callers consume both workflows
@main, so the firstmainrun of each seeds its caches and the second hits. Hot-vs-cold lands intimings/unit/<repo>.jsonlandtimings/scripts/<repo>.jsonlwith the daily runs; the board brackets it per leg. Mind record:PyAutoMind/complete/2026/09/lib-tests-compile-caches.md.Generated by Claude Code