Skip to content

[WIP] Fix BatchNormalization layer export issue in ONNX model - #2988

Draft
Justin Chu (justinchuby) with Copilot wants to merge 4 commits into
mainfrom
copilot/fix-batchnormalization-onnx-issue
Draft

[WIP] Fix BatchNormalization layer export issue in ONNX model#2988
Justin Chu (justinchuby) with Copilot wants to merge 4 commits into
mainfrom
copilot/fix-batchnormalization-onnx-issue

Conversation

Copilot AI commented Aug 4, 2026

Copy link
Copy Markdown
Contributor
  • Verify final name-fixing behavior and optimizer test conventions
  • Add a focused regression test for unnamed optional outputs
  • Remove the optimizer step that reassigns cleared output names
  • Run targeted tests, lintrunner, secret scan, and security validation

Co-authored-by: justinchuby <11205048+justinchuby@users.noreply.github.com>
@justinchuby

Copy link
Copy Markdown
Collaborator

Copilot name fix pass is still needed. Let me know if onnx-ir needs updating or if there is another way to fix it

Co-authored-by: justinchuby <11205048+justinchuby@users.noreply.github.com>
@codecov

codecov Bot commented Aug 5, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.15385% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 72.65%. Comparing base (457a260) to head (a7ec3f0).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
onnxscript/optimizer/_optimizer.py 94.11% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2988      +/-   ##
==========================================
+ Coverage   72.63%   72.65%   +0.01%     
==========================================
  Files         265      265              
  Lines       32205    32231      +26     
  Branches     3041     3047       +6     
==========================================
+ Hits        23392    23417      +25     
  Misses       7779     7779              
- Partials     1034     1035       +1     

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

@bas-aarts

Copy link
Copy Markdown

Copilot, adding a call to RemoveUnusedNodesPass (the pass that started this issue to begin with) for the sole purpose of clearing the output names of unused inference BatchNormalization layers, is a heavy handed and lazy way to circumvent the issue.

Apologies for speaking out of turn Justin Chu (@justinchuby). I just had to.

@justinchuby

Copy link
Copy Markdown
Collaborator

Copilot please update as commented

Co-authored-by: justinchuby <11205048+justinchuby@users.noreply.github.com>

Copilot AI commented Aug 12, 2026

Copy link
Copy Markdown
Contributor Author

Copilot please update as commented

Updated in a7ec3f0. The second RemoveUnusedNodesPass is replaced by a BatchNormalization-only output-slot cleanup before NameFixPass; the regression now validates the serialized model with the ONNX checker. Current onnx-ir releases still need an upstream general fix.

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

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

BatchNormalization layer with training_mode=1 results in incorrect ONNX model

3 participants