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

example of splitting up an FX graph into smaller subgraphs with own submodules #45404

Closed
wants to merge 11 commits into from

Conversation

Lilyjjo
Copy link
Contributor

@Lilyjjo Lilyjjo commented Sep 28, 2020

Stack from ghstack:

Differential Revision: D23956147

Lilyjjo added a commit that referenced this pull request Sep 28, 2020
…ubmodules

ghstack-source-id: c0fd45f73b59740dded48bd355bcd622f1ab8c55
Pull Request resolved: #45404
@dr-ci
Copy link

dr-ci bot commented Sep 28, 2020

💊 CI failures summary and remediations

As 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.

See how this bot performed.

This comment has been revised 43 times.

Lilyjjo added a commit that referenced this pull request Sep 28, 2020
…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
Lilyjjo added a commit that referenced this pull request Sep 29, 2020
…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
Copy link
Contributor Author

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]

Copy link
Collaborator

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

Copy link
Contributor Author

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

Lilyjjo added a commit that referenced this pull request Sep 29, 2020
…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
Copy link

codecov bot commented Sep 29, 2020

Codecov Report

❗ No coverage uploaded for pull request base (gh/Lilyjjo/8/base@4f685ec). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@                 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.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4f685ec...08565d4. Read the comment docs.

Lilyjjo added a commit that referenced this pull request Sep 30, 2020
…ubmodules

ghstack-source-id: e53954180a6c8358168c46c45be6db097a7fb20f
Pull Request resolved: #45404

moved from torch/fx/experimental to test/test_fx.py
Lilyjjo added a commit that referenced this pull request Oct 1, 2020
…ubmodules

ghstack-source-id: 19c439eb0a11f968361cc4d2f5b6f6ba471ed47f
Pull Request resolved: #45404

moved from torch/fx/experimental to test/test_fx.py
Lilyjjo added a commit that referenced this pull request Oct 1, 2020
…ubmodules

ghstack-source-id: 0d5bae18ae5b8f6b7f4ab064aef3ec03dfa3059f
Pull Request resolved: #45404

moved from torch/fx/experimental to test/test_fx.py
@facebook-github-bot
Copy link
Contributor

@Lilyjjo merged this pull request in f6dc256.

@facebook-github-bot facebook-github-bot deleted the gh/Lilyjjo/8/head branch October 5, 2020 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FX] Write up an example of splitting up an FX graph into smaller subgraphs
4 participants