Likelihoods

Likelihood framework used for cosmological constraints

Last update

August 31, 2026

Overview

The SPT-3G D1 lensing analysis uses the differentiable CMB likelihood framework candl, together with the official SPT data release for candl, spt_candl_data. spt_candl_data packages the band-power data, covariance matrices, and short-cut initialisers needed to run the SPT likelihoods.

There are two types of inference associated with this work, differing in the sampler used:

Route Used for
Cobaya The main inference — CMB lensing, and CMB + BAO
CosmoSIS Inference involving LSS

Both routes run the same underlying candl likelihoods and the same spt_candl_data data products; they differ only in the sampler and in the template configuration files used to launch chains. The installation below is therefore common to both.

Installation

1. Install candl

pip install candl-like

See the candl repository for more detailed installation instructions.

2. Download and install spt_candl_data

Navigate to where you would like to store the data, then clone and install it into the same environment:

git clone https://github.com/SouthPoleTelescope/spt_candl_data.git
cd spt_candl_data
pip install .

This downloads the data files and installs the short-cut initialisers that make it easier to set up the likelihoods. Version 3.0.0 or later of spt_candl_data is required.

3. Verify the installation

Run the supplied tests:

import spt_candl_data
spt_candl_data.run_all_tests()

You can list the available likelihood shortcuts with:

import spt_candl_data
spt_candl_data.print_all_shortcuts()

Running Chains

This is the main inference route, used for the CMB lensing and the CMB + BAO constraints. To install Cobaya, see the Cobaya installation instructions.

Template Cobaya .yaml files and ΛCDM proposal matrices are provided in the cobaya/ folder of spt_candl_data. Depending on your setup you may need to install the likelihoods as external likelihoods in Cobaya — see External likelihoods in the Cobaya documentation.

First set the chain output directory, then move into the likelihood’s template folder and launch:

export DIR_CHAINS=/path/to/output/
export YAML_FILE=base_lens/gmv.yaml
cd /path/to/spt_candl_data/cobaya/SPT3G_D1_KK/
cobaya-run "${YAML_FILE}"

Here DIR_CHAINS is where the chains will be written, and YAML_FILE is the template .yaml you want to run — base_lens/gmv.yaml above is one example.

Example submit script. These are illustrative templates — the account, partition/queue, and module lines will differ on your cluster.

#!/bin/bash
#SBATCH --job-name=spt3g_d1_kk
#SBATCH --nodes=1
#SBATCH --ntasks=4              # MPI ranks = Cobaya chains
#SBATCH --cpus-per-task=8       # OpenMP threads per chain
#SBATCH --time=24:00:00
#SBATCH --output=logs/%x-%j.out
#SBATCH --account=your_account
#SBATCH --partition=your_partition

source /path/to/your/env/bin/activate   # or: conda activate candl

export OMP_NUM_THREADS=${SLURM_CPUS_PER_TASK}
export DIR_CHAINS=/path/to/output/
export YAML_FILE=base_lens/gmv.yaml

cd /path/to/spt_candl_data/cobaya/SPT3G_D1_KK/
srun -n "${SLURM_NTASKS}" cobaya-run "${YAML_FILE}"

Submit with sbatch run_cobaya.sh.

#!/bin/bash
#PBS -N spt3g_d1_kk
#PBS -l select=1:ncpus=32:mpiprocs=4:ompthreads=8
#PBS -l walltime=24:00:00
#PBS -j oe
#PBS -A your_account
#PBS -q your_queue

cd "${PBS_O_WORKDIR}"
source /path/to/your/env/bin/activate   # or: conda activate candl

export OMP_NUM_THREADS=8
export DIR_CHAINS=/path/to/output/
export YAML_FILE=base_lens/gmv.yaml

cd /path/to/spt_candl_data/cobaya/SPT3G_D1_KK/
mpirun -np 4 cobaya-run "${YAML_FILE}"

Submit with qsub run_cobaya.sh.

This route is used for the inference involving LSS. In addition to the installation above, you will need a working CosmoSIS installation — see the CosmoSIS installation instructions. You need to have both cosmosis and cosmosis-standard-library installed.

Template CosmoSIS .ini files are provided in the cosmosis/examples/SPT3G_D1_KK/ folder of spt_candl_data.

Example submit script. As above, adapt the account, partition/queue, and module lines to your cluster.

#!/bin/bash
#SBATCH --job-name=spt3g_d1_lss
#SBATCH --nodes=1
#SBATCH --ntasks=8              # MPI ranks
#SBATCH --cpus-per-task=4       # OpenMP threads per rank
#SBATCH --time=24:00:00
#SBATCH --output=logs/%x-%j.out
#SBATCH --account=your_account
#SBATCH --partition=your_partition

source /path/to/your/env/bin/activate
source cosmosis-configure

export OMP_NUM_THREADS=${SLURM_CPUS_PER_TASK}

# This is a must
cd /path/to/cosmosis-standard-library

# --- chain output location (referenced as ${DIR_CHAIN} throughout the inis) ---
export DIR_CHAIN=/path/to/cosmosis-standard-library/output/

export INI_FILE=/path/to/spt_candl_data/cosmosis/examples/SPT3G_D1_KK/gmv/gmv.ini

srun -n "${SLURM_NTASKS}" cosmosis --mpi "${INI_FILE}"

Submit with sbatch run_cosmosis.sh.

#!/bin/bash
#PBS -N spt3g_d1_lss
#PBS -l select=1:ncpus=32:mpiprocs=8:ompthreads=4
#PBS -l walltime=24:00:00
#PBS -j oe
#PBS -A your_account
#PBS -q your_queue

source /path/to/your/env/bin/activate
source cosmosis-configure

export OMP_NUM_THREADS=4

# This is a must
cd /path/to/cosmosis-standard-library

# --- chain output location (referenced as ${DIR_CHAIN} throughout the inis) ---
export DIR_CHAIN=/path/to/cosmosis-standard-library/output/

export INI_FILE=/path/to/spt_candl_data/cosmosis/examples/SPT3G_D1_KK/gmv/gmv.ini

mpirun -np 8 cosmosis --mpi "${INI_FILE}"

Submit with qsub run_cosmosis.sh.