Skip to content

Handle is/is not #146496

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

[ghstack-poisoned]
Copy link

pytorch-bot bot commented Feb 5, 2025

🔗 Helpful Links

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

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

✅ No Failures

As of commit 4b55b2a with merge base fd8ae1a (image):
💚 Looks good so far! There are no failures yet. 💚

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

[ghstack-poisoned]
# is => left is not right -> False
# is not => left is right -> False
# is not => left is not right -> True
return ConstantVariable(op(left, right))
Copy link
Contributor

Choose a reason for hiding this comment

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

I am not sure if this is safe today.

If the types don't match, we can safely return a constant.

But if the types match, this change basically relies on comparing two variable trackers. For is_ op, this is equivalent to saying return left is right. I am concerned if we can create two different variable trackers for the same object, and then this op fails. This can happen for sourceless builder.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

For the use case that I have, I only care about exceptions right now. Would you think the code now is safe?

Copy link
Contributor

@anijain2305 anijain2305 left a comment

Choose a reason for hiding this comment

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

Added a comment.

[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
@zou3519 zou3519 self-requested a review February 13, 2025 17:06
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
Comment on lines 663 to 666
(
(variables.ExceptionVariable, variables.ExceptionVariable),
lambda tx, l, r: ConstantVariable(op(l, r)),
),
Copy link
Contributor

@zou3519 zou3519 Feb 20, 2025

Choose a reason for hiding this comment

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

I think this is safe to do on ExceptionVariable because we do not use SourcelessBuilder on it. Maybe we should just add an assertion into SourcelessBuilder that we don't see one? Thoughts @anijain2305

[ghstack-poisoned]
[ghstack-poisoned]
@pytorchmergebot
Copy link
Collaborator

Starting merge as part of PR stack under #146497

[ghstack-poisoned]
@pytorchmergebot
Copy link
Collaborator

Starting merge as part of PR stack under #146497

pytorchmergebot pushed a commit that referenced this pull request Feb 23, 2025
desai0007 pushed a commit to desai0007/test-repo-pytorch that referenced this pull request Feb 26, 2025
ghstack-source-id: 514ff83
Pull Request resolved: pytorch/pytorch#146496
aditew01 pushed a commit that referenced this pull request Feb 28, 2025
aditew01 pushed a commit that referenced this pull request Feb 28, 2025
majing921201 pushed a commit to majing921201/pytorch that referenced this pull request Mar 4, 2025
majing921201 pushed a commit to majing921201/pytorch that referenced this pull request Mar 4, 2025
@github-actions github-actions bot deleted the gh/guilhermeleobas/97/head branch March 27, 2025 02:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants