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

Fixed to dump the ignored_scope in quantization more gracefully #2578

Merged

Conversation

Viditagarwal7479
Copy link
Contributor

@Viditagarwal7479 Viditagarwal7479 commented Mar 15, 2024

Changes

In the case of dumping parameters of IgnoredScope in quantization:

  • The field validate isn't dumped
  • If the values corresponding to the rest of the fields are empty ([]) they aren't dumped
  • In case the IgnoredScope is passed blank, then only <ignored_scope value="[]"> is dumped

Related tickets

Ticket: 129593
Fixes Issue: #2564

Tests

The test case, tests/openvino/native/quantization/test_quantization_pipeline.py::test_meta_information has been modified to validate the new changes. To protect code from regressions.

@Viditagarwal7479 Viditagarwal7479 requested a review from a team as a code owner March 15, 2024 17:55
@github-actions github-actions bot added the NNCF OpenVINO Pull requests that updates NNCF OpenVINO label Mar 15, 2024
Copy link

codecov bot commented Mar 15, 2024

Codecov Report

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

Project coverage is 33.14%. Comparing base (12f4720) to head (7845e42).
Report is 60 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##           develop    #2578       +/-   ##
============================================
- Coverage    91.18%   33.14%   -58.05%     
============================================
  Files          492      493        +1     
  Lines        45096    45551      +455     
============================================
- Hits         41123    15099    -26024     
- Misses        3973    30452    +26479     
Files Coverage Δ
nncf/openvino/rt_info.py 0.00% <0.00%> (-86.67%) ⬇️

... and 315 files with indirect coverage changes

Flag Coverage Δ
COMMON 43.98% <ø> (+0.05%) ⬆️
ONNX ?
OPENVINO ?
TENSORFLOW 30.05% <0.00%> (+0.18%) ⬆️
TORCH ?

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

Components Coverage Δ
common 85.62% <ø> (-8.15%) ⬇️
torch 0.01% <ø> (-93.59%) ⬇️
tensorflow 93.74% <ø> (-0.01%) ⬇️
onnx 0.00% <ø> (-93.06%) ⬇️
openvino 0.00% <0.00%> (-94.07%) ⬇️
ptq 28.00% <ø> (-62.22%) ⬇️

@Viditagarwal7479
Copy link
Contributor Author

Hello @ljaljushkin, a gentle reminder to review the PR.

Copy link
Contributor

@ljaljushkin ljaljushkin left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution!
Please address the comments

nncf/openvino/rt_info.py Outdated Show resolved Hide resolved
@ljaljushkin
Copy link
Contributor

@Viditagarwal7479 please fix the test to pass CI

https://github.com/openvinotoolkit/nncf/actions/runs/8344527642/job/22869598068?pr=2578

>           assert quantized_model.get_rt_info(rt_path) == str(value)
E           RuntimeError: Check 'rt_info.find(name) != rt_info.end()' failed at src/core/include/openvino/core/model.hpp:502:
E           Cannot get runtime attribute. Path to runtime attribute is incorrect.

tests/openvino/native/quantization/test_quantization_pipeline.py:108: RuntimeError

@Viditagarwal7479
Copy link
Contributor Author

@Viditagarwal7479 please fix the test to pass CI

https://github.com/openvinotoolkit/nncf/actions/runs/8344527642/job/22869598068?pr=2578

>           assert quantized_model.get_rt_info(rt_path) == str(value)
E           RuntimeError: Check 'rt_info.find(name) != rt_info.end()' failed at src/core/include/openvino/core/model.hpp:502:
E           Cannot get runtime attribute. Path to runtime attribute is incorrect.

tests/openvino/native/quantization/test_quantization_pipeline.py:108: RuntimeError

While making modifications through the model.set_rt_info we are making changes in the output of model.get_rt_info so, I guess we need to update this test case accordingly to facilitate the changes.

@Viditagarwal7479
Copy link
Contributor Author

The pre-commit-linters / pre-commit (pull_request) is failing because of this unknown reason:

Run actions/setup-python@v3
Version 3.8.10 was not found in the local cache
Error: read ECONNRESET

@AlexanderDokuchaev
Copy link
Collaborator

@Viditagarwal7479 rerun the job helped, tests passed.

@Viditagarwal7479
Copy link
Contributor Author

It's showing "1 review requesting changes by reviewers with write access" but I have incorporated all the requested changes so far.

nncf/openvino/rt_info.py Outdated Show resolved Hide resolved
nncf/openvino/rt_info.py Outdated Show resolved Hide resolved
nncf/openvino/rt_info.py Outdated Show resolved Hide resolved
nncf/openvino/rt_info.py Outdated Show resolved Hide resolved
@ljaljushkin
Copy link
Contributor

@Viditagarwal7479, the last commit was a month ago. There's still one unresolved comment. Are you going to resolve it? Do you need a help? Please inform us if you do not plan to continue working on this task. Thanks!

@Viditagarwal7479
Copy link
Contributor Author

@Viditagarwal7479, the last commit was a month ago. There's still one unresolved comment. Are you going to resolve it? Do you need a help? Please inform us if you do not plan to continue working on this task. Thanks!

Yes, I need help in determining the parameters for subgraph in IgnoredScope for a given model. I looked at the PR you mentioned, but that PR wasn't of much help in resolving this, one thing that can be of help is if we also use the same model used in the PR, then as requested, we can include a subgraph based test case for this PR.

@ljaljushkin
Copy link
Contributor

@Viditagarwal7479, the last commit was a month ago. There's still one unresolved comment. Are you going to resolve it? Do you need a help? Please inform us if you do not plan to continue working on this task. Thanks!

Yes, I need help in determining the parameters for subgraph in IgnoredScope for a given model. I looked at the PR you mentioned, but that PR wasn't of much help in resolving this, one thing that can be of help is if we also use the same model used in the PR, then as requested, we can include a subgraph based test case for this PR.

Firstly, I suggest using not quantized model, since the ignored scope defines nodes that should not be quantized.
If they are already quantized, this attribute does not make sense and do nothing.

For instance, you can consider WeightsModel.
image
To not quantize all layers in the subgraph marked red, you can specify the names of input and output nodes, as follows.

IgnoredScope(
    subgraphs=[
        nncf.Subgraph(
            inputs=[
                "MatMul_1",
            ],
            outputs=[
                "MatMul"
            ],
        )
    ],
),

Hope this example, makes things clear.

@ljaljushkin
Copy link
Contributor

@Viditagarwal7479 one week left since my last comment
Please inform us if you do not plan to continue working on this task. Thanks!

@Viditagarwal7479
Copy link
Contributor Author

@Viditagarwal7479 one week left since my last comment Please inform us if you do not plan to continue working on this task. Thanks!

Thank you so much, @ljaljushkin, for helping me (in fact, spoon-feeding on how to add the subgraph-based test case).

Through the diagram, you showed it's clear, but just to make sure, for any model whose subgraph we want to ignore in the quantised model, we just have to mention the input node and the output node. Through this, the nodes that are taking the input as the value passed from the mentioned input node and whose output is, in a way, being passed to the mentioned output node get removed from the quantised model. Is my interpretation correct?

Sorry, for the delay from my end in making the minor changes. If my above interpretation is correct so should we make some more guides related to how to specify the subgraph in the IgnoredScope maybe just by adding similar subgraph based test cases or a tutorial kind of stuff?

@ljaljushkin
Copy link
Contributor

@Viditagarwal7479 one week left since my last comment Please inform us if you do not plan to continue working on this task. Thanks!

Thank you so much, @ljaljushkin, for helping me (in fact, spoon-feeding on how to add the subgraph-based test case).

Through the diagram, you showed it's clear, but just to make sure, for any model whose subgraph we want to ignore in the quantised model, we just have to mention the input node and the output node. Through this, the nodes that are taking the input as the value passed from the mentioned input node and whose output is, in a way, being passed to the mentioned output node get removed from the quantised model. Is my interpretation correct?

Sorry, for the delay from my end in making the minor changes. If my above interpretation is correct so should we make some more guides related to how to specify the subgraph in the IgnoredScope maybe just by adding similar subgraph based test cases or a tutorial kind of stuff?

Yes, your interpretation is correct. More guidance about defining subgraph in the IgnoredScope would be definitely useful.
Feel free to add it in another PR. Probably, just updating docstring with some examples for IgnoredScope class can be enough.
You can visualize my example using symbols and tabs:

  |                  |     
input1        input2
   \               /
    node...
        |
       ...
        |
     output1

@Viditagarwal7479
Copy link
Contributor Author

@Viditagarwal7479 one week left since my last comment Please inform us if you do not plan to continue working on this task. Thanks!

Thank you so much, @ljaljushkin, for helping me (in fact, spoon-feeding on how to add the subgraph-based test case).
Through the diagram, you showed it's clear, but just to make sure, for any model whose subgraph we want to ignore in the quantised model, we just have to mention the input node and the output node. Through this, the nodes that are taking the input as the value passed from the mentioned input node and whose output is, in a way, being passed to the mentioned output node get removed from the quantised model. Is my interpretation correct?
Sorry, for the delay from my end in making the minor changes. If my above interpretation is correct so should we make some more guides related to how to specify the subgraph in the IgnoredScope maybe just by adding similar subgraph based test cases or a tutorial kind of stuff?

Yes, your interpretation is correct. More guidance about defining subgraph in the IgnoredScope would be definitely useful. Feel free to add it in another PR. Probably, just updating docstring with some examples for IgnoredScope class can be enough. You can visualize my example using symbols and tabs:

  |                  |     
input1        input2
   \               /
    node...
        |
       ...
        |
     output1

Thank you for the confirmation. I will soon (2-3 days) create a PR corresponding to this.

@ljaljushkin ljaljushkin merged commit 3586e58 into openvinotoolkit:develop May 3, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NNCF OpenVINO Pull requests that updates NNCF OpenVINO
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants