Skip to content

Conversation

@titaiwangms
Copy link
Contributor

Regarding the concern from #2791 (comment), this PR specifically raises when function has RefAttr.


This pull request adds a new validation to the version converter to ensure nodes with reference attributes (RefAttr) are not supported, and introduces a corresponding unit test to verify that the version converter raises an error in such cases.

Validation for unsupported reference attributes:

  • Added a check in visit_graph_or_function in onnxscript/version_converter/_version_converter.py to raise a VersionConverterError if any node has a reference attribute (RefAttr), as these are not currently supported by the version converter.

Testing and error handling:

  • Added a new unit test test_version_convert_raises_on_function_node_with_ref_attribute in onnxscript/version_converter/_version_converter_test.py to ensure that converting a model containing a function node with a reference attribute raises the appropriate error and includes a clear message.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a guardrail in the ONNX opset version converter to explicitly reject functions containing RefAttr (reference attributes), since the converter/adapters don’t currently support them, and adds a regression test to ensure an error is raised.

Changes:

  • Add validation in visit_graph_or_function to raise VersionConverterError when an ONNX-domain node contains a RefAttr.
  • Add a unit test that builds a model with a function containing a node with a RefAttr and asserts conversion fails with the expected message.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
onnxscript/version_converter/_version_converter.py Adds a hard-fail validation for RefAttr on nodes processed by the version converter.
onnxscript/version_converter/_version_converter_test.py Adds a unit test covering the new RefAttr rejection behavior.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
ir.passes.PassError,
)
) as ctx:
version_converter.convert_version(model, target_version=target_version)
Copy link
Collaborator

Choose a reason for hiding this comment

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

It is an issue that PassError is raised. I realized this in the shape inferencer as well. I think we should find a way to move the main logic out of the pass, and make the pass a simple wrapper around the logic so VersionConverterError can be properly raised by convert_version

version_converter.convert_version(model, target_version=target_version)
# Check the error message, unwrapping PassError if needed
error = ctx.exception
if isinstance(error, ir.passes.PassError) and error.__cause__ is not None:
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should use assertRegex, after the error is properly raised

@codecov
Copy link

codecov bot commented Feb 12, 2026

Codecov Report

❌ Patch coverage is 95.23810% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 70.52%. Comparing base (0d460ff) to head (5ce524f).
⚠️ Report is 7 commits behind head on main.

Files with missing lines Patch % Lines
...cript/version_converter/_version_converter_test.py 94.73% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2806      +/-   ##
==========================================
+ Coverage   70.50%   70.52%   +0.01%     
==========================================
  Files         228      228              
  Lines       27211    27136      -75     
  Branches     2737     2728       -9     
==========================================
- Hits        19186    19137      -49     
+ Misses       7090     7065      -25     
+ Partials      935      934       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Co-authored-by: Justin Chu <justinchuby@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Development

Successfully merging this pull request may close these issues.

2 participants