-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Matter power spectrum as function of cosmology (most likely emulator, or E.H.) #2
Comments
In BORG, we have Eisenstein-Hu and CLASS. |
Ok great, thanks @nataliaporqueres :-) but I guess you can't take the derivatives of CLASS, do you have a CLASS emulator? or do you use some trick to get the derivatives by finite differences from CLASS? |
We only need the derivative with respect to the initial conditions delta^{IC} because the HMC is only used to sample the density field. We use a slice sampler for the cosmological parameters, which doesn't involve derivatives. |
Ah! Interesting! I hadn't realized that, sorry. Very interesting :-) |
I have a PCE emulator as well as a GP emulator for power spectrum. |
I have setup this Jax-CLASS emulator based on the original work by the authors of https://arxiv.org/pdf/2105.02256.pdf |
This is great @jecampagne :-D Only thing is your repo is private, people will probably not be able to see the content, would you be ok with making it public? |
In fact the 1D and 2D interpolation in the (k,z) grid is performed (and constrained) to be done over a regular grid in (log scale for the k, and linear scale for the redshift z) and ideally I would sample differently to get better accuracy in the interval k=[0.1-1] h/Mpc. But the bottleneck is certainly the cosmo param sampling at the end of the day. |
I would like to share something that is quite stupid (sorry this is not great ML Bayesian theory): it concerns the time spent to load the parameters of the emulators. In the current version, I need to load : 2x120 (PkLin and PkNLin at z=0) + 2x120x20 (the fucntions P(k,z)/P(k,z=0) both Linear and Non Linear) ~ 5200 GPs. The total amount of data is 288MB (not a big deal, isn't it) Now depending where are located the files containing the parameters and the link Bandwidth, it can take (here at the Computing center at Lyon, if the data are in the system cache Growth end-start (sec) 10.849421180784702
Pk Lin end-start (sec) 0.5452490821480751
Pk Non Lin end-start (sec) 0.541755635291338
Q func end-start (sec) 11.04175541549921 but it can takes 10 times more if the data are not in the system cache. End in Google Collab, the data are on the "MyDrive" and it has taken 1h to be loaded on a notebook! But two days after it has taken 30sec... Does someone can help to try to speed this boring process? Notice that after performing the computation of the Linear & Non linear Pk pk_linear_interp = emu.linear_pk(cosmo_jax, k_star,z_star)
pk_nonlin_interp = emu.nonlinear_pk(cosmo_jax,k_star, z_star) with 1200 k-values (k_star) for 4 differents redshits (z_start) the XLA times can vary abd last 10min. After the execution is about 15-30ms. |
I have refactoring the code (not yet public) which allow a jitted version of k_star = jnp.geomspace(5e-4, 50, 1200, endpoint=True) #h/Mpc
z_star = jnp.array([0.,1., 2., 3.])
pk_linear_interp = emu.linear_pk(cosmo_jax, k_star,z_star) The XLA compilation takes 400sec while the execution after takes 25 ms. Now, the XLA may perhaps be speed up using more JAX idioms. |
I succeed to speed up the data loading thanks to parallelized code. It takes 25sec @ CC and Google Colab. Of course if the bandwidth is greater then this overhead can be reducted. Concerning JAX/JIT I'm making an exhaustive code review and XLA tweeking. But, the work is not yet satisfactory. If no JITization done the emulator is althought faster than jax-cosmo. If JIT is turn on, the XLA compilation can take several minutes, but then the emulator is at the level of millisec. |
With the help of XLA experts, I proceed to a code review to use PyTree as well as JIT with parsimony. |
I finally succeed to boost the prediction speed at a moderate price for XLA compilation time. So, it yields with the new committed version of Jemu
|
I write some scripts to
|
This issue is to discuss the particular choice for the matter power spectrum that will be an input to all forward pipelines.
Here are a question to get us started:
@Supranta @nataliaporqueres : What are your options in terms of differentiable matter power spectra?
With @jecampagne and @dlanzieri we are still just using Eisenstein & Hu in jax-cosmo and flowpm respectively, but we can adapt to whatever other solution you are currently using.
The text was updated successfully, but these errors were encountered: