Skip to content
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][MinMax][Torch] One shared quantizer is used for all unified scale quantization points #2622

Conversation

daniil-lyakhov
Copy link
Collaborator

@daniil-lyakhov daniil-lyakhov commented Apr 10, 2024

Changes

  • MinMax: new backend method create_unified_scales_quantizers_insertion_commands is introduced: it receives several target points and one quantization parameter. Depending on implementation, one or several insertion commands are generated and returned back to the common algorithm.

Reason for changes

  • Torch backend requires one PTSharedFNInsertionCommand to make quantizers aligned during QAT in comparison with OV/ONNX backend, which can use separate commands/quantizers for each insertion point without any restrictions

Related tickets

104304

Tests

[Template test] test_ptq_params: test_unified_scales_command_creation
test_create_shared_quantizer_insertion_command

Jobs

manual/job/post_training_quantization/350/: passed

@github-actions github-actions bot added NNCF PT Pull requests that updates NNCF PyTorch NNCF OpenVINO Pull requests that updates NNCF OpenVINO NNCF ONNX Pull requests that updates NNCF ONNX NNCF PTQ Pull requests that updates NNCF PTQ labels Apr 10, 2024
@daniil-lyakhov daniil-lyakhov force-pushed the dl/torch/min_max_unified_scales_support branch from fe0f86f to c36b461 Compare April 11, 2024 12:37
@daniil-lyakhov daniil-lyakhov marked this pull request as ready for review April 11, 2024 12:38
@daniil-lyakhov daniil-lyakhov requested a review from a team as a code owner April 11, 2024 12:38
Copy link

codecov bot commented Apr 11, 2024

Codecov Report

Attention: Patch coverage is 68.42105% with 12 lines in your changes are missing coverage. Please review.

Project coverage is 77.93%. Comparing base (0b407de) to head (7a5e29d).
Report is 2 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##           develop    #2622       +/-   ##
============================================
- Coverage    91.16%   77.93%   -13.23%     
============================================
  Files          494      494               
  Lines        45373    45401       +28     
============================================
- Hits         41363    35383     -5980     
- Misses        4010    10018     +6008     
Files Coverage Δ
nncf/quantization/algorithms/min_max/backend.py 100.00% <100.00%> (ø)
...f/quantization/algorithms/min_max/torch_backend.py 97.46% <100.00%> (+0.07%) ⬆️
...cf/torch/graph/transformations/command_creation.py 100.00% <100.00%> (ø)
...cf/quantization/algorithms/min_max/onnx_backend.py 0.00% <0.00%> (-94.91%) ⬇️
...uantization/algorithms/min_max/openvino_backend.py 0.00% <0.00%> (-97.41%) ⬇️
nncf/quantization/algorithms/min_max/algorithm.py 90.54% <62.50%> (-7.01%) ⬇️

... and 102 files with indirect coverage changes

Flag Coverage Δ
COMMON ?
ONNX ?
OPENVINO ?
TENSORFLOW 30.10% <0.00%> (-0.02%) ⬇️
TORCH 65.95% <68.42%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
common 88.28% <ø> (-5.47%) ⬇️
torch 93.49% <100.00%> (-0.01%) ⬇️
tensorflow 93.74% <ø> (ø)
onnx 0.00% <0.00%> (-93.08%) ⬇️
openvino 25.70% <0.00%> (-68.46%) ⬇️
ptq 53.06% <61.29%> (-37.05%) ⬇️

@AlexanderDokuchaev AlexanderDokuchaev merged commit 35f1215 into openvinotoolkit:develop Apr 12, 2024
11 checks passed
KodiaqQ added a commit that referenced this pull request Aug 9, 2024
### Changes

- Fixed the `MinMax` algorithm for the `FakeConvert` insertion case.

### Reason for changes

- Incorrect `MinMax` behaviour introduced in
#2622.

### Related tickets

- 149128

### Tests

- Manual

Incorrect behaviour - two identical layers were inserted:

![image](https://github.com/user-attachments/assets/28fb5419-c9ac-400d-a8cc-bcf1d0e32241)
Corrected behaviour - only one layer for each branch was inserted:

![image](https://github.com/user-attachments/assets/d0ab38e5-320a-49b3-8c02-5669b42257f4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NNCF ONNX Pull requests that updates NNCF ONNX NNCF OpenVINO Pull requests that updates NNCF OpenVINO NNCF PT Pull requests that updates NNCF PyTorch NNCF PTQ Pull requests that updates NNCF PTQ
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants