Replies: 1 comment
-
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
TL DR:
This doc lists the existing way of dynamic shapes (DS) support in Torch-TRT using torch.compile and suggested improvements.
For a dynamic input shaped graph to be optimized by TensorRT , we would need the (min, max) shape info for the nodes. With Pytorch 2.X, we are able to get these ranges using the symbolic shape data in the
node.meta
and ensure TensorRT can use this data. However, there are some usability concerns intorch.compile
workflow which are listed below.Current DS workflow in export
The
dynamic_shapes
argument is very helpful to provide all the DS info we need for any number of inputs and their dimensions.Current DS workflow in compile
Based on this discussion thread, the current workflow that works is
In
torch.compile
workflow, we would have to add thetorch._check
s and mark the input dynamic viatorch._dynamo.mark_dynamic
Limitations in the
torch.compile
workflowWe don't always have access to the model directly. Models sometimes get wrapped (if we use external third party libraries like huggingface). In the following GPT2 code, we have to modify the forward function in the source code which isn't always straightforward.
In general, it would be great if users don't have to modify their source code for their models.
Proposal
A straightforward way to handle this would be in
torch._dynamo.mark_dynamic
. If we could have an API liketorch._dynamo.mark_dynamic(input, dimension, min, max)
, it would be easier for end-users. An end-end example is as followsBeta Was this translation helpful? Give feedback.
All reactions