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
Low performance compared to dynesty? (I'm probably doing something wrong) #149
Comments
Hi @asmasca, Firstly, thanks for trying nessai out! As for the slow performance you're seeing, I think there could be a few possible causes. The warning you're getting is an indication that the process of drawing new samples (before computing the likelihood) is inefficient. This isn't necessarily a problem (it's more common the higher the dimensionality of the problem) and won't bias results but it can be an indication that, as you suggested, the flow proposal isn't configured correctly and it will slow things down. Just so I have a better handle on things, which version of nessai are you running? The latest release (v0.4.0) changed some of the default settings and included a new default mode that is more stable. If you have the latest release, I think the possible issues/causes of the slow performance could be:
Model I can't see any obvious issues with how you've configured the model, though one possible issue could be the Gaussian priors. Nessai can handle Gaussian priors but it requires a little more configuration. Are the Gaussian priors you mentioned defined on (-inf, inf) or are they truncated on some bounds? If it's the former then I would expect you to get an error when the sampler starts. I can give you an example of the additions needed to the model. Diagnosis plots It's probably worth having a look at the diagnostics plots nessai produces. In particular
Configuration of flow proposal The configuration of the flow can make or break things, most of this relates to the complexity of normalising flow. The more complex the space, the more complex the flow needs to be (and the default values are not designed for especially complex problems). The flow is configured using flow_config=dict(
model_config=dict(
n_neurons=32,
n_blocks=8,
)
) And then just pass that to There are other settings that can help speed things up, such as telling the proposal about particular types of parameters like angles, but I'm hesitant to recommend anything without checking the things I've already mentioned. Parallelisation
So the parallelisation in nessai is very different to that in dynasty since drawing new samples is inherently parallelised. In the current version, the multiprocessing pool is only used for evaluating the likelihood. This happens in large batches when new points are being drawn. This means that whilst other parts of the sampling are happening, like training the normalising flow, the pool isn't being used. So the usage will vary depending on what stage of sampling that algorithm is at. I suspect this is what you're seeing. This could no doubt be improved to make more constant use of the pool but my current focus has been on other more fundamental bottlenecks in the algorithm. I realise this is a lot of information, but I hope it's helpful. Thanks, |
I recently found about NESSAI and I'm trying to implement some of my analysis of radial velocity time-series (for exoplanets) to test the performance compared to dynesty, as I have a few problems which will hugely benefit from a 2x reduction in computing time.
To give some context, I'm working with the data of this article (https://ui.adsabs.harvard.edu/abs/2022A%26A...658A.115F/abstract). So basically 2 time-series fitted simultaneously, with Gaussian processes and a custom likelihood function (written below).
In my first try it is running much slower than dinesty (parallel). My test case takes around 3x longer (in a 4-cores/8-threads laptop). I am also getting a few warnings I have trouble linking to configuration parameters. The final distributions (and logZ) is basically the same.
I have trouble figuring out if I am doing something wrong with NESSAI, or if this is just a problem at which dynesty is very good. I'm also not sure the parallelization is scaling correctly. The CPU load seems quite low (compared to dynesty).
I'm using the sampler as:
The model is written at the end of the message.
I'm getting this warning nonstop:
02-24 15:16 nessai.proposal.flowproposal WARNING : Rejection sampling accepted less than 1 percent of samples!
Could the default configuration of the flow proposal have issues with this problem? Or maybe that it's not the right problem for it? I'm also not sure the paralellization is scaling correctly. The CPU load is quite low (compared to dynesty).
Here's the model, in case there's something that shouldn't be written the way it is. The priors are a mix of gaussian and uniform, with distributions created with scity.stats.
The text was updated successfully, but these errors were encountered: