Use source tensor sizes after the sharding created so far when tie-breaking between candidates during explicit reshards. #429
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.
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>
}