-
Notifications
You must be signed in to change notification settings - Fork 19
Remove the Bijectors extension
#219
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Red-Portal
wants to merge
18
commits into
main
Choose a base branch
from
remove_bijectors
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
+279
−825
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
…l into remove_bijectors
Red-Portal
commented
Nov 21, 2025
|
|
||
| include("normallognormal.jl") | ||
| include("unconstrdist.jl") | ||
| struct Dist{D<:ContinuousMultivariateDistribution} |
Member
Author
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The content of unconstrdist.jl have been moved here.
Contributor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Benchmark Results
| Benchmark suite | Current: 9a64db7 | Previous: 4d8d95e | Ratio |
|---|---|---|---|
normal/RepGradELBO + STL/meanfield/Zygote |
2663625575.5 ns |
2602386322 ns |
1.02 |
normal/RepGradELBO + STL/meanfield/ReverseDiff |
610381229 ns |
609712269 ns |
1.00 |
normal/RepGradELBO + STL/meanfield/Mooncake |
247490722 ns |
245084270 ns |
1.01 |
normal/RepGradELBO + STL/fullrank/Zygote |
2035966984 ns |
2041835270 ns |
1.00 |
normal/RepGradELBO + STL/fullrank/ReverseDiff |
1152744904 ns |
1155642268 ns |
1.00 |
normal/RepGradELBO + STL/fullrank/Mooncake |
678304005.5 ns |
674570404.5 ns |
1.01 |
normal/RepGradELBO/meanfield/Zygote |
1609768612 ns |
1567343454.5 ns |
1.03 |
normal/RepGradELBO/meanfield/ReverseDiff |
300903420 ns |
304931634 ns |
0.99 |
normal/RepGradELBO/meanfield/Mooncake |
172911707.5 ns |
171032782.5 ns |
1.01 |
normal/RepGradELBO/fullrank/Zygote |
1161734600 ns |
1095442215 ns |
1.06 |
normal/RepGradELBO/fullrank/ReverseDiff |
601496820 ns |
592074381 ns |
1.02 |
normal/RepGradELBO/fullrank/Mooncake |
557909715 ns |
554962334.5 ns |
1.01 |
This comment was automatically generated by workflow using github-action-benchmark.
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Consider the case where we would like to approximate a constrained target distribution with density $\pi : \mathcal{X} \to \mathbb{R}{> 0}$ with an unconstrained variational approximation with density $q : \mathbb{R}^d \to \mathbb{R}{> 0}$. The canonical way to deal with this, popularized by the ADVI paper1, is to use a$b$ bijective transformation ("Bijectors") $b : \mathbb{R}^d \to \mathcal{X}$ such that $q$ is augmented into $q_{b}$ as
Then
AdvancedVIneeds to solve the problemBut notice that the optimization is, in reality, over$q$ . Therefore, often times,
AdvancedVIneeds access to the underlyingq. I will refer to this as the "primal" scheme.Previously, this was done by giving a special treatment to
q <: Bijectors.TransformedDistributionthrough theBijectorsextension. In particular, theBijectorsextension had to add a specialization to a lot of methods that simply unwrap aTransformedDistributionto do something. This behavior is difficult to document and, therefore, wasn't fully explained in the documentation. Furthermore, each of the relevant methods needs to be specialized in the Bijectors extension, which resulted in a multiplicative complexity, especially for unit testing.This, however, is unnecessary. Instead, there exists an equivalent "dual" problem that operates in unconstrained space by approximating the transformed posterior
That is, we can solve the problem
and then post-process the output to retrieve$q_{b^{-1}}^*$ .
Within this context, this PR removes the
Bijectorsextension to fix this problem. Here are the reationals:AdvancedVIdoesn't need to implement the primal scheme. In fact, the upcoming interface inTuringis planned to implement the dual scheme above.KLMinNaturalGradDescent,KLMinWassFwdBwd,FisherMinBatchMatch, for example, do not work in constrained support at all, so they can only be used via the dual scheme. So the way thatKLMinRepGradDescentand friends implemented the primal scheme is a bit redundant in terms of consistency at this point.Instead, a tutorial has been added to the documentation on how to use VI with constrained supports via the dual scheme.
Footnotes
Kucukelbir, A., Tran, D., Ranganath, R., Gelman, A., & Blei, D. M. (2017). Automatic differentiation variational inference. Journal of machine learning research, 18(14), 1-45. ↩