Skip to content

feat: FitWeak per-galaxy sigma_crit scaling + JAX support (weak series step 10)#591

Merged
Jammy2211 merged 1 commit into
mainfrom
feature/weak-sigma-crit-jax
Jul 9, 2026
Merged

feat: FitWeak per-galaxy sigma_crit scaling + JAX support (weak series step 10)#591
Jammy2211 merged 1 commit into
mainfrom
feature/weak-sigma-crit-jax

Conversation

@Jammy2211

Copy link
Copy Markdown
Collaborator

Summary

The two library follow-ups from the completed weak series, on one branch (both rework FitWeak internals). Σ_crit scaling: when dataset.redshifts is present, the model signal is scaled per galaxy by β_i/β_ref (LensingCosmology.scaling_factor_between_redshifts_from; unity at the tracer's source plane, zero at/below the lens plane); reduced datasets scale both γ and κ (g_i = s·γ/(1−s·κ)); no redshifts → bit-identical previous behaviour. JAX: xp threaded through the fit statistics, AnalysisWeak._register_fit_weak_pytrees mirroring AnalysisPoint, use_jax=True supported (default stays False). Scale factors are concrete constants (redshifts are not sampled parameters), documented. Closes #590 together with the companion workspace_test PR.

API Changes

Behaviour addition, no signature breaks: FitWeak(dataset, tracer, xp=np) gains the optional xp; datasets carrying redshifts (stored-but-unused since #589, merged earlier today) now have them applied.
See full details on #590.

Test Plan

  • Full test_autolens/: 373 passed (52 weak; 4 new scaling tests — factor endpoints, per-galaxy scaling ratio, unchanged no-redshift behaviour, reduced+scaled composition).
  • JAX parity (workspace_test companion script): fitness._vmap == eager NumPy at rtol 1e-6 for plain AND redshift-scaled datasets.

Validation checklist (--auto run)

🤖 Generated with Claude Code

- When WeakDataset.redshifts is present, FitWeak scales the model signal per
  galaxy by beta_i/beta_ref via LensingCosmology.scaling_factor_between_
  redshifts_from (unity at the tracer's source plane, zero at/below the lens
  plane); reduced datasets scale both gamma and kappa: g_i = s*g/(1-s*k).
  No redshifts -> bit-identical to the previous single-plane behaviour.
  Factors are concrete NumPy constants (plane/catalogue redshifts are not
  sampled parameters), keeping them outside any JAX trace.
- xp threaded through the fit statistics (LensCalc hessian methods already
  take xp); model_shear returns a raw array on the jnp path (LensCalc guard
  pattern); AnalysisWeak._register_fit_weak_pytrees mirrors AnalysisPoint
  (no_flatten: dataset, _xp, _redshift_scale_factors). use_jax default stays
  False.
- 4 new NumPy-only tests (factor endpoints, per-galaxy scaling, unchanged
  no-redshift behaviour, reduced+scaled composition); JAX validated by the
  companion autolens_workspace_test weak vmap-parity script (plain + scaled
  variants match eager NumPy at rtol 1e-6).

Weak series step 10 (#590).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@Jammy2211 Jammy2211 added the pending-release PR queued for the next release build label Jul 9, 2026
@Jammy2211 Jammy2211 merged commit 42b0851 into main Jul 9, 2026
4 checks passed
@Jammy2211 Jammy2211 deleted the feature/weak-sigma-crit-jax branch July 9, 2026 14:26
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.

feat: FitWeak per-galaxy sigma_crit scaling + JAX support (weak series step 10)

1 participant