docs(research): Ludlow16 JAX concentration feasibility study (#397)#402
Merged
Conversation
Phase 1 deliverable for #397. Adds a written feasibility report and a working JAX prototype (Approach A — full port of modelLudlow16) that demonstrates the jax.pure_callback wrapping colossus.halo.concentration in mcr_util.py can be replaced with ~330 lines of straight-line JAX. Numbers from the prototype vs the current colossus callback: c200c max rel error over lensing grid : 7.5e-4 NFW convergence/deflection max rel : 8.2e-4 cNFW deflection max rel : 7.6e-4 kappa_s max rel error : 1.1e-3 Intrinsic Ludlow16 scatter (sigma_log10(c) = 0.13 dex) is ~350x larger, so the JAX-vs-colossus offset is scientifically invisible. No production code is changed. All artefacts live under docs/research/. A separate Phase 2 PR will swap the prototype into mcr_util.py. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This was referenced May 14, 2026
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.
Summary
Phase 1 deliverable for #397 — assess whether the
jax.pure_callbackwrappingcolossus.halo.concentrationinautogalaxy/profiles/mass/dark/mcr_util.pycan be replaced by a JAX-native implementation.Verdict: yes, Approach A is viable. A full port of
modelLudlow16— Eisenstein-Hu '98 transfer + Heath '77 growth factor + Einastogammainc+ 200-point Ludlow16 solver — comes to ~330 lines of straight-line JAX in one file. Max relative error in c200c vs colossus over the lensing parameter grid (log M ∈ [10, 14] Msun/h, z ∈ [0.1, 2.5]) is 7.5 × 10⁻⁴. Single-call post-JIT is 0.69 ms vs colossus' 0.83 ms.jax.gradworks end-to-end;vmap × 32is 1.29× faster than colossus serial.End-to-end propagation through
NFWMCRScatterLudlowandcNFWMCRScatterLudlow:kappa_smax rel error: 1.07 × 10⁻³The intrinsic scatter of the Ludlow16 relation itself (
σ_log10(c) = 0.13 dex, the dispersion thescatter_sigmaparameter marginalises over) is ~350× larger than this offset. Scientifically invisible.No production code is changed in this PR. All artefacts live under
docs/research/nfw_ludlow16_jax/and serve as the basis for a separate Phase 2 PR that will swap the prototype intomcr_util.py, collapse the JAX/NumPy branches in the two callers, and makecolossusan optional dependency.API Changes
None — internal changes only (research artefact in
docs/research/).Test Plan
python -m pytest test_autogalaxy/passes (production code is untouched).docs/research/nfw_ludlow16_jax_assessment.md:docs/research/nfw_ludlow16_jax_assessment.mdrenders cleanly on GitHub.Full API Changes (for automation & release notes)
Added
docs/research/nfw_ludlow16_jax_assessment.md— feasibility report.docs/research/nfw_ludlow16_jax/ludlow16_jax.py— Approach A prototype (~330 lines: EH98 transfer, σ(R) via top-hat log-k quadrature, flat-LCDM growth factor via Heath '77 integral, Einastogammaincmass ratio, 200-point Ludlow16 c-solver).docs/research/nfw_ludlow16_jax/validate.py— accuracy comparison vs colossus over the lensing parameter grid.docs/research/nfw_ludlow16_jax/bench.py—jax.gradcorrectness +jax.vmaptiming.docs/research/nfw_ludlow16_jax/tune.py—(nk, nz)quadrature grid sweep.docs/research/nfw_ludlow16_jax/science_check.py— end-to-end NFW / cNFW lensing comparison (helper outputs + convergence + deflection maps).Removed
None.
Renamed
None.
Changed Signature
None.
Changed Behaviour
None.
Migration
N/A — no production API is touched.
🤖 Generated with Claude Code