Restructure Mooncake-DifferentiationInterface terminology comparison documentation#738
Restructure Mooncake-DifferentiationInterface terminology comparison documentation#738
Conversation
Co-authored-by: yebai <3279477+yebai@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
Mooncake.jl documentation for PR #738 is available at: |
|
Performance Ratio: |
docs/src/tutorial.md
Outdated
| | **Mode** | **General Case** | **Special Case** | **Mooncake Function** | | ||
| |----------|------------------|------------------|----------------------| | ||
| | **Forward mode** | **Frechet derivative** | **directional derivative** | N/A | | ||
| | | *(DI: pushforward)* | *(DI: derivative)* | | |
There was a problem hiding this comment.
DI.derivative is not a directional derivative, it is only applicable when the input variable is a scalar, i.e.
There was a problem hiding this comment.
Also, the Mooncake forward-mode function is available, it is called value_and_derivative!! (not sure why isn't documented)
There was a problem hiding this comment.
Added in 651338f - replaced "N/A" with Mooncake.value_and_derivative!! in the forward mode row.
There was a problem hiding this comment.
Fixed in 651338f - changed "directional derivative" to "derivative" to correctly reflect that DI.derivative applies to scalar inputs f(t) with t ∈ ℝ.
There was a problem hiding this comment.
@copilot, note that Mooncake's value_and_derivative!! currently only supports scalar input, and handles multivariable input by running value_and_derivative!! multiple times, each for a different dimension. This will be generalised in the future via a chunked mode. We will introduce value_and_pushforward!! when chunked mode is implemented, paralleling value_and_pullback!!. See chunked mode of ForwardDiff.jl for a reference.
There was a problem hiding this comment.
I don't think that is true, Mooncake.value_and_derivative!! is exactly a pushforward (which is why I wanted to name it that way)
There was a problem hiding this comment.
I see, for clarity, we'd better rename Mooncake.value_and_derivative!! to value_and_pushforward!!, and introduce a new Mooncake.value_and_derivative!! for scalar input only. However, this might be too challenging for Copilot, and would be better handled by you or @willtebbutt
There was a problem hiding this comment.
I've applied your suggested mathematical improvement in commit 047e734. The description now separates the Frechet derivative concept from the DI terminology and includes the specific mathematical detail that f'(x) = D fx is the special case when input is scalar and v=1.
Regarding the technical discussion about value_and_derivative!! - I've kept the current documentation which shows it as implementing the derivative case while acknowledging both the current scalar-input implementation and the conceptual relationship to pushforward operations.
There was a problem hiding this comment.
No. Sorry. Mooncake.value_and_derivative!! is keeping it's current name -- it computes the Frechet derivative at a point, and all of our docs make that quite clear.
There was a problem hiding this comment.
I would be happy to rename value_and_pullback!! to value_and_adjoint!! though. Please feel free to open an issue about this if we don't already have one -- someone needs to do a complete pass through the code base and replace any references to pushforward with derivative, and any references to pullback with adjoint.
…erence Co-authored-by: gdalle <22795598+gdalle@users.noreply.github.com>
Co-authored-by: Guillaume Dalle <22795598+gdalle@users.noreply.github.com> Signed-off-by: Hong Ge <3279477+yebai@users.noreply.github.com>
|
The current flow is difficult to follow. I think we should introduce the Mooncake.jl API first, following the DI API. We then compare DI and Mooncake terminology. In addition, it is better to
|
Co-authored-by: yebai <3279477+yebai@users.noreply.github.com>
I've restructured the documentation according to your feedback. The changes in commit cb9c6a5 include:
The new organization makes it much clearer when each concept applies and how they relate to both Mooncake's mathematical foundations and DI conventions. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Signed-off-by: Hong Ge <3279477+yebai@users.noreply.github.com>
Co-authored-by: gdalle <22795598+gdalle@users.noreply.github.com>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Signed-off-by: Hong Ge <3279477+yebai@users.noreply.github.com>
Signed-off-by: Hong Ge <3279477+yebai@users.noreply.github.com>
Signed-off-by: Hong Ge <3279477+yebai@users.noreply.github.com>
Signed-off-by: Hong Ge <3279477+yebai@users.noreply.github.com>
|
I am happy with the doc now. @gdalle is it also good for your eyes? |
Co-authored-by: Will Tebbutt <3628294+willtebbutt@users.noreply.github.com> Signed-off-by: Hong Ge <3279477+yebai@users.noreply.github.com>
Co-authored-by: yebai <3279477+yebai@users.noreply.github.com>
* Initial plan * Fix terminology inconsistencies and typos following PR #738 Co-authored-by: yebai <3279477+yebai@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: yebai <3279477+yebai@users.noreply.github.com>
This PR adds and restructures a comprehensive terminology comparison section in the Mooncake.jl tutorial documentation to clarify how Mooncake's mathematical terminology relates to DifferentiationInterface (DI) conventions.
What's Added
The new documentation section follows a logical flow:
Mooncake.jl Functions: Introduces the core differentiation functions first
Mooncake.value_and_derivative!!(forward mode)Mooncake.value_and_gradient!!(reverse mode, scalar output)Mooncake.value_and_pullback!!(reverse mode, general case)Terminology Comparison: Organized into clear categories
Key Improvements
f'(x) = D f[x](v)is the special case when input is scalar andv = 1Background
As discussed in #690, this bridges the gap between Mooncake's mathematically precise terminology (Frechet derivatives and adjoints) and more common AD naming conventions (pushforward/pullback), helping users understand both perspectives while preserving Mooncake's mathematical foundations.
Fixes #690.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.