Diffused uniform prior has zero score far outside the box

Open
#2,291 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 6 days

Nobody has claimed this yet.

  • #2295 by @JayBhadoria11 — closed without merging

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
python, pytorch

Research direction

Find the UniformNormalConvolution implementation returned by BoxUniform.marginalize and read how log_prob computes tail mass. Check the score behavior at 10, 13, and 500 noise standard deviations against the Gaussian-tail expectation, then add a regression test comparing the far-outside score with that tail. An open linked pull request (#2295) indicates work is already underway.

Written by the indexing model from the issue text.

Description

bug

The diffused uniform prior loses its score far outside the box.

Affine classifier-free guidance and the iid methods gauss, auto_gauss and jac_gauss need the score of the prior at each diffusion time. For a BoxUniform prior, marginalize returns a UniformNormalConvolution: the box convolved with Gaussian noise. Outside the box, its score should point back to the box and grow with the distance, as in a Gaussian tail.

From about 13 noise standard deviations outside the box, the probability mass underflows in float32. log_prob clamps it to the smallest float, so the score becomes exactly zero:

Distance outside the box Score Expected
10 noise sd -1010 about -1000
13 noise sd 0 about -1300
500 noise sd 0 about -50000

Near the end of sampling the noise is small, so 13 noise standard deviations are close to the box. Samples beyond that get no pull back towards the box.

The fix: compute the log of the mass in log space, for example with torch.special.log_ndtr, so that the tail keeps its slope. A test can compare the score far outside the box with the Gaussian tail.

Dominant language
Python
Stars
894
Forks
306
Avg merge
5d 21h
Merged PRs (30d)
61

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from sbi-dev/sbi

All issues in sbi-dev/sbi

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.