Skip to content

Conversation

@titaiwangms
Copy link
Contributor

@titaiwangms titaiwangms commented Jan 26, 2026

Fix pytorch/pytorch#172784


This pull request adds support for ONNX opset version 25 in the version converter and introduces a new mechanism to copy node metadata during version conversions. It also includes comprehensive tests to ensure that metadata is properly transferred to new or replacement nodes created by adapters during the conversion process.

Version converter improvements:

  • Increased the maximum supported ONNX opset version from 23 to 25 in SUPPORTED_MAX_ONNX_OPSET within onnxscript/version_converter/_version_converter.py.
  • Integrated a new metadata_merger utility and implemented a default metadata merger to ensure node metadata is copied during version conversion. Metadata is now merged from original nodes to all replacement nodes in the conversion process. [1] [2]

Testing and validation:

  • Added a new VersionConverterMetadataMergeTest class in onnxscript/version_converter/_version_converter_test.py to verify that metadata is copied correctly to replacement nodes and to all nodes created by adapters during conversion.
  • Updated the test suite to reflect the new maximum supported opset version and to ensure that conversion beyond version 25 is marked as expected to fail for future-proofing.

@titaiwangms
Copy link
Contributor Author

Fix pytorch/pytorch#172784

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

This pull request enhances the ONNX version converter by adding metadata preservation during version conversions and expanding support to ONNX opset version 25. The changes ensure that custom metadata attached to nodes is properly carried over when nodes are replaced or modified during version upgrades.

Changes:

  • Increased maximum supported ONNX opset version from 23 to 25
  • Integrated metadata merger utility to copy node metadata during version conversions
  • Added comprehensive tests to verify metadata preservation for single and multiple replacement nodes

Reviewed changes

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

File Description
onnxscript/version_converter/_version_converter.py Updated SUPPORTED_MAX_ONNX_OPSET to 25, added metadata_merger import and integration to copy metadata from original nodes to replacement nodes during conversion
onnxscript/version_converter/_version_converter_test.py Added VersionConverterMetadataMergeTest class with two tests verifying metadata copying behavior, updated boundary test class to reflect new maximum version

@codecov
Copy link

codecov bot commented Jan 26, 2026

Codecov Report

❌ Patch coverage is 97.36842% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 70.50%. Comparing base (55ed939) to head (0bfa086).

Files with missing lines Patch % Lines
...cript/version_converter/_version_converter_test.py 97.05% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2782      +/-   ##
==========================================
+ Coverage   70.46%   70.50%   +0.03%     
==========================================
  Files         228      228              
  Lines       27258    27292      +34     
  Branches     2761     2763       +2     
==========================================
+ Hits        19208    19241      +33     
  Misses       7100     7100              
- Partials      950      951       +1     

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

@titaiwangms titaiwangms changed the title Support metadata_prop merge and version 26 in version converter Support metadata_prop merge and version 25 in version converter Jan 27, 2026
Copy link
Collaborator

@justinchuby justinchuby left a comment

Choose a reason for hiding this comment

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

Thank you!

for new_node in replacement.new_nodes:
# TODO: control-flow
new_node.version = to_version
_default_metadata_merger.copy_merged_metadata([node], replacement.new_nodes)
Copy link
Member

Choose a reason for hiding this comment

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

Do we need a global variable?

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.

[ONNX] GridSample nodes lose all metadata_props when exporting with dynamo=True and opset >= 20

3 participants