[ONNX] Fix lower opset version support in dynamo=True#161056
[ONNX] Fix lower opset version support in dynamo=True#161056justinchuby wants to merge 7 commits intopytorch:mainfrom
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/161056
Note: Links to docs will display an error until the docs builds have been completed. ✅ You can merge normally! (1 Unrelated Failure)As of commit 171f3f0 with merge base d228a77 ( BROKEN TRUNK - The following job failed but were present on the merge base:👉 Rebase onto the `viable/strict` branch to avoid these failures
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
There was a problem hiding this comment.
Pull Request Overview
This PR fixes support for ONNX opset versions lower than 18 when using dynamo=True by ensuring the torchlib registry is always constructed with opset 18 or higher, then relying on version conversion to target lower opsets.
Key changes:
- Modified registry creation logic to use
_constants.TORCHLIB_OPSET(18) when requested opset is lower - Added informational logging when falling back to higher opset version
- Added test coverage for lower opset version support with opset 16
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| torch/onnx/_internal/exporter/_compat.py | Updated registry creation logic to handle lower opset versions and added logging |
| test/onnx/exporter/test_api.py | Added test model and test case to verify opset 16 support works correctly |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
titaiwangms
left a comment
There was a problem hiding this comment.
I wonder if we should consider supporting the opset_version < 18.
We do that via version converter. Or do you mean implementing the ops directly? Even opset 18 is kind of old at this point though |
I forget about how version converter does on converting opset to < 18. Does it only do its best? (It fails for attribute changed ops, for example, ReduceMean?) |
I think so |
|
@pytorchbot rebase |
|
@pytorchbot started a rebase job onto refs/remotes/origin/viable/strict. Check the current status here |
|
Successfully rebased |
5973ac0 to
de50d28
Compare
|
@pytorchbot merge |
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
Merge failedReason: 1 mandatory check(s) failed. The first few are: Dig deeper by viewing the failures on hud |
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
de50d28 to
5df8fb6
Compare
|
@pytorchbot merge |
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Merge failedReason: New commits were pushed while merging. Please rerun the merge command. Details for Dev Infra teamRaised by workflow job |
|
@pytorchbot merge |
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
After we switched to constructing the registry with the specified opset version in dynamo=True, support for opset<18 was broken because there would be no torchlib ops registered for these opsets. I updated the registry creation logic to always use opset 18 if the requested opset is lower, and use the version converter (as designed) to target those opsets. This requires onnxscript>=0.4 (pytorch#161312) Fixes onnx/onnx#7235 Pull Request resolved: pytorch#161056 Approved by: https://github.com/titaiwangms
After we switched to constructing the registry with the specified opset version in dynamo=True, support for opset<18 was broken because there would be no torchlib ops registered for these opsets. I updated the registry creation logic to always use opset 18 if the requested opset is lower, and use the version converter (as designed) to target those opsets.
This requires onnxscript>=0.4 (#161312)
Fixes onnx/onnx#7235
cc @titaiwangms