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

Use source tensor sizes after the sharding created so far when tie-breaking between candidates during explicit reshards. #429

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

copybara-service[bot]
Copy link

Use source tensor sizes after the sharding created so far when tie-breaking between candidates during explicit reshards.

Instead of source tensor sizes from unsharded tensors.

It for example prefers:

reshard lhs: {"x":(2)2}, {"y"} -> {}, {"y"}
reshard rhs: {"y"}, {} -> {"y"}, {"x"}
dot to obtain the result in sharding {}, {"x"}
all-reduce along "y"
return all-reduce

instead of:

reshard rhs: {"y"}, {} -> {"y"}, {"x":(1)2}
dot to obtain the result in sharding {"x":(2)2}, {"x":(1)2}
all-reduce along "y"
reshard to {}, {"x"}
return reshard

for the following example:

func.func @main(
%arg0: tensor<8x32xf32> {sdy.sharding = #sdy.sharding<@mesh, [{"x":(2)2}, {"y"}]>},
%arg1: tensor<32x16xf32> {sdy.sharding = #sdy.sharding<@mesh, [{"y"}, {}]>})
-> (tensor<8x16xf32> {sdy.sharding = #sdy.sharding<@mesh, [{}, {"x"}]>}) {
%0 = stablehlo.dot %arg0, %arg1
{sdy.sharding = #sdy.sharding_per_value<[<@mesh, [{}, {"x"}]>]>}
: (tensor<8x32xf32>, tensor<32x16xf32>) -> tensor<8x16xf32>
return %0 : tensor<8x16xf32>
}

…eaking between candidates during explicit reshards.

Instead of source tensor sizes from unsharded tensors.

It for example prefers:

reshard lhs: {"x":(2)2}, {"y"} -> {}, {"y"}
reshard rhs: {"y"}, {} -> {"y"}, {"x"}
dot to obtain the result in sharding {}, {"x"}
all-reduce along "y"
return all-reduce

instead of:

reshard rhs: {"y"}, {} -> {"y"}, {"x":(1)2}
dot to obtain the result in sharding {"x":(2)2}, {"x":(1)2}
all-reduce along "y"
reshard to {}, {"x"}
return reshard

for the following example:

func.func @main(
  %arg0: tensor<8x32xf32> {sdy.sharding = #sdy.sharding<@mesh, [{"x":(2)2}, {"y"}]>},
  %arg1: tensor<32x16xf32> {sdy.sharding = #sdy.sharding<@mesh, [{"y"}, {}]>})
  -> (tensor<8x16xf32> {sdy.sharding = #sdy.sharding<@mesh, [{}, {"x"}]>}) {
  %0 = stablehlo.dot %arg0, %arg1
    {sdy.sharding = #sdy.sharding_per_value<[<@mesh, [{}, {"x"}]>]>}
    : (tensor<8x32xf32>, tensor<32x16xf32>) -> tensor<8x16xf32>
  return %0 : tensor<8x16xf32>
}

PiperOrigin-RevId: 738822108
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