LimberJack.jl
<p align="center"> A differentiable cosmological code in Julia. </p>
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
mimicsCCL.py
class structure by usingJulia
'sstructures
. - Transparency:
LimberJack.jl
is fully written inJulia
without needing to interface 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:
- Clone the git repository
- From the repository directory open
Julia
- In the
Julia
command line run:
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
- 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 ineficiencies in the code. - GPU's:
LimberJack.jl
currently cannot run on GPUs which are known to significantly speed-up cosmological inference. Future works could study implementingJulia
GPU libraries such asCUDA.jl
. - 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 makingLimberJack.jl
compatible with the latestJulia
AD libraries such asZygote.jl
to implement efficient backwards-AD.