Repository navigation
Conversation
curvature_matrix_diag_from and curvature_matrix_off_diag_from ran an eager lax.fori_loop whose body was a fresh closure on every call, so JAX retraced and recompiled every time. HowToLens chapter_3 tutorial_6, the slowest smoke script, makes 118 calls and triggered 132 backend compiles of about 0.1s each. That is below JAX's persistent-cache threshold, so the CI compile cache did not help. Both block loops are now module-level jax.jit kernels with their sizes static, built lazily behind lru_cache, so importing autoarray still never imports JAX. Same-size calls, such as a regularization scan over a fixed mesh, reuse one compile, and under an outer jit the kernel is inlined. The method signatures are unchanged. Array operands are unwrapped with .array, since inverse_variances_native can be an Array2D in the NumPy path. Numerics: old and new outputs are bit-identical for diag 300x300 and 129x129 and off-diag 129x77 with random triplets on a 150x150 grid. Verification: - test_autoarray: 2297 passed, 4 xfailed. New tests check both blocks against a dense A^T W A reference (padded tail exercised) and that repeated same-shape calls add no compile. - autolens_workspace_test JAX parity: fit_imaging_sparse_operator, sparse_operators, imaging/jax_likelihood rectangular, _rtu, _dspl (off-diag), _dspl_rtu, _mge and delaunay all pass. - HowToLens tutorial_6 (py3.12, smoke env plus full_datasets), interleaved A/B: old 93.2s / 90.9s, new 78.2s / 76.1s. Curvature-call time went from 63.4 / 62.3s to 48.3 / 46.1s. All printed log evidences are unchanged. Closes #678 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016nhQ8McPUvDThp9s9JAiZz
Collaborator
Author
|
Closing without merging, at the maintainer's request (2026-11-08). The CI motivation went away: the HowTo chapter-3 tutorials whose repeated curvature calls drove this now run on small datasets in smoke (HowToLens#131, HowToGalaxy#105). The measurements and the bit-identical check stay here and on #678 for reference. The branch is kept, so it can be reopened if wanted. Generated by Claude Code |
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.
Closes #678.
Why
ImagingSparseOperator.curvature_matrix_diag_from/curvature_matrix_off_diag_fromran an eagerlax.fori_loopwhosebodywas a new closure on every call, so JAX retraced and recompiled every time. HowToLens chapter_3tutorial_6_adaptive_reconstruction.py, the slowest smoke script on the Heart board, makes 118 calls and triggered 132 backend compiles of about 0.1s each. That is below JAX's persistent-cache threshold, so the CI compile cache never helped.Change
jax.jitkernels with their sizes static (S/S0/S1, batch, grid and FFT shapes). They are built lazily behindlru_cache, so importing autoarray still never imports JAX. Same-size calls, such as a regularization scan over a fixed mesh, reuse one compile, and under an outerjitthe kernel is inlined..array, becauseinverse_variances_nativecan be anArray2Din the NumPy path.autoarray/preloads/abstract.pyfor why that stays explicit).Verification
Numerics: old and new outputs are bit-identical (diag 300×300 and 129×129, off-diag 129×77, random triplets on a 150×150 grid).
test_autoarray: 2297 passed, 4 xfailed. New tests:
JAX parity (autolens_workspace_test): all pass, including
jit(fit_from)matching NumPy:misc/jax_assertions/fit_imaging_sparse_operator.pyandsparse_operators.py;imaging/jax_likelihood/rectangular,_rtu,_dspl(off-diag),_dspl_rtu,_mgeanddelaunay.Timing: HowToLens tutorial_6 (py3.12, smoke env plus
full_datasets), interleaved A/B on one machine:Every printed log evidence is unchanged (Overlay 15907.596, Hilbert 16432.066, best 16687.265538008818).
Coordination
PyAutoArray is also claimed by the active
magnification-maps-wiringtask (PyAutoLens#818, a branch local to the dev box). The maintainer approved proceeding for this single-file change on 2026-11-08. Merge order is a human/prmcall.Generated by Claude Code