Skip to content

Conversation

@gcunhase
Copy link
Contributor

@gcunhase gcunhase commented Nov 26, 2025

What does this PR do?

Type of change: Bug fix

Overview: Some tensor's precision weren't set in the ONNX graph (value_info) when converting the model with Autocast. This caused ONNX-Graphsurgeon to incorrectly interpret those precisions in gs.import_onnx(ModelProto), which caused quantization of the converted model to fail.

Usage

$ python -m modelopt.onnx.autocast --onnx_path=$MODEL_NAME.onnx --keep_io_types
$ python -m modelopt.onnx.quantization --onnx_path=$MODEL_NAME.fp16.onnx --calibration_eps cpu

Testing

See bug 5680954@12.

Before your PR is "Ready for review"

  • Make sure you read and follow Contributor guidelines and your commits are signed.
  • Is this change backward compatible?: Yes
  • Did you write any new necessary tests?: No
  • Did you add or update any necessary documentation?: No
  • Did you update Changelog?: No

@gcunhase gcunhase requested a review from a team as a code owner November 26, 2025 20:50
@gcunhase gcunhase requested review from ajrasane and galagam November 26, 2025 20:50
@codecov
Copy link

codecov bot commented Nov 26, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.64%. Comparing base (261858c) to head (6832f24).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #611      +/-   ##
==========================================
- Coverage   74.80%   74.64%   -0.16%     
==========================================
  Files         183      183              
  Lines       18626    18546      -80     
==========================================
- Hits        13933    13844      -89     
- Misses       4693     4702       +9     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment on lines +961 to +963
def _update_value_info_in_graph(self):
for vi in self.model.graph.value_info:
vi.type.tensor_type.elem_type = self.value_info_map[vi.name].type.tensor_type.elem_type
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you find the location where we update self.value_info_map instead of self.model.graph.value_info ?
Maybe graph outputs/inputs?

This fix is a little patchy IMO.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants