Skip to content

Conversation

Red-Portal
Copy link
Member

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

Previously, for KLMinReGradDescent, the default operator keyword argument was ClipScale(). Now, ClipScale assumes the variational family is <:MvLocationScale. So if a different variational family is used, it would return an error. This will probably be confusing to the users ( although I expect location-scales to be used most of the time, so it was a decision optimized for this use case). On the other hand, when using location-scales, it is essential to use ClipScale, which has to be communicated in some way.

This PR fixes the issues above as follows: IdentityOperator is now the default value for operator. However, whenever a <:MvLocationScale family is used in combination with IdentityOperator, a warning will be displayed explaining that this is not a good idea while instructing to use ClipScale.

@Red-Portal Red-Portal requested review from sunxd3 and yebai August 26, 2025 19:58
Red-Portal and others added 5 commits August 26, 2025 15:59
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>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Copy link
Contributor

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

@yebai
Copy link
Member

yebai commented Aug 26, 2025

I'll leave this to @zuhengxu or @sunxd3 for a review.

@yebai yebai removed their request for review August 26, 2025 20:05
…ngLang/AdvancedVI.jl into change_default_operator_advi
@Red-Portal Red-Portal requested a review from zuhengxu August 26, 2025 20:06
@Red-Portal Red-Portal added the enhancement New feature or request label Aug 26, 2025
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: b5f30b6 Previous: 89792f5 Ratio
normal/RepGradELBO + STL/meanfield/Zygote 3854411925.5 ns 3885127850.5 ns 0.99
normal/RepGradELBO + STL/meanfield/ReverseDiff 1132239771 ns 1134192546 ns 1.00
normal/RepGradELBO + STL/meanfield/Mooncake 1229203243 ns 1189440216 ns 1.03
normal/RepGradELBO + STL/fullrank/Zygote 3849984126 ns 3875571674 ns 0.99
normal/RepGradELBO + STL/fullrank/ReverseDiff 1625327857 ns 1630205282.5 ns 1.00
normal/RepGradELBO + STL/fullrank/Mooncake 1253912550 ns 1251609883 ns 1.00
normal/RepGradELBO/meanfield/Zygote 2688901547 ns 2776185010 ns 0.97
normal/RepGradELBO/meanfield/ReverseDiff 780829400 ns 796550877 ns 0.98
normal/RepGradELBO/meanfield/Mooncake 1090922281 ns 1077307075 ns 1.01
normal/RepGradELBO/fullrank/Zygote 2742295948.5 ns 2781660852.5 ns 0.99
normal/RepGradELBO/fullrank/ReverseDiff 958847335 ns 947239522.5 ns 1.01
normal/RepGradELBO/fullrank/Mooncake 1136824194 ns 1117639731 ns 1.02
normal + bijector/RepGradELBO + STL/meanfield/Zygote 5521801742 ns 5507943890 ns 1.00
normal + bijector/RepGradELBO + STL/meanfield/ReverseDiff 2412856875 ns 2400012438 ns 1.01
normal + bijector/RepGradELBO + STL/meanfield/Mooncake 4028904376.5 ns 4067417017.5 ns 0.99
normal + bijector/RepGradELBO + STL/fullrank/Zygote 5583900806 ns 5518202036 ns 1.01
normal + bijector/RepGradELBO + STL/fullrank/ReverseDiff 3040109403 ns 3002283069 ns 1.01
normal + bijector/RepGradELBO + STL/fullrank/Mooncake 4119691765.5 ns 4121790814.5 ns 1.00
normal + bijector/RepGradELBO/meanfield/Zygote 4370908715 ns 4221420082.5 ns 1.04
normal + bijector/RepGradELBO/meanfield/ReverseDiff 2030847373 ns 2000407104 ns 1.02
normal + bijector/RepGradELBO/meanfield/Mooncake 3864032093.5 ns 3872951671.5 ns 1.00
normal + bijector/RepGradELBO/fullrank/Zygote 4405243285.5 ns 4329628829 ns 1.02
normal + bijector/RepGradELBO/fullrank/ReverseDiff 2287718739 ns 2255868329 ns 1.01
normal + bijector/RepGradELBO/fullrank/Mooncake 3930085455.5 ns 4022021340.5 ns 0.98

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

@Red-Portal Red-Portal requested a review from penelopeysm August 28, 2025 17:31
@Red-Portal Red-Portal added this to the v0.5.0 milestone Aug 29, 2025
@Red-Portal
Copy link
Member Author

Gentle ping for anybody around @zuhengxu @sunxd3 @penelopeysm

@zuhengxu
Copy link
Member

zuhengxu commented Sep 1, 2025

This looks good to me if we do want to use IdentityOperator as the default one.
Personally, I prefer to have the default operator to be IdentityOperator (which enables optimizing NF through the advi interface). However, considering that most of the use case of advi.jl might be of the structure VI family, not using ClipScale() can result in NaN during training.

I'd like to hear about @penelopeysm's and @sunxd3's opinion.

@Red-Portal
Copy link
Member Author

@penelopeysm @sunxd3 Gentle ping

@Red-Portal
Copy link
Member Author

@penelopeysm @sunxd3 Gentle ping

@Red-Portal
Copy link
Member Author

@yebai @sunxd3 @penelopeysm Gentle ping. Sorry for the hassle you all!

@Red-Portal
Copy link
Member Author

@penelopeysm Thanks!

@Red-Portal Red-Portal merged commit ca2b3e4 into main Sep 14, 2025
28 of 34 checks passed
@Red-Portal Red-Portal deleted the klminrepgradescent_default_identity branch September 14, 2025 19:46
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.

4 participants