Skip to content

[clad] Bump clad to v1.10. #18383

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

Merged
merged 1 commit into from
Apr 28, 2025
Merged

Conversation

guitargeek
Copy link
Contributor

@guitargeek guitargeek commented Apr 12, 2025

This release introduces significant updates, including support for clang versions 10 through 20 and improved diagnostics for unsupported features. Forward mode now handles variadic functions, while reverse mode sees major enhancements like marking const methods as non-differentiable, enabling differentiation of global variables and static member functions, generating constructor pullbacks automatically, and reducing tape usage through optimizations. CUDA support has been expanded with better handling of device pullbacks and kernel variables. For details, please see the release notes.

@guitargeek guitargeek added the clean build Ask CI to do non-incremental build on PR label Apr 12, 2025
@guitargeek guitargeek self-assigned this Apr 12, 2025
@guitargeek
Copy link
Contributor Author

As one can see from the CladDericatorTests, the gradient generation with Clad doesn't seem to work anymore. There is no function call happening then calling exec() on the gradient, and dump() also doesn't give you any code output.

Here an example macro:

#include <Math/CladDerivator.h>

double g(double *variables) { return variables[0] * variables[0] * variables[1]; }

void simpleclad() {

    // Call clad to generate the gradient of g.
    auto g_grad = clad::gradient(g, "variables");

    // Execute the generated gradient function.
    double variables[]{3., 4.};
    double grad_output[]{0., 0.};
    g_grad.execute(variables, grad_output);
    std::cout << "grad_output[0]: " << grad_output[0] << std::endl;
    std::cout << "grad_output[1]: " << grad_output[1] << std::endl;

    // Dump the generated gradient code to standard output.
    g_grad.dump();

}

The output with ROOT compiled with Clad master is empty:

root [0]
Processing simpleclad.C...
grad_output[0]: 0
grad_output[1]: 0
The code is:

root [1]

@guitargeek
Copy link
Contributor Author

The regression originated from this commit, @vgvassilev:

vgvassilev/clad@612eeb8

Copy link

github-actions bot commented Apr 12, 2025

Test Results

    18 files      18 suites   3d 22h 56m 23s ⏱️
 2 728 tests  2 728 ✅ 0 💤 0 ❌
47 707 runs  47 707 ✅ 0 💤 0 ❌

Results for commit 9b1aa3b.

♻️ This comment has been updated with latest results.

@vgvassilev
Copy link
Member

The regression originated from this commit, @vgvassilev:

vgvassilev/clad@612eeb8

Can you try this patch:

diff --git a/tools/ClangPlugin.cpp b/tools/ClangPlugin.cpp
index 8f5a2550..919ccb79 100644
--- a/tools/ClangPlugin.cpp
+++ b/tools/ClangPlugin.cpp
@@ -138,7 +138,7 @@ namespace clad {
         if (!isa<FunctionDecl>(D))
           continue;
         FunctionDecl* FD = cast<FunctionDecl>(D);
-        if (FD->isConstexpr()) {
+        if (FD->isConstexpr() || !m_Multiplexer) {
           DiffCollector collector(DGR, CladEnabledRange, m_DiffRequestGraph, S,
                                   opts);
           break;

@guitargeek
Copy link
Contributor Author

Indeed, that fixes it! Thanks for your quick help

@vgvassilev
Copy link
Member

Indeed, that fixes it! Thanks for your quick help

Ok, in that case I can land that on the other side and release.

@vgvassilev
Copy link
Member

@guitargeek, do we need somehow a clean build or there is something else to be fixed?

@guitargeek
Copy link
Contributor Author

The problem will be fixed by this PR:
#18478

This release introduces significant updates, including support for clang
versions 10 through 20 and improved diagnostics for unsupported features.
Forward mode now handles variadic functions, while reverse mode sees major
enhancements like marking const methods as non-differentiable, enabling
differentiation of global variables and static member functions, generating
constructor pullbacks automatically, and reducing tape usage through
optimizations. CUDA support has been expanded with better handling of device
pullbacks and kernel variables. For details, please see the release notes.
@vgvassilev vgvassilev changed the title Try ROOT with Clad master on the CI [clad] Bump clad to v1.10. Apr 26, 2025
@vgvassilev vgvassilev marked this pull request as ready for review April 26, 2025 09:21
@vgvassilev vgvassilev requested a review from bellenot as a code owner April 26, 2025 09:21
@vgvassilev
Copy link
Member

@dpiparo this seems that it can go forward for the 6.36 release.

@guitargeek
Copy link
Contributor Author

Hi @vgvassilev yes I think we can do that. Can you approve this PR so it can me merged? Then we'll see about the 6.36 backport

Copy link
Member

@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.

@guitargeek guitargeek merged commit e511751 into root-project:master Apr 28, 2025
40 of 41 checks passed
@guitargeek guitargeek deleted the clad_master branch April 28, 2025 09:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clean build Ask CI to do non-incremental build on PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants