-
Notifications
You must be signed in to change notification settings - Fork 108
Support CUDA stream operators in ThunderFX #2761
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
base: main
Are you sure you want to change the base?
Changes from 5 commits
2cab398
52dcc2c
31e8622
a9860e4
cb80636
7db7b53
04d80dc
26d429d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,6 +28,22 @@ | |
| if TYPE_CHECKING: | ||
| from collections.abc import Callable | ||
| from typing import Any | ||
| from torch.fx import GraphModule | ||
|
|
||
|
|
||
| def _preprocess_cuda_stream_objects(gm: GraphModule) -> None: | ||
| """Preprocess the graph to handle :class:`torch.cuda.Stream` objects. | ||
|
|
||
| Since :class:`torch.cuda.Stream` does not have sympy expression apparently, | ||
| manually setting its metadata to :obj:`None` to avoid an error such as | ||
| ``cannot extract sympy expressions from <torch.cuda.Stream device=cuda:0 cuda_stream=0x0> <class 'torch.cuda.streams.Stream'>`` | ||
| """ | ||
| for node in gm.graph.nodes: | ||
| if hasattr(node, "meta") and "example_value" in node.meta: | ||
| example_value = node.meta["example_value"] | ||
| if isinstance(example_value, torch.cuda.Stream): | ||
| node.meta["example_value"] = None | ||
| node.meta["_original_stream_type"] = type(example_value).__name__ | ||
|
||
|
|
||
|
|
||
| def _splitter( | ||
|
|
@@ -166,6 +182,7 @@ def callback(node) -> int: | |
| for n in functionctx_nodes_to_del: | ||
| gm.graph.erase_node(n) | ||
| gm.recompile() | ||
| _preprocess_cuda_stream_objects(gm) | ||
|
|
||
| # `split_module` iterates over nodes and determines the partition to place them based on the callback. | ||
| split_gm: torch.fx.GraphModule = split_module( | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.