Skip to content
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 1 commit into from
Sep 23, 2024
Merged

Conversation

copybara-service[bot]
Copy link

@copybara-service copybara-service bot commented Sep 16, 2024

[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.

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 copybara-service bot merged commit ff8d1d8 into main Sep 23, 2024
1 check passed
@copybara-service copybara-service bot deleted the test_671128754 branch September 23, 2024 00:53
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 copybara-service bot mentioned this pull request Sep 23, 2024
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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant