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

Updated Code Snippet for PyTorch tutorial for "example_pytorch_data_generation.ipynb" #1327

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

SumaiyaTarannumNoor
Copy link

@SumaiyaTarannumNoor SumaiyaTarannumNoor commented Jan 15, 2025

Pull Request Description:

Previous Code Snippet:

run post training quantization on the model to get the quantized model output

quantized_model_generated_data, quantization_info = mct.ptq.pytorch_post_training_quantization(
in_module=float_model,
representative_data_gen=representative_data_gen,
target_platform_capabilities=target_platform_cap
)
This code snippet is unable to detect the float_model and it's parameters. While using all the same snippets from "example_pytorch_data_generation.ipynb" in here - https://github.com/sony/model_optimization/blob/main/tutorials/notebooks/mct_features_notebooks/pytorch/example_pytorch_data_generation.ipynb
I was given this runtime error in Google Colab.
RuntimeError: Only Tensors created explicitly by the user (graph leaves) support the deepcopy protocol at the moment. If you were attempting to deepcopy a module, this may be because of a torch.nn.utils.weight_norm usage, see pytorch/pytorch#103001

However, I have updated this code snippets, which will make a new float_model with the same architecture and using it for Quantization. This is working perfectly.

Checklist before requesting a review:

  • I set the appropriate labels on the pull request.
  • I have added/updated the release note draft (if necessary).
  • I have updated the documentation to reflect my changes (if necessary).
  • All function and files are well documented.
  • All function and classes have type hints.
  • There is a licenses in all file.
  • The function and variable names are informative.
  • I have checked for code duplications.
  • I have added new unittest (if necessary).

@ofirgo ofirgo self-requested a review January 15, 2025 11:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant