Use AddBufferDonor to replace SetUpAlias for input output aliasing#6769
Merged
Use AddBufferDonor to replace SetUpAlias for input output aliasing#6769
Conversation
yeounoh
reviewed
Mar 20, 2024
| @@ -1261,59 +1260,14 @@ XLAGraphExecutor::BuildInputOutputAliases( | |||
| // this buffer is not needed after execution since XLATensor will get a | |||
Contributor
There was a problem hiding this comment.
This is the case we reuse / donate?
Collaborator
Author
There was a problem hiding this comment.
yea, the idea is we don't care which output will this input get aliased to. It is up to the compiler.
Contributor
There was a problem hiding this comment.
Makes sense, we are reusing instead of creating a new one.
Collaborator
Author
|
Let's see if TPUCI will pass before merging. |
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.
Existing
SetUpAliasrequires us(PyTorch/XLA) to specify the input and output index we want to alias. This can be difficult for the SPMD use case because we don't know the output sharding hence we can't be sure if input and output will have the same buffer size.AddBufferDonoris a newish API added by XLA team. It only requires us to give compiler a list of input buffer that can be reused for the output. It is up to the compiler to determine how to reuse these buffer. I have been userAddBufferDonorfor the manual buffer donation for dynamo. In this pr I extend the use case to the auto-aliasing in LTC(the way it works is to determine all of the input buffers that does not have a XLATensor associated and conclude an inplace operation happened so the buffer can be reused).