-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#13127: Add support for new logical sharding + alignment in TensorLay…
…out and tensor creation - Add ShardMode enum to specify shard shape in shard spec as either physical or logical - Update PageConfig create_default_alignment to use physical shard shape in shard spec if provided for logical sharding - Add optional physical shard shape to shard spec for logical sharding * Add ShardSpec constructor that takes in physical shard shape (which will automatically set shard mode to ShardMode::LOGICAL) * ShardMode::PHYSICAL: This is current behaviour that we will deprecate! ** It is less expressive than using shard shape as logical (ie. must be tile aligned for TILE layout etc...) ** It fundamentally operates on padded shape and is confusing and incompatible with logical shape * ShardMode::LOGICAL: Shard shape cuts 2D logical shape and each shard is aligned after ** Without alignment restrictions, you can cut 2D logical shape more arbitrarily ** Existing sharding can be switched over to this entirely (just need codeowners to help out and flip...) ** If physical shard shape is provided, align to it instead of default alignment * Default everywhere will be ShardMode::PHYSICAL (TODO: Add a warning message?) - Switch tests/ttnn/unit_tests/operations/test_paged_update_cache.py to use logical shard shape as an example * Introduce tensor.logical_volume() (as opposed to tensor.volume() which returns physical volume based on padded shape) * TODO: Rename volume() -> physical_volume() and logical_volume() -> volume() - Add new c++ tests to test tensor creation with logical shard shape + alignment * IMPORTANT: Need to update host data manipulation to be aware of new logical sharding for use from python! To support these changes, some changes to TensorLayout: - Update private TensorLayout constructor with alignment with these changes: * legacyShapeToAlignment will try to return 2D alignment if possible (ie. only padding on height/width) ** Goal is to transition alignment to be 2D only if we remove poor use cases of padding on non-height/width dims * legacyShapeToAlignment uses default alignment for sharded tensors ** Before interleaved or sharded will just use padded shape for alignment ** One exception is for row major sharded tensors where we use shard width if shape is padded; otherwise, we only take shard width for BLOCK/WIDTH sharded cases and original physical shape for HEIGHT sharded * legacyShapeToAlignment (and alignment in general) will work iff there is only padding on height and/or width ** IMPORTANT: This means we are expecting tensors with arbitrary padding along non-height/width to be interleaved only! - If ShardMode::LOGICAL: * In TensorLayout::compute_shard_spec_buffer, calculate physical shard shape based on shard shape + alignment if not provided * In TensorLayout::compute_physical_shape, calculate physical shape based on number of logical shards - Clean up handling of sharded tensors and error messages in ttnn/cpp/ttnn/tensor/layout/page_config.cpp - Add Size constructor for std::array<uint32_t, 2>
- Loading branch information
1 parent
02f5747
commit 36d9c9d
Showing
16 changed files
with
511 additions
and
97 deletions.
There are no files selected for viewing
310 changes: 275 additions & 35 deletions
310
tests/ttnn/unit_tests/gtests/tensor/test_sharding_with_alignment.cpp
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.