Repository navigation
Keep the augmented call when it returns an empty tape directly - #3376
Merged
Merged
Conversation
When a call is differentiated with an augmented forward pass that returns
only its tape (tapeIdx == -1), the tape value is the augmented call itself.
If the tape type is empty ({}), the isEmptyTy() branch erased the tape to
replace it with undef, which deleted the augmented call and the primal side
effects of the callee.
Only erase the tape when it is an extractvalue of the augmented call.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01G9QZewtK4oCErzZphHWd8u
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by Valentin · project thread
Before: when a callee is differentiated in split mode and its augmented forward pass returns only an empty tape (
{}), the augmented call is deleted from the caller's augmented forward pass. The callee's primal side effects (for example a store to an output argument) are silently lost.After: the augmented call is kept, and the empty tape is still replaced by
undef.How: in
AdjointGenerator.h, withtapeIdx == -1the tape value is the augmented call itself, so theisEmptyTy()branch now erases the tape only when it is anextractvalueof the call.Test:
ReverseMode/custom-split-empty-tape.ll.@squarehas a customenzyme_augmentreturning{}that stores to%out;@topreads%outafter calling@caller, so@calleris differentiated in split mode. On main,@augmented_callerhas no call to@augment_square; with the fix it does. The fulltest/Enzymelit suite against LLVM 18 has the same set of failures with and without the change (the pre-existing typed-pointer failures in this setup).Found while writing the test for #3373.
🤖 Generated with Claude Code
https://claude.ai/code/session_01G9QZewtK4oCErzZphHWd8u
Generated by Claude Code