Repository navigation
Closed
Labels
bugSomething isn't working
Description
Improper Empirical still saves simulations
In #1700 the simulation cache should have been removed from the ImproperEmpirical prior, but its still there because it call super().__init__(values, log_weights=log_weights) and subclasses Empirical. Given that sample now raises an error these are not used at all and should be removed (i.e. by not using inheriting from Empirical.
Furthermore there is a bug in to method i.e. see below. This surfaced in #1793 .
class ImproperEmpirical(Empirical):
"""
Wrapper around pyro's `Emprirical` distribution that returns constant `log_prob()`.
This class is used in SNPE when no prior is passed. Having a constant
log-probability will lead to no samples being rejected during rejection-sampling.
The default behavior of `pyro.distributions.Empirical` is that it returns `-inf`
for any value that does not **exactly** match one of the samples passed at
initialization. Thus, all posterior samples would be rejected for not fitting this
criterion.
"""
def __init__(self, values: Tensor, log_weights: Optional[Tensor] = None):
super().__init__(values, log_weights=log_weights)
# Warn if extremely large to inform about memory/serialization cost.
self._mean = self._compute_mean(values, log_weights)
self._variance = self._compute_variance(values, log_weights)
...
...
...
def to(self, device: Union[str, torch.device]) -> None:
"""
Move the distribution to a different device.
Args:
device: The device to move the distribution to.
Returns:
The distribution on the specified device.
"""
self._mean = self._mean.to(device)
self._variance = self._variance.to(device)
#super().to(device) TODO: This needs to be removed as neither Distirbution nor Empirical implement it.Metadata
Metadata
Assignees
Labels
bugSomething isn't working
Activity
patelshivani2283-lab commentedon Mar 20, 2026
Nice catch! I had a look and agree this could be simplified by removing the
Empiricalinheritance and avoiding storing the simulations altogether.I’m happy to work on this and fix the
.to()issue as well—unless someone is already working on itmanuelgloeckler commentedon Mar 20, 2026
Hey @patelshivani2283-lab,
No one is working on this currently, happy for an PR on this :)
manuelgloeckler commentedon Apr 9, 2026
I close this as it was fixed in #1822