[FX] Add Interpreter and Transformer#50420
[FX] Add Interpreter and Transformer#50420jamesr66a wants to merge 12 commits intogh/jamesr66a/350/basefrom
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]
zdevito
left a comment
There was a problem hiding this comment.
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.
still need a different name for this
There was a problem hiding this comment.
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
Transformerclass that is anInterpreterbut provides atransformmethod that yields a GraphModule from interpreting the codeTODO:
Differential Revision: D25880330