-
Notifications
You must be signed in to change notification settings - Fork 4
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
add AD (Enzyme) support via MeshIntegralsEnzymeExt #152
Conversation
I simply created an error for a handful (4) of troublesome geometries with Enzyme so we can at least get this out for the rest of them |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #152 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 18 18
Lines 165 184 +19
=========================================
+ Hits 165 184 +19 ☔ View full report in Codecov by Sentry. |
Benchmark Results
Benchmark PlotsA plot of the benchmark results have been uploaded as an artifact to the workflow run for this PR. |
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.
Thanks a lot! Please find below some suggestions and comments. The main suggestion is about refactoring the check_diff_method_support
function.
I would be interested in some benchmarks. Could we maybe (at least temporarily) change the _default_diff_method
to use AutoEnzyme
to let the benchmarks script run for the AutoEnzyme
backend, such that we get a comparison between this and the FiniteDifference
backend?
This also leads to the question whether we want AutoEnzyme
to be the _default_diff_backend
permanently. We could define something like
function _default_diff_method(g::Type{G}) where {G <: Geometry}
if supports_autoenzyme(g)
return AutoEnzyme()
else
return FiniteDifference()
end
end
but that's something to discuss and maybe also depends on the benchmark results. (The code snippet above wouldn't run with my suggestions below because they define supports_autoenzyme(::Geometry)
and not supports_autoenzyme(::Type{G}) where {G <: Geometry}
, but these are details.)
Project.toml
Outdated
[compat] | ||
CliffordNumbers = "0.1.9" | ||
CoordRefSystems = "0.12, 0.13, 0.14, 0.15, 0.16" | ||
Enzyme = "0.13.22" |
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.
This looks like a pretty high compat (v0.13.22 is only a couple of days old). Does the compat bound need to be that high?
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.
I'm sure it doesn't, but I've always wondered the best approach to finding the lowest
compat other than sweeping the tests with lower versions until it breaks?
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.
I'm usually coming from the other side meaning I first try very low compat bounds. If it fails I see the reason why it fails and check what the smallest compat bound is such that this particular reason is not a problem anymore (e.g., because I use functionality from a specific version). Then I directly jump to this version. If it breaks again I repeat until it doesn't break. This avoids to try out many different successful compat bounds. And it's usually faster to wait for failing tests than to wait for successful tests 😉
But I would also be fine if we just pick a smaller compat bound without spending too much time in trying to find the minimal possible one.
You would need to |
Ahh thanks. Initial ideas about the Downgrade run? |
Co-authored-by: Joshua Lampert <[email protected]>
Co-authored-by: Joshua Lampert <[email protected]>
Co-authored-by: Joshua Lampert <[email protected]>
If we're updating the lower bound on Meshes.jl to v0.51.20 then we can
probably remove the version check in the `combinations.jl` ***@***.***
"ParametrizedCurve"` section.
…On Fri, Dec 13, 2024 at 10:30 AM Joshua Lampert ***@***.***> wrote:
@JoshuaLampert requested changes on this pull request.
________________________________
In benchmark/Project.toml:
> LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Meshes = "eacbb407-ea5a-433e-ab97-5258b1ca43fa"
Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"
[compat]
BenchmarkTools = "1.5"
+Enzyme = "0.13"
LinearAlgebra = "1"
Meshes = "0.50, 0.51, 0.52"
⬇️ Suggested change
-Meshes = "0.50, 0.51, 0.52"
+Meshes = "0.51.20, 0.52
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because your review was requested.Message ID: ***@***.***>
|
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Joshua Lampert <[email protected]>
The benchmark results look quite nice. Overall mostly a pretty solid speedup 👍 |
I just added some formatting tweaks and docstrings. Is it possible to make What currently happens if a user tries to use |
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.
I think we are almost done.
Co-authored-by: Joshua Lampert <[email protected]>
Co-authored-by: Joshua Lampert <[email protected]>
Co-authored-by: Joshua Lampert <[email protected]>
I had this originally, but was fighting with it a bit so I dropped it. If the user tries to use it withoput loading Enzyme, you'll just see a method error, but it won't tell you why that method does not exist. One way around this is to write |
@mikeingold thanks for the docstrings and sorry about removing the newer |
How come the benchmarks don't print out as a comment here anymore? Does it just take some time? |
IMO, we can also add it later if needed or desired. But if you think it's easy and can be done also in this PR, I would also be fine.
The initial comment will always be updated for each (successful) run. |
Ok, agreed. I think this may be ready to merge then? |
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.
Thanks a lot @kylebeggs! I would like to see a final approvement by @mikeingold. Then this is good to go!
No worries. I was going to add a comment but realized I already had the file open locally, so it was a quick fix.
Concur with @JoshuaLampert here. I think this is definitely worth exploring. If it’s a quick change with obvious implementation I’d be up for seeing it here, but it might be worth completing this as-is and then exploring that in a new PR/branch with a tighter focus. |
Approved. Edit: just saw your last post. |
This is a fresh PR continuing the work in #129 because the rebase for that one was driving me insane:
Adds support to calculate the jacobian via Enzyme autodiff #35. This is done by adding a package extension for Enzyme, MeshIntegralsEnzymeExt.