[6.2 🍒] Fix ownership issues with sequences of partial_apply's in AutoDiff closure specialization pass #81240
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.
Explanation:
Fix ownership issues with sequences of partial_apply's in AutoDiff closure specialization pass (Fix ownership issues with sequences of partial_apply's in AutoDiff closure specialization pass #80662)
Each partial_apply consumes its arguments, therefore we should never release intermediate ones in the sequence of closures.
(cherry picked from commit 87ca0f8)
Scope:
The workaround for the original issue caused a severe performance regression in AutoDiff performance because it disabled the closure specialization pass in the AutoDiff case. This fix and the removal of the workaround restores performance back to the expected levels.
Issues:
The AutodiffClosureSpecialization pass creates SIL with invalid ownership when enabling OSSA modules #78847
Original PRs:
Fix ownership issues with sequences of partial_apply's in AutoDiff closure specialization pass #80662
Risk:
Low. Resolves the underlying issue in the closure specialization pass, and restores performance for the AutoDiff case.
Testing:
A test case has been added to exercise this optimization path.
Reviewers:
@asl @eeckstein