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

created original copy of the model by loading from disk #2406

Merged
merged 7 commits into from
Jun 7, 2023

Conversation

Samsonboadi
Copy link
Contributor

@Samsonboadi Samsonboadi commented Jun 2, 2023

Fixes #2334

Description

updated the deepcopy method , to load the pretrained model from disk to create a copy

Checklist

cc @albanD

@netlify
Copy link

netlify bot commented Jun 2, 2023

Deploy Preview for pytorch-tutorials-preview ready!

Name Link
🔨 Latest commit f3e45d9
🔍 Latest deploy log https://app.netlify.com/sites/pytorch-tutorials-preview/deploys/6480e4bf9100f00008a2a6d6
😎 Deploy Preview https://deploy-preview-2406--pytorch-tutorials-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@github-actions github-actions bot added core Tutorials of any level of difficulty related to the core pytorch functionality docathon-h1-2023 A label for the docathon in H1 2023 easy and removed cla signed labels Jun 2, 2023
@Samsonboadi
Copy link
Contributor Author

/assigntome

Copy link
Member

@kit1980 kit1980 left a comment

Choose a reason for hiding this comment

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

I don't think this will work: model_to_quantize will be a dictionary, not a nn.Module, and the next line will fail.
Have you verified it?

I think you need to copy the logic starting with the line 164: create LSTMModel and then use load_state_dict.

# to keep the original model for future comparison
model_to_quantize = copy.deepcopy(model)

# Load the model
Copy link
Member

Choose a reason for hiding this comment

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

A duplicate comment now?

prototype_source/fx_graph_mode_ptq_dynamic.py Outdated Show resolved Hide resolved
updated solution not to override the model parameter
model_to_quantize = copy.deepcopy(model)


# Load Pretrained Model
Copy link
Member

Choose a reason for hiding this comment

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

This comment is redundant?

@pytorch-bot
Copy link

pytorch-bot bot commented Jun 7, 2023

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/tutorials/2406

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit f3e45d9:
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@svekars svekars merged commit d9938ee into pytorch:main Jun 7, 2023
svekars pushed a commit that referenced this pull request Jun 9, 2023
* created original copy of the model by loading from disk
* Update fx_graph_mode_ptq_dynamic.py

---------

Co-authored-by: Svetlana Karslioglu <svekars@fb.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla signed core Tutorials of any level of difficulty related to the core pytorch functionality docathon-h1-2023 A label for the docathon in H1 2023 easy
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update tutorial to avoid use of copy.deepcopy()-FX Graph Mode Post Training Dynamic Quantization
4 participants