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

Add basic Kokkos support for the original tests of #783 #977

Merged
merged 1 commit into from
Jul 22, 2024

Conversation

gojakuch
Copy link
Collaborator

This commit adds a test from the original Kokkos PR #783 and provides the implementation of the simplest Kokkos features in the form of custom pushforwards. This commit only addresses the forward mode.

@gojakuch
Copy link
Collaborator Author

The exact way this has been implemented in this PR is a subject for a discussion. I'm specifically talking about the way I put all the pushforwards in this file in the unittest directory. I also removed the initial tests I'd written in favour of the original ones from the PR #783 that basically cover the same things.

@gojakuch
Copy link
Collaborator Author

@vgvassilev as far as I can see, clang-format and some other checks are failing because there's no valid OpenPGP data being found, so it's probably not the PR's fault.

Copy link
Contributor

clang-tidy review says "All clean, LGTM! 👍"

Copy link

codecov bot commented Jul 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.80%. Comparing base (ed26dbd) to head (faec3f7).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #977   +/-   ##
=======================================
  Coverage   93.80%   93.80%           
=======================================
  Files          55       55           
  Lines        8065     8065           
=======================================
  Hits         7565     7565           
  Misses        500      500           

@gojakuch gojakuch marked this pull request as draft July 10, 2024 12:26
@MihailMihov
Copy link
Collaborator

@gojakuch It couldn't resolve the url (curl: (6) Could not resolve host: apt.llvm.org), but the url is working now, so maybe just re-run the checks?

@gojakuch
Copy link
Collaborator Author

@MihailMihov thanks, I'll do that a bit later.

@gojakuch gojakuch force-pushed the kokkos-support branch 2 times, most recently from 35000d0 to 9244e85 Compare July 13, 2024 15:05
github-actions[bot]

This comment was marked as outdated.

@gojakuch gojakuch force-pushed the kokkos-support branch 3 times, most recently from e0d814e to dfd46aa Compare July 13, 2024 18:24
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

include/clad/Differentiator/KokkosBuiltins.h Show resolved Hide resolved
@gojakuch
Copy link
Collaborator Author

@vgvassilev the failing check I have right now in this PR is the most important Kokkos one and yet I cannot replicate it on my machine. it works out fine for me. what shall I do in this situation?

@vgvassilev
Copy link
Owner

@vgvassilev the failing check I have right now in this PR is the most important Kokkos one and yet I cannot replicate it on my machine. it works out fine for me. what shall I do in this situation?

Debug on the bots?

@gojakuch
Copy link
Collaborator Author

Debug on the bots?

how do I do that?

@vgvassilev
Copy link
Owner

@gojakuch gojakuch force-pushed the kokkos-support branch 2 times, most recently from 79d9de3 to 3c08112 Compare July 17, 2024 09:59
@gojakuch
Copy link
Collaborator Author

@vgvassilev so basically I've managed to debug and fix this on the GitHub runner, but only by modifying a line of code in Clad's main code base. the change is quite small and honestly seems reasonable to me, but that's still something I'd like to discuss during today's meeting. I'm pushing it here for now to have all the checks passing, but maybe it'd be better to have it as a separate commit.

@gojakuch gojakuch marked this pull request as ready for review July 17, 2024 10:08
@gojakuch gojakuch requested a review from vgvassilev July 17, 2024 14:34
Copy link
Owner

@vgvassilev vgvassilev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is heading in a good direction.

@kliegeois, @brian-kelley can you take a look?

// pullbacks. Please include it manually to use Clad on Kokkos code.

#ifndef CLAD_KOKKOS_BUILTINS_H
#define CLAD_KOKKOS_BUILTINS_H
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good suggestion.

#ifndef CLAD_KOKKOS_BUILTINS_H
#define CLAD_KOKKOS_BUILTINS_H

#include <Kokkos_Core.hpp>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe wrap this in _has_include?

@@ -1198,7 +1198,7 @@ StmtDiff BaseForwardModeVisitor::VisitCallExpr(const CallExpr* CE) {
// If all arguments are constant literals, then this does not contribute to
// the gradient.
// FIXME: revert this when this is integrated in the activity analysis pass.
if (!callDiff) {
if (!callDiff && !CE->getType().getTypePtr()->isVoidType()) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should move this as a separate PR with an appropriate test.

Copy link

@kliegeois kliegeois left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @gojakuch it looks good to me!

@brian-kelley
Copy link

brian-kelley commented Jul 17, 2024

@gojakuch It also looks good to me, I just suggest using variadic template arguments to simplify the constructor_pushforward specializations and support more general Kokkos::View types.

unittests/Kokkos/ViewBasics.cpp Outdated Show resolved Hide resolved
unittests/Kokkos/ViewBasics.cpp Outdated Show resolved Hide resolved
@gojakuch gojakuch force-pushed the kokkos-support branch 2 times, most recently from 7260cd0 to d154949 Compare July 18, 2024 09:51
github-actions[bot]

This comment was marked as off-topic.

@gojakuch
Copy link
Collaborator Author

gojakuch commented Jul 18, 2024

@vgvassilev the ubu22-clang16-runtime18 check started failing both here and on another PR of mine for some reason related to package setup there, so that's not on my side

@@ -0,0 +1,55 @@
// This header file contains the implementation of the Kokkos framework
// differentiation support in Clad in the form of custom pushforwards and
// pullbacks. Please include it manually to use Clad on Kokkos code.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// pullbacks. Please include it manually to use Clad on Kokkos code.
// pullbacks. Please include it manually to enable Clad for Kokkos code.

#define CLAD_KOKKOS_BUILTINS_H

#include <Kokkos_Core.hpp>
#include "clad/Differentiator/Differentiator.h"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can ignore that suggestion.

namespace Kokkos {
template <typename View1, typename View2, typename T>
inline void deep_copy_pushforward(const View1& dst, const View2& src, T param,
const View1& _d_dst, const View2& _d_src,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These suggestions are relevant. The _ identifiers are normally reserved for special builtins and we are not doing anything special here.

This commit adds a test from the original Kokkos PR vgvassilev#783
and provides the implementation of the simplest Kokkos
features in the form of custom pushforwards. This commit
only addresses the forward mode.
Copy link
Owner

@vgvassilev vgvassilev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@vgvassilev vgvassilev merged commit f03fc98 into vgvassilev:master Jul 22, 2024
89 checks passed
@kliegeois
Copy link

Thanks a lot for having merged the PR @vgvassilev and @gojakuch !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants