Skip to content

Conversation

@XuehaiPan
Copy link
Collaborator

@XuehaiPan XuehaiPan commented Feb 12, 2025

[ghstack-poisoned]
@pytorch-bot
Copy link

pytorch-bot bot commented Feb 12, 2025

🔗 Helpful Links

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

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

✅ No Failures

As of commit e02bcaa with merge base 1677a31 (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]
[ghstack-poisoned]
XuehaiPan added a commit to XuehaiPan/pytorch that referenced this pull request Feb 12, 2025
isinstance_type_tuple: tuple[type, ...]
if isinstance(isinstance_type, type) or callable(
# E.g. isinstance([], typing.Sequence)
getattr(isinstance_type, "__instancecheck__", None)
Copy link
Contributor

Choose a reason for hiding this comment

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

Couldn't this call arbirary code at compile time? Do we need to trace through it?

Copy link
Collaborator Author

@XuehaiPan XuehaiPan Feb 13, 2025

Choose a reason for hiding this comment

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

Couldn't this call arbirary code at compile time?

Yes, it can. But I'm not sure we need to support this. The previous implementation before this PR already can run an arbitrary __subclasscheck__ method. We did not trace through it.

Do we need to trace through it?

Trace through this can have intensive overheads of isinstance(...) which is really common in user code. Also, most __subclasscheck__ can be constant fold through, which degenerates to issubclass(vt1.as_python_constant(), vt2.as_python_constant()).

Copy link
Contributor

@jansel jansel left a comment

Choose a reason for hiding this comment

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

Looks like the previous code had the same issue.

[ghstack-poisoned]
@XuehaiPan
Copy link
Collaborator Author

@pytorchbot merge

@pytorch-bot pytorch-bot bot added the ciflow/trunk Trigger trunk jobs on your pull request label Feb 16, 2025
@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

XuehaiPan added a commit to XuehaiPan/pytorch that referenced this pull request Feb 16, 2025
@github-actions github-actions bot deleted the gh/XuehaiPan/243/head branch March 25, 2025 02:16
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