Commit 08e5f92
authored
Protobuf 7.34 fix for model size > 2gib (#1058)
### What does this PR do?
Type of change: Bug fix
For the newer version of protobuf when model size > 2gb the model throws
an error when serializing to string specifically in windows.
```
Traceback (most recent call last):
File "quantize.py", line 643, in <module>
main(args)
File "quantize.py", line 428, in main
quantized_onnx_model = quantize_int4(
args.onnx_path,
...
use_column_major=args.use_column_major,
)
File ".venv\Lib\site-packages\modelopt\onnx\quantization\int4.py", line 1529, in quantize
onnx_model = _quantize_awq_lite(
onnx_model,
...
)
File ".venv\Lib\site-packages\modelopt\onnx\quantization\int4.py", line 1088, in _quantize_awq_lite
save_onnx(augmented_model, augmented_onnx_path, use_external_data_format)
File ".venv\Lib\site-packages\modelopt\onnx\utils.py", line 646, in save_onnx
model_proto = model.SerializeToString()
google.protobuf.message.EncodeError: Failed to serialize proto
```
See Nvbugid 5989474 for more context
Suggested fix is to force it to save as external data when this happens.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **Bug Fixes**
* Improved handling of model size checks so failures no longer crash
workflows—serialization attempts now log warnings and fall back to
external-data storage.
* Loading now tolerates size-query errors and enables external-data mode
when size is invalid or exceeds limits.
* **Improvements**
* Resilient opset upgrade path: version-conversion failures log a
warning and apply a safe opset import fallback before saving.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Signed-off-by: Hrishith Thadicherla <hthadicherla@nvidia.com>1 parent 547d8fe commit 08e5f92
3 files changed
Lines changed: 67 additions & 18 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
176 | 176 | | |
177 | 177 | | |
178 | 178 | | |
179 | | - | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
180 | 194 | | |
181 | 195 | | |
182 | 196 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
322 | 322 | | |
323 | 323 | | |
324 | 324 | | |
325 | | - | |
326 | | - | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
327 | 341 | | |
328 | 342 | | |
329 | 343 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
558 | 558 | | |
559 | 559 | | |
560 | 560 | | |
561 | | - | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
562 | 574 | | |
563 | 575 | | |
564 | 576 | | |
| |||
642 | 654 | | |
643 | 655 | | |
644 | 656 | | |
645 | | - | |
646 | | - | |
647 | | - | |
648 | | - | |
649 | | - | |
650 | | - | |
651 | | - | |
652 | | - | |
653 | | - | |
654 | | - | |
655 | | - | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
656 | 662 | | |
657 | 663 | | |
658 | | - | |
659 | | - | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
660 | 669 | | |
661 | 670 | | |
662 | 671 | | |
| |||
1162 | 1171 | | |
1163 | 1172 | | |
1164 | 1173 | | |
1165 | | - | |
| 1174 | + | |
| 1175 | + | |
| 1176 | + | |
| 1177 | + | |
| 1178 | + | |
| 1179 | + | |
| 1180 | + | |
| 1181 | + | |
| 1182 | + | |
| 1183 | + | |
| 1184 | + | |
| 1185 | + | |
| 1186 | + | |
1166 | 1187 | | |
1167 | 1188 | | |
1168 | 1189 | | |
| |||
0 commit comments