Skip to content
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

Make global AD indexing with sparse container MOOSE default config #16091

Closed
lindsayad opened this issue Nov 5, 2020 · 2 comments · Fixed by #16440
Closed

Make global AD indexing with sparse container MOOSE default config #16091

lindsayad opened this issue Nov 5, 2020 · 2 comments · Fixed by #16440
Assignees
Labels
C: Automatic Differentiation Tickets pertaining the MetaPhysicL based forward mode AD system C: Framework P: normal A defect affecting operation with a low possibility of significantly affects. T: task An enhancement to the software.

Comments

@lindsayad
Copy link
Member

lindsayad commented Nov 5, 2020

Reason

Pros:

  • Much simpler code
  • Much lower chance of accidentally creating slow code because if you try to do a bunch of DualNumber math with an unseeded sparse container, you don't take much of a performance hit. You can see Speed up nonsparse AD initial setup significantly #16089 for an example of why nonsparse containers are a pain
  • Much more flexible code. You can build residuals depending on totally arbitrary nonlinear degrees of freedom and track it with ease
  • Maintain speed over a broad class of physics and dimensionality. It's nice to able to do a 3D Navier-Stokes calculation and a 1D diffusion calculation with the same binary and not see a penalty in performance in the 1D calculation

Cons:

  • Maybe it's slower sometimes? Someone has yet to show me a concrete example of this, however.

Design

It's already done. Just have to change MooseDefaultConfig.h. I'm going to give users some time to give feedback before making this change. If I see enough concrete examples of global-sparse AD being slow relative to local-nonsparse AD, then I won't make the change. Unless that happens, however, I'm planning to make the change in January.

An important note is that even if we change to global-sparse as the default config, nonsparse isn't going to disappear as a configure option, at least not for the foreseeable future and not without proper deprecation warnings (they would be compiler-time warnings).

Impact

I think I would probably spend a lot less time doing AD maintenance in a framework that was global-sparse-AD based. For example I've sunk a half-day into #16089 which I wouldn't have if we lived in a world of global-sparse-AD. Also if we were to one day deprecate the nonsparse code, our AD code base would get much simpler and it would be easier to do AD development. Moreover, I think it would positively impact users for the reasons mentioned above.

@lindsayad lindsayad added T: task An enhancement to the software. P: normal A defect affecting operation with a low possibility of significantly affects. C: Automatic Differentiation Tickets pertaining the MetaPhysicL based forward mode AD system labels Nov 5, 2020
@lindsayad lindsayad self-assigned this Nov 5, 2020
@veeshy
Copy link
Contributor

veeshy commented Nov 6, 2020

Very cool! Any examples of the non local jac usage alluded to in #15732? I’m guessing in FV somewhere?

@lindsayad
Copy link
Member Author

lindsayad commented Nov 6, 2020 via email

lindsayad added a commit to lindsayad/moose that referenced this issue Dec 9, 2020
lindsayad added a commit to lindsayad/moose that referenced this issue Jan 21, 2021
lindsayad added a commit to lindsayad/moose that referenced this issue Jan 22, 2021
jain651 pushed a commit to jain651/moose that referenced this issue Apr 19, 2021
aeslaughter pushed a commit to aeslaughter/moose that referenced this issue Jun 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: Automatic Differentiation Tickets pertaining the MetaPhysicL based forward mode AD system C: Framework P: normal A defect affecting operation with a low possibility of significantly affects. T: task An enhancement to the software.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants