Fix input output alias for custom inplace ops #7822
Merged
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.
Fix the issue where the input output alias does not work when using custom inplace operations such as
xm.optimization_barrier_. This issue mainly arises from custom inplace operations not updating the alias id with_propagate_xla_data, so it still uses the outdated alias id. This issue is very common in FSDP and can result in param not being alias.Consider the case without this pr
In the second graph, the t1 cannot be aliased because the tensor id of t1 is 3, not 2.
with this pr
In the second graph, the t1 can be aliased because the output alias id and input tensor id of t1 are both 3.
xla/torch_xla/csrc/xla_graph_executor.cpp
Lines 1258 to 1282 in 9fbd64a