-
Notifications
You must be signed in to change notification settings - Fork 651
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
Rework iree-compile pipeline for ONNX #18803
Comments
Oof. That's not good. Test suites should be using the same tools that we recommend to users. If tests fail when using those tools, the tools should be fixed instead of changing the tests.
Generally:
We can put options in the torch (onnx) plugin if there are decisions for users to make, like the existing If the passes and pipelines in torch-mlir change, IREE should adapt as well. See also #17021. I don't have specific feedback about the proposed concrete changes. They all look pretty standard for converting from one representation to another. |
I have added the WIP patch here: llvm/torch-mlir#3801 for adding the torch-onnx-to-torch-backend pipeline in Torch-MLIR. |
I only disagree based on my incompetence. It's been some trial and error to figure out what passes we actually need, and where to put them in the pipeline. It would have been several iterations of sloppy iree commits to converge on something meaningful. Instead, we tried some different combinations of pre-proccessing passes in the test suite, and finally have a good understanding of what passes are actually necessary to apply to onnx-importer generated IR. It's time to upstream the correct pipeline. |
Fair points. It's definitely the end state that matters, not necessarily the journey. I think there are some process / development workflow changes we could make that would make that convergence less sloppy. Manually specifying pass pipelines and adding extra flags is a crutch that we've been leaning on in many places for far too long. The tools need to work (correctly and with high performance) out of the box. |
For the first proposed change, I have added a PR here: llvm/torch-mlir#3801 CC: @zjgarvey @ScottTodd |
What's the status of this issue? I'm comparing test coverage between https://github.com/nod-ai/SHARK-TestSuite/tree/main/alt_e2eshark/onnx_tests and https://github.com/iree-org/iree-test-suites/tree/main/onnx_models and I'm wondering if the higher test pass rate in SHARK-TestSuite is due to some of the extra |
We aren't running torch-mlir preprocessing anymore in the ci, so we can close this issue. |
Are you sure about that? the code I linked is using torch-mlir directly in |
Yeah, the preprocessing stage is only used if the flag --torchtolinalg is passed. We turned that off in the CI after updating the torch-to-iree pipeline. We will soon use iree-import-onnx when adding some larger models to the CI. So right now the only place torch-mlir is being used in the CI is the import phase. |
Ah. I think the import phase should also be moved to I specifically was looking at this test failure earlier and was wondering if the torch-mlir import was affected by the same bug: https://github.com/iree-org/iree-test-suites/actions/runs/12202034018/job/34041791439#step:6:180
(maybe some invalid symbol in a resource name?) |
Yeah, this "-" issue should get fixed by llvm/torch-mlir#3901. When this gets added and bumped into iree, the importer there should get fixed too. |
Request description
The current onnx-specific intake logic in PluginRegistration.cpp is insufficient for iree-compile. Currently, this single pass is not enough to get the torch IR into an acceptable state to hand off to the torch-to-iree pipeline that follows.
I'd like to request that we do the following.
Use the following passes when lowering torch-onnx-to-torch:
Remove the following pass from torch-to-iree pipeline:
Recommended:
I'd recommend rolling the "torch-onnx-to-torch-backend passes" into a pass pipeline in torch-mlir, then it would be much easier to just include this pass pipeline in the iree-compile pipeline for onnx models. Maybe call it
--torch-onnx-to-torch-backend-pipeline
.If reasonable, it would be a good idea to re-apply cycles of shape refinement, shape-scalarization, and possibly decompose complex ops, until the IR reaches a fixed state (or a max number of iterations). If doing this, please disable the unflatten.int and flatten.using_ints decompositions, since these might create a cycle with view op.
What component(s) does this issue relate to?
Frontends, Compiler, MLIR
Additional context
We are currently pre-applying torch-mlir passes in our test suite before handing off linalg IR to iree-compile. Making the suggested changes would mean we could just run iree-compile on the onnx ir and get the same results (or better, since torch-to-iree might handle the lowering to linalg more carefully).
The removal of additional pre-compile processing could resolve some compilation issues. For example, the generation of affine.apply ops that seem to be relevant to the issue #18386 (comment), evidently don't get created when using
torch-to-iree
, but do get created when usingtorch-backend-to-linalg-on-tensors-backend-pipeline
.The text was updated successfully, but these errors were encountered: