Skip to content

Conversation

titaiwangms
Copy link
Contributor

@titaiwangms titaiwangms commented May 5, 2025

Fix #2261

A draft for discussion. We should cover all post-processing the model shipping needs

Copy link

codecov bot commented May 5, 2025

Codecov Report

❌ Patch coverage is 33.33333% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.75%. Comparing base (2ae13be) to head (fd1a225).
⚠️ Report is 130 commits behind head on main.

Files with missing lines Patch % Lines
onnxscript/rewriter/ort_fusions/_core.py 33.33% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2274      +/-   ##
==========================================
- Coverage   73.76%   73.75%   -0.02%     
==========================================
  Files         239      239              
  Lines       30904    30907       +3     
  Branches     3494     3494              
==========================================
- Hits        22797    22796       -1     
- Misses       6907     6911       +4     
  Partials     1200     1200              

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

@gramalingam
Copy link
Collaborator

Please also consider whether this method should be optimize in-place or not. I think we can make it in-place now that shape-inference itself is in-place.

@justinchuby
Copy link
Collaborator

Please also consider whether this method should be optimize in-place or not. I think we can make it in-place now that shape-inference itself is in-place.

I think making it out-of-place is safer, in case we have passes in the future that need to be functional?

# https://github.com/microsoft/onnxruntime/blob/74dcf7e296639095dfa55d31336998b6f719ed76/onnxruntime/python/tools/transformers/dynamo_onnx_helper.py#L172
common_passes.ClearMetadataAndDocStringPass(),
# https://github.com/microsoft/onnxruntime/blob/74dcf7e296639095dfa55d31336998b6f719ed76/onnxruntime/python/tools/transformers/dynamo_onnx_helper.py#L139
common_passes.LiftConstantsToInitializersPass(lift_all_constants=False, size_limit=1),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We have another pass called LiftSubgraphInitializersToMainGraphPass. Do we know if it's needed in genAI? @kunal-vaishnavi

Choose a reason for hiding this comment

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

If the pass logic is in DynamoOnnxHelper, then it is used for ONNX Runtime GenAI.

Copy link
Collaborator

Choose a reason for hiding this comment

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

We don't really produce graphs with subgraph initializers. I think we are ok either way

rewrite(model, ORT_PATTERN_REWRITE_RULES)
return model, fusion_count

passes = [
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
passes = [
passes = ir.passes.Sequential(

Comment on lines +149 to +150
]
optimize_for_ort_passes = ir.passes.Sequential(*passes)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
]
optimize_for_ort_passes = ir.passes.Sequential(*passes)
)

@titaiwangms
Copy link
Contributor Author

I will set up Whisper and test it before merge this PR microsoft/onnxruntime#24382

@justinchuby
Copy link
Collaborator

Do you intend to merge this?

@titaiwangms titaiwangms self-assigned this Aug 29, 2025
@titaiwangms
Copy link
Contributor Author

Do you intend to merge this?

Do we still need this? I can check again and land it.

@titaiwangms
Copy link
Contributor Author

#2532

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.

Higher level API for post-processing/optimization
4 participants