Skip to content

perf(galaxy): skip the second deflection call for the over-sampled grid at sub-size 1 (PyAutoArray#514) - #595

Merged
Jammy2211 merged 1 commit into
mainfrom
feature/numpy-deflections-p1
Sep 2, 2026
Merged

Jammy2211 merged 1 commit into
mainfrom
feature/numpy-deflections-p1

Conversation

@Jammy2211

Copy link
Copy Markdown
Collaborator

Summary

Phase 1 of the numpy-deflections-cpu epic (PyAutoArray#514). Galaxy.traced_grid_2d_from called deflections_yx_2d_from twice on a Grid2D: once for the grid and once for grid.over_sampled. At a uniform over-sample size of 1 the over-sampled grid is the slim grid in the same order, so the second call doubled the deflection cost for a bit-identical result. Same guard as the companion PyAutoLens tracer change: the over-sample size is host numpy, so the branch is static at JAX trace time; sub-size > 1 is unchanged.

API Changes

None — internal changes only.
See full details below.

Test Plan

  • test_autogalaxy: 1158 passed (new tests in test_autogalaxy/galaxy/test_galaxy.py: traced .over_sampled equals the separately traced over-sampled grid and differs from the untraced one, at sub-size 1 and 4; at sub-size 1 it equals the traced slim grid exactly).
  • autolens_profiling lens cells hst: deflection pins PASSED (rtol 1e-6).
  • CI green.
Full API Changes (for automation & release notes)

Changed Behaviour

  • autogalaxy.galaxy.galaxy.Galaxy.traced_grid_2d_from — when every entry of grid.over_sample_size is 1, the over-sampled traced grid is a Grid2DIrregular copy of the traced slim grid instead of a second deflections_yx_2d_from call (bit-identical values).

Generated by the PyAutoLabs agent workflow. Companion PRs: PyAutoArray (to_grid / Grid2D.over_sampled), PyAutoLens (Tracer.traced_grid_2d_list_from), autolens_profiling (scripts/lens/ measurement package).

Companion: PyAutoLabs/PyAutoArray#516

…id at sub-size 1 (PyAutoArray#514)

`Galaxy.traced_grid_2d_from` called `deflections_yx_2d_from` twice — once for
the slim grid and once for `grid.over_sampled`. When the grid's over-sampler is
uniform at sub-size 1 — the pixelization grid in every CPU likelihood cell —
`grid.over_sampled` is the slim grid in the same order, so the second call
recomputes a bit-identical answer at full cost and is now reused instead.

The sub-size is host numpy, so the guard is a static Python bool and the branch
is resolved at JAX trace time rather than becoming a traced `cond`.

The equivalent guard in `Tracer.traced_grid_2d_list_from` (PyAutoLens) measures
the tracer/raw deflection ratio on hst dropping from 2.52x to 1.41x for
Isothermal and 1.94x to 0.88x for PowerLaw, with every pinned value still
PASSING — the change is bit-identical.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HWjPT94MPbEHT45kJmDpDh
@Jammy2211 Jammy2211 added the pending-release PR queued for the next release build label Sep 2, 2026
@Jammy2211
Jammy2211 merged commit e76c062 into main Sep 2, 2026
4 checks passed
@Jammy2211
Jammy2211 deleted the feature/numpy-deflections-p1 branch September 2, 2026 21:23
@Jammy2211 Jammy2211 removed the pending-release PR queued for the next release build label Sep 4, 2026
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