Skip to content

Fix protobuf serialization failure in ort_fusions ort_run for large models#2955

Merged
justinchuby merged 3 commits into
mainfrom
copilot/investigate-fix-ci-issues
Jul 9, 2026
Merged

Fix protobuf serialization failure in ort_fusions ort_run for large models#2955
justinchuby merged 3 commits into
mainfrom
copilot/investigate-fix-ci-issues

Conversation

Copilot AI commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

TestFuseXformers.test_fuse_xformers intermittently failed with google.protobuf.message.EncodeError: Failed to serialize proto (observed on the onnx_weekly Windows CI).

The ort_run test helper serialized the whole model in memory via ModelProto.SerializeToString(). The SmolLM test model is ~671MB — dominated by the 49152×2048 head_weight (~402MB) — close enough to protobuf's 2GB single-message serialization ceiling that in-memory serialization can fail depending on platform/library version.

Changes

  • onnxscript/rewriter/ort_fusions/_test_utils.py: ort_run now writes the model to a temp file with external data via ir.save and loads it into InferenceSession by path, bypassing the in-memory protobuf size limit. ir.save leaves the in-memory model unchanged, so repeated ort_run calls on the same model still work.
with tempfile.TemporaryDirectory() as temp_dir:
    model_path = os.path.join(temp_dir, f"{model_name}.onnx")
    ir.save(model, model_path, external_data=f"{model_name}.onnx.data")
    session = onnxruntime.InferenceSession(model_path, options, providers=providers)
    return session.run(None, inputs)

This helper is shared across the ort_fusions test suite, so the fix applies to all fusion tests that round-trip models through ORT.

Copilot AI changed the title [WIP] Investigate and fix CI issues with serialization error Fix protobuf serialization failure in ort_fusions ort_run for large models Jul 8, 2026
Copilot AI requested a review from justinchuby July 8, 2026 17:11
@justinchuby justinchuby marked this pull request as ready for review July 8, 2026 17:21
@codecov

codecov Bot commented Jul 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.65%. Comparing base (69a6938) to head (c0b2527).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2955   +/-   ##
=======================================
  Coverage   72.65%   72.65%           
=======================================
  Files         259      259           
  Lines       31766    31770    +4     
  Branches     3007     3007           
=======================================
+ Hits        23078    23082    +4     
  Misses       7670     7670           
  Partials     1018     1018           

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

@justinchuby justinchuby enabled auto-merge (squash) July 8, 2026 23:25
@github-project-automation github-project-automation Bot moved this from Todo to Done in ONNX Script Review Board Jul 9, 2026
@justinchuby justinchuby merged commit 7958d19 into main Jul 9, 2026
30 of 33 checks passed
@justinchuby justinchuby deleted the copilot/investigate-fix-ci-issues branch July 9, 2026 00:10
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.

Investigate and fix CI issues

3 participants