Add pushforwards for the Kokkos:: math functions. - #1899
Open
vgvassilev wants to merge 1 commit into
Open
Conversation
vgvassilev
force-pushed
the
kokkos-math-pushforwards
branch
from
July 17, 2026 10:41
c54e692 to
f5b2d14
Compare
Contributor
|
clang-tidy review says "All clean, LGTM! 👍" |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
vgvassilev
force-pushed
the
kokkos-math-pushforwards
branch
from
July 17, 2026 11:14
f5b2d14 to
4c236ee
Compare
Contributor
|
clang-tidy review says "All clean, LGTM! 👍" |
Kokkos ships its own math functions (Kokkos::cos, Kokkos::sqrt, ...) so a kernel differentiates identically on host and device. clad has no registered derivatives for them, so it descends into the wrapper's body and trips an internal assertion instead of differentiating the call. Register pushforwards for cos, sin, and sqrt in KokkosBuiltins.h, mirroring how BuiltinDerivatives.h handles the std:: math functions: clad now emits a call to the known derivative rather than cloning the wrapper. Reverse mode is synthesized from the same pushforward, so no pullback is added. The change is header-only: dispatch to clad::custom_derivatives::Kokkos::* is the path the View pushforwards in this header already use. fabs is left out for now -- Kokkos::fabs is not present in every supported Kokkos version.
vgvassilev
force-pushed
the
kokkos-math-pushforwards
branch
from
July 17, 2026 11:24
4c236ee to
0370085
Compare
Contributor
|
clang-tidy review says "All clean, LGTM! 👍" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Kokkos ships its own math functions (Kokkos::cos, Kokkos::sqrt, ...) so a kernel differentiates identically on host and device. clad has no registered derivatives for them, so it descends into the wrapper's body and trips an internal assertion instead of differentiating the call.
Register pushforwards for cos, sin, sqrt, and fabs in KokkosBuiltins.h, mirroring how BuiltinDerivatives.h handles the std:: math functions: clad now emits a call to the known derivative rather than cloning the wrapper. Reverse mode is synthesized from the same pushforward, so no pullback is added. The change is header-only: dispatch to clad::custom_derivatives::Kokkos::* is the path the View pushforwards in this header already use.