Skip to content

JaimeRZP/LimberJack.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

87 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LimberJack.jl

Build Status Dev size

A differentiable cosmological code in Julia.

Design Philosophy

  • Modularity: each main function within LimberJack.jl has its own module. New functions can be added by including extra modules. LimberJack.jl has the following modules:
Module function
boltzmann.jl Performs the computation of primordial power spectrum
core.jl Defines the structures where the theoretical predictions are stored and computes the background quantities
data_utils.jl Manages sacc files for large data vectors
growth.jl Computes the growth factor
halofit.jl Computes the non-linear matter power spectrum as given by the Halofit fitting formula
spectra.jl Computes the power spectra of any two tracers
theory.jl Computes large data vectors that combine many spectra
tracers.jl Computes the kernels associated with each type of kernel
  • Object-oriented: LimberJack.jl mimics CCL.py class structure by using Julia's structures.
  • Transparency: LimberJack.jl is fully written in Julia without needing to inerface to any other programming language (C, Python...) to compute thoretical predictions. This allows the user full access to the code from input to output.

Goals

  • Gradients: one order of magnitude faster gradients than finite differences.
  • Precision: sub-percentage error with respect to CCL.
  • Speed: C-like performance.

Installation

In order to run LimberJack.jl you will need Julia-1.7.0 or newer installed in your system. Older versions of Julia might be compatible but haven't been tested. You can find instructions on how to install Julia here: https://julialang.org/downloads/.

Once you have installed Julia you can install LimberJack.jl following these steps:

    using Pkg
    Pkg.add("LimberJack")

Installing Sacc.py in Julia

    using Pkg
    Pkg.add("CondaPkg")
    CondaPkg.add("sacc")

Use

    # Import
    using LimberJack
    
    # create LimberJack.jl Cosmology instance
    cosmology = Cosmology(Ωm=0.30, Ωb=0.05, h=0.70, ns=0.96, s8=0.81;
                          tk_mode="EisHu",
                          Pk_mode="Halofit")
    
    z = Vector(range(0., stop=2., length=256))
    nz = @. exp(-0.5*((z-0.5)/0.05)^2)
    tracer = NumberCountsTracer(cosmology, zs, nz; b=1.0)
    ls = [10.0, 30.0, 100.0, 300.0]
    cls = angularCℓs(cosmology, tracer, tracer, ls)

Challenges

  1. Parallelization: the current threading parallelization of LimberJack.jl is far away from the optimal one over number of threads scaling. Future works could study alternative parallalization schemes or possible inneficiencies in the code.
  2. GPU's: LimberJack.jl currently cannot run on GPU's which are known to significantly speed-up cosmological inference. Future works could study implementing Julia GPU libraries such as CUDA.jl.
  3. Backwards-AD: currently LimberJack.jl's preferred AD mode is forward-AD. However, the key computation of cosmological inference, obtaining the $\chi^2$, is a map from N parameters to a scalar. For a large number of parameters, backwards-AD is in theory the preferred AD mode and should significantly speed up the computation of the gradient. Future works could look into making LimberJack.jl compatible with the latest Julia AD libraries such as Zygote.jl to implement efficient backwards-AD.

Contributors

Jaime Ruiz-Zapatero Andrina Nicola Carlos Garcia-garcia David Alonso Arrykrishna Mootoovaloo Jamie Sullivan Marco Bonici
Lead Halofit Validation Tracers EmuPk Bolt.jl Benchmarks

Citing LimberJack

@ARTICLE{2023arXiv231008306R,
       author = {{Ruiz-Zapatero}, J. and {Alonso}, D. and {Garc{\'\i}a-Garc{\'\i}a}, C. and {Nicola}, A. and {Mootoovaloo}, A. and {Sullivan}, J.~M. and {Bonici}, M. and {Ferreira}, P.~G.},
        title = "{LimberJack.jl: auto-differentiable methods for angular power spectra analyses}",
      journal = {arXiv e-prints},
     keywords = {Astrophysics - Cosmology and Nongalactic Astrophysics, Astrophysics - Instrumentation and Methods for Astrophysics},
         year = 2023,
        month = oct,
          eid = {arXiv:2310.08306},
        pages = {arXiv:2310.08306},
          doi = {10.48550/arXiv.2310.08306},
archivePrefix = {arXiv},
       eprint = {2310.08306},
 primaryClass = {astro-ph.CO},
       adsurl = {https://ui.adsabs.harvard.edu/abs/2023arXiv231008306R},
      adsnote = {Provided by the SAO/NASA Astrophysics Data System}
}