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] NNCFNetwork.transformation_layout #2595

Conversation

daniil-lyakhov
Copy link
Collaborator

@daniil-lyakhov daniil-lyakhov commented Mar 22, 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

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

codecov bot commented Mar 22, 2024

Codecov Report

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

Project coverage is 79.57%. Comparing base (fa1a4ce) to head (6937ca0).
Report is 4 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##           develop    #2595       +/-   ##
============================================
- Coverage    89.84%   79.57%   -10.28%     
============================================
  Files          494      493        -1     
  Lines        45374    45519      +145     
============================================
- Hits         40768    36223     -4545     
- Misses        4606     9296     +4690     
Files Coverage Δ
nncf/torch/graph/graph.py 98.46% <100.00%> (+0.04%) ⬆️
...cf/torch/graph/transformations/command_creation.py 100.00% <100.00%> (ø)
nncf/torch/graph/transformations/commands.py 98.86% <100.00%> (+0.01%) ⬆️
nncf/torch/nncf_network.py 94.26% <98.48%> (+0.49%) ⬆️

... and 125 files with indirect coverage changes

Flag Coverage Δ
COMMON 44.04% <ø> (?)
ONNX ?
OPENVINO ?
TENSORFLOW 30.03% <0.00%> (-0.09%) ⬇️
TORCH 66.04% <98.63%> (+0.08%) ⬆️

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

Components Coverage Δ
common 92.81% <ø> (+3.27%) ⬆️
torch 93.61% <98.63%> (+0.11%) ⬆️
tensorflow 93.74% <ø> (-0.01%) ⬇️
onnx 0.00% <ø> (-93.08%) ⬇️
openvino 25.67% <ø> (-68.50%) ⬇️
ptq 59.81% <ø> (-25.39%) ⬇️

@daniil-lyakhov daniil-lyakhov force-pushed the dl/torch/get_applied_modification_commands branch from 7ae777e to ada7683 Compare March 22, 2024 13:58
@daniil-lyakhov daniil-lyakhov changed the title Dl/torch/get applied modification commands [Torch] NNCFNetwork.get_applied_transformation_layout Mar 22, 2024
@daniil-lyakhov daniil-lyakhov force-pushed the dl/torch/get_applied_modification_commands branch 4 times, most recently from d8867d0 to 3c8a7de Compare March 25, 2024 12:55
@daniil-lyakhov daniil-lyakhov force-pushed the dl/torch/get_applied_modification_commands branch from 52c098c to 0767521 Compare March 27, 2024 14:33
@daniil-lyakhov daniil-lyakhov force-pushed the dl/torch/get_applied_modification_commands branch from 0767521 to 0eca703 Compare April 2, 2024 13:53
@github-actions github-actions bot removed the NNCF PTQ Pull requests that updates NNCF PTQ label Apr 2, 2024
tests/torch/test_nncf_network.py Outdated Show resolved Hide resolved
tests/torch/test_nncf_network.py Outdated Show resolved Hide resolved
tests/torch/test_nncf_network.py Outdated Show resolved Hide resolved
tests/torch/helpers.py Outdated Show resolved Hide resolved
nncf/torch/graph/graph.py Outdated Show resolved Hide resolved
nncf/torch/nncf_network.py Show resolved Hide resolved
nncf/torch/nncf_network.py Outdated Show resolved Hide resolved
tests/torch/helpers.py Outdated Show resolved Hide resolved
tests/torch/helpers.py Outdated Show resolved Hide resolved
nncf/torch/nncf_network.py Outdated Show resolved Hide resolved
nncf/torch/graph/graph.py Show resolved Hide resolved
tests/torch/nncf_network/helpers.py Show resolved Hide resolved
tests/torch/nncf_network/helpers.py Outdated Show resolved Hide resolved
@daniil-lyakhov daniil-lyakhov force-pushed the dl/torch/get_applied_modification_commands branch from d65a6b1 to 1b1e015 Compare April 12, 2024 12:42
@daniil-lyakhov daniil-lyakhov force-pushed the dl/torch/get_applied_modification_commands branch from 1b1e015 to e5c159c Compare April 12, 2024 12:54
nncf/torch/nncf_network.py Outdated Show resolved Hide resolved
tests/torch/nncf_network/helpers.py Outdated Show resolved Hide resolved
tests/torch/nncf_network/helpers.py Show resolved Hide resolved
tests/torch/nncf_network/test_get_applied_modifications.py Outdated Show resolved Hide resolved
tests/torch/nncf_network/test_get_applied_modifications.py Outdated Show resolved Hide resolved
tests/torch/nncf_network/test_get_applied_modifications.py Outdated Show resolved Hide resolved
tests/torch/nncf_network/test_get_applied_modifications.py Outdated Show resolved Hide resolved
tests/torch/nncf_network/test_get_applied_modifications.py Outdated Show resolved Hide resolved
@daniil-lyakhov daniil-lyakhov force-pushed the dl/torch/get_applied_modification_commands branch from 63935da to 56b8a23 Compare April 15, 2024 15:26
@daniil-lyakhov daniil-lyakhov changed the title [Torch] NNCFNetwork.get_applied_transformation_layout [Torch] NNCFNetwork.transformation_layout Apr 19, 2024
@daniil-lyakhov daniil-lyakhov force-pushed the dl/torch/get_applied_modification_commands branch from b54fe9a to a6abd0a Compare April 22, 2024 12:13
),
)

COMMAND_CLASSES = [PTInsertionCommand, PTSharedFnInsertionCommand, PTSharedFnInsertionCommand]
Copy link
Collaborator

Choose a reason for hiding this comment

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

unused?

Copy link
Collaborator Author

@daniil-lyakhov daniil-lyakhov Apr 22, 2024

Choose a reason for hiding this comment

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

Yes, I've removed it, thanks

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

nncf/torch/nncf_network.py Outdated Show resolved Hide resolved
@daniil-lyakhov daniil-lyakhov requested a review from alexsu52 April 24, 2024 16:05
@daniil-lyakhov daniil-lyakhov force-pushed the dl/torch/get_applied_modification_commands branch from 8c49de4 to 6937ca0 Compare April 24, 2024 16:16
@alexsu52 alexsu52 merged commit a95e9af into openvinotoolkit:develop Apr 25, 2024
11 checks passed
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants