Skip to content

Commit 47ddd14

Browse files
authored
Fix the onnx checker to use model path when model size > 2gib (#502)
## What does this PR do? **Type of change:** Bug Fix **Overview:** There was a failure during quantization for fp32 whisper large model. `Error: ValueError: This protobuf of onnx model is too large (>2GiB). Call check_model with model path instead.` Essentially the bug was that while using the checker, we can only give model object as input if model size < 2gb, otherwise the path to model needs to be given as input. So, I changed the input given to the checker according to size of model in trt_utils.py. ## Testing Tried quantizing after the fix. The quantization is working after applying the fix with no errors. Signed-off-by: Hrishith Thadicherla <[email protected]>
1 parent c3f6cef commit 47ddd14

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

modelopt/onnx/trt_utils.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,13 @@ def load_onnx_model(
335335
intermediate_generated_files.append(ir_version_onnx_path)
336336

337337
# Check that the model is valid
338-
onnx.checker.check_model(onnx_model)
338+
if use_external_data_format:
339+
# For large models, use the file path to avoid protobuf size limitation
340+
model_path_to_check = ir_version_onnx_path or static_shaped_onnx_path or onnx_path
341+
onnx.checker.check_model(model_path_to_check)
342+
else:
343+
# For smaller models, checking the model object is fine
344+
onnx.checker.check_model(onnx_model)
339345

340346
return (
341347
onnx_model,

0 commit comments

Comments
 (0)