-
Notifications
You must be signed in to change notification settings - Fork 218
[5676209][ONNX][Autocast] Add check for input bs vs calibration data bs #652
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[5676209][ONNX][Autocast] Add check for input bs vs calibration data bs #652
Conversation
Signed-off-by: gcunhase <[email protected]>
Signed-off-by: gcunhase <[email protected]>
galagam
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this fix!
|
Tests failing on this PR. @gcunhase PTAL |
Signed-off-by: gcunhase <[email protected]>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #652 +/- ##
==========================================
- Coverage 74.57% 74.46% -0.11%
==========================================
Files 183 183
Lines 18451 18413 -38
==========================================
- Hits 13759 13712 -47
- Misses 4692 4701 +9 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…bs (#652) ## What does this PR do? **Type of change:** Bug fix **Overview:** Autocast crashes if the input batch size in the ONNX model is different to the calibration data input batch size. For example: calibration data has shape `[10, 6, 3, 480, 800]` and ONNX model has shape `[1, 6, 3, 480, 800]`. The quantization workflow interprets this as 10 calibration samples, so ideally, Autocast would also interpret them similarly. This PR just allows Autocast to exit gracefully with a custom message. ## Usage ```python $ python -m modelopt.onnx.autocast --onnx_path=$MODEL_NAME.onnx --calibration_data=calib_data_10.npz ``` ## Testing See bug 5676209. ## Before your PR is "*Ready for review*" <!-- If you haven't finished some of the above items you can still open `Draft` PR. --> - **Make sure you read and follow [Contributor guidelines](https://github.com/NVIDIA/TensorRT-Model-Optimizer/blob/main/CONTRIBUTING.md)** and your commits are signed. - **Is this change backward compatible?**: Yes - **Did you write any new necessary tests?**: No - **Did you add or update any necessary documentation?**: Yes - **Did you update [Changelog](https://github.com/NVIDIA/TensorRT-Model-Optimizer/blob/main/CHANGELOG.rst)?**: No ## Additional Information Original error: ```sh polygraphy.exception.exception.PolygraphyException: Input tensor: image | Received incompatible shape: (10, 6, 3, 480, 800). Note: Expected a shape compatible with: BoundedShape([1, 6, 3, 480, 800], min=None, max=None) ``` Autocast error: ```sh ValueError: Input shape from 'image' does not match provided input shape: [1, 6, 3, 480, 800] vs [10, 6, 3, 480, 800]. Please make sure that your calibration data matches the ONNX input shapes. ``` --------- Signed-off-by: gcunhase <[email protected]>
…bs (NVIDIA#652) ## What does this PR do? **Type of change:** Bug fix **Overview:** Autocast crashes if the input batch size in the ONNX model is different to the calibration data input batch size. For example: calibration data has shape `[10, 6, 3, 480, 800]` and ONNX model has shape `[1, 6, 3, 480, 800]`. The quantization workflow interprets this as 10 calibration samples, so ideally, Autocast would also interpret them similarly. This PR just allows Autocast to exit gracefully with a custom message. ## Usage ```python $ python -m modelopt.onnx.autocast --onnx_path=$MODEL_NAME.onnx --calibration_data=calib_data_10.npz ``` ## Testing See bug 5676209. ## Before your PR is "*Ready for review*" <!-- If you haven't finished some of the above items you can still open `Draft` PR. --> - **Make sure you read and follow [Contributor guidelines](https://github.com/NVIDIA/TensorRT-Model-Optimizer/blob/main/CONTRIBUTING.md)** and your commits are signed. - **Is this change backward compatible?**: Yes - **Did you write any new necessary tests?**: No - **Did you add or update any necessary documentation?**: Yes - **Did you update [Changelog](https://github.com/NVIDIA/TensorRT-Model-Optimizer/blob/main/CHANGELOG.rst)?**: No ## Additional Information Original error: ```sh polygraphy.exception.exception.PolygraphyException: Input tensor: image | Received incompatible shape: (10, 6, 3, 480, 800). Note: Expected a shape compatible with: BoundedShape([1, 6, 3, 480, 800], min=None, max=None) ``` Autocast error: ```sh ValueError: Input shape from 'image' does not match provided input shape: [1, 6, 3, 480, 800] vs [10, 6, 3, 480, 800]. Please make sure that your calibration data matches the ONNX input shapes. ``` --------- Signed-off-by: gcunhase <[email protected]>
What does this PR do?
Type of change: Bug fix
Overview: Autocast crashes if the input batch size in the ONNX model is different to the calibration data input batch size. For example: calibration data has shape
[10, 6, 3, 480, 800]and ONNX model has shape[1, 6, 3, 480, 800]. The quantization workflow interprets this as 10 calibration samples, so ideally, Autocast would also interpret them similarly. This PR just allows Autocast to exit gracefully with a custom message.Usage
Testing
See bug 5676209.
Before your PR is "Ready for review"
Additional Information
Original error:
polygraphy.exception.exception.PolygraphyException: Input tensor: image | Received incompatible shape: (10, 6, 3, 480, 800). Note: Expected a shape compatible with: BoundedShape([1, 6, 3, 480, 800], min=None, max=None)Autocast error:
ValueError: Input shape from 'image' does not match provided input shape: [1, 6, 3, 480, 800] vs [10, 6, 3, 480, 800]. Please make sure that your calibration data matches the ONNX input shapes.