Repository navigation
fix: reject out-of-prior proposals in the Gaussian mixture reference sampler - #2100
Conversation
…thout log_prob samples_true_posterior_gaussian_mixture_uniform_prior used prior.log_prob to detect proposals outside the uniform prior. With torch argument validation on (the default), log_prob raises a ValueError for such values instead of returning -inf, so the sampler failed for observations near the prior bound. The sampler now checks the prior's support directly.
The true-posterior sampler for the Gaussian mixture no longer raises for proposals outside the prior, so the tutorial no longer needs to turn off torch argument validation around it.
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Check prior support during rejection sampling sbi/simulators/gaussian_mixture.py |
The bounds check uses the prior distribution’s support check instead of summed prior log probability. |
Call the true-posterior sampler in the tutorial docs/advanced_tutorials/13_diagnostics_lc2st.ipynb |
The reference-sample loop calls the true-posterior sampler directly for each observation. It no longer changes PyTorch’s global argument-validation setting. |
Priority:
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix
Suggested reviewers: bharath0153
Merge Risk: 
Minimal · up to d35d6
-
No merge-blocking risk was identified in the sampler or tutorial changes.
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passed-
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. (1 skipped: 1 unsupported.)
-
-
Finishing Touches
-
📝 Generate docstrings
-
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2100 +/- ##
=======================================
Coverage 90.24% 90.24%
=======================================
Files 142 142
Lines 14799 14799
=======================================
Hits 13355 13355
Misses 1444 1444
Flags with carried forward coverage won't be shown. Click here to find out more.
|
samples_true_posterior_gaussian_mixture_uniform_priorrejected proposals outside the prior viaprior.log_prob(sample) == -inf. With torch argument validation on,log_probraises instead, so the sampler crashed for observations near the prior bound (e.g. observation 2 in the L-C2ST tutorial). It now checksprior.supportdirectly.This also removes the validation workaround that #1987 added to the L-C2ST tutorial.