-
Notifications
You must be signed in to change notification settings - Fork 505
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
Support Unbounded Dynamism for torch.export #6393
Comments
@ezyang We are trying to support unbounded dynamic shape only for export. The exported FX Graph is dynamic and has sym_size op that extracts the size of a tensor and store it in a SymInt. During LTC tracing, we are using static tensors. (Not sure if there is a way to create a tensor with unbounded dynamic dimension and trace with it) In this process, all tensors are static from PyTorch's perspective so it will try to collapse the symint into concrete integer instead of treating the size as a symbolic things. What's the correct way to make PyTorch always treat symint as unbacked and not collapsing it? We want to lower the symint to an IR in the final HLO. |
Are you dead set on lazy tensor for this, or can you be flexible? Because if you can be flexible, I would tell you to use torch.export and you'd get a graph with non-collapsed dynamic dimensions and size compute for whatever you needed to be dynamic. And then life is good. To get it to work with LTC... ugh, I don't even wanna think about it lol. |
@ezyang we are already using the |
Inductor does just handle it! For example, when generating kernels for pointwise operations, we support symbolic ranges. We can also deal with symbolic indexing formulas and use sympy to simplify them. |
#6653 Provides support with limitations to this uses case by applying a FX pass to group the |
Code contributions that enabled this unbounded dynamism: Propagating dynamism information from PyTorch down to StableHLO Support unbounded dynamism for torch ops
FX passes to to support dynamism in op argument |
🚀 Feature
The unbounded dynamic shape needs to be propagated through ops.
Scope:
Example:
In LazyIR, we need to capture the
aten.sym_size.int
and the subsequent arithmetic operations on the SymInt. So that the semantic can be lowered.In the lowered HLO graph, we should have something like
Rough Plan
aten.sym_size.int
, which generates a SymInt)sym_int
version of the op is lowered, it needs to retrieve the underlying LazyIR of the SymInt argumentOpen questions
Example
Let's say input.shape[0] has a bound of <= 5. In bounded dynamism, only knowing the upper bound in the op is enough. In unbounded dynamism, the arithmetic on SymInt needs to be traced and lowered in LTC.
The text was updated successfully, but these errors were encountered: