-
Notifications
You must be signed in to change notification settings - Fork 3.8k
[Relax][PyTorch] Add run_ep_decomposition flag to control PyTorch decomposition #18399
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
Conversation
Summary of ChangesHello @tlopex, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces a crucial, temporary flag to the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces a run_ep_decomposition flag to control PyTorch operator decomposition, which is a good approach for enabling a gradual migration. The change also correctly handles the return value of run_decompositions(), fixing a subtle bug in the previous implementation. My review includes suggestions to add a TODO for the temporary flag and to include tests for the new code path to ensure its correctness.
| if run_ep_decomposition: | ||
| exported_program = exported_program.run_decompositions() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this flag is temporary, it would be good practice to add a TODO comment here to track its future removal. This helps ensure the codebase is cleaned up after the migration is complete.
# TODO(user): Remove this flag and always run decomposition once all operators are supported.
if run_ep_decomposition:
exported_program = exported_program.run_decompositions()It would also be helpful to note the temporary nature of this flag in its docstring.
|
@tvm-bot rerun |
|
cc @mshr-h |
This PR adds a new
run_ep_decompositionflag to thefrom_exported_programfunction to control whether PyTorch's decomposition should be run before translation. This enables gradual migration from non-decomposed to decomposed operator support. This flag will be a temporary one and will be removed until everything is fixed.Motivation
Currently, when
run_decompositions()is called on an ExportedProgram, high-level operators are decomposed into their constituent parts (e.g.,torch.square→torch.pow(x, 2)). However, the current translator expects the original high-level operators, causing ~40% of tests to fail when decomposition is enabled. Previously, we couldn't enable decomposition becauserun_decompositions()is not an in-place operation so that it cannot be used.This flag allows us to:
Future Work
This PR sets up the foundation for:
pow.Tensor_Scalar,mul.Tensor)Example Usage