Skip to content

Conversation

cdzhan
Copy link
Contributor

@cdzhan cdzhan commented Mar 12, 2024

support following case:

import torch
...
class CustomFooTensor(torch.Tensor):
  @classmethod
  def __torch_function__(cls, func, types, args=(), kwargs=None):
    ...
a = CustomFooTensor([3])
print(a.is_foo)

@cdzhan cdzhan requested review from albanD and soulitzer as code owners March 12, 2024 12:07
Copy link

pytorch-bot bot commented Mar 12, 2024

🔗 Helpful Links

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

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

✅ You can merge normally! (4 Unrelated Failures)

As of commit b422679 with merge base a56e057 (image):

FLAKY - The following jobs failed but were likely due to flakiness present on trunk:

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

Copy link

linux-foundation-easycla bot commented Mar 12, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

@cdzhan cdzhan force-pushed the privateuse_zcd branch 2 times, most recently from 14dca8c to 3b1329c Compare March 12, 2024 13:02
@drisspg drisspg added triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module module: PrivateUse1 private use labels Mar 13, 2024
Copy link
Collaborator

@albanD albanD left a comment

Choose a reason for hiding this comment

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

I don't think we should add this attribute because:

  • It moves us away from device generic code
  • it doesn't make sense once the privateuse1 module is renamed.

@cdzhan cdzhan changed the title add __torch_function__ support for is_privateuseone property of torch… Add __torch_function__ support for generated tensor methods/property of PrivateUse1 Mar 18, 2024
@cdzhan
Copy link
Contributor Author

cdzhan commented Mar 18, 2024

I don't think we should add this attribute because:

  • It moves us away from device generic code
  • it doesn't make sense once the privateuse1 module is renamed.

Thanks for your comment! Please let me know If there is anything else that needs to be modified.

@cdzhan cdzhan requested a review from albanD March 18, 2024 11:46
@soulitzer soulitzer removed their request for review April 1, 2024 17:20
@albanD
Copy link
Collaborator

albanD commented Apr 2, 2024

Sorry, but I don't think we want this at all. You can use t.device.type == some_device_type to get the same thing in a more generic way. So I'm not sure we really want to add more of these one-off attributes.

@cdzhan
Copy link
Contributor Author

cdzhan commented Apr 3, 2024

I thought about this question again, but a related more general question came to mind #123245 @albanD

@cdzhan
Copy link
Contributor Author

cdzhan commented Apr 19, 2024

Thanks to #122468 's clarification of the gpu_migration method, I can express my motivation more clearly. Just because is_cuda has this attribute, if PrivateUse1 do not have this, extra change may need to be made and users have to write more device-specific code. After all, we can't predict how users will use those APIs. None of us are fans of gpu_migration, but it may be a good short term opt-in. @albanD

Copy link
Collaborator

@albanD albanD left a comment

Choose a reason for hiding this comment

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

Ok, I still think we want to remove a lot of these device-specific method/attributes.
But I agree that adding torch_function support to these existing one is an ok thing to do.

@albanD
Copy link
Collaborator

albanD commented Apr 19, 2024

@pytorchbot merge -r

Copy link

pytorch-bot bot commented Apr 19, 2024

Pull workflow has not been scheduled for the PR yet. It could be because author doesn't have permissions to run those or skip-checks keywords were added to PR/commits, aborting merge. Please get/give approval for the workflows and/or remove skip ci decorators before next merge attempt. If you think this is a mistake, please contact PyTorch Dev Infra.

@seemethere
Copy link
Member

@pytorchbot rebase

@pytorchmergebot
Copy link
Collaborator

@pytorchbot started a rebase job onto refs/remotes/origin/viable/strict. Check the current status here

@pytorchmergebot
Copy link
Collaborator

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

@albanD
Copy link
Collaborator

albanD commented Apr 19, 2024

@pytorchbot merge

@pytorch-bot pytorch-bot bot added the ciflow/trunk Trigger trunk jobs on your pull request label Apr 19, 2024
@pytorchmergebot
Copy link
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

@cdzhan cdzhan deleted the privateuse_zcd branch April 20, 2024 03:27
pytorch-bot bot pushed a commit that referenced this pull request Apr 22, 2024
…of PrivateUse1 (#121723)

support following case:
```python
import torch
...
class CustomFooTensor(torch.Tensor):
  @classmethod
  def __torch_function__(cls, func, types, args=(), kwargs=None):
    ...
a = CustomFooTensor([3])
print(a.is_foo)
```
Pull Request resolved: #121723
Approved by: https://github.com/albanD
petrex pushed a commit to petrex/pytorch that referenced this pull request May 3, 2024
…of PrivateUse1 (pytorch#121723)

support following case:
```python
import torch
...
class CustomFooTensor(torch.Tensor):
  @classmethod
  def __torch_function__(cls, func, types, args=(), kwargs=None):
    ...
a = CustomFooTensor([3])
print(a.is_foo)
```
Pull Request resolved: pytorch#121723
Approved by: https://github.com/albanD
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 module: PrivateUse1 private use open source topic: not user facing topic 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.

6 participants