Skip to content

CLOE JAX likelihood, harmonic 3×2pt forecast and GLASS 3×2pt mocks - #502

Draft
cailmdaley wants to merge 4 commits into
developfrom
feat/cloe-jax
Draft

cailmdaley wants to merge 4 commits into
developfrom
feat/cloe-jax

Conversation

@cailmdaley

Copy link
Copy Markdown
Collaborator

CLOE JAX likelihood, harmonic 3×2pt forecast and GLASS 3×2pt mocks

This PR adds sp_validation.cloe, a differentiable likelihood for any SACC of harmonic spectra (shear, galaxy–shear, galaxy clustering), and runs the UNIONS v2 × LSx 3×2pt forecast and its GLASS mocks through it.
The theory is CLOE's (cloelib's background, NLA, Limber, CosmoPower-JAX HMcode-2020 with baryonic feedback), traced by JAX, so it is jit-, vmap- and grad-able; a 3×2pt chain takes 7 minutes on 64 cores.

snakemake --profile workflow/profiles/default -s workflow/cloe/Snakefile -j 64 cloe_all

runs the whole forecast in 30 minutes on 64 cores, from config/cloe/unions_v2_lsx.yaml (the survey recipe: v2.0.0 n(z), survey_tomo.json, footprint, LSx lens bins, priors, scale cuts): masks, theory spectra, coupled-bandpower covariance (Gaussian iNKA + super-sample), a noiseless SACC, Fisher widths, GLASS mocks and nautilus chains through cloerun.
Each rule is one step of python -m sp_validation.cloe.forecast or python -m sp_validation.mocks.glass_3x2pt, so every step also runs by hand.

What is new

  • cloe/vector.py: data vectors as linear maps of C_ℓ. Vector.from_sacc reads a SACC's E-mode spectra (shear EE, galaxy–shear, galaxy clustering) with their bandpower windows, covariance and n(z), ignoring B modes and real-space points; cut applies scale cuts (shear ℓ range, linear-bias cut k_max h χ(⟨z⟩) on lens bins, lens–source pairs). The ξ±, γt, w and COSEBIs operators are here too, but no SACC reader uses them yet.
  • cloe/probe.py: the likelihood of a SACC as a cloerun external probe, checking the SACC's blind stamp.
  • cloe/survey.py, covariance.py, forecast.py: the forecast pipeline. mocks/glass_3x2pt.py: GLASS mocks of the same survey, measured with the same estimator and written as SACCs.
  • sacc_io gains lens tracers (lens_<i>), the galaxy_density_cl and galaxy_shearDensity_cl_e types and add_cl; add_pseudo_cl is unchanged in behaviour.
  • A [cloe] extra (jax 0.12.1, cloelib 0.11, cosmopower-jax, interpax 0.3.16, nautilus, cloerun at cailmdaley/cloerun@56ac7bc6); uv.lock only adds packages. The image fetches the four CosmoPower-JAX networks by sha256 from the emulator repository's commit 61144e21 (python -m sp_validation.cloe.networks), because the sigma8 network on its main has changed.

Vendored theory

src/sp_validation/cloe/theory/ holds six files copied byte for byte from likelihood/euclid_spt_like/ of cailmdaley/euclid-spt-6x2pt at commit 2fc432e3: cloe.py, cloe_jax.py, cloelib_patches.py, jax_hmcode.py, jax_vector.py, vector.py.
Every commit touching them there is by Cail Daley (four, co-authored by Claude Opus); the JAX adapter came into that repository from the Euclid cmbx pipeline with its numerics unchanged.
Only theory is vendored: no Euclid or SPT data or configuration.
Ruff skips the directory so that a diff against the source stays empty.

cloelib_patches.py is a separate layer: six patches (P1, P3–P6, P8), each a mixin on one cloelib class that makes the Limber sum fast and traceable under JAX, written against cloelib 0.11 alone.
Each is meant to go upstream into CLOE; once cloelib carries one, its layer is deleted here, and over time this module disappears.

Relation to what sp_validation has

  • PR Restore SACC-based CosmoSIS inference with tomographic conversion #461 (SACC → CosmoSIS, real space) is untouched: this is the harmonic path beside it, reading the same SACC layout.
  • pseudo_cl decouples spin-2 × spin-2 bandpowers per pair through NaMaster workspaces. The forecast instead uses coupled pseudo-C_ℓ over the mean mask product, whose window and covariance follow in closed form from the mask couplings for all 45 spectra of mixed spin; both estimators carry the same information. NaMaster still computes every coupling matrix.
  • mocks/glass.py is the shear-only Paper II mock (σ8-normalised Planck18, 200 Mpc shells). Narrow lens bins need shells 0.01 wide in z and every tracer as a linear mix of shells, so the 3×2pt mock calls GLASS directly; it uses the same glass.ext.camb.matter_cls and that module's Cosmology_from_camb.
  • blinding.py and the CosmoSIS templates are not changed. Blinding on this theory is the next step.

Validation

All numbers below come from that Snakemake run on fir, in the sp_validation image ddd58fe0 with the [cloe] extra installed into a sandbox; the same steps run by hand give identical chains.

Theory against CosmoSIS (the UNIONS template's modules: CAMB mead2020_feedback, NLA, kmax 20), at the input point and 30 points across the prior, as band shifts in σ of the forecast's Gaussian + SSC covariance:

spectra all bands ℓ 10–2000: input point / worst of 30 kept bands: input point / worst
shear 0.053σ / 0.076σ 0.0006σ / 0.026σ
galaxy × shear 0.018σ / 0.10σ 0.008σ / 0.018σ
galaxy × galaxy 0.059σ / 0.49σ 0.004σ / 0.084σ

The largest shear shift is at ℓ < 30, where CosmoSIS omits the spin-2 prefactor; the galaxy autos above 0.1σ are at ℓ > 200, beyond the linear-bias cut.

theory vs cosmosis

Forecast (noiseless vector, shear 300 < ℓ < 1600, 31 sampled parameters; reference: the forecast's own chains made outside sp_validation with the same inputs):

σ(S8) σ(Ωm) σ(σ8) reference Fisher
3×2pt 0.0220 0.0377 0.061 0.0218, 0.0379 0.0196, 0.0333
shear alone 0.0275 0.099 0.127 0.0278, 0.098 0.0222, 0.087

Two seeds of the reference differ by 0.0003 in σ(S8), so the two codes agree within sampler noise.
sp_validation averages the release's nside-4096 footprint onto nside 1024, where the reference upgraded an nside-512 map; that lowers every band error by about 0.5%.

forecast contours

GLASS 3×2pt mocks (lognormal shells, Poisson lenses, shape noise, the forecast's masks and estimator): ten seeds have a mean χ² of 317 for the 315 kept bands against the model and its Gaussian + SSC covariance (range 271–355), and their mean sits on the model within its error in every family.
A chain on seed 1 gives S8 = 0.847 ± 0.021 and Ωm = 0.290 ± 0.034 for an input of 0.839 and 0.319.
The mock's own expectation departs from the model by up to 0.2σ in the lowest lens-auto bands, where the model's Limber approximation meets the mock's exact projection.

glass validation

Not in this PR

No data vector was measured or read and no blind was drawn.
The lens n(z) shapes, the split of lenses between bins and the lens mask are estimates (marked in the recipe), since the LSx files are only on nibi.

— Claude Opus on behalf of Cail

🤖 Generated with Claude Code

https://claude.ai/code/session_01JK7o9FiKmtK4WCS6BGAKwu

cailmdaley and others added 4 commits November 26, 2026 21:36
sp_validation.cloe vendors the CLOE JAX theory from euclid-spt-6x2pt at
2fc432e3 (theory/, byte-identical, cloelib_patches its separable layer),
reads harmonic SACC data vectors with their bandpower windows (vector.py),
runs them through cloerun as an external probe (probe.py), and builds the
UNIONS v2 x LSx 3x2pt forecast from a survey recipe: masks, spectra,
coupled-bandpower iNKA and super-sample covariance, a noiseless SACC,
Fisher and chains (survey.py, covariance.py, forecast.py,
workflow/cloe/). sacc_io gains lens tracers and add_cl. The image gains
the cloe extra and the pinned CosmoPower-JAX networks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JK7o9FiKmtK4WCS6BGAKwu
Lognormal matter shells 0.01 wide in z, mixed linearly into lens density
and source convergence (lensing + NLA), Poisson lenses and noisy E-mode
shear, measured with the forecast's coupled-bandpower estimator and
written as the forecast SACC with the mock's bands. The shell spectra are
rescaled from cold to total matter, n(z) regridded with Akima as the
theory does, and the lognormal spectra clipped where not positive
definite; the mock's expectation is what the clipped fields realise.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JK7o9FiKmtK4WCS6BGAKwu
…s by model

Vector.from_sacc and cut read only the harmonic E-mode types, so a
pseudo-C_ell SACC with BB/EB (or real-space statistics) gives the vector
of its E modes. The GLASS 3x2pt mock's lens fields carry magnification
(5s - 2) kappa and its NLA term the (1 + z) power about the pivot, as the
theory does; the SSC tracers carry the same NLA, and its docstring says
why magnification stays out of that term. The mock refuses an n(z) above
its top shell. reads() drops magnification slopes without magnification
and log T_AGN off the feedback engine, and the forecast's spectra filter
the input point through it. Unchanged for unions_v2_lsx (5s - 2 = 0,
eta_IA = 0).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JK7o9FiKmtK4WCS6BGAKwu

This branch has not been deployed

No deployments
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