Skip to content

Keep the augmented call when it returns an empty tape directly - #3376

Merged
vchuravy merged 1 commit into
mainfrom
claude/fix-empty-tape-augmented-erase-0ow2at
Oct 3, 2026
Merged

vchuravy merged 1 commit into
mainfrom
claude/fix-empty-tape-augmented-erase-0ow2at

Conversation

@vchuravy

@vchuravy vchuravy commented Oct 1, 2026

Copy link
Copy Markdown
Member

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, with tapeIdx == -1 the tape value is the augmented call itself, so the isEmptyTy() branch now erases the tape only when it is an extractvalue of the call.

Test: ReverseMode/custom-split-empty-tape.ll. @square has a custom enzyme_augment returning {} that stores to %out; @top reads %out after calling @caller, so @caller is differentiated in split mode. On main, @augmented_caller has no call to @augment_square; with the fix it does. The full test/Enzyme lit 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

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
@vchuravy vchuravy self-assigned this Oct 1, 2026
@vchuravy
vchuravy requested a review from wsmoses October 2, 2026 04:34
@vchuravy
vchuravy merged commit d3c235e into main Oct 3, 2026
52 checks passed
@vchuravy
vchuravy deleted the claude/fix-empty-tape-augmented-erase-0ow2at branch October 3, 2026 16:33
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.

1 participant