-
Notifications
You must be signed in to change notification settings - Fork 19
Optimize code for better performance and maintainability #163
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
Conversation
Optimize and refactor various functions for better performance and maintainability. * **bench/benchmarks.jl** - Uncomment the AD backends in the `for` loop. - Add Mooncake and Enzyme AD backends for testing. * **bench/normallognormal.jl** - Optimize the `LogDensityProblems.logdensity` function by separating the log density calculations for `LogNormal` and `MvNormal`. * **ext/AdvancedVIBijectorsExt.jl** - Refactor the `AdvancedVI.apply` function to remove repetitive code for different types. - Introduce `apply_clip_scale` function to handle different distribution types. * **src/AdvancedVI.jl** - Simplify the `optimize` function structure for better readability and maintainability. - Add detailed documentation for the `optimize` function. * **src/families/location_scale.jl** - Optimize the `Distributions.logpdf` function by separating the standardization step. --- For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/TuringLang/AdvancedVI.jl?shareId=XXXX-XXXX-XXXX-XXXX).
I experimented with Co-pilot -- all seem very reasonable suggestions! |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #163 +/- ##
==========================================
+ Coverage 91.76% 91.78% +0.02%
==========================================
Files 13 13
Lines 352 353 +1
==========================================
+ Hits 323 324 +1
Misses 29 29 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this 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: de81456 | Previous: c55528e | Ratio |
---|---|---|---|
normal/RepGradELBO + STL/meanfield/Zygote |
15382128189 ns |
13802519072 ns |
1.11 |
normal/RepGradELBO + STL/meanfield/ForwardDiff |
4537244324.5 ns |
3356403413.5 ns |
1.35 |
normal/RepGradELBO + STL/meanfield/ReverseDiff |
3471695161 ns |
3021926516 ns |
1.15 |
normal/RepGradELBO + STL/meanfield/Mooncake |
9336748853 ns |
||
normal/RepGradELBO + STL/fullrank/Zygote |
15312445282 ns |
13681473373 ns |
1.12 |
normal/RepGradELBO + STL/fullrank/ForwardDiff |
4546036635.5 ns |
3689636504.5 ns |
1.23 |
normal/RepGradELBO + STL/fullrank/ReverseDiff |
6567681491 ns |
5663417464 ns |
1.16 |
normal/RepGradELBO + STL/fullrank/Mooncake |
9539435397 ns |
||
normal/RepGradELBO/meanfield/Zygote |
7035276783 ns |
6116693013 ns |
1.15 |
normal/RepGradELBO/meanfield/ForwardDiff |
2466526668 ns |
2466536350 ns |
1.00 |
normal/RepGradELBO/meanfield/ReverseDiff |
1493587239 ns |
1321012473 ns |
1.13 |
normal/RepGradELBO/meanfield/Mooncake |
7339348743 ns |
||
normal/RepGradELBO/fullrank/Zygote |
7075901888 ns |
6203991729 ns |
1.14 |
normal/RepGradELBO/fullrank/ForwardDiff |
2886252837.5 ns |
2629277548 ns |
1.10 |
normal/RepGradELBO/fullrank/ReverseDiff |
2900271879 ns |
2459356113 ns |
1.18 |
normal/RepGradELBO/fullrank/Mooncake |
7598264040 ns |
||
normal + bijector/RepGradELBO + STL/meanfield/Zygote |
23715507310 ns |
22084065176 ns |
1.07 |
normal + bijector/RepGradELBO + STL/meanfield/ForwardDiff |
13497905690 ns |
10546466980 ns |
1.28 |
normal + bijector/RepGradELBO + STL/meanfield/ReverseDiff |
4670737107.5 ns |
4530973116.5 ns |
1.03 |
normal + bijector/RepGradELBO + STL/meanfield/Mooncake |
25964400761 ns |
||
normal + bijector/RepGradELBO + STL/fullrank/Zygote |
23566405974 ns |
22345253347 ns |
1.05 |
normal + bijector/RepGradELBO + STL/fullrank/ForwardDiff |
13685992287 ns |
10945544739 ns |
1.25 |
normal + bijector/RepGradELBO + STL/fullrank/ReverseDiff |
8462077032 ns |
7859941162 ns |
1.08 |
normal + bijector/RepGradELBO + STL/fullrank/Mooncake |
26526217091 ns |
||
normal + bijector/RepGradELBO/meanfield/Zygote |
14611902776 ns |
13813477870 ns |
1.06 |
normal + bijector/RepGradELBO/meanfield/ForwardDiff |
11096163496 ns |
9270416271 ns |
1.20 |
normal + bijector/RepGradELBO/meanfield/ReverseDiff |
2563882411 ns |
2587262809 ns |
0.99 |
normal + bijector/RepGradELBO/meanfield/Mooncake |
23737562263 ns |
||
normal + bijector/RepGradELBO/fullrank/Zygote |
14787023027 ns |
14000051621 ns |
1.06 |
normal + bijector/RepGradELBO/fullrank/ForwardDiff |
10888674674 ns |
9875600981 ns |
1.10 |
normal + bijector/RepGradELBO/fullrank/ReverseDiff |
4294694220 ns |
4083240829 ns |
1.05 |
normal + bijector/RepGradELBO/fullrank/Mooncake |
24388566270 ns |
This comment was automatically generated by workflow using github-action-benchmark.
No description provided.