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

[Torch] Drop PTQuantizerInsertionCommand #2584

Conversation

daniil-lyakhov
Copy link
Collaborator

Preparation for #2531

Changes

  1. PTQuantizerInsertionCommand is removed and replaced with create_quantizer_insertion_command function
  2. SharedFNInsertionCommand updates with one new attribute: compression_module_type
  3. ExtraOpCallHook doesn't require context in constructor anymore
  4. Multidevice support is moved from apply_quantizers_insertion_commands_transformation to apply_insertion_transformation

Reason for changes

  1. To make it easier to store and restore commands: less commands - less amount of adapters are needed
  2. To make it possible to express PTQuantizerInsertionCommand by SharedFNInsertionCommand
  3. To make it possible to create ExtraOpCallHook outside of the PTModelTransformer
  4. To unify multidevice support for all insertion operations

Related tickets

2531

Tests

1)test_quantizer_insertion_transformation is updated
2) -
3) test_shared_fn_insertion_point is updated
4) test_pt_insertion_command is introduced

@daniil-lyakhov daniil-lyakhov requested a review from a team as a code owner March 19, 2024 16:17
@github-actions github-actions bot added NNCF PT Pull requests that updates NNCF PyTorch NNCF PTQ Pull requests that updates NNCF PTQ labels Mar 19, 2024
Copy link

codecov bot commented Mar 19, 2024

Codecov Report

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

Project coverage is 84.90%. Comparing base (b7ba5ad) to head (91397ba).

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #2584      +/-   ##
===========================================
- Coverage    91.16%   84.90%   -6.26%     
===========================================
  Files          494      494              
  Lines        45350    45368      +18     
===========================================
- Hits         41342    38521    -2821     
- Misses        4008     6847    +2839     
Files Coverage Δ
...f/quantization/algorithms/min_max/torch_backend.py 97.38% <100.00%> (-0.02%) ⬇️
nncf/torch/external_hook.py 100.00% <100.00%> (ø)
...cf/torch/graph/transformations/command_creation.py 100.00% <100.00%> (ø)
nncf/torch/graph/transformations/commands.py 98.85% <100.00%> (-0.03%) ⬇️
nncf/torch/model_graph_manager.py 84.55% <100.00%> (+0.34%) ⬆️
nncf/torch/model_transformer.py 100.00% <100.00%> (ø)
nncf/torch/quantization/algo.py 95.93% <100.00%> (ø)
nncf/torch/quantization/external_quantizer.py 100.00% <100.00%> (ø)
...ncf/torch/quantization/precision_init/base_init.py 95.34% <100.00%> (ø)
...cf/torch/quantization/precision_init/hawq_debug.py 97.38% <100.00%> (ø)
... and 3 more

... and 59 files with indirect coverage changes

Flag Coverage Δ
COMMON 44.15% <0.00%> (+<0.01%) ⬆️
ONNX 34.65% <25.64%> (+<0.01%) ⬆️
OPENVINO ∅ <ø> (∅)
TENSORFLOW 30.11% <0.00%> (-0.02%) ⬇️
TORCH 65.92% <97.43%> (-0.03%) ⬇️

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

Components Coverage Δ
common 93.14% <ø> (-0.65%) ⬇️
torch 93.48% <97.43%> (-0.01%) ⬇️
tensorflow 93.74% <ø> (ø)
onnx 93.12% <ø> (+0.09%) ⬆️
openvino 25.75% <ø> (-68.39%) ⬇️
ptq 69.88% <100.00%> (-20.24%) ⬇️

nncf/torch/external_hook.py Show resolved Hide resolved
nncf/torch/nncf_network.py Show resolved Hide resolved
@daniil-lyakhov daniil-lyakhov force-pushed the dl/torch/remove_pt_qauntizer_insertion_command branch from 1281a0d to 317f263 Compare March 20, 2024 10:26
@daniil-lyakhov daniil-lyakhov requested a review from alexsu52 March 20, 2024 14:35
Copy link
Contributor

@alexsu52 alexsu52 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@AlexanderDokuchaev AlexanderDokuchaev merged commit f7a5660 into openvinotoolkit:develop Apr 2, 2024
11 checks passed
alexsu52 pushed a commit that referenced this pull request Apr 25, 2024
On top of #2584 

### Changes

`NNCFNetwork.transformation_layout` method is introduced

### Reason for changes

To make it possible to collect applied transformation commands from a
modified `NNCFNetwork`

### Related tickets

129586

### Tests

TestGetAppliedModificationCommands
alexsu52 pushed a commit that referenced this pull request May 6, 2024
On top of #2584 #2595 
### Changes

* `serialize_transformations` and `load_transformations` functions are
introduced: `serialize_transformations` could serialize
`PTTransformationLayout` to a dict which could be serialized by json;
serialized transformation could be recovered by the
`load_transformations` function.
* `StatefullTorchModuleInterface` is introduced to make it possible to
serialize all compression modules for quantization, sparisification,
weights compression and pruning algorithms
* Quantizers are created with scale shape specified in the quantization
spec


### Reason for changes

* To make it possible to serialize/deserialize PT nncf transformations
* To make it possible to serialize/deserialize compression modules which
are the part of each transformation
* To align scales shapes after `nncf.quantize` and quantizes
initialization

### Related tickets

129586

### Tests

* tests/torch/test_serialization.py
* tests/torch/test_serialization.py
* tests/torch/test_serialization.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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