Skip to content

perf(smoke): persist sub-second XLA compiles for interferometer delaunay_mge - #121

Closed
Jammy2211 wants to merge 2 commits into
mainfrom
claude/ci-smoke-test-speed-rzu8bg
Closed

Jammy2211 wants to merge 2 commits into
mainfrom
claude/ci-smoke-test-speed-rzu8bg

Conversation

@Jammy2211

Copy link
Copy Markdown
Collaborator

Found by /ci_speedup auditing the five slowest entries on the CI smoke gate.
This is rank #2 across all of CI (32.2s on py3.13, 6% of that leg).

What changes

config/build/profile_smoke.yaml only — one set: override:

- pattern: "interferometer/jax_likelihood/delaunay_mge.py"
  set:
    JAX_PERSISTENT_CACHE_MIN_COMPILE_TIME_SECS: "0"

The script is not touched. No assertion, tolerance, dataset size or sizing
knob changes. Nothing is skipped, disabled or quarantined.

Why

The script compiles 507 distinct XLA executables. Exactly one — jit(call),
the vmapped likelihood at 2.54s — clears JAX's default
jax_persistent_cache_min_compile_time_secs of 1.0s, which is also what
autonerves/jax_wrapper.py os.environ.setdefault()s, so CI inherits it. The
other 506 compile in 12.9s and are never written to the persistent cache
that PyAutoHeart's smoke-tests.yml restores and saves. So CI re-pays that 12.9s
on every run, which is why the board shows cache_jax: HIT beside a
cold-looking number.

Why the assertions survive

The persistent cache is a memo of XLA compilation keyed on the lowered HLO — a
hit returns the same executable the compiler would otherwise have built, so no
computation changes. Printed output is byte-identical across both regimes and
the script exits RC=0 under the smoke profile. profile_smoke.yaml is
smoke-only, so the release profile is untouched.

Note for review

The general fix is one line in PyAutoHeart's smoke-tests.yml beside
JAX_COMPILATION_CACHE_DIR — every JAX smoke script pays this same tax and none
of them sets the threshold. That is a wider trade (it grows the cached artefact
by roughly 500 entries per script across two workspaces and both python legs),
so it is filed for a human as
draft/refactor/pyautoheart/smoke_jax_cache_threshold.md rather than taken
here. This per-script override does not preclude it.

Two sibling findings from the same audit were filed rather than acted on,
because each would change what a script asserts or costs more than an agent
should price: draft/refactor/autofit/parameterization_prior_count_blowup.md
(AbstractPriorModel.parameterization is O(N·depth) — 7.25s of a 19.4s warm run
on multi_dataset/jax_likelihood/mge_group.py, and 25 of this workspace's 39
smoke entries print a .info) and
draft/refactor/autonerves/config_yaml_parse_cache.md.

🤖 Generated with Claude Code

https://claude.ai/code/session_01ARBtVPNAVEZmdG2iDTqfMk


Generated by Claude Code

Jammy2211 and others added 2 commits September 10, 2026 04:27
…nay_mge

interferometer/jax_likelihood/delaunay_mge.py is the slowest entry in this
workspace on the board (32.2s py3.13 / 31.8s py3.12). It compiles 507 distinct
XLA executables and exactly one -- the vmapped likelihood, 2.54s -- clears
JAX's default jax_persistent_cache_min_compile_time_secs of 1.0s. The other 506
compile in ~12.9s and are never written to JAX_COMPILATION_CACHE_DIR, so CI
re-pays them every run. The board's cache_jax: HIT is a hit on a one-entry
cache.

Setting the threshold to 0 for this script lets them be persisted and reloaded.
Measured locally, smoke profile, numba installed, cache built and read under
each regime:

  threshold 1.0 (CI today)  30.5 / 31.3s   cache 1 entry, 324K
  threshold 0   (this)      18.1 / 18.3 / 18.4s   cache ~490-729 entries
  first run against an empty cache  34.0s (+1.2s one-off to write the entries)

The CI regime reproduces the board closely (30.5-31.3s local vs 32.2s), so the
~12.5s saving is real rather than a local artefact.

The script is not touched, so the release profile is unaffected and every
assertion is untouched: this changes which XLA executables are persisted, not
the graph, dtypes, backend or arithmetic. Output byte-identical either side
(NumPy -3320.1587601763285, JIT -3320.158760510604), RC=0 throughout, and
RC=0 under PROFILE=release.

Verified with PyAutoHands' own tooling: env_config.build_env_for_script
resolves the override for this script alone (multi_dataset/ and
imaging/visualization/ correctly do not match), and validate_env_profiles
reports 0 errors, including under --strict-declarations.

Note: measuring this script at all requires numba; without it
autoarray/numba_util.py falls back to pure Python and the script takes 96.8s
instead of 18.3s, 76s of it interpreting cholesky_funcs._solve_upper_transposed_buffer.

The same tax is paid by every jax_likelihood/jax_grad script in the leg, so
the general fix is one line in defaults: or in PyAutoHeart's smoke-tests.yml
beside the cache step; that is left as a human's call.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ARBtVPNAVEZmdG2iDTqfMk
Replaces a drafting header ("A2 — scripts/interferometer/...") with a plain
description of what the override does. Comment only -- the pattern, key and
value are unchanged.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ARBtVPNAVEZmdG2iDTqfMk

Copy link
Copy Markdown
Collaborator Author

Superseded by PyAutoLabs/PyAutoHeart#222 (merged 2026-09-10): smoke-tests.yml now exports JAX_PERSISTENT_CACHE_MIN_COMPILE_TIME_SECS: "0" for every script in the smoke leg, which this per-script override was the in-lane form of. The measurements and reasoning in this diff are carried in that PR and in PyAutoMind/complete/2026/09/smoke-jax-cache-threshold.md. Closing without merge; nothing else in the diff.


Generated by Claude Code

@Jammy2211 Jammy2211 closed this Sep 10, 2026
@Jammy2211
Jammy2211 deleted the claude/ci-smoke-test-speed-rzu8bg branch November 25, 2026 20:20
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.

1 participant