-
Notifications
You must be signed in to change notification settings - Fork 434
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[XLA] Introduce infeed token propagation #17228
Merged
Merged
Conversation
This file contains 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
copybara-service
bot
force-pushed
the
test_671128754
branch
7 times, most recently
from
September 23, 2024 00:22
57ad661
to
787d1f5
Compare
During computation inlining, specifically loop unrolling, it is posibble for infeeds (and outfeeds) to get reordered in a way that breaks the original scheduling constraints set by the computation boundaries. This is a result of Tensorflow not exposing tokens for these ops to the user, so the input and output tokens end up dangling. Loop unrolling in XLA can be thought of applying the same function repeatedly to itself, e.g. transforming f(x) into f(f(x)). By pushing the tokens outside the loop body, we can guarantee that the output token of the first infeed will become the input token of the next infeed, thus creating a data dependency chain and preserving the original ordering. PiperOrigin-RevId: 677572109
copybara-service
bot
force-pushed
the
test_671128754
branch
from
September 23, 2024 00:53
787d1f5
to
ff8d1d8
Compare
copybara-service bot
pushed a commit
that referenced
this pull request
Sep 23, 2024
A couple of changes from the original change: 1. Don't use HloInstruction::operand_index() - this only returns the *first* occurence of an instruction in the operand sequence, thus if the same instruction is used in place of multiple orepards, we'll miss the subsequent ones. 2. Handle propagating throught root instructions better. We originally only fixed up entry computation roots but we need should the same for any while/conditional root, otherwise inserting tokens in these types of roots is non-trivial. Simplify things by explicitly disjoining these instructions from being roots during canonicalization. Reverts 1162b7e PiperOrigin-RevId: 677963786
Merged
copybara-service bot
pushed a commit
that referenced
this pull request
Sep 23, 2024
A couple of changes from the original change: 1. Don't use HloInstruction::operand_index() - this only returns the *first* occurence of an instruction in the operand sequence, thus if the same instruction is used in place of multiple orepards, we'll miss the subsequent ones. 2. Handle propagating throught root instructions better. We originally only fixed up entry computation roots but we need should the same for any while/conditional root, otherwise inserting tokens in these types of roots is non-trivial. Simplify things by explicitly disjoining these instructions from being roots during canonicalization. Reverts 1162b7e PiperOrigin-RevId: 677963786
copybara-service bot
pushed a commit
that referenced
this pull request
Sep 24, 2024
A couple of changes from the original change: 1. Don't use HloInstruction::operand_index() - this only returns the *first* occurence of an instruction in the operand sequence, thus if the same instruction is used in place of multiple orepards, we'll miss the subsequent ones. 2. Handle propagating throught root instructions better. We originally only fixed up entry computation roots but we need should the same for any while/conditional root, otherwise inserting tokens in these types of roots is non-trivial. Simplify things by explicitly disjoining these instructions from being roots during canonicalization. Reverts 1162b7e PiperOrigin-RevId: 677963786
copybara-service bot
pushed a commit
that referenced
this pull request
Sep 24, 2024
A couple of changes from the original change: 1. Don't use HloInstruction::operand_index() - this only returns the *first* occurence of an instruction in the operand sequence, thus if the same instruction is used in place of multiple orepards, we'll miss the subsequent ones. 2. Handle propagating throught root instructions better. We originally only fixed up entry computation roots but we need should the same for any while/conditional root, otherwise inserting tokens in these types of roots is non-trivial. Simplify things by explicitly disjoining these instructions from being roots during canonicalization. Reverts 1162b7e PiperOrigin-RevId: 677963786
copybara-service bot
pushed a commit
that referenced
this pull request
Sep 24, 2024
A couple of changes from the original change: 1. Don't use HloInstruction::operand_index() - this only returns the *first* occurence of an instruction in the operand sequence, thus if the same instruction is used in place of multiple orepards, we'll miss the subsequent ones. 2. Handle propagating throught root instructions better. We originally only fixed up entry computation roots but we need should the same for any while/conditional root, otherwise inserting tokens in these types of roots is non-trivial. Simplify things by explicitly disjoining these instructions from being roots during canonicalization. Reverts 1162b7e PiperOrigin-RevId: 677963786
copybara-service bot
pushed a commit
that referenced
this pull request
Sep 24, 2024
A couple of changes from the original change: 1. Don't use HloInstruction::operand_index() - this only returns the *first* occurence of an instruction in the operand sequence, thus if the same instruction is used in place of multiple orepards, we'll miss the subsequent ones. 2. Handle propagating throught root instructions better. We originally only fixed up entry computation roots but we need should the same for any while/conditional root, otherwise inserting tokens in these types of roots is non-trivial. Simplify things by explicitly disjoining these instructions from being roots during canonicalization. Reverts 1162b7e PiperOrigin-RevId: 677963786
copybara-service bot
pushed a commit
that referenced
this pull request
Sep 24, 2024
A couple of changes from the original change: 1. Don't use HloInstruction::operand_index() - this only returns the *first* occurence of an instruction in the operand sequence, thus if the same instruction is used in place of multiple orepards, we'll miss the subsequent ones. 2. Handle propagating throught root instructions better. We originally only fixed up entry computation roots but we need should the same for any while/conditional root, otherwise inserting tokens in these types of roots is non-trivial. Simplify things by explicitly disjoining these instructions from being roots during canonicalization. Reverts 1162b7e PiperOrigin-RevId: 677963786
copybara-service bot
pushed a commit
that referenced
this pull request
Sep 24, 2024
A couple of changes from the original change: 1. Don't use HloInstruction::operand_index() - this only returns the *first* occurence of an instruction in the operand sequence, thus if the same instruction is used in place of multiple orepards, we'll miss the subsequent ones. 2. Handle propagating throught root instructions better. We originally only fixed up entry computation roots but we need should the same for any while/conditional root, otherwise inserting tokens in these types of roots is non-trivial. Simplify things by explicitly disjoining these instructions from being roots during canonicalization. Reverts 1162b7e PiperOrigin-RevId: 678374890
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.
[XLA] Introduce infeed token propagation
During computation inlining, specifically loop unrolling, it is posibble for infeeds (and outfeeds) to get reordered in a way that breaks the original scheduling constraints set by the computation boundaries. This is a result of Tensorflow not exposing tokens for these ops to the user, so the input and output tokens end up dangling.
Loop unrolling in XLA can be thought of applying the same function repeatedly to itself, e.g. transforming f(x) into f(f(x)). By pushing the tokens outside the loop body, we can guarantee that the output token of the first infeed will become the input token of the next infeed, thus creating a data dependency chain and preserving the original ordering.