-
Notifications
You must be signed in to change notification settings - Fork 25.4k
[FX] Add Interpreter and Transformer #50420
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
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]
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]
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   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   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]
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   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   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   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   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]
@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