Skip to content

ci(smoke): persist every JAX compile in the smoke leg (threshold 0) #221

Closed

Description

@Jammy2211

Overview

The reusable smoke-tests.yml restores and saves a JAX persistent compilation cache but sets no compile-time threshold, so autonerves/jax_wrapper.py's setdefault of JAX_PERSISTENT_CACHE_MIN_COMPILE_TIME_SECS=1 wins and only executables that took over a second are ever written to disk. The JAX smoke scripts are made of many sub-second compiles, so a cache_jax: HIT leg holds 1–4 entries and every run re-pays the compile. /ci_speedup (2026-09-10) set the threshold to 0 per-script for the three slowest entries; this task hoists it to the whole leg, in the one place that owns the cache. Measured locally: 23–31s → 10–18s per script, output byte-identical, at the cost of ~500 entries / ~3 MB of cache artefact per JAX script.

Plan

  • Export JAX_PERSISTENT_CACHE_MIN_COMPILE_TIME_SECS=0 in the runner step's env of smoke-tests.yml, next to JAX_COMPILATION_CACHE_DIR, so every script subprocess inherits it (the runner copies the job env).
  • Record in the step comment why the threshold is 0, what it costs (artefact growth) and how to back it out (delete the line, or bump PYAUTO_CACHE_EPOCH to drop the fat caches).
  • Pin it in tests/test_smoke_tests_wiring.py beside the existing runner-step assertions: the key is present, is exactly "0", and the runner command is still untouched.
  • No epoch bump: the accumulating cache simply gains entries under the same key prefix; restore-time cost is priced after merge from the board's cache_state.json sizes.
  • Out of scope, recorded as follow-ups: the now-redundant per-script overrides in the autolens/autogalaxy profile_smoke.yaml; the same missing threshold on lib-tests.yml's unit leg.
Detailed implementation plan

Affected Repositories

  • PyAutoHeart (primary, only)

Branch Survey

Repository Current Branch Dirty?
./PyAutoHeart main (e08b049) clean

No open PRs on PyAutoHeart; no branch touches smoke-tests.yml. Web session: no task worktree; the branch is pushed from the session clone.

Suggested branch: claude/jax-cache-threshold-smoke-nfobes (the session's designated branch; feature/smoke-jax-cache-threshold on a local checkout)

Work Classification: Library (organ workflow + its wiring test)

Worktree root: n/a — web-github session clone (/home/user/PyAutoHeart)

Implementation Steps

  1. .github/workflows/smoke-tests.yml, step Run the workspace runner (the smoke runner by default): add JAX_PERSISTENT_CACHE_MIN_COMPILE_TIME_SECS: "0" to the step env: immediately after JAX_COMPILATION_CACHE_DIR. Comment: autonerves defaults it to 1s when the cache dir is set; JAX's own default is 1.0s; the smoke scripts compile hundreds of sub-second executables so the 1s regime persists almost nothing (measured 2→513, 4→299, 1→~490 entries on the three slowest scripts, 23–31s → 10–18s); the price is cache-artefact size, and the way out is this one line or an epoch bump. The run: body stays byte-identical (a workspace owns its runner; the wiring test pins that).
  2. tests/test_smoke_tests_wiring.py: extend test_the_runner_step_names_both_cache_dirs_and_is_otherwise_untouched (or add a sibling test_the_runner_persists_every_compile_it_makes) asserting step["env"]["JAX_PERSISTENT_CACHE_MIN_COMPILE_TIME_SECS"] == "0", that it sits in the same step as JAX_COMPILATION_CACHE_DIR, and that python "$RUNNER" $RUNNER_ARGS is still the command. Update the docstring/comment that says "one env key is the whole change".
  3. Leave PYAUTO_CACHE_EPOCH alone: the restore-keys prefix still matches the existing entries, and the next save is the superset. Nothing else in the file moves.
  4. Validate: python3 -m pytest -q -n auto in PyAutoHeart (the wiring test file alone is 46 tests at baseline), then commit, push, open the PR.
  5. PR body carries the pricing note for the human: what to watch on the board ([jax cache hit|miss] per-repo lines and cache_state.json jax_mb/jax_n), the expected order of magnitude (~3 MB × JAX scripts per workspace per Python leg), and the rollback.

Key Files

  • .github/workflows/smoke-tests.yml — the runner step env (line ~591 today, JAX_COMPILATION_CACHE_DIR); cache restore/save at ~380 and ~790
  • tests/test_smoke_tests_wiring.py — runner-step assertions (test_the_runner_step_names_both_cache_dirs_and_is_otherwise_untouched, test_the_runner_command_is_still_byte_identical_and_still_fatal)
  • PyAutoNerves/autonerves/jax_wrapper.py:133 — the setdefault("JAX_PERSISTENT_CACHE_MIN_COMPILE_TIME_SECS", "1") this overrides; a preset value is respected (test_min_compile_time_respects_preset_value)

Follow-ups (not this PR)

  • autolens_workspace_test / autogalaxy_workspace_test profile_smoke.yaml: the three per-script JAX_PERSISTENT_CACHE_MIN_COMPILE_TIME_SECS overrides from /ci_speedup 2026-09-10 become redundant once this is on main (harmless while they stay).
  • lib-tests.yml (the libraries' unit gate) restores the same cache with the same missing threshold; a separate pricing, since its suites are a different compile profile.

Original Prompt

Click to expand starting prompt

Set JAX_PERSISTENT_CACHE_MIN_COMPILE_TIME_SECS=0 for the whole smoke leg

Type: refactor
Target: pyautoheart
Repos:

  • PyAutoHeart
    Themes:
  • performance
  • ci
    Difficulty: small
    Autonomy: supervised
    Priority: high
    Status: formalised
    Consequence: judge
    Review-minutes: 15
    Unattended: ready
    Filed: 2026-09-10

/ci_speedup (2026-09-10) fixed this per-script for the three slowest JAX smoke
entries. The general fix is one line, and it is a human's call because of what
it does to the cache artefact.

The finding

PyAutoHeart's reusable smoke-tests.yml restores/saves .pyauto_jax_cache and
exports JAX_COMPILATION_CACHE_DIR, but sets no compile-time threshold.
JAX's default jax_persistent_cache_min_compile_time_secs is 1.0s
(jax/_src/config.py:1500), and autonerves/jax_wrapper.py setdefaults the
same, so only executables taking longer than a second are ever written to disk.

The JAX smoke scripts are made of many small compiles, so almost nothing is
cached and CI re-pays the compile on every run. This is why the board shows
cache_jax: HIT beside numbers that match a cold run — the cache it hits holds
1–4 entries.

Measured, cache built and read under each regime (local, smoke profile):

script threshold 1.0 (CI today) threshold 0 cache entries
autolens imaging/jax_likelihood/delaunay.py 23.4–27.1s 10.4–10.5s 2 → 513
autolens misc/jax_assertions/delaunay_nn.py 27.2–27.8s 13.0–13.5s 4 → 299
autogalaxy interferometer/jax_likelihood/delaunay_mge.py 30.5–31.3s 18.1–18.4s 1 → ~490

Compile censuses (JAX_LOG_COMPILES=1): 504 executables / 471 cold; 312 / 308
under 1s; 507 with exactly 1 over the threshold.

Why it is not already done

Three per-script overrides shipped instead (autolens + autogalaxy
profile_smoke.yaml, 2026-09-10). Hoisting to defaults: or into
smoke-tests.yml would pay on every jax_likelihood/jax_grad script in
the leg — but it grows the saved cache artefact by roughly 500 entries /
~3 MB per script
, across two workspaces and both python legs. That is a
cache-size and restore-time trade a human should price, not an agent.

Not a correctness risk

The threshold governs which XLA executables are persisted, not the graph,
dtypes, backend or arithmetic. A cache hit returns the executable the compiler
would have built. Printed output was diffed byte-for-byte across both regimes on
all three scripts; RC=0 throughout.

Caveat worth carrying

misc/jax_assertions/delaunay_nn_caps.py is genuinely threshold-insensitive
(17.0s vs 15.1s) because four of its six compiles take 1.048–1.094s — they clear
1.0s by under 10%. A faster runner would silently drop them below the threshold
and the script would regress with no code change. That fragility is an argument
for setting the threshold globally rather than per-script.

Activity

  1. Jammy2211 commented on Sep 10, 2026

    @Jammy2211
    ContributorAuthor

    Shipped

    • PR: ci(smoke): persist every JAX compile in the smoke leg (threshold 0) #222 — merged 30af9f9 (head b1afb3e) into main, 2026-09-10.
    • Change: smoke-tests.yml runner step now exports JAX_PERSISTENT_CACHE_MIN_COMPILE_TIME_SECS: "0" beside JAX_COMPILATION_CACHE_DIR; wiring test test_the_runner_persists_every_compile_it_makes pins it. Runner command untouched; no epoch bump.
    • CI: Heart Tests green on both legs (3.12, 3.13); 966 tests locally.
    • Live from the next smoke run in every workspace calling the workflow @main. What to watch: the board's [jax cache hit|miss] lines and cache_state.json jax_mb / jax_n. Rollback: delete the one line or bump PYAUTO_CACHE_EPOCH.
    • Follow-ups (not filed): the three per-script overrides in the autolens/autogalaxy profile_smoke.yaml are now redundant; lib-tests.yml has the same missing threshold.

    Mind: active/smoke_jax_cache_threshold.md → complete/2026/09/smoke-jax-cache-threshold.md.


    Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions