PR #20808: [GSPMD] Partitions collective permute instructions in manual sharding group. #84637
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.
PR #20808: [GSPMD] Partitions collective permute instructions in manual sharding group.
Imported from GitHub PR openxla/xla#20808
This is a small fix in GSPMD partitioning for partitioning collective permutes instructions added in manual sharding group.
In JAX, we can add
ppermute
instruction in shard_map. In cases where we have shard_map with auto axes specified, collective permuting an operand even with the same sharding will end up with anall-gather
and then collective permute, which leads to inefficient collectives. The correct and efficient way is to partition the collective permute as an element-wise op.The unit test added provides a repro. Also, the JAX unit test in https://github.com/jax-ml/jax/blob/fa9c7edf736516052df6eab22947bc627d0deca3/tests/shard_map_test.py#L2167 gives a real-world JAX example.
Copybara import of the project:
--
8ee6ecd51f6e4aae8e3d92a6a439a60f53ab02ae by Yunlong Liu yunlongl@x.ai:
A hacky fix on partitioning collective permute.
--
e50e87696defb290f7561a7808ee42ebbc11e144 by Yunlong Liu yunlongl@x.ai:
Local change.
--
84eb38597c783a4488774823c2c464296a8c54c7 by Yunlong Liu yunlongl@x.ai:
Simplifies sharding in tests.
Merging this change closes #20808
FUTURE_COPYBARA_INTEGRATE_REVIEW=openxla/xla#20808 from yliu120:cp_sharding_2 84eb38597c783a4488774823c2c464296a8c54c7