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

[ONNX] Relax unsupported node analysis on complex dtype #113785

Closed
wants to merge 3 commits into from

Conversation

titaiwangms
Copy link
Collaborator

@titaiwangms titaiwangms commented Nov 15, 2023

Stack from ghstack (oldest at bottom):

In cases like #113444, users usually stop at UnsupportedNodeAnalysis with unsupported nodes information. Although in SARIF, they can clearly see it's due to lack of COMPLEX support, in screen error message, it's only showing original FX node name, such as aten.mul.Tensor. This PR catches the information from diagnostic messages and reveal it to users.

The root cause is that UnsupportedNodeAnalysis is leveraging on onnxfunction_dispatcher.get_function_overloads() to decide if an ATen is supported or not. However, in onnxfunction_dispatcher.get_function_overloads(), lacking of complex function support is considered unsupported. This PR defines Unsupported FX nodes as not in registry.

Copy link

pytorch-bot bot commented Nov 15, 2023

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/113785

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit 018ec28 with merge base 7183926 (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@pytorch-bot pytorch-bot bot added the release notes: onnx torch.onnx related changes that should show up in the release notes label Nov 15, 2023
titaiwangms added a commit that referenced this pull request Nov 15, 2023
ghstack-source-id: 948556b7aad93e6c9102dfccc6608999ade02de6
Pull Request resolved: #113785
@titaiwangms titaiwangms added module: onnx Related to torch.onnx topic: improvements topic category labels Nov 15, 2023
target = node.target
op_to_target_mapping.setdefault(op, {}).setdefault(str(target), None)
# Extract the dtype information from the diagnostic message.
if e.diagnostic.message and e.diagnostic.message.startswith(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we raise specific exception type instead of string matching to detect this error? string matching on logs is usually flaky. we log in one place and check the string matching in another. Unless we have a test for guarding this string matching, it will eventually break

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We all know that. The root cause is that the mismatch message in SARIF and screen error message. I wonder if we should create a new rule to get a new template in this error message. @BowenBao Do you have any suggestion.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added test for the current approach

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can just expand the error being emitted from this analysis, showing diagnostic.message for each op. That way we don't need to do string parsing on them.

Copy link
Collaborator

@BowenBao BowenBao Nov 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or maybe we can make it standard to attach dtype with optype, through looking at the graph/node instead of string parsing.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. The first one seems good and we can align the message in screen printing with SARIF.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can just expand the error being emitted from this analysis, showing diagnostic.message for each op. That way we don't need to do string parsing on them.

Not relying on string matching is a nice improvement. Could we go further and populate op_to_target_mapping (thus the error message) without using diagnostic at all?

The diagnostics is a passive component that captures extra debug information and put on a SARIF file - only that. Ideally, it should not influence (by populating op_to_target_mapping) and alter UnsupportedFxNodesAnalysisResult outcome.

Maybe I am missing something, but by reusing diagnostics for anything other than SARIF, we are creating a direct coupling between UnsupportedFxNodesAnalysis and SARIF; That is, UnsupportedFxNodesAnalysis cannot properly report the error without depending on diagnostics machinery.

IMO, if we could find a way to capture the missing information on the analysis pass independently of diagnostics, we can keep the analysis pass and diagnostics decoupled.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made some modifications. Essentially, now we don't leverage on get_function_overloads, instead, we use is_registered_op to capture the ATen that doesn't even have at least one ONNX invariant. Completely extract out the arg/function sig matching from UnsupoortedNodeAnalysis.

If ATen is only missing complex support, the error will be emitted during dispatcher now, which provides a more suitable error message.

…nalysis"


In cases like #113444, users usually stop at UnsupportedNodeAnalysis with unsupported nodes information. Although in SARIF, they can clearly see it's due to lack of COMPLEX support, in screen error message, it's only showing original FX node name, such as `aten.mul.Tensor`. This PR catches the information from diagnostic messages and reveal it to users.

[ghstack-poisoned]
titaiwangms added a commit that referenced this pull request Nov 16, 2023
ghstack-source-id: 1fdea28a307b830429c0e6ed223cbd43ff837261
Pull Request resolved: #113785
…nalysis"


In cases like #113444, users usually stop at UnsupportedNodeAnalysis with unsupported nodes information. Although in SARIF, they can clearly see it's due to lack of COMPLEX support, in screen error message, it's only showing original FX node name, such as `aten.mul.Tensor`. This PR catches the information from diagnostic messages and reveal it to users.

[ghstack-poisoned]
titaiwangms added a commit that referenced this pull request Nov 17, 2023
ghstack-source-id: 184cdbab860f428798a5ec68495b4cddd0910a33
Pull Request resolved: #113785
@titaiwangms titaiwangms changed the title [ONNX] Specify unsupported data type in unsupported node analysis [ONNX] Relax unsupported node analysis on complex dtype Nov 17, 2023
@titaiwangms titaiwangms added the ciflow/trunk Trigger trunk jobs on your pull request label Nov 17, 2023
@titaiwangms
Copy link
Collaborator Author

@pytorchbot merge

@pytorchmergebot
Copy link
Collaborator

Merge started

Your 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

Advanced Debugging
Check the merge workflow status
here

@facebook-github-bot facebook-github-bot deleted the gh/titaiwangms/38/head branch November 21, 2023 15:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ciflow/trunk Trigger trunk jobs on your pull request Merged module: onnx Related to torch.onnx open source release notes: onnx torch.onnx related changes that should show up in the release notes topic: improvements topic category
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

[ONNX] Raise a specific error of unsupported symbolic function for complex dtype
5 participants