Repository navigation
Fix protobuf size-check failures in ONNX deployment - #2403
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📥 CommitsReviewing files that changed from the base of the PR and between 59d93af and 40b2c3fe1703db6c01ed394d133ea306de0abe17. 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 12 included reviews per hour; 10 remain after this review. 📝 WalkthroughWalkthroughThe ONNX shape-inference and serialization utilities now use ChangesONNX protobuf size detection
Priority: ⬇️ Low Estimated code review effort: 1 (Trivial) | ~5 minutes Change: Bug fix Merge Risk: ⚪ Minimal · up to The shared protobuf size handling is applied consistently to both ONNX workflows without an identified regression. 🚥 Pre-merge checks | ✅ 6✅ Passed checks (6 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2403 +/- ##
==========================================
+ Coverage 71.15% 78.77% +7.62%
==========================================
Files 543 543
Lines 64346 64345 -1
==========================================
+ Hits 45785 50690 +4905
+ Misses 18561 13655 -4906
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Signed-off-by: Noey Yang <[email protected]>
40b2c3f to
ba36ce2
Compare
### What does this PR do? Type of change: Bug fix:6701737 The ONNX deployment path assumed that ModelProto.ByteSize() would always return a valid size. With newer protobuf versions, querying the size of a model exceeding the protobuf serialization limit can itself raise EncodeError: Failed to serialize proto. Replaced both direct size checks with the existing is_model_too_large_for_protobuf() helper. This helper handles size-query failures conservatively and checks the protobuf size limit: Shape inference now selects the external-data/file-based path when ByteSize() fails or the model is too large. Metadata creation uses the same safe check instead of raising another serialization error. The unused TWO_GB constant was also removed. ### Usage ``` python examples/diffusers/quantization/diffusion_trt.py --model flux-dev --benchmark --skip-image ``` ### Testing the above test case pass on B100 ### Before your PR is "*Ready for review*" Make sure you read and follow [Contributor guidelines](https://github.com/NVIDIA/Model-Optimizer/blob/main/CONTRIBUTING.md) and your commits are signed (`git commit -s -S`). Make sure you read and follow the [Security Best Practices](https://github.com/NVIDIA/Model-Optimizer/blob/main/SECURITY.md#security-coding-practices-for-contributors) (e.g. avoiding hardcoded `trust_remote_code=True`, `torch.load(..., weights_only=False)`, `pickle`, etc.). - Is this change backward compatible?: N/A - If you copied code from any other sources or added a new PIP dependency, did you follow guidance in `CONTRIBUTING.md`: N/A - Did you write any new necessary tests?: N/A - Did you update [Changelog](https://github.com/NVIDIA/Model-Optimizer/blob/main/CHANGELOG.rst)?: N/A - Did you get Claude approval on this PR?: N/A ### Additional Information N/A <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Improved ONNX model size detection during shape inference and export processing. * Ensured large models consistently use the appropriate external-data handling path. <!-- end of auto-generated comment: release notes by coderabbit.ai --> Signed-off-by: Noey Yang <[email protected]> Signed-off-by: Chad Voegele <[email protected]>
#2438 #2402 #2434 (#2504) ## Cherry-picked PRs - #2202 - #2317 - #2314 - #2403 - #2203 - #2413 - #2436 - #2451 - #2336 - #2438 - #2402 - #2434 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added Step-3.7 PTQ recipes for routed experts and MLPs using NVFP4, with FP8 KV-cache support. * Added SDXL FP4 quantization with FP8 convolution support. * Expanded FP4 ONNX export guidance to include Flux and SDXL. * Added BF16 compatibility for FP8 ONNX export. * **Bug Fixes** * Improved ONNX handling for large models, external data, metadata, opsets, and output types. * Improved attention quantization and invalid dynamic-scale handling. * Quantization now reports unmatched weight configurations, with an override for valid pipeline-parallel workflows. * **Documentation** * Updated calibration, ONNX opset, CLI, Step-3.7, and TensorRT-LLM deployment guidance. * Updated deployment guidance to use unified Hugging Face exports with the TensorRT-LLM PyTorch backend. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: Zhiyu Cheng <[email protected]> Signed-off-by: Chad Voegele <[email protected]> Signed-off-by: ajrasane <[email protected]> Signed-off-by: Noey Yang <[email protected]> Signed-off-by: Ajinkya Rasane <[email protected]> Signed-off-by: Yue <[email protected]> Signed-off-by: yingguo-trt <[email protected]> Co-authored-by: Zhiyu <[email protected]> Co-authored-by: Claude Opus 5 (1M context) <[email protected]> Co-authored-by: Ajinkya Rasane <[email protected]> Co-authored-by: Codex <[email protected]> Co-authored-by: Codex <[email protected]> Co-authored-by: noeyy-mino <[email protected]> Co-authored-by: Ajinkya Rasane <[email protected]> Co-authored-by: yueshen2016 <[email protected]> Co-authored-by: yingguo-trt <[email protected]>
What does this PR do?
Type of change: Bug fix:6701737
The ONNX deployment path assumed that ModelProto.ByteSize() would always return a valid size. With newer protobuf versions, querying the size of a model exceeding the protobuf serialization limit can itself raise EncodeError: Failed to serialize proto.
Replaced both direct size checks with the existing is_model_too_large_for_protobuf() helper. This helper handles size-query failures conservatively and checks the protobuf size limit:
Shape inference now selects the external-data/file-based path when ByteSize() fails or the model is too large.
Metadata creation uses the same safe check instead of raising another serialization error.
The unused TWO_GB constant was also removed.
Usage
Testing
the above test case pass on B100
Before your PR is "Ready for review"
Make sure you read and follow Contributor guidelines and your commits are signed (
git commit -s -S).Make sure you read and follow the Security Best Practices (e.g. avoiding hardcoded
trust_remote_code=True,torch.load(..., weights_only=False),pickle, etc.).CONTRIBUTING.md: N/AAdditional Information
N/A
Summary by CodeRabbit