Skip to content

Conversation

@vkuzo
Copy link
Contributor

@vkuzo vkuzo commented Aug 24, 2020

Stack from ghstack:

Summary:

  1. adds support for testing BC on data format and numerics for graph mode
    quantized modules
  2. using the above, adds coverage for quantized conv2d on graph mode

Test Plan:

python test/test_quantization.py TestSerialization.test_conv2d_nobias
python test/test_quantization.py TestSerialization.test_conv2d_graph
python test/test_quantization.py TestSerialization.test_conv2d_nobias_graph

Reviewers:

Subscribers:

Tasks:

Tags:

Differential Revision: D23335222

Summary:

Adding coverage for quantized conv without bias in the backwards
compatibility tests

Test Plan:

```
python test/test_quantization.py TestSerialization.test_conv2d_nobias
```

Reviewers:

Subscribers:

Tasks:

Tags:

[ghstack-poisoned]
Summary:

Adding coverage for quantized conv without bias in the backwards
compatibility tests

Test Plan:

```
python test/test_quantization.py TestSerialization.test_conv2d_nobias
```

Reviewers:

Subscribers:

Tasks:

Tags:

[ghstack-poisoned]
@vkuzo vkuzo changed the title quantized conv: add additional bc test quantized conv: add support for graph mode BC testing, and increase coverage Aug 25, 2020
Comment on lines 88 to 104
module_id = self.__class__.__module__
munged_id = remove_prefix(self.id(), module_id + ".")
test_file = os.path.realpath(sys.modules[module_id].__file__)
base_name = os.path.join(os.path.dirname(test_file),
"serialized",
munged_id)

subname_output = ""
if subname:
base_name += "_" + subname
subname_output = " ({})".format(subname)

input_file = base_name + ".input.pt"
state_dict_file = base_name + ".state_dict.pt"
scripted_module_file = base_name + ".scripted.pt"
traced_module_file = base_name + ".traced.pt"
expected_file = base_name + ".expected.pt"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, there is potential to reuse some part of this code, it didn't seem worth it at first glance as it would increase complexity and the benefit would be small as not all of this can be reused. I can take another look if you prefer.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't have a strong preference, I just feel in general we should not be copying code.

vkuzo added 2 commits August 25, 2020 14:10
… increase coverage"


Summary:

1. adds support for testing BC on data format and numerics for graph mode
quantized modules
2. using the above, adds coverage for quantized conv2d on graph mode

Test Plan:

```
python test/test_quantization.py TestSerialization.test_conv2d_nobias
python test/test_quantization.py TestSerialization.test_conv2d_graph
python test/test_quantization.py TestSerialization.test_conv2d_nobias_graph
```

Reviewers:

Subscribers:

Tasks:

Tags:

[ghstack-poisoned]
… increase coverage"


Summary:

1. adds support for testing BC on data format and numerics for graph mode
quantized modules
2. using the above, adds coverage for quantized conv2d on graph mode

Test Plan:

```
python test/test_quantization.py TestSerialization.test_conv2d_nobias
python test/test_quantization.py TestSerialization.test_conv2d_graph
python test/test_quantization.py TestSerialization.test_conv2d_nobias_graph
```

Reviewers:

Subscribers:

Tasks:

Tags:

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

[ghstack-poisoned]
@yns88 yns88 changed the base branch from gh/vkuzo/131/base to master August 26, 2020 16:50
@yns88 yns88 changed the base branch from master to gh/vkuzo/131/base August 26, 2020 16:56
@dr-ci
Copy link

dr-ci bot commented Aug 26, 2020

💊 CI failures summary and remediations

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


  • 1/1 failures possibly* introduced in this PR
    • 1/1 non-CircleCI failure(s)

Extra GitHub checks: 1 failed


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 12 times.

Copy link

@z-a-f z-a-f left a comment

Choose a reason for hiding this comment

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

LGTM

torch.save(scripted_q(input_tensor), expected_file)

input_tensor = torch.load(input_file)
qmodule_scripted = torch.jit.load(scripted_module_file)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we also have a test to catch regressions in the size of the quantized module files? We have had one issue before where the quantized model was storing both fp32 and quantized weights.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree, that would be valuable as well. It would probably be good for that live somewhere else since there could be things which don't break BC but change model size, and vice versa. For this PR stack we are doing manual testing of file size, and it's a reduction.

qmodule_scripted = torch.jit.load(scripted_module_file)
qmodule_traced = torch.jit.load(traced_module_file)
expected = torch.load(expected_file)
self.assertEqual(qmodule_scripted(input_tensor), expected, atol=prec)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there any value in comparing graph with eager expected outputs?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is definitely value in that, looks like that's already done in test_quantize_jit.py, so by those tests and the fact that both eager and graph are tested here for BC numerics, we can prove that eager vs graph condition is satisfied indirectly.

vkuzo added 3 commits August 27, 2020 12:37
… increase coverage"


Summary:

1. adds support for testing BC on data format and numerics for graph mode
quantized modules
2. using the above, adds coverage for quantized conv2d on graph mode

Test Plan:

```
python test/test_quantization.py TestSerialization.test_conv2d_nobias
python test/test_quantization.py TestSerialization.test_conv2d_graph
python test/test_quantization.py TestSerialization.test_conv2d_nobias_graph
```

Reviewers:

Subscribers:

Tasks:

Tags:

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

[ghstack-poisoned]
… increase coverage"


Summary:

1. adds support for testing BC on data format and numerics for graph mode
quantized modules
2. using the above, adds coverage for quantized conv2d on graph mode

Test Plan:

```
python test/test_quantization.py TestSerialization.test_conv2d_nobias
python test/test_quantization.py TestSerialization.test_conv2d_graph
python test/test_quantization.py TestSerialization.test_conv2d_nobias_graph
```

Reviewers:

Subscribers:

Tasks:

Tags:

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

[ghstack-poisoned]
… increase coverage"


Summary:

1. adds support for testing BC on data format and numerics for graph mode
quantized modules
2. using the above, adds coverage for quantized conv2d on graph mode

Test Plan:

```
python test/test_quantization.py TestSerialization.test_conv2d_nobias
python test/test_quantization.py TestSerialization.test_conv2d_graph
python test/test_quantization.py TestSerialization.test_conv2d_nobias_graph
```

Reviewers:

Subscribers:

Tasks:

Tags:

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

[ghstack-poisoned]
@codecov
Copy link

codecov bot commented Aug 28, 2020

Codecov Report

Merging #43524 into gh/vkuzo/131/base will decrease coverage by 0.00%.
The diff coverage is n/a.

Impacted file tree graph

@@                  Coverage Diff                  @@
##           gh/vkuzo/131/base   #43524      +/-   ##
=====================================================
- Coverage              69.34%   69.33%   -0.01%     
=====================================================
  Files                    378      378              
  Lines                  46698    46698              
=====================================================
- Hits                   32381    32380       -1     
- Misses                 14317    14318       +1     
Impacted Files Coverage Δ
torch/testing/_internal/expecttest.py 77.55% <0.00%> (-1.03%) ⬇️

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 c177d25...b2e469d. Read the comment docs.

@facebook-github-bot
Copy link
Contributor

This pull request has been merged in af4ecb3.

@facebook-github-bot facebook-github-bot deleted the gh/vkuzo/131/head branch September 1, 2020 14:17
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.

8 participants