Skip to content

Fix ShardedTensorMetadata.tensor_properties for Python 3.11#91795

Closed
ConnorBaker wants to merge 1 commit intopytorch:masterfrom
ConnorBaker:master
Closed

Fix ShardedTensorMetadata.tensor_properties for Python 3.11#91795
ConnorBaker wants to merge 1 commit intopytorch:masterfrom
ConnorBaker:master

Conversation

@ConnorBaker
Copy link
Copy Markdown
Contributor

The tensor_properties field of the ShardedTensorMetadata dataclass is a reference to a TensorProperties object. However, the field is set to field(default=TensorProperties()) instead of field(default_factory=TensorProperties). This causes an error when using Python 3.11 or later:

ValueError: mutable default <class 'torch.distributed._shard.sharded_tensor.metadata.TensorProperties'> for field tensor_properties is not allowed: use default_factory

This change in dataclass behavior was introduced in bpo-44674: Use unhashability as a proxy for mutability for default dataclass init arguments.

The current use of default instead of default_factory also means that all ShardedTensorMetadata objects created without specifying tensor_properties will share the same TensorProperties object.

@pytorch-bot
Copy link
Copy Markdown

pytorch-bot bot commented Jan 6, 2023

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/91795

Note: Links to docs will display an error until the docs builds have been completed.

❌ 5 Failures

As of commit fa43c9f:

NEW FAILURES - The following jobs have failed:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@pytorch-bot pytorch-bot bot added the release notes: distributed (sharded) release notes category label Jan 6, 2023
@linux-foundation-easycla
Copy link
Copy Markdown

linux-foundation-easycla bot commented Jan 6, 2023

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: ConnorBaker / name: Connor Baker (b253b338f4fe2effc847412f4a05f9cd9927643c)

@drisspg drisspg added the triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module label Jan 12, 2023
Copy link
Copy Markdown
Contributor

@fduwjj fduwjj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for fixing!

@fduwjj
Copy link
Copy Markdown
Contributor

fduwjj commented Jan 18, 2023

@pytorchbot rebase

@pytorchmergebot
Copy link
Copy Markdown
Collaborator

@pytorchbot successfully started a rebase job. Check the current status here

@pytorchmergebot
Copy link
Copy Markdown
Collaborator

Successfully rebased master onto refs/remotes/origin/viable/strict, please pull locally before adding more changes (for example, via git checkout master && git pull --rebase)

@fduwjj
Copy link
Copy Markdown
Contributor

fduwjj commented Jan 18, 2023

@pytorchbot merge

@pytorch-bot pytorch-bot bot added the ciflow/trunk Trigger trunk jobs on your pull request label Jan 18, 2023
@pytorchmergebot
Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

@pytorchmergebot
Copy link
Copy Markdown
Collaborator

Merge failed

Reason: The following mandatory check(s) failed (Rule Distributed):

Dig deeper by viewing the failures on hud

Details for Dev Infra team Raised by workflow job

@fduwjj
Copy link
Copy Markdown
Contributor

fduwjj commented Jan 18, 2023

@pytorchbot rebase

@pytorchmergebot
Copy link
Copy Markdown
Collaborator

@pytorchbot successfully started a rebase job. Check the current status here

The `tensor_properties` field of the `ShardedTensorMetadata` dataclass is a reference to a `TensorProperties` object. However, the field is set to `field(default=TensorProperties())` instead of `field(default_factory=TensorProperties)`. This causes an error when using Python 3.11 or later:

```python
ValueError: mutable default <class 'torch.distributed._shard.sharded_tensor.metadata.TensorProperties'> for field tensor_properties is not allowed: use default_factory
```

This change in dataclass behavior was introduced in [bpo-44674: Use unhashability as a proxy for mutability for default dataclass __init__ arguments](python/cpython#29867).

The current use of `default` instead of `default_factory` also means that all `ShardedTensorMetadata` objects created without specifying `tensor_properties` will share the same `TensorProperties` object.
@pytorchmergebot
Copy link
Copy Markdown
Collaborator

Successfully rebased master onto refs/remotes/origin/viable/strict, please pull locally before adding more changes (for example, via git checkout master && git pull --rebase)

@fduwjj
Copy link
Copy Markdown
Contributor

fduwjj commented Jan 19, 2023

@pytorchbot merge -f "CI failure not related to this PR also this PR fixes blockers for PT3.11 so we want to merge it ASAP".

@pytorchmergebot
Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged immediately since you used the force (-f) flag, bypassing any CI checks (ETA: 1-5 minutes).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/trunk Trigger trunk jobs on your pull request Merged open source release notes: distributed (sharded) release notes category triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants