Skip to content

Serialization and range reduction support for Fake Quant/Observer#26519

Closed
raghuramank100 wants to merge 12 commits intogh/raghuramank100/28/basefrom
gh/raghuramank100/28/head
Closed

Serialization and range reduction support for Fake Quant/Observer#26519
raghuramank100 wants to merge 12 commits intogh/raghuramank100/28/basefrom
gh/raghuramank100/28/head

Conversation

@raghuramank100
Copy link
Copy Markdown
Contributor

@raghuramank100 raghuramank100 commented Sep 20, 2019

Stack from ghstack:

Differential Revision: D17217408

Comment thread torch/quantization/fake_quantize.py Outdated
Comment thread torch/quantization/fake_quantize.py Outdated
Copy link
Copy Markdown
Contributor

@jerryzh168 jerryzh168 left a comment

Choose a reason for hiding this comment

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

see comments

Comment thread torch/quantization/fake_quantize.py Outdated
default_fake_quant = FakeQuantize
def _save_to_state_dict(self, destination, prefix, keep_vars):
super(FakeQuantize, self)._save_to_state_dict(destination, prefix, keep_vars)
destination[prefix + 'quant_min'] = self.quant_min
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

interesting, looks like we have a legit use cases for non-Tensor register_buffer (cc @gchanan). No action now, just interesting

Comment thread torch/quantization/fake_quantize.py Outdated
Comment thread torch/quantization/fake_quantize.py Outdated
Comment thread torch/quantization/observer.py Outdated
Comment thread torch/quantization/observer.py Outdated
Comment thread torch/quantization/fake_quantize.py Outdated
raghuramank100 pushed a commit that referenced this pull request Sep 24, 2019
Pull Request resolved: #26519


ghstack-source-id: 90622881

Differential Revision: [D17217408](https://our.internmc.facebook.com/intern/diff/D17217408/)
raghuramank100 pushed a commit that referenced this pull request Sep 24, 2019
Pull Request resolved: #26519


ghstack-source-id: 90701068

Differential Revision: [D17217408](https://our.internmc.facebook.com/intern/diff/D17217408/)
Comment thread test/test_fake_quant.py Outdated
Comment thread torch/quantization/fake_quantize.py Outdated
supriyar pushed a commit to supriyar/pytorch that referenced this pull request Sep 25, 2019
Pull Request resolved: pytorch#26519


ghstack-source-id: 90622881

Differential Revision: [D17217408](https://our.internmc.facebook.com/intern/diff/D17217408/)
Copy link
Copy Markdown
Collaborator

@dzhulgakov dzhulgakov 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, please address nits before landing

Comment thread torch/quantization/fake_quantize.py Outdated
@@ -13,23 +12,20 @@ class FakeQuantize(Module):
`calcqparam`: A function that calculates quantization parameters
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

the docstring is way out of date - please update

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch, will update

Comment thread torch/quantization/fake_quantize.py
self.ch_axis = ch_axis
self.min_vals = None
self.max_vals = None
self.register_buffer('min_vals', None)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

maybe just register empty tensor? (torch.tensor([])). Then you don't need to override _load_from_state_dict?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Will try that

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Doesnt work, so sticking with current approach

@raghuramank100
Copy link
Copy Markdown
Contributor Author

@pytorchbot Retest this please

@raghuramank100
Copy link
Copy Markdown
Contributor Author

@pytorchbot retest this please

1 similar comment
@raghuramank100
Copy link
Copy Markdown
Contributor Author

@pytorchbot retest this please

raghuramank100 pushed a commit that referenced this pull request Sep 27, 2019
Pull Request resolved: #26519


ghstack-source-id: 90895631

Differential Revision: [D17217408](https://our.internmc.facebook.com/intern/diff/D17217408/)
Comment thread torch/quantization/fake_quantize.py
Copy link
Copy Markdown
Contributor

@jerryzh168 jerryzh168 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

@facebook-github-bot
Copy link
Copy Markdown
Contributor

This pull request has been merged in b0a2f6f.

@raghuramank100 raghuramank100 added this to the 1.3 milestone Sep 30, 2019
pdlive215 pushed a commit to pdlive215/pytorch that referenced this pull request Nov 27, 2019
…torch#26519)

Summary:
Pull Request resolved: pytorch#26519

ghstack-source-id: 90895631

Test Plan:
buck test caffe2/test:quantization -- 'test_histogram_observer \(test_quantization\.ObserverTest\)' --print-passing-details
and
buck test caffe2/test:fake_quant -- 'test_fq_serializable \(test_fake_quant\.TestFakeQuantizePerTensorAffine\)' --print-passing-details

Differential Revision: D17217408

fbshipit-source-id: 0da7efdcdae0c065dd035c5dd2b6a78231545ece
xxtEchjovs44 pushed a commit to xxtEchjovs44/pytorch that referenced this pull request Jan 29, 2020
xxtEchjovs44 pushed a commit to xxtEchjovs44/pytorch that referenced this pull request Jan 29, 2020
laurentdupin pushed a commit to laurentdupin/pytorch that referenced this pull request Apr 24, 2026
…torch#26519)

Summary:
Pull Request resolved: pytorch#26519

ghstack-source-id: 90895631

Test Plan:
buck test caffe2/test:quantization -- 'test_histogram_observer \(test_quantization\.ObserverTest\)' --print-passing-details
and
buck test caffe2/test:fake_quant -- 'test_fq_serializable \(test_fake_quant\.TestFakeQuantizePerTensorAffine\)' --print-passing-details

Differential Revision: D17217408

fbshipit-source-id: 0da7efdcdae0c065dd035c5dd2b6a78231545ece
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants