Skip to content

Conversation

Red-Portal
Copy link
Member

@Red-Portal Red-Portal commented Aug 20, 2025

This PR does the following:

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Remaining comments which cannot be posted as a review comment to avoid GitHub Rate Limit

JuliaFormatter

[JuliaFormatter] reported by reviewdog 🐶

import DifferentiationInterface
import LogDensityProblemsAD


[JuliaFormatter] reported by reviewdog 🐶

```@example basic


[JuliaFormatter] reported by reviewdog 🐶

The bijector can now be applied to `q` to match the support of the target problem.


[JuliaFormatter] reported by reviewdog 🐶

```@example basic


[JuliaFormatter] reported by reviewdog 🐶

We can now run VI:


[JuliaFormatter] reported by reviewdog 🐶

```@example basic


[JuliaFormatter] reported by reviewdog 🐶

alg,
max_iter,
model_ad,
q_transformed;
show_progress=false,


[JuliaFormatter] reported by reviewdog 🐶

plot([i.iteration for i in info], [i.elbo for i in info]; xlabel="Iteration", ylabel="ELBO", label=nothing)


[JuliaFormatter] reported by reviewdog 🐶

import StatsFuns


[JuliaFormatter] reported by reviewdog 🐶


[JuliaFormatter] reported by reviewdog 🐶

samples = rand(q_avg, n_samples)
β = samples[1:end-1,:]


[JuliaFormatter] reported by reviewdog 🐶

logit = model.X*β
pred_prob = mean(StatsFuns.logistic.(logit), dims=2)
y_pred = pred_prob .> 0.5


[JuliaFormatter] reported by reviewdog 🐶


[JuliaFormatter] reported by reviewdog 🐶

(elbo_callback = elbo_callback, accuracy = acc,)


[JuliaFormatter] reported by reviewdog 🐶

Note that the interface for the callback function will depend on the VI algorithm being used.


[JuliaFormatter] reported by reviewdog 🐶

```@example basic


[JuliaFormatter] reported by reviewdog 🐶

alg,
max_iter,
model_ad,
q_transformed;
show_progress=false,
callback=callback,


[JuliaFormatter] reported by reviewdog 🐶

```@example basic


[JuliaFormatter] reported by reviewdog 🐶

![](basic_example_elbo_callback.svg)


[JuliaFormatter] reported by reviewdog 🐶

```@example basic


[JuliaFormatter] reported by reviewdog 🐶

plot(t_callback, acc_callback; xlabel="Iteration", ylabel="Prediction Accuracy", label=nothing)


[JuliaFormatter] reported by reviewdog 🐶

![](basic_example_acc.svg)


[JuliaFormatter] reported by reviewdog 🐶


[JuliaFormatter] reported by reviewdog 🐶


[JuliaFormatter] reported by reviewdog 🐶


[JuliaFormatter] reported by reviewdog 🐶


[JuliaFormatter] reported by reviewdog 🐶


[JuliaFormatter] reported by reviewdog 🐶

import OpenML
import DataFrames


[JuliaFormatter] reported by reviewdog 🐶

stan_data = (X=transpose(X), y=y, N=size(X,1), D=size(X,2))


[JuliaFormatter] reported by reviewdog 🐶


[JuliaFormatter] reported by reviewdog 🐶


[JuliaFormatter] reported by reviewdog 🐶


[JuliaFormatter] reported by reviewdog 🐶

import StanLogDensityProblems


[JuliaFormatter] reported by reviewdog 🐶


[JuliaFormatter] reported by reviewdog 🐶

alg = KLMinRepGradProxDescent(ADTypes.AutoReverseDiff(), optimizer=DoG())


[JuliaFormatter] reported by reviewdog 🐶

q_out, info, _ = AdvancedVI.optimize(
alg,
max_iter,
model,
q;
show_progress=false,
)


[JuliaFormatter] reported by reviewdog 🐶

Copy link
Contributor

AdvancedVI.jl documentation for PR #195 is available at:
https://TuringLang.github.io/AdvancedVI.jl/previews/PR195/

Copy link
Contributor

@github-actions github-actions bot left a 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: a6bee5c Previous: 3494495 Ratio
normal/RepGradELBO + STL/meanfield/Zygote 3926634559 ns 3996757467 ns 0.98
normal/RepGradELBO + STL/meanfield/ReverseDiff 1095369782 ns 1140047768 ns 0.96
normal/RepGradELBO + STL/meanfield/Mooncake 1227522224 ns 1230760781 ns 1.00
normal/RepGradELBO + STL/fullrank/Zygote 3922841597 ns 3936331638.5 ns 1.00
normal/RepGradELBO + STL/fullrank/ReverseDiff 1559768677 ns 1641473569.5 ns 0.95
normal/RepGradELBO + STL/fullrank/Mooncake 1267644104 ns 1252509818 ns 1.01
normal/RepGradELBO/meanfield/Zygote 2792369270 ns 2793834189 ns 1.00
normal/RepGradELBO/meanfield/ReverseDiff 757805271 ns 787744069 ns 0.96
normal/RepGradELBO/meanfield/Mooncake 1093440132 ns 1093725423 ns 1.00
normal/RepGradELBO/fullrank/Zygote 2802181226 ns 2807135945 ns 1.00
normal/RepGradELBO/fullrank/ReverseDiff 933451124 ns 971111099 ns 0.96
normal/RepGradELBO/fullrank/Mooncake 1136995207 ns 1146732313 ns 0.99
normal + bijector/RepGradELBO + STL/meanfield/Zygote 5521524597 ns 5608462304 ns 0.98
normal + bijector/RepGradELBO + STL/meanfield/ReverseDiff 2367096923 ns 2417067769 ns 0.98
normal + bijector/RepGradELBO + STL/meanfield/Mooncake 4094493188.5 ns 4104543374 ns 1.00
normal + bijector/RepGradELBO + STL/fullrank/Zygote 5547829229 ns 5672628843 ns 0.98
normal + bijector/RepGradELBO + STL/fullrank/ReverseDiff 3008094862.5 ns 3036403182 ns 0.99
normal + bijector/RepGradELBO + STL/fullrank/Mooncake 4268212649.5 ns 4247049117 ns 1.00
normal + bijector/RepGradELBO/meanfield/Zygote 4356303801 ns 4346947957.5 ns 1.00
normal + bijector/RepGradELBO/meanfield/ReverseDiff 2069840696 ns 2050795942 ns 1.01
normal + bijector/RepGradELBO/meanfield/Mooncake 3958629341.5 ns 3967316792 ns 1.00
normal + bijector/RepGradELBO/fullrank/Zygote 4434786693 ns 4416104778.5 ns 1.00
normal + bijector/RepGradELBO/fullrank/ReverseDiff 2256610991 ns 2295255958 ns 0.98
normal + bijector/RepGradELBO/fullrank/Mooncake 4093637525 ns 4063691177.5 ns 1.01

This comment was automatically generated by workflow using github-action-benchmark.

Copy link

codecov bot commented Aug 20, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.38%. Comparing base (c3ddbac) to head (5899b9d).
⚠️ Report is 5 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #195      +/-   ##
==========================================
- Coverage   88.98%   87.38%   -1.61%     
==========================================
  Files          18       18              
  Lines         445      444       -1     
==========================================
- Hits          396      388       -8     
- Misses         49       56       +7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Red-Portal Red-Portal requested review from sunxd3 and yebai August 22, 2025 19:45
Copy link
Member

@zuhengxu zuhengxu left a comment

Choose a reason for hiding this comment

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

Looks good to me aside from a few minor comments!

@Red-Portal Red-Portal requested a review from zuhengxu August 28, 2025 16:10
@zuhengxu
Copy link
Member

Great work and great tutorial (very nice interface for the subsampling part)! This PR looks good to me!

@Red-Portal
Copy link
Member Author

@zuhengxu Thanks! @yebai how should we go from here? Should I wait for the others to take a look?

@Red-Portal Red-Portal added this to the v0.5.0 milestone Aug 29, 2025
@Red-Portal
Copy link
Member Author

@yebai @penelopeysm @sunxd3 Gentle ping

@Red-Portal
Copy link
Member Author

@yebai @penelopeysm @sunxd3 Gentle ping

@yebai
Copy link
Member

yebai commented Sep 8, 2025

yes, feel free to merge

@Red-Portal Red-Portal merged commit cb11ac4 into main Sep 8, 2025
29 of 35 checks passed
@Red-Portal Red-Portal deleted the add_basic_tutorials branch September 8, 2025 17:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants