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
example of splitting up an FX graph into smaller subgraphs with own submodules #45404
Conversation
…ubmodules [ghstack-poisoned]
…ubmodules ghstack-source-id: c0fd45f73b59740dded48bd355bcd622f1ab8c55 Pull Request resolved: #45404
💊 CI failures summary and remediationsAs of commit 08565d4 (more details on the Dr. CI page): Commit 08565d4 was recently pushed. Waiting for builds... This comment was automatically generated by Dr. CI (expand for details).Follow this link to opt-out of these comments for your Pull Requests.Please report bugs/suggestions on the GitHub issue tracker or post in the (internal) Dr. CI Users group. This comment has been revised 43 times. |
… with own submodules" Differential Revision: [D23956147](https://our.internmc.facebook.com/intern/diff/D23956147) [ghstack-poisoned]
…ubmodules ghstack-source-id: 1bda5dfcfc897f7de45ee0a1fd53fe1c1de7544c Pull Request resolved: #45404 has mypy errors as follows: torch/fx/experimental/subgraph_creation_example.py:139: error: Argument "args" to "create_node" of "Graph" has incompatible type "Union[Tuple[Any, ...], List[Any], Dict[str, Any], slice, Node, str, int, float, bool, dtype, Tensor, None]"; expected "Optional[Tuple[Union[Tuple[Any, ...], List[Any], Dict[str, Any], slice, Node, str, int, float, bool, dtype, Tensor, None], ...]]" [arg-type] torch/fx/experimental/subgraph_creation_example.py:140: error: Argument "kwargs" to "create_node" of "Graph" has incompatible type "Union[Tuple[Any, ...], List[Any], Dict[str, Any], slice, Node, str, int, float, bool, dtype, Tensor, None]"; expected "Optional[Dict[str, Union[Tuple[Any, ...], List[Any], Dict[str, Any], slice, Node, str, int, float, bool, dtype, Tensor, None]]]" [arg-type] torch/fx/experimental/subgraph_creation_example.py:177: error: Argument 2 to "call_module" of "Graph" has incompatible type "List[Node]"; expected "Optional[Tuple[Union[Tuple[Any, ...], List[Any], Dict[str, Any], slice, Node, str, int, float, bool, dtype, Tensor, None], ...]]" [arg-type] torch/fx/experimental/subgraph_creation_example.py:182: error: Value of type "Proxy" is not indexable [index] Found 4 errors in 1 file (checked 1 source file) I'm not sure how to fix these
… with own submodules" Differential Revision: [D23956147](https://our.internmc.facebook.com/intern/diff/D23956147) [ghstack-poisoned]
…ubmodules ghstack-source-id: 98bbfea76824b765785c08d13eff905e732b5fc6 Pull Request resolved: #45404 has mypy errors as follows: torch/fx/experimental/subgraph_creation_example.py:139: error: Argument "args" to "create_node" of "Graph" has incompatible type "Union[Tuple[Any, ...], List[Any], Dict[str, Any], slice, Node, str, int, float, bool, dtype, Tensor, None]"; expected "Optional[Tuple[Union[Tuple[Any, ...], List[Any], Dict[str, Any], slice, Node, str, int, float, bool, dtype, Tensor, None], ...]]" [arg-type] torch/fx/experimental/subgraph_creation_example.py:140: error: Argument "kwargs" to "create_node" of "Graph" has incompatible type "Union[Tuple[Any, ...], List[Any], Dict[str, Any], slice, Node, str, int, float, bool, dtype, Tensor, None]"; expected "Optional[Dict[str, Union[Tuple[Any, ...], List[Any], Dict[str, Any], slice, Node, str, int, float, bool, dtype, Tensor, None]]]" [arg-type] torch/fx/experimental/subgraph_creation_example.py:177: error: Argument 2 to "call_module" of "Graph" has incompatible type "List[Node]"; expected "Optional[Tuple[Union[Tuple[Any, ...], List[Any], Dict[str, Any], slice, Node, str, int, float, bool, dtype, Tensor, None], ...]]" [arg-type] torch/fx/experimental/subgraph_creation_example.py:182: error: Value of type "Proxy" is not indexable [index] Found 4 errors in 1 file (checked 1 source file) I'm not sure how to fix these
partition.targets[node.target] = target_attr | ||
target = target_atoms[-1] | ||
|
||
new_node = partition.graph.create_node(op=node.op, target=target, args=gathered_args, # type: ignore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are two mypy errors here that I'm not sure how to go about resolving, both are related to the types of the args/kwargs
mypy error: Argument "args" to "create_node" of "Graph" has incompatible type "Union[Tuple[Any, ...], List[Any], Dict[str, Any], slice, Node, str, int, float, bool, dtype, Tensor, None]"; expected "Optional[Tuple[Union[Tuple[Any, ...], List[Any], Dict[str, Any], slice, Node, str, int, float, bool, dtype, Tensor, None], ...]]" [arg-type]
error: Argument "kwargs" to "create_node" of "Graph" has incompatible type "Union[Tuple[Any, ...], List[Any], Dict[str, Any], slice, Node, str, int, float, bool, dtype, Tensor, None]"; expected "Optional[Dict[str, Union[Tuple[Any, ...], List[Any], Dict[str, Any], slice, Node, str, int, float, bool, dtype, Tensor, None]]]" [arg-type]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't repro this locally but I think if you put:
assert isinstance(gathered_args, tuple)
assert isinstance(gathered_kwargs, dict)
Before this line, mypy might match the types correctly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep this fixed it-- thanks
… with own submodules" Differential Revision: [D23956147](https://our.internmc.facebook.com/intern/diff/D23956147) [ghstack-poisoned]
…ubmodules ghstack-source-id: 3bdd63f180a0b8d0434bbef955ad662ed77ddbc5 Pull Request resolved: #45404 has mypy errors as follows: torch/fx/experimental/subgraph_creation_example.py:139: error: Argument "args" to "create_node" of "Graph" has incompatible type "Union[Tuple[Any, ...], List[Any], Dict[str, Any], slice, Node, str, int, float, bool, dtype, Tensor, None]"; expected "Optional[Tuple[Union[Tuple[Any, ...], List[Any], Dict[str, Any], slice, Node, str, int, float, bool, dtype, Tensor, None], ...]]" [arg-type] torch/fx/experimental/subgraph_creation_example.py:140: error: Argument "kwargs" to "create_node" of "Graph" has incompatible type "Union[Tuple[Any, ...], List[Any], Dict[str, Any], slice, Node, str, int, float, bool, dtype, Tensor, None]"; expected "Optional[Dict[str, Union[Tuple[Any, ...], List[Any], Dict[str, Any], slice, Node, str, int, float, bool, dtype, Tensor, None]]]" [arg-type] torch/fx/experimental/subgraph_creation_example.py:177: error: Argument 2 to "call_module" of "Graph" has incompatible type "List[Node]"; expected "Optional[Tuple[Union[Tuple[Any, ...], List[Any], Dict[str, Any], slice, Node, str, int, float, bool, dtype, Tensor, None], ...]]" [arg-type] torch/fx/experimental/subgraph_creation_example.py:182: error: Value of type "Proxy" is not indexable [index] Found 4 errors in 1 file (checked 1 source file) I'm not sure how to fix these
Codecov Report
@@ Coverage Diff @@
## gh/Lilyjjo/8/base #45404 +/- ##
====================================================
Coverage ? 68.55%
====================================================
Files ? 409
Lines ? 52592
Branches ? 0
====================================================
Hits ? 36056
Misses ? 16536
Partials ? 0 Continue to review full report at Codecov.
|
… with own submodules" Differential Revision: [D23956147](https://our.internmc.facebook.com/intern/diff/D23956147) [ghstack-poisoned]
… with own submodules" Differential Revision: [D23956147](https://our.internmc.facebook.com/intern/diff/D23956147) [ghstack-poisoned]
… with own submodules" Differential Revision: [D23956147](https://our.internmc.facebook.com/intern/diff/D23956147) [ghstack-poisoned]
… with own submodules" Differential Revision: [D23956147](https://our.internmc.facebook.com/intern/diff/D23956147) [ghstack-poisoned]
… with own submodules" Differential Revision: [D23956147](https://our.internmc.facebook.com/intern/diff/D23956147) [ghstack-poisoned]
…ubmodules ghstack-source-id: e53954180a6c8358168c46c45be6db097a7fb20f Pull Request resolved: #45404 moved from torch/fx/experimental to test/test_fx.py
… with own submodules" Differential Revision: [D23956147](https://our.internmc.facebook.com/intern/diff/D23956147) [ghstack-poisoned]
…ubmodules ghstack-source-id: 19c439eb0a11f968361cc4d2f5b6f6ba471ed47f Pull Request resolved: #45404 moved from torch/fx/experimental to test/test_fx.py
… with own submodules" Differential Revision: [D23956147](https://our.internmc.facebook.com/intern/diff/D23956147) [ghstack-poisoned]
…ubmodules ghstack-source-id: 0d5bae18ae5b8f6b7f4ab064aef3ec03dfa3059f Pull Request resolved: #45404 moved from torch/fx/experimental to test/test_fx.py
Stack from ghstack:
Differential Revision: D23956147