Closed maho3 closed 1 year ago
Results of the new SNLE integration shows robustness for the toy example:
Added emcee samplers for sbi modules, and integrated it in with a modular interface in the validation step. Now, users can choose which sampler (emcee or sbi/Pyro) they want to use for each metric in the validation phase. This could be useful if you want high resolution sampling for a single example, but low resolution sampling for the entire test set (to check posterior coverage).
Here's an example posterior constraint from using emcee on an SNLE model.
This is built to work fluidly with the pydelfi version, but hasn't yet been tested. It should address #47 if everything works well.
Pydelfi version works with emcee! Here's an example:
This is another fairly extensive PR, so here's a summary of major changes:
And here are some minor changes:
Questions:
A non-exhaustive list of things to test:
(sbi backend only) On a new Python 3.10.12 environment with ili-summarizer also installed, SNRE, SNPE and SNLE work without issue in the toy_sbi example. Changing the _samplemethod attribute to emcee instead of "slice_np_vectorize" for the utils.samplers instances also runs without apparent issue. Next I'm going to look at the actual posterior coverage, try to change the configurations and check the type A/B/C instances (toy_sbi.py only for now).
Temporary workarounds with emcee sampler instances invoked in metrics.py:
[sbi backend] Hello! I do not understand the second major bullet point, namely that emcee- and pyro-backed MCMC samplers are available for SNLE or SNRE instances.
Hey Nicolas, thanks for looking into this.
Yes so here are the answers to some questions:
Hello, moving now to testing the toy examples with the pydelfi backend on a fresh Python==3.6.0 environment. Have you installed the version of this PR as such ? There is no compatible version of "mpsort" when installing ili-summarizer, looking into it.
When do you get this issue? If I run
git clone -b 32-fix-snle git@github.com:maho3/ltu-ili.git
git clone https://github.com/florpi/ili-summarizer.git
conda create -n ili-pydelfi python=3.6 -y
conda activate ili-pydelfi
pip install -e "ltu-ili[pydelfi]"
pip install -e ili-summarizer
then everything seems to install fine. Does this happen at installation stage or when you run a particular script?
It does work with that way actually, the fault was me being stubborn on using a venv ==3.6 instead of conda and asking for trouble (installation stage) Thank you
Question
Answer about MCMC for SNPE (sbi) If sbi already allows MCMC sampling for trained posteriors from SNPE instances, we should include this possibility as well.
Some notes before finishing tests for review
python -m pip install git+https://github.com/cosmodesi/pycorr
Given the previous point, it seems however we do not needs summarizer backends to work as of now.
Hey Nicolas,
Thanks a lot for the detailed review. Some notes:
Hey Nicolas,
Additonal notes:
Fixes SBIRunner to allow for SNLE and SNRE models. Solves #32