-
Notifications
You must be signed in to change notification settings - Fork 36
Don't use closure for enzyme #1048
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
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1048 +/- ##
==========================================
- Coverage 82.41% 82.39% -0.03%
==========================================
Files 39 39
Lines 3964 3965 +1
==========================================
Hits 3267 3267
- Misses 697 698 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Pull Request Test Coverage Report for Build 17981527989Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
@wsmoses Is there a particular motivation for avoiding closures? I benchmarked Enzyme on the demo models before / after this PR and I don't think there's a significant difference.
Benchmarking code: using DynamicPPL, Distributions, Enzyme, ADTypes, DataFrames, CSV
using DynamicPPL.TestUtils.AD: run_ad, ADResult, NoTest
# For this PR I removed `function_annotation`
ADTYPES = Dict(
"EnzymeForward" => AutoEnzyme(; mode=set_runtime_activity(Forward, true), function_annotation=Const),
"EnzymeReverse" => AutoEnzyme(; mode=set_runtime_activity(Reverse, true), function_annotation=Const),
)
MODELS = DynamicPPL.TestUtils.DEMO_MODELS
RESULTS = []
for model in MODELS
for (adtype_name, adtype) in ADTYPES
result = run_ad(model, adtype; test=NoTest(), benchmark=true)
time_vs_primal = result.grad_time / result.primal_time
push!(RESULTS, (model="$(model.f)", adtype=adtype_name, time=time_vs_primal))
end
end
RESULT_DF = DataFrame(RESULTS)
CSV.write("results.csv", RESULT_DF) |
It makes it more natively compatible (eg no need for function annotation), which comes with plenty of benefits including a partial prereq for reactant compatibility |
Okay, I'll bump a patch and release! |
No description provided.