Skip to content

Add caching and friendly tangents in forward mode#980

Merged
Technici4n merged 5 commits intochalk-lab:mainfrom
gdalle:gd/forwardcache
Jan 29, 2026
Merged

Add caching and friendly tangents in forward mode#980
Technici4n merged 5 commits intochalk-lab:mainfrom
gdalle:gd/forwardcache

Conversation

@gdalle
Copy link
Copy Markdown
Collaborator

@gdalle gdalle commented Jan 28, 2026

Fixes #917

Inspired and triggered by @Technici4n's DI contribution in JuliaDiff/DifferentiationInterface.jl#957, might as well make it available in Mooncake instead of using (even more) internals.

Remaining questions:

  • Is the tuple interface the one we want?
  • Are there enough tests?
  • Are there enough docs?
  • Is this breaking? I don't think so even though we rename rule to cache in the existing value_and_derivative!! API

@codecov
Copy link
Copy Markdown

codecov Bot commented Jan 28, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Comment thread src/interface.jl Outdated
Comment thread src/interface.jl Outdated
Comment thread src/interface.jl Outdated
Comment thread src/interface.jl
Comment thread src/interface.jl
Comment thread src/interface.jl
Comment thread src/interface.jl
cache.rule(fx...) # TODO: handle friendly tangents for the output here?

"""
value_and_derivative!!(cache::ForwardCache, (f, df), (x, dx), ...)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Remember to update the docs as well (interface.md I believe?)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The reason I didn't is because if we want to avoid breaking changes until Mooncake 0.6, the existing API with Dual inputs has to keep working, and keep being part of the public docs. That's why I didn't specialize the signature (but we could add a deprecation warning after all)

Copy link
Copy Markdown
Collaborator

@Technici4n Technici4n left a comment

Choose a reason for hiding this comment

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

This seems good to go, can you just update the signatures at the end of docs/src/interface.md?

@gdalle gdalle marked this pull request as ready for review January 29, 2026 16:37
Copy link
Copy Markdown
Collaborator

@Technici4n Technici4n left a comment

Choose a reason for hiding this comment

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

Thanks!

@Technici4n Technici4n merged commit a18d35c into chalk-lab:main Jan 29, 2026
110 of 140 checks passed
@Technici4n
Copy link
Copy Markdown
Collaborator

Oops I didn't wait for the tests to pass it seems. But it should be fine and will unblock DI.

@gdalle
Copy link
Copy Markdown
Collaborator Author

gdalle commented Jan 29, 2026

@Technici4n let's still wait to see if the ambiguity issue was resolved and if code coverage was 100% before releasing Mooncake v0.5.1?

@Technici4n
Copy link
Copy Markdown
Collaborator

Indeed, formatting failed. I see a segfault for basic-lts as well, not sure if it's related or not. Let me know if I should try to fix some of these!

@gdalle
Copy link
Copy Markdown
Collaborator Author

gdalle commented Jan 29, 2026

Feel free to open a PR to fix the formatting. As for the segfault, do you have the permissions for relaunching the CI job? Sometimes they randomly fail

@gdalle
Copy link
Copy Markdown
Collaborator Author

gdalle commented Jan 30, 2026

Took care of the formatting in #983

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.

Expand the forward-mode interface to support caching and friendly tangents

2 participants