Merged
Conversation
This change introduces two main improvements to the `shardy` package: 1. **`ShardSpec.ToStableHLO()` implementation:** A new method, `ToStableHLO()`, has been added to the `ShardSpec` struct. This method converts the sharding specification into the string format required by StableHLO, as detailed in the OpenXLA Shardy documentation. It correctly handles sharded, replicated, open, and sub-axis dimensions, and it ensures the output is deterministic by sorting the replicated axis names. 2. **Enhanced `ShardSpec.Validate()`:** The `Validate()` method has been updated to include more robust checks for sharding specifications that use sub-axes. It now verifies that the `PreSize` and `Size` of a sub-axis are mathematically compatible with the total size of the corresponding mesh axis, preventing invalid sharding configurations. A comprehensive suite of unit tests has been added in `shardspec_test.go` to validate both the new `ToStableHLO` method and the enhanced validation logic, ensuring the correctness and reliability of the implementation.
Added an alias in stablehlo in case end-users want to use it.
…fiers. Added DeviceMesh.ToStableHLO().
Added comments discouraging using other distributed (collective) mechanisms other than Shardy.
This change introduces the ability to add attributes to function inputs and outputs in the `stablehlo.Builder`. This is essential for generating StableHLO modules with XLA Shardy annotations. Key changes: - The `Value` struct now includes an `Attributes` map. - `Function.Write` has been updated to serialize these attributes for both inputs and outputs. - The attribute writing logic has been refactored into a reusable `writeAttributes` function. - A new test case has been added to validate the generation of sharded StableHLO modules.
Improved test.
…requested: it's not compatible with SPMD.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Added shardy types for DeviceMesh and ShardSpec.