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

Run __setstate__ when cloning modules #45858

Closed
wants to merge 3 commits into from

Conversation

bzinodev
Copy link
Contributor

@bzinodev bzinodev commented Oct 5, 2020

Stack from ghstack:

When cloning a module that has setstate, getstate methods.
We need to load these methods to initialize these modules.

Differential Revision: D24116524

When cloning a module that has __setstate__, __getstate__ methods.
We need to load these methods to initialize these modules.

[ghstack-poisoned]
@bzinodev bzinodev requested a review from apaszke as a code owner October 5, 2020 18:19
bzinodev added a commit that referenced this pull request Oct 5, 2020
When cloning a module that has __setstate__, __getstate__ methods.
We need to load these methods to initialize these modules.

ghstack-source-id: 6311fc9279524e7e0b39fb5939e0294cde26031f
Pull Request resolved: #45858
@facebook-github-bot facebook-github-bot added the oncall: jit Add this issue/PR to JIT oncall triage queue label Oct 5, 2020
@supriyar
Copy link
Contributor

supriyar commented Oct 5, 2020

@bzinodev can you also make the same change in the quantization code? We have a clone implementation here https://github.com/pytorch/pytorch/blob/master/torch/csrc/jit/passes/quantization/insert_observers.cpp#L96

@bzinodev bzinodev requested review from suo and eellison October 8, 2020 20:58
Copy link
Contributor

@eellison eellison left a comment

Choose a reason for hiding this comment

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

Looks good to me, but I would like another set of eyes from something with more knowledge of setstate / getstate - cc @suo, @jamesr66a

@dr-ci
Copy link

dr-ci bot commented Oct 13, 2020

💊 CI failures summary and remediations

As of commit f74a8ff (more details on the Dr. CI page):


💚 💚 Looks good so far! There are no failures yet. 💚 💚


This comment was automatically generated by Dr. CI (expand for details).Follow this link to opt-out of these comments for your Pull Requests.

Please report bugs/suggestions on the GitHub issue tracker or post in the (internal) Dr. CI Users group.

See how this bot performed.

This comment has been revised 5 times.

When cloning a module that has __setstate__, __getstate__ methods.
We need to load these methods to initialize these modules.

Differential Revision: [D24116524](https://our.internmc.facebook.com/intern/diff/D24116524)

[ghstack-poisoned]
When cloning a module that has __setstate__, __getstate__ methods.
We need to load these methods to initialize these modules.

Differential Revision: [D24116524](https://our.internmc.facebook.com/intern/diff/D24116524)

[ghstack-poisoned]
bzinodev added a commit that referenced this pull request Oct 13, 2020
When cloning a module that has __setstate__, __getstate__ methods.
We need to load these methods to initialize these modules.

ghstack-source-id: efe8c81a9d1e46b0b8ebe03c2cfba31eab1680eb
Pull Request resolved: #45858
@codecov
Copy link

codecov bot commented Oct 13, 2020

Codecov Report

Merging #45858 into gh/bzinodev/19/base will increase coverage by 0.00%.
The diff coverage is n/a.

Impacted file tree graph

@@                 Coverage Diff                  @@
##           gh/bzinodev/19/base   #45858   +/-   ##
====================================================
  Coverage                68.25%   68.26%           
====================================================
  Files                      410      410           
  Lines                    53608    53608           
====================================================
+ Hits                     36592    36593    +1     
+ Misses                   17016    17015    -1     
Impacted Files Coverage Δ
torch/testing/_internal/expecttest.py 78.57% <0.00%> (+1.02%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7b7f251...f74a8ff. Read the comment docs.

Copy link
Member

@suo suo left a comment

Choose a reason for hiding this comment

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

This looks fine. If getstate is defined it should be called on a deepcopy. It appears that clone is a deepcopy.

Some followups that could be good (doesn't have to be in this PR, just recording):

  1. deepcopy should do the same thing if it doesn't already.
  2. Can we please rename clone to something actually meaningful? I had to read the implementation to see if it was a copy vs. deepcopy, since literally just says "clone" in the method documentation. Maybe, deepcopy_with_type cc @jerry39213gh

@facebook-github-bot
Copy link
Contributor

@bzinodev merged this pull request in 11cc7f1.

@facebook-github-bot facebook-github-bot deleted the gh/bzinodev/19/head branch October 20, 2020 14:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Merged oncall: jit Add this issue/PR to JIT oncall triage queue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants