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
[FX] Add Interpreter and Transformer #50420
Conversation
[ghstack-poisoned]
💊 CI failures summary and remediationsAs of commit 64d7a19 (more details on the Dr. CI page):
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 to the (internal) Dr. CI Users group. |
[ghstack-poisoned]
ghstack-source-id: 9a68a477723120d2fa256450dbe8d75c3eb19a8c Pull Request resolved: #50420
I think it might be easier to implement vmap with this. |
1. Codify the interpreter pattern that was used, for ex, in [shape prop](https://github.com/pytorch/pytorch/blob/c3b4b2062748ed70e689f9f9ffe670e6fa20a071/torch/fx/experimental/shape_prop.py#L7). This is a pattern users will likely find repeatedly useful so it's good to have it first-class in the API. As seen in the test cases, this makes it incredibly easy to do simple analysis and transforms like swapping out individual nodes 2. Add a small `Transformer` class that is an `Interpreter` but provides a `transform` method that yields a GraphModule from interpreting the code TODO: - [ ] Write docstrings - [ ] Write docs - [ ] Look for more places this can be used Differential Revision: [D25880330](https://our.internmc.facebook.com/intern/diff/D25880330) [ghstack-poisoned]
ghstack-source-id: 04dc1ab9f73d27ed33bae333349ef27fb2bfe126 Pull Request resolved: #50420
1. Codify the interpreter pattern that was used, for ex, in [shape prop](https://github.com/pytorch/pytorch/blob/c3b4b2062748ed70e689f9f9ffe670e6fa20a071/torch/fx/experimental/shape_prop.py#L7). This is a pattern users will likely find repeatedly useful so it's good to have it first-class in the API. As seen in the test cases, this makes it incredibly easy to do simple analysis and transforms like swapping out individual nodes 2. Add a small `Transformer` class that is an `Interpreter` but provides a `transform` method that yields a GraphModule from interpreting the code TODO: - [ ] Write docstrings - [ ] Write docs - [ ] Look for more places this can be used Differential Revision: [D25880330](https://our.internmc.facebook.com/intern/diff/D25880330) [ghstack-poisoned]
1. Codify the interpreter pattern that was used, for ex, in [shape prop](https://github.com/pytorch/pytorch/blob/c3b4b2062748ed70e689f9f9ffe670e6fa20a071/torch/fx/experimental/shape_prop.py#L7). This is a pattern users will likely find repeatedly useful so it's good to have it first-class in the API. As seen in the test cases, this makes it incredibly easy to do simple analysis and transforms like swapping out individual nodes 2. Add a small `Transformer` class that is an `Interpreter` but provides a `transform` method that yields a GraphModule from interpreting the code TODO: - [ ] Write docstrings - [ ] Write docs - [ ] Look for more places this can be used Differential Revision: [D25880330](https://our.internmc.facebook.com/intern/diff/D25880330) [ghstack-poisoned]
1. Codify the interpreter pattern that was used, for ex, in [shape prop](https://github.com/pytorch/pytorch/blob/c3b4b2062748ed70e689f9f9ffe670e6fa20a071/torch/fx/experimental/shape_prop.py#L7). This is a pattern users will likely find repeatedly useful so it's good to have it first-class in the API. As seen in the test cases, this makes it incredibly easy to do simple analysis and transforms like swapping out individual nodes 2. Add a small `Transformer` class that is an `Interpreter` but provides a `transform` method that yields a GraphModule from interpreting the code TODO: - [x] Write docstrings - [ ] Write docs - [ ] Look for more places this can be used Differential Revision: [D25880330](https://our.internmc.facebook.com/intern/diff/D25880330) [ghstack-poisoned]
1. Codify the interpreter pattern that was used, for ex, in [shape prop](https://github.com/pytorch/pytorch/blob/c3b4b2062748ed70e689f9f9ffe670e6fa20a071/torch/fx/experimental/shape_prop.py#L7). This is a pattern users will likely find repeatedly useful so it's good to have it first-class in the API. As seen in the test cases, this makes it incredibly easy to do simple analysis and transforms like swapping out individual nodes 2. Add a small `Transformer` class that is an `Interpreter` but provides a `transform` method that yields a GraphModule from interpreting the code ![image](https://user-images.githubusercontent.com/4685384/105924691-a7b0b700-5ff3-11eb-8de8-7967d6b8ac69.png) ![image](https://user-images.githubusercontent.com/4685384/105924696-abdcd480-5ff3-11eb-8454-a2bc36c3248e.png) TODO: - [x] Write docstrings - [ ] Write docs - [ ] Look for more places this can be used Differential Revision: [D25880330](https://our.internmc.facebook.com/intern/diff/D25880330) [ghstack-poisoned]
1. Codify the interpreter pattern that was used, for ex, in [shape prop](https://github.com/pytorch/pytorch/blob/c3b4b2062748ed70e689f9f9ffe670e6fa20a071/torch/fx/experimental/shape_prop.py#L7). This is a pattern users will likely find repeatedly useful so it's good to have it first-class in the API. As seen in the test cases, this makes it incredibly easy to do simple analysis and transforms like swapping out individual nodes 2. Add a small `Transformer` class that is an `Interpreter` but provides a `transform` method that yields a GraphModule from interpreting the code ![image](https://user-images.githubusercontent.com/4685384/105924691-a7b0b700-5ff3-11eb-8de8-7967d6b8ac69.png) ![image](https://user-images.githubusercontent.com/4685384/105924696-abdcd480-5ff3-11eb-8454-a2bc36c3248e.png) TODO: - [x] Write docstrings - [ ] Write docs - [ ] Look for more places this can be used Differential Revision: [D25880330](https://our.internmc.facebook.com/intern/diff/D25880330) [ghstack-poisoned]
ghstack-source-id: 9c449a5c6205a7e78e30bf5fb9e71e89db5d99ce Pull Request resolved: #50420
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.
Looks pretty reasonable. I have a few suggestions to better decompose the components into reusable parts.
.. autoclass:: torch.fx.Interpreter | ||
:members: | ||
|
||
.. autoclass:: torch.fx.Transformer |
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.
still need a different name for this
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 haven't heard any good suggestions for this. Is the concern that this is the same name as the Transformer
architecture? In that case, I would argue that "Transformer" is a terrible name for that architecture and I don't think we should let them squat on an English language common noun
1. Codify the interpreter pattern that was used, for ex, in [shape prop](https://github.com/pytorch/pytorch/blob/c3b4b2062748ed70e689f9f9ffe670e6fa20a071/torch/fx/experimental/shape_prop.py#L7). This is a pattern users will likely find repeatedly useful so it's good to have it first-class in the API. As seen in the test cases, this makes it incredibly easy to do simple analysis and transforms like swapping out individual nodes 2. Add a small `Transformer` class that is an `Interpreter` but provides a `transform` method that yields a GraphModule from interpreting the code ![image](https://user-images.githubusercontent.com/4685384/105924691-a7b0b700-5ff3-11eb-8de8-7967d6b8ac69.png) ![image](https://user-images.githubusercontent.com/4685384/105924696-abdcd480-5ff3-11eb-8454-a2bc36c3248e.png) TODO: - [x] Write docstrings - [x] Write docs - [ ] Look for more places this can be used Differential Revision: [D25880330](https://our.internmc.facebook.com/intern/diff/D25880330) [ghstack-poisoned]
1. Codify the interpreter pattern that was used, for ex, in [shape prop](https://github.com/pytorch/pytorch/blob/c3b4b2062748ed70e689f9f9ffe670e6fa20a071/torch/fx/experimental/shape_prop.py#L7). This is a pattern users will likely find repeatedly useful so it's good to have it first-class in the API. As seen in the test cases, this makes it incredibly easy to do simple analysis and transforms like swapping out individual nodes 2. Add a small `Transformer` class that is an `Interpreter` but provides a `transform` method that yields a GraphModule from interpreting the code ![image](https://user-images.githubusercontent.com/4685384/105924691-a7b0b700-5ff3-11eb-8de8-7967d6b8ac69.png) ![image](https://user-images.githubusercontent.com/4685384/105924696-abdcd480-5ff3-11eb-8454-a2bc36c3248e.png) TODO: - [x] Write docstrings - [x] Write docs - [ ] Look for more places this can be used Differential Revision: [D25880330](https://our.internmc.facebook.com/intern/diff/D25880330) [ghstack-poisoned]
ghstack-source-id: 9d200c9512549670d0c78e7ba86bb38cf3f79b4a Pull Request resolved: #50420
1. Codify the interpreter pattern that was used, for ex, in [shape prop](https://github.com/pytorch/pytorch/blob/c3b4b2062748ed70e689f9f9ffe670e6fa20a071/torch/fx/experimental/shape_prop.py#L7). This is a pattern users will likely find repeatedly useful so it's good to have it first-class in the API. As seen in the test cases, this makes it incredibly easy to do simple analysis and transforms like swapping out individual nodes 2. Add a small `Transformer` class that is an `Interpreter` but provides a `transform` method that yields a GraphModule from interpreting the code ![image](https://user-images.githubusercontent.com/4685384/105924691-a7b0b700-5ff3-11eb-8de8-7967d6b8ac69.png) ![image](https://user-images.githubusercontent.com/4685384/105924696-abdcd480-5ff3-11eb-8454-a2bc36c3248e.png) TODO: - [x] Write docstrings - [x] Write docs - [ ] Look for more places this can be used Differential Revision: [D25880330](https://our.internmc.facebook.com/intern/diff/D25880330) [ghstack-poisoned]
ghstack-source-id: 67c6b316a18cfe576c0a33d64f5a376788d3189b Pull Request resolved: #50420
1. Codify the interpreter pattern that was used, for ex, in [shape prop](https://github.com/pytorch/pytorch/blob/c3b4b2062748ed70e689f9f9ffe670e6fa20a071/torch/fx/experimental/shape_prop.py#L7). This is a pattern users will likely find repeatedly useful so it's good to have it first-class in the API. As seen in the test cases, this makes it incredibly easy to do simple analysis and transforms like swapping out individual nodes 2. Add a small `Transformer` class that is an `Interpreter` but provides a `transform` method that yields a GraphModule from interpreting the code ![image](https://user-images.githubusercontent.com/4685384/105924691-a7b0b700-5ff3-11eb-8de8-7967d6b8ac69.png) ![image](https://user-images.githubusercontent.com/4685384/105924696-abdcd480-5ff3-11eb-8454-a2bc36c3248e.png) TODO: - [x] Write docstrings - [x] Write docs - [ ] Look for more places this can be used Differential Revision: [D25880330](https://our.internmc.facebook.com/intern/diff/D25880330) [ghstack-poisoned]
ghstack-source-id: 5f2bd6fd7aeacb31455b55fa9eb3a30144583826 Pull Request resolved: #50420
@jamesr66a merged this pull request in 609f76f. |
Stack from ghstack:
Codify the interpreter pattern that was used, for ex, in shape prop. This is a pattern users will likely find repeatedly useful so it's good to have it first-class in the API. As seen in the test cases, this makes it incredibly easy to do simple analysis and transforms like swapping out individual nodes
Add a small
Transformer
class that is anInterpreter
but provides atransform
method that yields a GraphModule from interpreting the codeTODO:
Differential Revision: D25880330