Skip to content

Return log-densities + divergent transition info from impulse.infer#2958

Merged
sbrantq merged 4 commits into
EnzymeAD:mainfrom
penelopeysm:py/logdens
Jul 22, 2026
Merged

Return log-densities + divergent transition info from impulse.infer#2958
sbrantq merged 4 commits into
EnzymeAD:mainfrom
penelopeysm:py/logdens

Conversation

@penelopeysm

@penelopeysm penelopeysm commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Currently infer only returns a single diagnostic, a boolean which indicates whether or not the transition was accepted. Naturally, it's often useful to have more info :)
Right now (some of) this info is already calculated but is thrown away. This PR is a pretty mechanical way of surfacing that. The diagnostics tensor is expanded to include a second column which indicates whether the transition is divergent, plus a separate new tensor containing the logdensities is returned.
This is a bit ugly and not incredibly generalisable, but since it's quite closely tied to the sampling algorithm and infer only admits two algorithms, I think it's fine for now. My feeling is that properly generalising diagnostics only really makes sense in the context of broader programmable inference APIs.
This ofc needs changes in Reactant as well which I'll push separately. I have tested this locally end to end and it all works as intendeds

@wsmoses
wsmoses requested a review from sbrantq July 20, 2026 01:16

@sbrantq sbrantq left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks this looks great! ... and by returning log densities it helps with EnzymeAD/Reactant.jl#2920

@sbrantq

sbrantq commented Jul 21, 2026

Copy link
Copy Markdown
Member

(looks like we had a CI fix upstream)

@sbrantq
sbrantq added this pull request to the merge queue Jul 22, 2026
Merged via the queue into EnzymeAD:main with commit 53358c5 Jul 22, 2026
34 of 35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants