Skip to content

[XLA] Add placements property to XLAShardedTensor for DTensor compatibility#9509

Merged
rpsilva-aws merged 7 commits intopytorch:masterfrom
Hoomaaan:placements
Jul 30, 2025
Merged

[XLA] Add placements property to XLAShardedTensor for DTensor compatibility#9509
rpsilva-aws merged 7 commits intopytorch:masterfrom
Hoomaaan:placements

Conversation

@Hoomaaan
Copy link
Copy Markdown
Contributor

@Hoomaaan Hoomaaan commented Jul 24, 2025

[XLA] Add placements property to XLAShardedTensor for DTensor compatibility

Implements a placements property on XLAShardedTensor that provides direct access to tensor placement information for DTensor interface compatibility.

  • Adds placements property that reads from cached _spec if available, otherwise creates _spec on-demand
  • Includes proper error handling when mesh_shape or partition_spec are missing
  • Adds comprehensive unit tests covering success, failure, and caching scenarios

This enables seamless integration between XLAShardedTensor and DTensor APIs by exposing placement information through a standard interface.

@Hoomaaan Hoomaaan changed the title [XLA] Add placements property to XLAShardedTensor for DTensor compati… [XLA] Add placements property to XLAShardedTensor for DTensor compatibility Jul 25, 2025
…bility

Implements a placements property on XLAShardedTensor that provides direct access to tensor placement information for DTensor interface compatibility.

- Adds placements property that reads from cached _spec if available,
  otherwise creates _spec on-demand
- Includes proper error handling when mesh_shape or partition_spec are missing
- Adds comprehensive unit tests covering success, failure, and caching scenarios

This enables seamless integration between XLAShardedTensor and DTensor APIs
by exposing placement information through a standard interface.
Comment thread torch_xla/distributed/spmd/xla_sharded_tensor.py Outdated
@Hoomaaan Hoomaaan requested a review from bfolie July 25, 2025 23:42
Comment thread test/spmd/test_xla_dtensor_placements.py Outdated
@Hoomaaan Hoomaaan requested a review from bfolie July 28, 2025 17:11
Comment thread test/spmd/test_xla_dtensor_placements.py Outdated
Comment thread test/spmd/test_xla_dtensor_placements.py Outdated
Comment thread test/spmd/test_xla_dtensor_placements.py Outdated
Comment thread test/spmd/test_xla_dtensor_placements.py Outdated
Comment thread test/spmd/test_xla_dtensor_placements.py
@rpsilva-aws rpsilva-aws merged commit 95bee8f into pytorch:master Jul 30, 2025
23 of 24 checks passed
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.

3 participants