-
Notifications
You must be signed in to change notification settings - Fork 231
Update variational inference interface to match [email protected]
#2699
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
Merged
Merged
Changes from all commits
Commits
Show all changes
62 commits
Select commit
Hold shift + click to select a range
ea69430
update vi interface to match [email protected]
Red-Portal 86ee6dd
revert unintended commit of `runtests.jl`
Red-Portal 3e30e04
Merge branch 'breaking' of github.com:TuringLang/Turing.jl into bump_…
Red-Portal d870045
update docs for `vi`
Red-Portal 2d928e0
add history entry for `[email protected]`
Red-Portal 5211b37
remove export for removed symbol
Red-Portal f0d615d
fix formatting
Red-Portal 1b2351f
fix formatting
Red-Portal 2be31b4
tidy tests advi
Red-Portal e48ae42
fix rename file `advi.jl` to `vi.jl` to reflect naming changes
Red-Portal 44f7762
fix docs
Red-Portal fd0e928
fix HISTORY.md
Red-Portal 77276bd
fix HISTORY.md
Red-Portal cb1620c
Merge branch 'main' of github.com:TuringLang/Turing.jl into bump_adva…
Red-Portal e70ddb4
update history
Red-Portal 115802d
Merge branch 'bump_advancedvi_0.5' of github.com:TuringLang/Turing.jl…
Red-Portal 25b5087
Merge branch 'main' of github.com:TuringLang/Turing.jl into bump_adva…
Red-Portal 4c02f7b
bump AdvancedVI version
Red-Portal 6518b82
add exports new algorithms, modify `vi` to operate in unconstrained
Red-Portal 5bd6978
Merge branch 'breaking' of github.com:TuringLang/Turing.jl into bump_…
Red-Portal 874a0b2
add clarification on initializing unconstrained algorithms
Red-Portal e021eb7
update api
Red-Portal eec7ef2
run formatter
Red-Portal b6d8202
run formatter
Red-Portal b900ab4
run formatter
Red-Portal e71b07b
run formatter
Red-Portal c08de12
run formatter
Red-Portal ae80f1e
run formatter
Red-Portal 73bd309
run formatter
Red-Portal eaac4c3
run formatter
Red-Portal 757ebb4
revert changes to README
Red-Portal 05ab711
fix wrong use of transformation in vi
Red-Portal 91606b5
change inital value for scale matrices to 0.6*I and update docs
Red-Portal 722153a
run formatter
Red-Portal 65bfaa3
fix rename advi to vi
Red-Portal 61e59a6
Merge branch 'bump_advancedvi_0.5' of github.com:TuringLang/Turing.jl…
Red-Portal 4a039dd
add batch-and-match
Red-Portal f782f56
fix format api table
Red-Portal 5251ee7
fix use fullrank Gaussian in tests since all algorithm support it
Red-Portal b665f96
fix tweak step sizes, remove unused kwargs
Red-Portal 15af544
fix increase budgets for failing algorithms
Red-Portal 7711e42
run formatter
Red-Portal a319962
rename main variational inference file to match module name
Red-Portal 6e76afa
run formatter
Red-Portal 2e78774
fix docstring
Red-Portal 98d07f8
run formatter
Red-Portal cc2cac9
update docstring
Red-Portal 2d88ddd
update docstring
Red-Portal 025202f
fix missing docstring for `unconstrained` keyword argument
Red-Portal 59fe8dc
fix relax assert transformed dist to an exception and add test
Red-Portal b1aa675
Update HISTORY.md
Red-Portal 22895b0
run formatter
Red-Portal 733f0be
run formatter
Red-Portal 2530f05
run formatter
Red-Portal cb5a798
fix document the change in output of `vi` in `HISTORY`
Red-Portal 8bd0ba7
run formatter
Red-Portal ed25920
run formatter
Red-Portal 6be562d
run formatter
Red-Portal df1b832
run formatter
Red-Portal d83148b
add missing namespace
Red-Portal a686cae
fix add missing import for `@test_throws`
Red-Portal 31256e3
Merge branch 'breaking' into bump_advancedvi_0.5
Red-Portal File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,6 +18,96 @@ As long as the above functions are defined correctly, Turing will be able to use | |
|
|
||
| The `Turing.Inference.isgibbscomponent(::MySampler)` interface function still exists, but in this version the default has been changed to `true`, so you should not need to overload this. | ||
|
|
||
| ## **AdvancedVI 0.6** | ||
|
|
||
| Turing.jl v0.42 updates `AdvancedVI.jl` compatibility to 0.6 (we skipped the breaking 0.5 update as it does not introduce new features). | ||
| `[email protected]` introduces major structural changes including breaking changes to the interface and multiple new features. | ||
| The summary of the changes below are the things that affect the end-users of Turing. | ||
| For a more comprehensive list of changes, please refer to the [changelogs](https://github.com/TuringLang/AdvancedVI.jl/blob/main/HISTORY.md) in `AdvancedVI`. | ||
|
|
||
| ### Breaking Changes | ||
|
|
||
| A new level of interface for defining different variational algorithms has been introduced in `AdvancedVI` v0.5. As a result, the function `Turing.vi` now receives a keyword argument `algorithm`. The object `algorithm <: AdvancedVI.AbstractVariationalAlgorithm` should now contain all the algorithm-specific configurations. Therefore, keyword arguments of `vi` that were algorithm-specific such as `objective`, `operator`, `averager` and so on, have been moved as fields of the relevant `<: AdvancedVI.AbstractVariationalAlgorithm` structs. | ||
|
|
||
| In addition, the outputs also changed. Previously, `vi` returned both the last-iterate of the algorithm `q` and the iterate average `q_avg`. Now, for the algorithms running parameter averaging, only `q_avg` is returned. As a result, the number of returned values reduced from 4 to 3. | ||
|
|
||
| For example, | ||
|
|
||
| ```julia | ||
| q, q_avg, info, state = vi( | ||
| model, q, n_iters; objective=RepGradELBO(10), operator=AdvancedVI.ClipScale() | ||
| ) | ||
| ``` | ||
|
|
||
| is now | ||
|
|
||
| ```julia | ||
| q_avg, info, state = vi( | ||
| model, | ||
| q, | ||
| n_iters; | ||
| algorithm=KLMinRepGradDescent(adtype; n_samples=10, operator=AdvancedVI.ClipScale()), | ||
| ) | ||
| ``` | ||
|
|
||
| Similarly, | ||
|
|
||
| ```julia | ||
| vi( | ||
| model, | ||
| q, | ||
| n_iters; | ||
| objective=RepGradELBO(10; entropy=AdvancedVI.ClosedFormEntropyZeroGradient()), | ||
| operator=AdvancedVI.ProximalLocationScaleEntropy(), | ||
| ) | ||
| ``` | ||
|
|
||
| is now | ||
|
|
||
| ```julia | ||
| vi(model, q, n_iters; algorithm=KLMinRepGradProxDescent(adtype; n_samples=10)) | ||
| ``` | ||
|
|
||
| Lastly, to obtain the last-iterate `q` of `KLMinRepGradDescent`, which is not returned in the new interface, simply select the averaging strategy to be `AdvancedVI.NoAveraging()`. That is, | ||
|
|
||
| ```julia | ||
| q, info, state = vi( | ||
| model, | ||
| q, | ||
| n_iters; | ||
| algorithm=KLMinRepGradDescent( | ||
| adtype; | ||
| n_samples=10, | ||
| operator=AdvancedVI.ClipScale(), | ||
| averager=AdvancedVI.NoAveraging(), | ||
| ), | ||
| ) | ||
| ``` | ||
|
|
||
| Additionally, | ||
|
|
||
| - The default hyperparameters of `DoG`and `DoWG` have been altered. | ||
| - The deprecated `[email protected]`-era interface is now removed. | ||
| - `estimate_objective` now always returns the value to be minimized by the optimization algorithm. For example, for ELBO maximization algorithms, `estimate_objective` will return the *negative ELBO*. This is breaking change from the previous behavior where the ELBO was returned. | ||
| - The initial value for the `q_meanfield_gaussian`, `q_fullrank_gaussian`, and `q_locationscale` have changed. Specificially, the default initial value for the scale matrix has been changed from `I` to `0.6*I`. | ||
| - When using algorithms that expect to operate in unconstrained spaces, the user is now explicitly expected to provide a `Bijectors.TransformedDistribution` wrapping an unconstrained distribution. (Refer to the docstring of `vi`.) | ||
|
|
||
| ### New Features | ||
|
|
||
| `[email protected]` adds numerous new features including the following new VI algorithms: | ||
|
|
||
| - `KLMinWassFwdBwd`: Also known as "Wasserstein variational inference," this algorithm minimizes the KL divergence under the Wasserstein-2 metric. | ||
| - `KLMinNaturalGradDescent`: This algorithm, also known as "online variational Newton," is the canonical "black-box" natural gradient variational inference algorithm, which minimizes the KL divergence via mirror descent under the KL divergence as the Bregman divergence. | ||
| - `KLMinSqrtNaturalGradDescent`: This is a recent variant of `KLMinNaturalGradDescent` that operates in the Cholesky-factor parameterization of Gaussians instead of precision matrices. | ||
| - `FisherMinBatchMatch`: This algorithm called "batch-and-match," minimizes the variation of the 2nd order Fisher divergence via a proximal point-type algorithm. | ||
|
|
||
| Any of the new algorithms above can readily be used by simply swappin the `algorithm` keyword argument of `vi`. | ||
| For example, to use batch-and-match: | ||
|
|
||
| ```julia | ||
| vi(model, q, n_iters; algorithm=FisherMinBatchMatch()) | ||
| ``` | ||
|
|
||
| # 0.41.4 | ||
|
|
||
| Fixed a bug where the `check_model=false` keyword argument would not be respected when sampling with multiple threads or cores. | ||
|
|
||
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.