Skip to content
Open
Show file tree
Hide file tree
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 AdvancedVI@0.5
Red-Portal Oct 22, 2025
86ee6dd
revert unintended commit of `runtests.jl`
Red-Portal Oct 22, 2025
3e30e04
Merge branch 'breaking' of github.com:TuringLang/Turing.jl into bump_…
Red-Portal Oct 24, 2025
d870045
update docs for `vi`
Red-Portal Oct 24, 2025
2d928e0
add history entry for `AdvancedVI@0.5`
Red-Portal Oct 24, 2025
5211b37
remove export for removed symbol
Red-Portal Oct 24, 2025
f0d615d
fix formatting
Red-Portal Oct 24, 2025
1b2351f
fix formatting
Red-Portal Oct 24, 2025
2be31b4
tidy tests advi
Red-Portal Oct 24, 2025
e48ae42
fix rename file `advi.jl` to `vi.jl` to reflect naming changes
Red-Portal Oct 24, 2025
44f7762
fix docs
Red-Portal Oct 25, 2025
fd0e928
fix HISTORY.md
Red-Portal Oct 25, 2025
77276bd
fix HISTORY.md
Red-Portal Oct 25, 2025
cb1620c
Merge branch 'main' of github.com:TuringLang/Turing.jl into bump_adva…
Red-Portal Oct 25, 2025
e70ddb4
update history
Red-Portal Oct 25, 2025
115802d
Merge branch 'bump_advancedvi_0.5' of github.com:TuringLang/Turing.jl…
Red-Portal Oct 25, 2025
25b5087
Merge branch 'main' of github.com:TuringLang/Turing.jl into bump_adva…
Red-Portal Nov 19, 2025
4c02f7b
bump AdvancedVI version
Red-Portal Nov 19, 2025
6518b82
add exports new algorithms, modify `vi` to operate in unconstrained
Red-Portal Nov 19, 2025
5bd6978
Merge branch 'breaking' of github.com:TuringLang/Turing.jl into bump_…
Red-Portal Nov 19, 2025
874a0b2
add clarification on initializing unconstrained algorithms
Red-Portal Nov 19, 2025
e021eb7
update api
Red-Portal Nov 19, 2025
eec7ef2
run formatter
Red-Portal Nov 19, 2025
b6d8202
run formatter
Red-Portal Nov 19, 2025
b900ab4
run formatter
Red-Portal Nov 19, 2025
e71b07b
run formatter
Red-Portal Nov 19, 2025
c08de12
run formatter
Red-Portal Nov 19, 2025
ae80f1e
run formatter
Red-Portal Nov 19, 2025
73bd309
run formatter
Red-Portal Nov 19, 2025
eaac4c3
run formatter
Red-Portal Nov 19, 2025
757ebb4
revert changes to README
Red-Portal Nov 19, 2025
05ab711
fix wrong use of transformation in vi
Red-Portal Nov 20, 2025
91606b5
change inital value for scale matrices to 0.6*I and update docs
Red-Portal Nov 20, 2025
722153a
run formatter
Red-Portal Nov 20, 2025
65bfaa3
fix rename advi to vi
Red-Portal Nov 21, 2025
61e59a6
Merge branch 'bump_advancedvi_0.5' of github.com:TuringLang/Turing.jl…
Red-Portal Nov 21, 2025
4a039dd
add batch-and-match
Red-Portal Nov 21, 2025
f782f56
fix format api table
Red-Portal Nov 21, 2025
5251ee7
fix use fullrank Gaussian in tests since all algorithm support it
Red-Portal Nov 21, 2025
b665f96
fix tweak step sizes, remove unused kwargs
Red-Portal Nov 21, 2025
15af544
fix increase budgets for failing algorithms
Red-Portal Nov 21, 2025
7711e42
run formatter
Red-Portal Nov 21, 2025
a319962
rename main variational inference file to match module name
Red-Portal Nov 22, 2025
6e76afa
run formatter
Red-Portal Nov 27, 2025
2e78774
fix docstring
Red-Portal Nov 27, 2025
98d07f8
run formatter
Red-Portal Nov 27, 2025
cc2cac9
update docstring
Red-Portal Nov 27, 2025
2d88ddd
update docstring
Red-Portal Nov 27, 2025
025202f
fix missing docstring for `unconstrained` keyword argument
Red-Portal Nov 27, 2025
59fe8dc
fix relax assert transformed dist to an exception and add test
Red-Portal Nov 27, 2025
b1aa675
Update HISTORY.md
Red-Portal Nov 27, 2025
22895b0
run formatter
Red-Portal Nov 27, 2025
733f0be
run formatter
Red-Portal Nov 27, 2025
2530f05
run formatter
Red-Portal Nov 27, 2025
cb5a798
fix document the change in output of `vi` in `HISTORY`
Red-Portal Nov 27, 2025
8bd0ba7
run formatter
Red-Portal Nov 27, 2025
ed25920
run formatter
Red-Portal Nov 27, 2025
6be562d
run formatter
Red-Portal Nov 27, 2025
df1b832
run formatter
Red-Portal Nov 27, 2025
d83148b
add missing namespace
Red-Portal Nov 27, 2025
a686cae
fix add missing import for `@test_throws`
Red-Portal Nov 29, 2025
31256e3
Merge branch 'breaking' into bump_advancedvi_0.5
Red-Portal Nov 29, 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
90 changes: 90 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
`AdvancedVI.jl@0.6` 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 `AdvancedVI@0.2`-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

`AdvancedVI@0.6` 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.
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Accessors = "0.1"
AdvancedHMC = "0.8.3"
AdvancedMH = "0.8.9"
AdvancedPS = "0.7"
AdvancedVI = "0.4"
AdvancedVI = "0.6"
BangBang = "0.4.2"
Bijectors = "0.14, 0.15"
Compat = "4.15.0"
Expand Down
19 changes: 13 additions & 6 deletions docs/src/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,19 @@ Turing.jl provides several strategies to initialise parameters for models.

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 |
| 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 |
| `KLMinRepGradDescent` | [`Turing.Variational.KLMinRepGradDescent`](@ref) | KL divergence minimization via stochastic gradient descent with the reparameterization gradient |
| `KLMinRepGradProxDescent` | [`Turing.Variational.KLMinRepGradProxDescent`](@ref) | KL divergence minimization via stochastic proximal gradient descent with the reparameterization gradient over location-scale variational families |
| `KLMinScoreGradDescent` | [`Turing.Variational.KLMinScoreGradDescent`](@ref) | KL divergence minimization via stochastic gradient descent with the score gradient |
| `KLMinWassFwdBwd` | [`Turing.Variational.KLMinWassFwdBwd`](@ref) | KL divergence minimization via Wasserstein proximal gradient descent |
| `KLMinNaturalGradDescent` | [`Turing.Variational.KLMinNaturalGradDescent`](@ref) | KL divergence minimization via natural gradient descent |
| `KLMinSqrtNaturalGradDescent` | [`Turing.Variational.KLMinSqrtNaturalGradDescent`](@ref) | KL divergence minimization via natural gradient descent in the square-root parameterization |
| `FisherMinBatchMatch` | [`Turing.Variational.FisherMinBatchMatch`](@ref) | Covariance-weighted Fisher divergence minimization via the batch-and-match algorithm |

### Automatic differentiation types

Expand Down
10 changes: 8 additions & 2 deletions src/Turing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ include("stdlib/distributions.jl")
include("stdlib/RandomMeasures.jl")
include("mcmc/Inference.jl") # inference algorithms
using .Inference
include("variational/VariationalInference.jl")
include("variational/Variational.jl")
using .Variational

include("optimisation/Optimisation.jl")
Expand Down Expand Up @@ -117,10 +117,16 @@ export
externalsampler,
# Variational inference - AdvancedVI
vi,
ADVI,
q_locationscale,
q_meanfield_gaussian,
q_fullrank_gaussian,
KLMinRepGradProxDescent,
KLMinRepGradDescent,
KLMinScoreGradDescent,
KLMinNaturalGradDescent,
KLMinSqrtNaturalGradDescent,
KLMinWassFwdBwd,
FisherMinBatchMatch,
# ADTypes
AutoForwardDiff,
AutoReverseDiff,
Expand Down
Loading
Loading