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

[PT] change api for get_config and load_from_config #3359

Conversation

AlexanderDokuchaev
Copy link
Collaborator

@AlexanderDokuchaev AlexanderDokuchaev commented Mar 19, 2025

Changes

Add get_config to nncf/torch/__init__.py
Use function get_config and load_from_config for new and old tracing as from nncf.torch import get_config, load_from_config

Tests

https://github.com/openvinotoolkit/nncf/actions/runs/13974357105

@github-actions github-actions bot added documentation Improvements or additions to documentation NNCF PT Pull requests that updates NNCF PyTorch labels Mar 19, 2025
@AlexanderDokuchaev AlexanderDokuchaev marked this pull request as ready for review March 19, 2025 14:24
@AlexanderDokuchaev AlexanderDokuchaev requested a review from a team as a code owner March 19, 2025 14:24
@AlexanderDokuchaev AlexanderDokuchaev requested review from alexsu52 and daniil-lyakhov and removed request for a team March 19, 2025 14:24
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, Please address my minor comments.

README.md Outdated
@@ -283,7 +284,7 @@ resuming_checkpoint = torch.load(path_to_checkpoint)
nncf_config = resuming_checkpoint['nncf_config']
state_dict = resuming_checkpoint['state_dict']

quantized_model = nncf.torch.load_from_config(model, nncf_config, example_input)
quantized_model = load_from_config(model, nncf_config, example_input)
Copy link
Contributor

Choose a reason for hiding this comment

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

IMHO: What do you think about such usage?

Suggested change
quantized_model = load_from_config(model, nncf_config, example_input)
quantized_model = nncf.torch.load_from_config(model, nncf_config, example_input)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It won't work

Backend-specific modules is not part of nncf namespace

import nncf
nncf.torch.load_from_config

# AttributeError: module 'nncf' has no attribute 'torch'

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you fix this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

not in this pr

Copy link
Collaborator

Choose a reason for hiding this comment

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

What about

import nncf.torch

nncf.torch.load_from_config

?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

will works, but i prefer

from nncf.torch import load_from_config
load_from_config

README.md Outdated
@@ -271,7 +272,7 @@ quantized_model = nncf.quantize(model, calibration_dataset)
# Save quantization modules and the quantized model parameters
checkpoint = {
'state_dict': model.state_dict(),
'nncf_config': model.nncf.get_config(),
'nncf_config': get_config(model),
Copy link
Contributor

Choose a reason for hiding this comment

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

IMHO: What do you think about such usage?

Suggested change
'nncf_config': get_config(model),
'nncf_config': nncf.torch.get_config(model),

@alexsu52 alexsu52 self-assigned this Mar 20, 2025
@AlexanderDokuchaev AlexanderDokuchaev merged commit 9f4aa76 into openvinotoolkit:develop Mar 21, 2025
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation NNCF PT Pull requests that updates NNCF PyTorch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants