Skip to content
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

Import symbolic shape information in MLIR while importing stateless graph #3655

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

patel-vimal
Copy link
Contributor

@patel-vimal patel-vimal commented Aug 21, 2024

This PR contains changes required to enable the import of symbolic shape information on the stateless graph import entry point of FxImporter.

I note that the FxImporter.import_stateless_graph API is deprecated. But, as per my knowledge, it's the only API that can be used with torch.compile(). The other API, namely import_program and importantly accepts torch's ExportedProgram format. However, the torch.export.exportthat generatesExportedProgram` does not support graph breaks, which is a limiting factor for us. We are ready to maintain this API.

@patel-vimal patel-vimal force-pushed the vimal/upstream/import_symbolic_shape_expr_for_stateless_graph_import branch 2 times, most recently from db18918 to 5000283 Compare August 22, 2024 06:59
New sympy type is introduced to represent integer infinity in upstream
PyTorch repo. Subsequently, sympy.oo is no longer used to represent
infinity upper bound for dynamic dimensions where the upper bound is
unknown. Instead `int_oo` is used to represent integer infinity. This
commit updates the `_sympy_int_to_int` utility in light of this change.
For the `stateless_fx_import` entry-point to import FX graph to MLIR,
importing symbolic shape expressions was not enabled. This commit
enabled this. Unlike the case of importing `ExportedProgram` here we
need to get range constraints from the shape environment that was used
during tracing. We rely on example inputs to get hold of ShapeEnv
object which we later use to get the variable to range mapping.
This commit adds information about which symbol a given function
argument corresponds to if any. This makes it possible to find the
corresponding `torch.symbolic_int` operation that provides bounds on the
range of a given function argument.
@patel-vimal patel-vimal force-pushed the vimal/upstream/import_symbolic_shape_expr_for_stateless_graph_import branch from 5000283 to a10215c Compare August 22, 2024 07:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant