Skip to content
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

Expose StreamBase and EventBase #126257

Closed
wants to merge 2 commits into from
Closed

Conversation

cyyever
Copy link
Collaborator

@cyyever cyyever commented May 15, 2024

So that we can use them in type hinting to avoid device-specific types like CUDAStream and XPUStream.

cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @chenyang78 @kadeng @chauhang

@cyyever cyyever requested a review from eqy as a code owner May 15, 2024 01:18
Copy link

pytorch-bot bot commented May 15, 2024

🔗 Helpful Links

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

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

❌ 1 New Failure, 15 Unrelated Failures

As of commit fb7e8d8 with merge base bed1c60 (image):

NEW FAILURE - The following job has failed:

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

BROKEN TRUNK - The following jobs failed but were present on the merge base:

👉 Rebase onto the `viable/strict` branch to avoid these failures

UNSTABLE - The following jobs failed but were likely due to flakiness present on trunk and has been marked as unstable:

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

@ezyang
Copy link
Contributor

ezyang commented May 15, 2024

I did some check in fbcode and the blast radius does not seem too big

@cyyever
Copy link
Collaborator Author

cyyever commented May 16, 2024

I did some check in fbcode and the blast radius does not seem too big

If we are careful not to break the existing extensions relying on the old class names, it should work in general. On the other hand, such reliance indicates that they should indeed be exposed as public classes.

@albanD
Copy link
Collaborator

albanD commented May 16, 2024

I don't think you need this. The shared class here are torch.Stream and torch.Event you can use these to do proper typing and subclass checking.
Unless I missed something in that (quite complex) collection of classes.

@cyyever
Copy link
Collaborator Author

cyyever commented May 16, 2024

I don't think you need this. The shared class here are torch.Stream and torch.Event you can use these to do proper typing and subclass checking. Unless I missed something in that (quite complex) collection of classes.

So you also think they should be moved to torch.types? If both of you think it is a better way to organize code, I will do it.

@albanD
Copy link
Collaborator

albanD commented May 17, 2024

I'm afraid I don't know what torch.types is ?
Also what you mean by "move" here?

@ezyang
Copy link
Contributor

ezyang commented May 19, 2024

@cyyever is talking about the module, torch/types.py

@albanD
Copy link
Collaborator

albanD commented May 20, 2024

Ho I missed that one, thanks!

My expectation is that you can use torch.Stream and torch.Event as type hints. Since they are already available in our public API, we don't need any special entry for them in torch.types.
So I'm not sure to understand why is this PR needed and what is the problem it is helping solve.

@drisspg drisspg added the triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module label May 20, 2024
@cyyever
Copy link
Collaborator Author

cyyever commented May 21, 2024

@albanD Their class names contains an underscore prefix before, which causing pylint and mypy complaining because that is the convention of inner classes. The main fix here is just to delete the underscore prefix.

@ezyang ezyang requested a review from albanD May 21, 2024 01:38
@albanD
Copy link
Collaborator

albanD commented May 22, 2024

I am not sure what you mean? torch.Stream and torch.Event don't have any underscore in their names?

@albanD
Copy link
Collaborator

albanD commented May 22, 2024

To be clear, these two APIs were added recently as the way to support device-generic stream/event.
The old _StreamBase/_EventBase classes don't really have a purpose anymore and can be deleted when we get around to do it.

You can check the mro for any stream/event-like object we have and they should all properly contain torch.Stream / torch.Event.

@cyyever cyyever marked this pull request as draft May 25, 2024 02:43
@cyyever cyyever closed this May 25, 2024
@cyyever cyyever deleted the unified_stream branch May 25, 2024 02:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ciflow/inductor module: dynamo open source 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.

None yet

5 participants