Uh oh!
There was an error while loading. Please reload this page.
[RFC]PyTorchTVM - #25
Conversation
masahi
commented
Aug 24, 2021
cc @t-vi |
junrushao
commented
Aug 24, 2021
Thanks for the nice RFC @Meteorix! It is definitely super important direction to embed TVM into PyTorch. I will read it carefully later this week. |
masahi
commented
Aug 25, 2021
Is this supposed to be useful for accelerating PyTorch training? |
Meteorix
commented
Aug 26, 2021
From my perspective, we are a little far from supporting PyTorch training. I can think of 2 possible ways:
It seems both ways are in early stage. Maybe we can further discuss the possibility, but not in the scope of this RFC. |
Uh oh!
There was an error while loading. Please reload this page.
t-vi
commented
Aug 27, 2021
I wonder whether this would make the torch fallback op (apache/tvm#7401) more or less useful (it would depend on what you (plan to) do with unsupported ops). I am still pondering whether to close it or dust it off. I should note that as far as I know NVidia has a TensorRT front end serving a similar goal and there also is one for ONNXRuntime-as-a-module (recently featured in the PyTorch blog). There may be useful design insights in how they work (or maybe they're too different to what you have in mind). |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| * Onnx cannot cover all models with dynamic control flow (e.g. for loop) | ||
| * TensorRT can only accelerate some standard networks | ||
| So we hope to use TVM to accelerate PyTorch model inference. |
There was a problem hiding this comment.
We should discuss more about the benefit of PyTorchTVM here
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| images: List[torch.Tensor] = [] | ||
| for path in image_path: | ||
| img = read_image(path) | ||
| images.append(img) | ||
| x = torch.stack(images).cuda().half() |
There was a problem hiding this comment.
Shall we conclude these lines to an abstract data loader to be consistent with our description? like, self.load_data()
There was a problem hiding this comment.
maybe just keep the class simple?
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| # Prior art | ||
| [prior-art]: #prior-art | ||
| Our implementation is inspired by this RFC: https://discuss.tvm.apache.org/t/rfc-add-tensorflow-custom-op-to-embed-tvm-runtime-in-tensorflow-graph-and-session/4601 |
There was a problem hiding this comment.
| Our implementation is inspired by this RFC: https://discuss.tvm.apache.org/t/rfc-add-tensorflow-custom-op-to-embed-tvm-runtime-in-tensorflow-graph-and-session/4601 | |
| Our implementation is inspired by this RFC which allows TVM operators to be embedded into TensorFlow: https://discuss.tvm.apache.org/t/rfc-add-tensorflow-custom-op-to-embed-tvm-runtime-in-tensorflow-graph-and-session/4601. Beyond a single operator, our RFC further extends the scope to embedding arbitrary TVM graphs to TorchScript, and enables smooth integration and serving with both `torch.jit.trace` and `torch.jit.script` APIs. |
There was a problem hiding this comment.
To clarify: a major difference is that, the TF RFC only support embedding a TVM op, but not a TVM graph. And we also have an internal implementation that embeds TVM graph into TF.
Uh oh!
There was an error while loading. Please reload this page.
junrushao
commented
Aug 30, 2021
Thanks again for the contribution! I have no doubt that it is going to be hugely important piece of work. Just made some suggestions in terms of wording. |
Co-authored-by: Junru Shao <junrushao1994@gmail.com>
Co-authored-by: Junru Shao <junrushao1994@gmail.com>
Co-authored-by: Junru Shao <junrushao1994@gmail.com>
@t-vi It will help a lot. If we have the torch fallback op support, users will less likely get stuck in frontend conversion phase. We are looking forward to this feature. Could you complete the PR?
And thanks for this information. Actually, we are inspired by another NVIDIA work: TRTorch. |
Co-authored-by: Junru Shao <junrushao1994@gmail.com>
Co-authored-by: Junru Shao <junrushao1994@gmail.com>
Co-authored-by: Junru Shao <junrushao1994@gmail.com>
Co-authored-by: Junru Shao <junrushao1994@gmail.com>
Co-authored-by: Junru Shao <junrushao1994@gmail.com>
Co-authored-by: Junru Shao <junrushao1994@gmail.com>
suluner
commented
Sep 9, 2021
Can this method split the graph automaticly given a torchscript, and convert the subgraph that tvm Relay IR can support or tvm outperforming pytorch? |
junrushao
commented
Sep 9, 2021
hogepodge
left a comment
There was a problem hiding this comment.
In general I support this effort. I'd like to see stronger integrations of TVM into adjacent projects like PyTorch. This looks like a good start.
One minor spelling point, but otherwise this looks good to me.
Uh oh!
There was an error while loading. Please reload this page.
tqchen
commented
Sep 10, 2021
Thanks for the great work, a minor note on rendering. it would be great to add the codeblock type to the code so we have syntax highlights |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Meteorix
commented
Sep 13, 2021
@hogepodge@tqchen thanks for your advices. I have updated the PR. |
junrushao
commented
Sep 13, 2021
It seems that we all reach consensus and no more comments are raised for several days, let's get this RFC finally merged! 🔥 🎉 |
This RFC add a
PyTorchTVMmodule to support: compile TorchScript to TVM and use accelerated module in PyTorch.Initial PR: apache/tvm#8777
Discuss: https://discuss.tvm.apache.org/t/rfc-pytorchtvm-compile-torchscript-to-tvm-and-use-accelerated-module-in-pytorch/10873