Skip to content

Conversation

@titaiwangms
Copy link
Contributor

@titaiwangms titaiwangms commented Oct 9, 2025

This PR moves the processing of constant ops upward to return before node-level shape type inference (including serialization) and optimizer optimization.

Essentially, avoiding serializing constant ops (potentially large weights in LLMs) reduces the export time in optimize_ir.

Before this PR:

Screenshot 2025-10-09 141403

After this PR:

Screenshot 2025-10-09 141238

@codecov
Copy link

codecov bot commented Oct 9, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.30%. Comparing base (075fc4d) to head (84deb77).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2622      +/-   ##
==========================================
+ Coverage   69.97%   70.30%   +0.33%     
==========================================
  Files         222      222              
  Lines       26324    26278      -46     
  Branches     2609     2625      +16     
==========================================
+ Hits        18420    18476      +56     
+ Misses       6992     6885     -107     
- Partials      912      917       +5     

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

@titaiwangms
Copy link
Contributor Author

I will merge by the end of the day so we can catch it in the next week benchmark.

@justinchuby justinchuby changed the title fix constant in constant folding Fix constant in constant folding Oct 10, 2025

# Propagate const_value, and manually find out shape and type
# to avoid potentially expensive shape inference on large tensors.
if _is_onnx_op(node, "Constant"):
Copy link
Collaborator

Choose a reason for hiding this comment

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

I feel that we can standardize this with other node processers, but non blocking for now.

@justinchuby justinchuby merged commit 28a8f56 into microsoft:main Oct 10, 2025
55 of 56 checks passed
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.

3 participants