-
Notifications
You must be signed in to change notification settings - Fork 240
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
[PTQ] Add support of arbitrary batch size for PTQ #2197
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #2197 +/- ##
===========================================
- Coverage 91.19% 84.89% -6.30%
===========================================
Files 492 494 +2
Lines 45100 45350 +250
===========================================
- Hits 41127 38502 -2625
- Misses 3973 6848 +2875
... and 45 files with indirect coverage changes
Flags with carried forward coverage won't be shown. Click here to find out more.
|
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.
Code looks ok for me, what about tests?
…ls bs>1 wit dynamic batch_size at input shape; make validation with bs=1
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.
Minor
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.
LGTM. Please provide test results for weights compression.
build 35 passed |
### Changes Restore total number of iterations for StatisticsAggregator after #2197 ### Reason for changes N/A ### Related tickets 136892 ### Tests Manually tested on yolov8 sample for OV. Before: ![image](https://github.com/openvinotoolkit/nncf/assets/32935044/6a1292ef-cf00-4571-bbe7-92acc36b44f4) After: ![image](https://github.com/openvinotoolkit/nncf/assets/32935044/aa5c1f6d-c4f8-4d6c-86d0-15a34bc9f86e)
Changes
Add a new advanced bool option for quantization -
batchwise_statistics
.When set to True then statistics collection for supported algorithms (see below) are calculated with the assumption that the 0-axis of a tensor is a batch axis.
If the value is False then statistics collection for algorithms is calculated with an assumption that the tensor has no batch axis.
If set to None statistics collection logic adapts based on the batch_size of the provided dataset.
These adjustments in statistical computation apply specifically to MinMax, ChannelAlighnment algorithms.
During the validation of proposed changes on a wide scope of models, some limitations were observed - if a model contains specific operations that output in a way that a tensor batch axis starts to contain no batch meaning anymore, then the statistics after such operations are collected not precisely.
The handling of such cases is introduced and determined by a warning message to a user with a recommendation using batch size = 1 for a specific model or set to False
batchwise_statistics
option.The torch sample for mobilenet_v2 was updated with
batch_size=128
value with a new recalculatedsubset_size
.The conformance test was updated with new options
batch_size
anddynamic_batch_shape
.Calibrate.py was updated with a new option
batch_size
.Algorithm support batch_size > 1:
Reason for changes
Speeding up statistics collection.
SpeedUp on mobilenet_v2 sample (local measurments):
Extend usage scenarios.
Related tickets
121650
Tests
Old tests were updated accordingly.
New test added:
test_tensor_collector_batch_size
test_min_max