Skip to content

Allow zero rate for Poisson distribution.#2176

Merged
Qazalbash merged 5 commits into
pyro-ppl:masterfrom
tillahoffmann:poisson-zero-rate
May 2, 2026
Merged

Allow zero rate for Poisson distribution.#2176
Qazalbash merged 5 commits into
pyro-ppl:masterfrom
tillahoffmann:poisson-zero-rate

Conversation

@tillahoffmann
Copy link
Copy Markdown
Collaborator

This PR uses xlogy to allow evaluation of the Poisson log likelihood for zero rates. The manual cast from integer value to dtype matching self.rate is required because xlogy defines a custom jvp that does not play well with integer arguments.

@Qazalbash Qazalbash self-requested a review April 29, 2026 03:48
Copy link
Copy Markdown
Collaborator

@Qazalbash Qazalbash left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, LGTM!

@Qazalbash Qazalbash requested a review from fehiepsi May 2, 2026 09:08
Copy link
Copy Markdown
Collaborator

@Qazalbash Qazalbash left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @tillahoffmann,

I merged the master branch into this branch to start CI. Currently, 10 test cases related to Poisson and Sparse Poisson distributions are failing. A summary,

=========================== short test summary info ============================
FAILED test/test_distributions.py::test_expand[sample_shape0-prepend_shape0-Poisson-<lambda>-params250] - ValueError: Poisson distribution got invalid rate parameter.
FAILED test/test_distributions.py::test_expand[sample_shape0-prepend_shape0-SparsePoisson-<lambda>-params254] - ValueError: SparsePoisson distribution got invalid rate parameter.
FAILED test/test_distributions.py::test_expand[sample_shape0-prepend_shape1-Poisson-<lambda>-params250] - ValueError: Poisson distribution got invalid rate parameter.
FAILED test/test_distributions.py::test_expand[sample_shape0-prepend_shape1-SparsePoisson-<lambda>-params254] - ValueError: SparsePoisson distribution got invalid rate parameter.
FAILED test/test_distributions.py::test_expand[sample_shape1-prepend_shape0-Poisson-<lambda>-params250] - ValueError: Poisson distribution got invalid rate parameter.
FAILED test/test_distributions.py::test_expand[sample_shape1-prepend_shape0-SparsePoisson-<lambda>-params254] - ValueError: SparsePoisson distribution got invalid rate parameter.
FAILED test/test_distributions.py::test_expand[sample_shape1-prepend_shape1-Poisson-<lambda>-params250] - ValueError: Poisson distribution got invalid rate parameter.
FAILED test/test_distributions.py::test_expand[sample_shape1-prepend_shape1-SparsePoisson-<lambda>-params254] - ValueError: SparsePoisson distribution got invalid rate parameter.
FAILED test/test_distributions.py::test_dist_pytree[Poisson-<lambda>-params250] - ValueError: Poisson distribution got invalid rate parameter.
--------------------
For simplicity, JAX has removed its internal frames from the traceback of the following exception. Set JAX_TRACEBACK_FILTERING=off to include these.
FAILED test/test_distributions.py::test_dist_pytree[SparsePoisson-<lambda>-params254] - ValueError: SparsePoisson distribution got invalid rate parameter.
--------------------
For simplicity, JAX has removed its internal frames from the traceback of the following exception. Set JAX_TRACEBACK_FILTERING=off to include these.
= 10 failed, 7464 passed, 2269 skipped, 49 deselected, 54 xfailed, 65 xpassed in 2218.40s (0:36:58) =

Comment thread numpyro/distributions/discrete.py Outdated
@Qazalbash Qazalbash self-requested a review May 2, 2026 13:39
@Qazalbash Qazalbash self-assigned this May 2, 2026
@Qazalbash Qazalbash merged commit 984c743 into pyro-ppl:master May 2, 2026
9 checks passed
@tillahoffmann
Copy link
Copy Markdown
Collaborator Author

Thank you for fixing the constraint and merging, @Qazalbash!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants