-
Notifications
You must be signed in to change notification settings - Fork 207
Description
🚀 Feature Request
Is your request related to a problem?
Almost all posterior sample with accept_reject_sample. This raises a warning that sampling will be slow if the acceptance rate is too low, but does not stop trying to sample with rejection.
This is fine when running sbi locally, e.g. in a notebook, but means you have to work around it if sbi is part of a bigger loop (e.g. when optimizing over hyperparameters @swag2198 or running many sbi runs in parallel on a cluster). Then your job is stuck and does not output anything, as it just runs until you stop it or the job times out.
Describe the solution you'd like
We should add an argument, e.g. max_sampling_time, after which we give up on rejection sampling. We can then raise an Error, which should include instructions on how to catch the error to define custom behaviour in this case (e.g. sample posterior without restriction or return prior samples, i.e. what to do in a "failed" run).
...
Describe alternatives you've considered
We can leave the code as it is and add a tutorial/faq entry.
...