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
[RFC][WIP] Introduce PT2 dynamo onnx exporter #1712
base: main
Are you sure you want to change the base?
Conversation
Hi @BowenBao, thank you for the PR! Yes I think moving to dynamo-based export is a good thing. One thing that is currently missing in Transformers, Diffusers, TIMM CI is testing that models can be traced with @Giuseppe5 was actually interested in something broader than this, namely generalizing the logic in |
@fxmarty what is the minimum requirement for us to have an initial version of this PR merged? The dynamo-based ONNX exporter is becoming our default ONNX exporter and it would be great to integrate and perfect it on Optimum framework |
@thiagocrepaldi In the current state, I think simply adding (slow) tests for dynamo, duplicating
@slow decorator, and using dynamo=True , and running RUN_SLOW=1 pytest tests/exporters/onnx -k "test_exporters_cli_pytorch_cpu" -s -vvvvv and reporting the failing tests / skipping them with a reason why would be enough.
For dynamo export to be the default, having the ability to specify the |
I need to check again, but I think dynamo already mimics the original input names in the user model, so the user doesnt have to do it themselves. Dynamo API does not provide such facility, so that would be a development in the pytorch core - not only on the onnx exporter module |
I'm updating the PR and resolving a few quick infra errors to get reasonable outputs from the unittests. Encountered this error and not sure how to proceed. I recall encountering this kind of error before when running standalone optimum export scripts, it feels like the error message does not describe the error cause accurately. @fxmarty do you have suggestions?
|
Found root cause to be optimum/optimum/utils/import_utils.py Line 61 in 548d0ac
returning False when installed package is onnx-weekly instead of onnx .
Looks like similar issue was noted for onnxruntime, and onnxruntime-gpu optimum/optimum/utils/import_utils.py Lines 63 to 64 in 548d0ac
|
Thank you @BowenBao, feel free to fix in this PR. |
Got an initial result after some tweaks to enable model patcher for dynamo.
We are also undergoing some changes in exporter to merge a few extra dependencies, will update this PR further once that part is done and triage the errors. |
c10f372
to
efbefbd
Compare
@@ -172,6 +171,12 @@ class OnnxCLIExportTestCase(unittest.TestCase): | |||
Integration tests ensuring supported models are correctly exported. | |||
""" | |||
|
|||
# TODO: Make this flag configurable. |
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.
Do you mean exposing it in the cli?
@@ -163,6 +164,8 @@ def main_export( | |||
If True, disables the use of dynamic axes during ONNX export. | |||
do_constant_folding (bool, defaults to `True`): | |||
PyTorch-specific argument. If `True`, the PyTorch ONNX export will fold constants into adjacent nodes, if possible. | |||
dynamo (bool, default to `False): |
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.
dynamo (bool, default to `False): | |
dynamo (bool, default to `False`): |
Hello from PyTorch ONNX exporter team. Since the early announcement of PT2 we have been actively developing the next generation of PyTorch ONNX exporter based on Dynamo, the new Python level JIT compiler.
With the upcoming PyTorch 2.3 release (targeting 4/24/24), we hope to introduce the new exporter as an experimental feature for early beta adoption in Optimum.
This is an initial PR to introduce the code path of calling the new exporter, which is now hidden behind a flag that is by default turned off. The goal is to kick off the discussion and start gathering feedback from the community.
Before submitting