Skip to content

Fix unused _d_i adjoints in hessian with -enable-va - #1880

Open
MdSaifAliMolla wants to merge 1 commit into
vgvassilev:masterfrom
MdSaifAliMolla:fix-1665
Open

Fix unused _d_i adjoints in hessian with -enable-va#1880
MdSaifAliMolla wants to merge 1 commit into
vgvassilev:masterfrom
MdSaifAliMolla:fix-1665

Conversation

@MdSaifAliMolla

Copy link
Copy Markdown
Contributor

shouldHaveAdjointForw now checks VariedDecls when EnableVariedAnalysis is true, and VariedDecls seeding covers forward, hessian, and hessian_diagonal modes. HandleNestedDiffRequest runs VariedAnalyzer for reverse-mode nested requests instead of unconditionally zeroing analysis flags.

Fixes #1665

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

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

Comment thread lib/Differentiator/DerivativeBuilder.cpp
Comment thread lib/Differentiator/DerivativeBuilder.cpp Outdated
@codecov

codecov Bot commented Jul 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

bool m_PrintNumericalDiffErrorDiag = false;
/// Stores AnalysisDeclContexts built for nested requests that don't go
/// through DiffPlanner's traversal.
std::vector<std::unique_ptr<clang::AnalysisDeclContext>>

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Which requests do not go via the DiffPlanner? Ideally these should be zero.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

the nested reverse-mode request created inline by the Hessian forward→reverse pipeline bypasses DifffPlanner's normal traversal.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

I'd prefer fixing that issue, rather than working it around.

@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

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

@MdSaifAliMolla
MdSaifAliMolla marked this pull request as draft July 9, 2026 17:13
@MdSaifAliMolla
MdSaifAliMolla force-pushed the fix-1665 branch 2 times, most recently from 6002a0b to e0ddadf Compare July 10, 2026 11:27

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

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

Comment thread include/clad/Differentiator/DiffPlanner.h
Comment thread lib/Differentiator/DiffPlanner.cpp
Extract the duplicated AnalysisDeclContext/VariedAnalyzer setup from
DiffCollector::VisitCallExpr and VisitCXXConstructExpr into a single
PrepareRequestAnalysis() function. HandleNestedDiffRequest now calls
this same function instead of maintaining a second copy of the logic,
reusing CladPlugin's existing OwnedAnalysisContexts storage.

shouldHaveAdjointForw checks VariedDecls when EnableVariedAnalysis is
true, and VariedDecls seeding covers forward, hessian, and
hessian_diagonal modes.

Fixes vgvassilev#1665
@github-actions

Copy link
Copy Markdown
Contributor

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

@github-actions

Copy link
Copy Markdown
Contributor

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

@MdSaifAliMolla
MdSaifAliMolla marked this pull request as ready for review July 11, 2026 15:35
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.

Don't generate adjoints of counters in weightedSum

2 participants