Skip to content

fix: Keep masked fit utility gradients finite - #607

Merged
Jammy2211 merged 1 commit into
mainfrom
feature/fit-util-masked-division
Oct 2, 2026
Merged

Jammy2211 merged 1 commit into
mainfrom
feature/fit-util-masked-division

Conversation

@Jammy2211

@Jammy2211 Jammy2211 commented Oct 2, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Prevent divisions by zero in discarded branches of three fit utilities. Denominators are made safe before division, so masked pixels no longer contaminate JAX gradients. Residual fractions now return zero for zero data in both masked and unmasked helpers.

Part of #604. Permanent compiled JAX regressions are in the linked workspace PR.

API Changes

residual_flux_fraction_map_with_mask_from now returns zero for included pixels whose data is zero, matching the unmasked helper. Defined forward results are unchanged. Included zero-noise chi-squared remains undefined. See full details below.

Test Plan

  • Focused NumPy tests: 33 passed.
  • Eager/JIT forward and numerator/denominator gradients at all three sites: passed; original code's invalid gradients reproduced.
  • Full suite: 1,924 passed, 0 failed; serial rerun exited 0 (initial parallel run printed all tests passing but its wrapper exited 143).
  • Workspace smoke: fit-util JAX regression and imaging rectangular passed with explicitly verified bundle imports (2.61s/43.60s), runner exit0; interferometer rectangular passed (271s). Initial imaging timeout retained in logs.
  • Heart: YELLOW, human acknowledged: “manifest drift: workspace checkouts (manifest ↔ disk) — 1 mismatch(es) vs PyAutoMind/repos.yaml”. Stale reason: “release validation incomplete: no rehearsal for current source”. Development PRs only; no release or merge.
Full API Changes (for automation & release notes)

Changed Behaviour

  • chi_squared_map_with_mask_from: zero noise in masked pixels no longer poisons gradients.
  • residual_flux_fraction_map_from: excluded zero-data divisions have finite gradients.
  • residual_flux_fraction_map_with_mask_from: zero-data pixels return zero with zero excluded derivatives, including unmasked pixels.

Migration

  • No signature changes. Callers relying on non-finite residual fractions at zero data should use explicit validity checks.

Generated by the PyAutoLabs agent workflow.

@Jammy2211 Jammy2211 added the pending-release PR queued for the next release build label Oct 2, 2026
@Jammy2211
Jammy2211 marked this pull request as draft October 2, 2026 10:09
@Jammy2211

Copy link
Copy Markdown
Collaborator Author

Heart YELLOW is now explicitly acknowledged for this bundle. PR remains draft until one imaging smoke check is repeated with explicit library-path provenance after repairing a shared activation-script symlink. Full PyAutoArray validation is confirmed against this worktree: 1,924 passed with captured exit 0. The current geometry delegate will finish before the shared worktree switches back.

@Jammy2211

Copy link
Copy Markdown
Collaborator Author

Workspace PR: PyAutoLabs/autolens_workspace_test#340. Final smoke verification used explicit bundle interpreter/import provenance: fit-util JAX and imaging rectangular both passed, runner exit0. Full suite1924 passed with exit0. Heart exact YELLOW reason acknowledged; library-first merge/release gate remains.

@Jammy2211
Jammy2211 merged commit 7513b38 into main Oct 2, 2026
3 checks passed
@Jammy2211
Jammy2211 deleted the feature/fit-util-masked-division branch October 2, 2026 11:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pending-release PR queued for the next release build

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant