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

Sharding custom calls cannot be hoisted individually in WhileLoopInvariantCodeMotion. #66574

Merged
merged 1 commit into from May 1, 2024

Conversation

copybara-service[bot]
Copy link

Sharding custom calls cannot be hoisted individually in WhileLoopInvariantCodeMotion.

A sharding custom call annotates sharding to its operand. If we move a single sharding custom call out of the while body, the sharding annotation may not take effect as expected.

Taking the follow while body as an example,

body {
  p_body = (f32[2], f32[2], s32[]) parameter(0)
  gte.0 = f32[2] get-tuple-element(p_body), index=0
  gte.1 = f32[2] get-tuple-element(p_body), index=1
  sharding.0 = f32[2] custom-call(gte.0), custom_call_target="Sharding", sharding={devices=[2]<=[2]}
  sharding.1 = f32[2] custom-call(gte.1), custom_call_target="Sharding", sharding={replicated}
  add.0 = f32[2] add(sharding.0, sharding.1)
  gte.2 = s32[] get-tuple-element(p_body), index=2
  const = s32[] constant(1)
  add.1 = s32[] add(gte.2, const)
  ROOT root = (f32[2], f32[2], s32[]) tuple(gte.0, add.0, add.1)
}

Before this cl, WhileLoopInvariantCodeMotion moves sharding.0 out of the body and keeps sharding.1 in the body. With this cl, WhileLoopInvariantCodeMotion does not modify this body.

@copybara-service copybara-service bot force-pushed the exported_pr_628743448 branch 4 times, most recently from df51c95 to 5a5ab0d Compare May 1, 2024 06:06
…ariantCodeMotion`.

A sharding custom call annotates sharding to its operand. If we move a single sharding custom call out of the while body, the sharding annotation may not take effect as expected.

Taking the follow while body as an example,
```
body {
  p_body = (f32[2], f32[2], s32[]) parameter(0)
  gte.0 = f32[2] get-tuple-element(p_body), index=0
  gte.1 = f32[2] get-tuple-element(p_body), index=1
  sharding.0 = f32[2] custom-call(gte.0), custom_call_target="Sharding", sharding={devices=[2]<=[2]}
  sharding.1 = f32[2] custom-call(gte.1), custom_call_target="Sharding", sharding={replicated}
  add.0 = f32[2] add(sharding.0, sharding.1)
  gte.2 = s32[] get-tuple-element(p_body), index=2
  const = s32[] constant(1)
  add.1 = s32[] add(gte.2, const)
  ROOT root = (f32[2], f32[2], s32[]) tuple(gte.0, add.0, add.1)
}
```

Before this cl, `WhileLoopInvariantCodeMotion` moves `sharding.0` out of the body and keeps `sharding.1` in the body. With this cl, `WhileLoopInvariantCodeMotion` does not modify this body.

PiperOrigin-RevId: 629637435
@copybara-service copybara-service bot closed this May 1, 2024
@copybara-service copybara-service bot deleted the exported_pr_628743448 branch May 1, 2024 07:18
@copybara-service copybara-service bot merged commit 5c90e79 into master May 1, 2024
4 of 5 checks passed
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.

None yet

1 participant