-
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
Implement more _ParametricGeometry transforms #139
Conversation
Benchmark Results
Benchmark PlotsA plot of the benchmark results have been uploaded as an artifact to the workflow run for this PR. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #139 +/- ##
==========================================
Coverage 100.00% 100.00%
==========================================
Files 18 18
Lines 284 167 -117
==========================================
- Hits 284 167 -117 ☔ View full report in Codecov by Sentry. |
Thanks @JoshuaLampert for all the support lately. My free dev time seems to come in waves lol. |
Just noticed that I didn't update the Update: fixed. |
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.
Looks good to me in general. I just have some small suggestions. I do have one question:
So Triangle
is the only geometry, which uses a guaranteed analytical derivative? Do I understand correctly that you propose to use _ParametricGeometry
for Line
, Plane
, and Ray
to simplify the code despite it being slower, while for Triangle
the performance loss is too high by using _ParametricGeometry
, which is why we still use this special method for the integration?
Some fun bikeshedding: Interestingly, the newest version of the spell checker doesn't like "parametrized" and wants it to be spelled as "parameterized". As a non-native English speaker I'm not sure, but always assumed both versions are fine (seeing you usually use "parameterized"). Wikipedia also says both are fine. As |
I actually hadn’t even realized the Meshes geometry was spelled that way until I saw the tagged bot comments last night. I often find that compound technical words, especially when they’re domain-specific, are flagged as mis-spellings by common spell checkers, so I think I’ve developed an unfortunate tendency to ignore those warnings. Looks like both spellings, with and without the “e” are valid but each is maybe more commonly used in certain contexts. If one is more widely preferred then I’d have no reservations about adjusting all of the spellings in this package. |
My personal preference would be to just “rip off the bandage” and implement them all, then focus on restoring some of the performance loss in patch updates, but I don’t want to dictate the path we take if that isn’t palatable to others. I went ahead and implemented these because the performance loss was less impactful, and I’m more willing to argue for these. |
I just tried out the
I'm willing to argue that a regression from 0.5 ms to 0.9 ms for integrating an infinite plane is acceptable given the other benefits, but this is a lot more impactful, especially given its status as the 2D simplex. I'll see if I can do some profiling to improve performance, but without significant improvements I'm going to have to revert this change and defer it again. Update: I tried disabling the bounds check inside Update: These numbers are now out-dated. Performance has gotten much better. See updated post at the top. |
I think I pulled it off. I refactored We've gone from a 27x performance degradation to only about 10%! 🎉 As a bonus, performance for integrals of |
Co-authored-by: Joshua Lampert <[email protected]>
I just added an Issue #143 to keep track of this point. I'm pretty happy with where this PR is at, despite it growing in scope from what I'd originally planned. |
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 already looks pretty good. I would guess that the main reason for the performance decrease is the fact that we need to apply finite differences now. Therefore, my hope is that we will gain some performance again after we have finished the AutoEnzyme
backend.
Can you please remove the reference to Analytical
in
MeshIntegrals.jl/src/differentiation.jl
Line 12 in c8f66c5
See also [`FiniteDifference`](@ref), [`Analytical`](@ref). |
@JoshuaLampert My main reason for concern is precisely what @mikeingold stated:
but 10% is not too bad at all, and hopefully using autodiff does help. The code simplification is enormous here, it looks great! |
Co-authored-by: Joshua Lampert <[email protected]>
Co-authored-by: Joshua Lampert <[email protected]>
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!
Changes
_ParametricGeometry
transforms to implement newintegral
methods for:Line
Plane
Ray
Triangle
_parametric(::Triangle)
, improving performance when integratingTetrahedron
by about 10x! 🎉Analytical <: DifferentiationMethod
and related utilities (_has_analytical
and_guarantee_analytical
) now that they're unused._parametric(::Geometry)
returns a transformed parametric function instead of being one.Triangle
)benchmarks.jl
scriptTetrahedron
now that Integral onTetrahedron
not fully supported #40 closed.N
benchmark sample size parameterDiscussion
Some of the new
_ParametricGeometry
implementations incur performance regressions, but I believe these are minor impacts relative to the significant benefits provided.Line
Plane
Ray
Tetrahedron
Triangle
Benefits:
integral
methods are simply decompositions/transforms that are then forwarded to the general_integral
solvers inintegral.jl
. This simplifies the methodologies used from: the general case, some decompositions, and a pile of special-case methods; to: the general case, and decompositions to the general case. I think this will ultimately make it easier to communicate what behavior to expect and lead to fewer surprised end-users (principle of lease surprise).Analytical
type and associated utilities to handle it.Triangle
, which will make the code easier to understand and maintain.