-
Notifications
You must be signed in to change notification settings - Fork 242
[5676209][ONNX][Autocast] Add support for single npz file with multiple samples
#815
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
base: main
Are you sure you want to change the base?
[5676209][ONNX][Autocast] Add support for single npz file with multiple samples
#815
Conversation
Signed-off-by: gcunhase <4861122+gcunhase@users.noreply.github.com>
Signed-off-by: gcunhase <4861122+gcunhase@users.noreply.github.com>
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the 📝 WalkthroughWalkthroughThese changes modify calibration data handling in ONNX quantization. CalibrationDataProvider now accepts pre-loaded ONNX ModelProto objects in addition to file paths, and the reference runner wraps NPZ calibration data within CalibrationDataProvider to enable batch handling from single files. Changes
Sequence DiagramsequenceDiagram
participant RR as Reference Runner
participant CDP as CalibrationDataProvider
participant ONNX as ONNX Model
rect rgba(100, 149, 237, 0.5)
Note over RR,ONNX: New Flow: NPZ Data with CalibrationDataProvider
RR->>RR: Load NPZ file
RR->>CDP: Wrap NPZ data + model path
CDP->>ONNX: Load model from path (if string)
ONNX-->>CDP: ModelProto returned
CDP-->>RR: CalibrationDataProvider with batches
end
rect rgba(144, 238, 144, 0.5)
Note over RR,ONNX: Alternative: Pre-loaded Model
RR->>RR: Load NPZ file + ModelProto
RR->>CDP: Wrap NPZ data + ModelProto
CDP->>CDP: Use ModelProto directly (skip loading)
CDP-->>RR: CalibrationDataProvider with batches
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Signed-off-by: gcunhase <4861122+gcunhase@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #815 +/- ##
==========================================
+ Coverage 74.17% 74.29% +0.12%
==========================================
Files 192 192
Lines 19246 19251 +5
==========================================
+ Hits 14276 14303 +27
+ Misses 4970 4948 -22 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
What does this PR do?
Type of change: New feature
Overview: Currently, Autocast only supports calibration data with shape matching the model's input. This PR adds support for calibration data with shape that is a multiple of the model's input. It does so by re-arranging the data as such that it contains multiple samples with shape matching the model's input.
Simplified example:
[1, 3, 224, 224][10, 3, 224, 224][1, 3, 224, 224] * 10Usage
Single
npzfile with multiple samples:$ python -m modelopt.onnx.autocast --onnx_path=$MODEL_NAME.onnx --calibration_data=calib_data_10.npzTesting
See bug 5676209.
Before your PR is "Ready for review"
Additional Information
Equivalent support is already included in the quantization workflow:
Model-Optimizer/modelopt/onnx/quantization/calib_utils.py
Line 50 in 1cc8e6b
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.