Skip to content

Update to the [email protected] interface #2506

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 69 commits into from
Jun 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
ed6946c
update to match the [email protected] interface
Red-Portal Mar 14, 2025
a94269d
run formatter
Red-Portal Mar 14, 2025
a4711a9
run formatter
Red-Portal Mar 14, 2025
3f8068b
run formatter
Red-Portal Mar 14, 2025
222a638
run formatter
Red-Portal Mar 14, 2025
57097f5
run formatter
Red-Portal Mar 14, 2025
a42eea8
run formatter
Red-Portal Mar 14, 2025
798f319
run formatter
Red-Portal Mar 14, 2025
69a4972
run formatter
Red-Portal Mar 14, 2025
cbcb8b5
run formatter
Red-Portal Mar 14, 2025
081d6ff
remove plotting
Red-Portal Mar 14, 2025
a32a673
Merge branch 'update_advancedvi' of github.com:TuringLang/Turing.jl i…
Red-Portal Mar 14, 2025
1bcec3e
fix formatting
Red-Portal Mar 14, 2025
b142832
fix formatting
Red-Portal Mar 14, 2025
061ec35
fix formatting
Red-Portal Mar 14, 2025
736bd3e
remove unused dependency
Red-Portal Mar 14, 2025
fd434d8
Merge branch 'update_advancedvi' of github.com:TuringLang/Turing.jl i…
Red-Portal Mar 14, 2025
57108ee
Merge branch 'main' into update_advancedvi
yebai Mar 18, 2025
8dc8067
Merge branch 'main' into update_advancedvi
yebai Mar 20, 2025
297c32a
Update Project.toml
yebai Mar 20, 2025
3010b5e
Merge branch 'main' of github.com:TuringLang/Turing.jl into update_ad…
Red-Portal Mar 25, 2025
0c04434
fix make some arugments of vi initializer to be optional kwargs
Red-Portal Mar 25, 2025
17a8290
Merge branch 'update_advancedvi' of github.com:TuringLang/Turing.jl i…
Red-Portal Mar 25, 2025
626c5b5
remove tests for custom optimizers
Red-Portal Mar 25, 2025
cb2c618
remove unused file
Red-Portal Mar 25, 2025
2b08a4b
Merge branch 'main' of github.com:TuringLang/Turing.jl into update_ad…
Red-Portal Mar 29, 2025
0e496c4
Merge branch 'main' into update_advancedvi
yebai Apr 18, 2025
c1533a8
Update src/variational/bijectors.jl
yebai Apr 18, 2025
231d6e2
Update Turing.jl
yebai Apr 21, 2025
c2ae04a
Merge branch 'main' of github.com:TuringLang/Turing.jl into update_ad…
Red-Portal Apr 29, 2025
69639ec
fix remove call to `AdvancedVI.turnprogress`, which has been removed
Red-Portal Apr 29, 2025
ef9aeb1
apply comments from @yebai
Red-Portal Apr 29, 2025
43c19aa
Merge branch 'update_advancedvi' of github.com:TuringLang/Turing.jl i…
Red-Portal Apr 29, 2025
cc18528
Update src/variational/VariationalInference.jl
yebai May 8, 2025
162899a
Merge branch 'main' into update_advancedvi
yebai May 8, 2025
0b79495
add old interface as deprecated
Red-Portal May 14, 2025
3818152
bump AdvancedVI version
Red-Portal May 14, 2025
91a9afe
add deprecation for `meanfield`
Red-Portal May 14, 2025
12539aa
add `default_rng` interfaces
Red-Portal May 14, 2025
0653bf1
add tests for variational inference
Red-Portal May 14, 2025
f74ec38
run formatter
Red-Portal May 14, 2025
406824f
Merge branch 'main' of github.com:TuringLang/Turing.jl into update_ad…
Red-Portal May 14, 2025
f62e7b8
remove "src/variational/bijectors.jl" (moved to `DynamicPPL.jl`)
Red-Portal May 18, 2025
e3b7618
Merge remote-tracking branch 'origin/main' into update_advancedvi
yebai May 21, 2025
f0374b6
add more tests for variational inference initializer
Red-Portal May 23, 2025
187a65c
remove non-essential reexports, fix tests
Red-Portal May 23, 2025
a5021d1
run formatter, rename functions
Red-Portal May 23, 2025
218eb23
add documentation
Red-Portal May 23, 2025
4714c3c
fix run formatter
Red-Portal May 23, 2025
f712755
fix remove debug commits
Red-Portal May 23, 2025
8086398
run formatter
Red-Portal May 24, 2025
37f6b06
run formatter
Red-Portal May 24, 2025
c717220
run formatter
Red-Portal May 24, 2025
e9f7f1e
add Variational submodule
Red-Portal May 24, 2025
6a8c6ed
fix docstring style
Red-Portal May 24, 2025
c4d73fb
update docstring style
Red-Portal May 26, 2025
feb1a57
format docstring style
Red-Portal May 26, 2025
ea417fc
Merge branch 'breaking' into update_advancedvi
penelopeysm May 28, 2025
4c9a538
fix typo
Red-Portal May 30, 2025
dfa8d20
fix use fixed seed with StableRNGs
Red-Portal May 30, 2025
a18f581
fix export variational families
Red-Portal May 30, 2025
f9528e0
fix forma
Red-Portal May 30, 2025
fb150c7
Merge branch 'main' into update_advancedvi
yebai May 30, 2025
8174725
Merge remote-tracking branch 'origin/breaking' into update_advancedvi
penelopeysm Jun 2, 2025
dec108b
update changelog for advancedvi 0.4
Red-Portal Jun 2, 2025
b0d791e
fix version number
Red-Portal Jun 2, 2025
29373ee
Format & add some links
penelopeysm Jun 2, 2025
d21e652
Merge branch 'breaking' into update_advancedvi
Red-Portal Jun 3, 2025
4c72501
fix formatting
Red-Portal Jun 3, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# Release 0.39.0

## Update to the AdvancedVI interface

Turing's variational inference interface was updated to match version 0.4 version of AdvancedVI.jl.

AdvancedVI v0.4 introduces various new features:

- location-scale families with dense scale matrices,
- parameter-free stochastic optimization algorithms like `DoG` and `DoWG`,
- proximal operators for stable optimization,
- the sticking-the-landing control variate for faster convergence, and
- the score gradient estimator for non-differentiable targets.

Please see the [Turing API documentation](https://turinglang.org/Turing.jl/stable/api/#Variational-inference), and [AdvancedVI's documentation](https://turinglang.org/AdvancedVI.jl/stable/), for more details.

## Removal of Turing.Essential

The Turing.Essential module has been removed.
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Accessors = "0.1"
AdvancedHMC = "0.3.0, 0.4.0, 0.5.2, 0.6, 0.7"
AdvancedMH = "0.8"
AdvancedPS = "0.6.0"
AdvancedVI = "0.2"
AdvancedVI = "0.4"
BangBang = "0.4.2"
Bijectors = "0.14, 0.15"
Compat = "4.15.0"
Expand Down
7 changes: 5 additions & 2 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ makedocs(;
pages=[
"Home" => "index.md",
"API" => "api.md",
"Submodule APIs" =>
["Inference" => "api/Inference.md", "Optimisation" => "api/Optimisation.md"],
"Submodule APIs" => [
"Inference" => "api/Inference.md",
"Optimisation" => "api/Optimisation.md",
"Variational " => "api/Variational.md",
],
],
checkdocs=:exports,
doctest=false,
Expand Down
14 changes: 8 additions & 6 deletions docs/src/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,14 @@ even though [`Prior()`](@ref) is actually defined in the `Turing.Inference` modu

### Variational inference

See the [variational inference tutorial](https://turinglang.org/docs/tutorials/09-variational-inference/) for a walkthrough on how to use these.

| Exported symbol | Documentation | Description |
|:--------------- |:---------------------------- |:--------------------------------------- |
| `vi` | [`AdvancedVI.vi`](@extref) | Perform variational inference |
| `ADVI` | [`AdvancedVI.ADVI`](@extref) | Construct an instance of a VI algorithm |
See the [docs of AdvancedVI.jl](https://turinglang.org/AdvancedVI.jl/stable/) for detailed usage and the [variational inference tutorial](https://turinglang.org/docs/tutorials/09-variational-inference/) for a basic walkthrough.

| Exported symbol | Documentation | Description |
|:---------------------- |:------------------------------------------------- |:---------------------------------------------------------------------------------------- |
| `vi` | [`Turing.vi`](@ref) | Perform variational inference |
| `q_locationscale` | [`Turing.Variational.q_locationscale`](@ref) | Find a numerically non-degenerate initialization for a location-scale variational family |
| `q_meanfield_gaussian` | [`Turing.Variational.q_meanfield_gaussian`](@ref) | Find a numerically non-degenerate initialization for a mean-field Gaussian family |
| `q_fullrank_gaussian` | [`Turing.Variational.q_fullrank_gaussian`](@ref) | Find a numerically non-degenerate initialization for a full-rank Gaussian family |

Comment on lines +82 to 88
Copy link
Member

Choose a reason for hiding this comment

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

Did you want these symbols to be exported when using Turing, or only when using Turing.Variational?

The table is only supposed to contain what gets brought into the namespace when using Turing, so technically, should only contain vi given the current code status. But, for these three exports that seem very unlikely to have name clashes with other things, it seems to me that we could actually just export them from Turing (or at least I don't see why not).

Copy link
Member

@yebai yebai May 29, 2025

Choose a reason for hiding this comment

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

I suggest we combine q_locationscale, q_meanfield_gaussian, q_fullrank_gaussian methods into a single method, e.g.: q_distribution, then

  • q_distribution(MvLocationScale, args...) = AdvancedVI.q_locationscale(args...)
  • q_distribution(DiagNormal, args...) = AdvancedVI.q_meanfield_gaussian(args...)
  • q_distribution(MvNormal, args...) = AdvancedVI.q_fullrank_gaussian(args...)

Here, MvLocationScale, DiagNormal and MvNormal are exported by Distributions via Turing. This would provide a unified q_distribution interface for all variational families, and are extensible if needed.

Copy link
Member Author

@Red-Portal Red-Portal May 30, 2025

Choose a reason for hiding this comment

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

@yebai I am afraid this would complicate/confuse things a bit since q_distribution(MvNormal, ...) will not return an MvNormal type but a MvLocationScale type.

Copy link
Member Author

Choose a reason for hiding this comment

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

@penelopeysm Thanks for the suggestion. I added the exports.

### Automatic differentiation types

Expand Down
6 changes: 6 additions & 0 deletions docs/src/api/Variational.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# API: `Turing.Variational`

```@autodocs
Modules = [Turing.Variational]
Order = [:type, :function]
```
5 changes: 3 additions & 2 deletions src/Turing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ function setprogress!(progress::Bool)
@info "[Turing]: progress logging is $(progress ? "enabled" : "disabled") globally"
PROGRESS[] = progress
AbstractMCMC.setprogress!(progress; silent=true)
# TODO: `AdvancedVI.turnprogress` is removed in AdvancedVI v0.3
AdvancedVI.turnprogress(progress)
return progress
end

Expand Down Expand Up @@ -118,6 +116,9 @@ export
# Variational inference - AdvancedVI
vi,
ADVI,
q_locationscale,
q_meanfield_gaussian,
q_fullrank_gaussian,
# ADTypes
AutoForwardDiff,
AutoReverseDiff,
Expand Down
Loading