Skip to content

speed up hardswish and hardsigmoid tests#38256

Closed
vkuzo wants to merge 3 commits intogh/vkuzo/63/basefrom
gh/vkuzo/63/head
Closed

speed up hardswish and hardsigmoid tests#38256
vkuzo wants to merge 3 commits intogh/vkuzo/63/basefrom
gh/vkuzo/63/head

Conversation

@vkuzo
Copy link
Copy Markdown
Contributor

@vkuzo vkuzo commented May 11, 2020

Stack from ghstack:

Summary:

Removes hypothesis to speed these tests up, as these tests were flagged as top slow
tests in CI. At the same time, combines the fbgemm and qnnpack test
cases together for better reuse.

Test Plan:

python test/test_quantization.py TestQuantizedOps.test_hardswish
python test/test_quantization.py TestQuantizedOps.test_qhardsigmoid

Reviewers:

Subscribers:

Tasks:

Tags:

Differential Revision: D21506831

Summary:

Removes hypothesis to speed these tests up, as these tests were flagged as top slow
tests in CI. At the same time, combines the fbgemm and qnnpack test
cases together for better reuse.

Test Plan:

```
python test/test_quantization.py TestQuantizedOps.test_hardswish
python test/test_quantization.py TestQuantizedOps.test_qhardsigmoid
```

Reviewers:

Subscribers:

Tasks:

Tags:

[ghstack-poisoned]
vkuzo added a commit that referenced this pull request May 11, 2020
Summary:

Removes hypothesis to speed these tests up, as these tests were flagged as top slow
tests in CI. At the same time, combines the fbgemm and qnnpack test
cases together for better reuse.

Test Plan:

```
python test/test_quantization.py TestQuantizedOps.test_hardswish
python test/test_quantization.py TestQuantizedOps.test_qhardsigmoid
```

Reviewers:

Subscribers:

Tasks:

Tags:

ghstack-source-id: 94bf814
Pull Request resolved: #38256
@vkuzo vkuzo requested review from malfet and supriyar May 11, 2020 18:37
Comment thread test/quantization/test_quantized_op.py Outdated
max_sides = (3, 5)
side_lens = (1, 7, 8)
torch_types = (torch.quint8, torch.qint8)
engines = ('fbgemm', 'qnnpack')
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe use @override_qengines instead?

Comment thread test/quantization/test_quantized_op.py Outdated

qY = torch.nn.quantized.functional.hardsigmoid(qX)
self.assertEqual(qY, qY_hat,
message="Hardsigmoid failed: {} vs. {}".format(qY, qY_hat))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Might help for debugging if we specify which backend this failed on.

@dr-ci
Copy link
Copy Markdown

dr-ci Bot commented May 11, 2020

💊 CI failures summary and remediations

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


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

ci.pytorch.org: 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.

See how this bot performed.

This comment has been revised 14 times.

@malfet
Copy link
Copy Markdown
Contributor

malfet commented May 11, 2020

Change looks good to me, but outside of CI environment test already finish in a reasonable amount of time:

$ python test/test_quantization.py TestQuantizedOps.test_hardswish TestQuantizedOps.test_qhardsigmoid -v
test_hardswish (quantization.test_quantized_op.TestQuantizedOps) ... /home/nshulga/git/pytorch/test/quantization/test_quantized_op.py:101: UserWarning: 0quantize_tensor_per_tensor_affine current rounding mode is not set to round-to-nearest-ties-to-even (FE_TONEAREST). This will cause accuracy issues in quantized models. (Triggered internally at  /pytorch/aten/src/ATen/native/quantized/affine_quantizer.cpp:25.)
  dtype=torch_type)
ok
test_qhardsigmoid (quantization.test_quantized_op.TestQuantizedOps) ... ok

----------------------------------------------------------------------
Ran 2 tests in 0.619s

OK

@malfet
Copy link
Copy Markdown
Contributor

malfet commented May 11, 2020

I've tried selecting different profiles, as defined in https://github.com/pytorch/pytorch/blob/master/torch/testing/_internal/common_utils.py#L659 but still can not get to 120 sec times reported during CircleCI runs

Summary:

Removes hypothesis to speed these tests up, as these tests were flagged as top slow
tests in CI. At the same time, combines the fbgemm and qnnpack test
cases together for better reuse.

Test Plan:

```
python test/test_quantization.py TestQuantizedOps.test_hardswish
python test/test_quantization.py TestQuantizedOps.test_qhardsigmoid
```

Reviewers:

Subscribers:

Tasks:

Tags:

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

[ghstack-poisoned]
vkuzo added a commit that referenced this pull request May 11, 2020
Summary:

Removes hypothesis to speed these tests up, as these tests were flagged as top slow
tests in CI. At the same time, combines the fbgemm and qnnpack test
cases together for better reuse.

Test Plan:

```
python test/test_quantization.py TestQuantizedOps.test_hardswish
python test/test_quantization.py TestQuantizedOps.test_qhardsigmoid
```

Reviewers:

Subscribers:

Tasks:

Tags:

ghstack-source-id: c510f9f
Pull Request resolved: #38256
Comment thread test/quantization/test_quantized_op.py Outdated
if torch.backends.quantized.engine == 'qnnpack' and torch_type != torch.quint8:
continue

with override_quantized_engine(engine):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This can be removed as well. The override will take care of it at the test level.

@malfet
Copy link
Copy Markdown
Contributor

malfet commented May 12, 2020

I know why tests can be slow when run by CI, but fast during single runs:
hu.array_shapes(1, 8, 1, 8) returns randomized tensor shape which can be as large as 16 million elements (i.e. 8**8)
During individual test runs those values are always the same(since we fix the seed), and by chance quite small.
But since the seed is not reset between the runs it can generate a very different (and apparently quite large) tensor shapes when run in sequence with other tests.

@malfet
Copy link
Copy Markdown
Contributor

malfet commented May 12, 2020

@vkuzo you might need to rebase your change against latest master as I've landed a PR that adds limit to max number of element for hypothesis generated tensors (and it touches the same files are your diff)

@vkuzo
Copy link
Copy Markdown
Contributor Author

vkuzo commented May 12, 2020

I know why tests can be slow when run by CI, but fast during single runs:
hu.array_shapes(1, 8, 1, 8) returns randomized tensor shape which can be as large as 16 million elements (i.e. 8**8)
During individual test runs those values are always the same(since we fix the seed), and by chance quite small.
But since the seed is not reset between the runs it can generate a very different (and apparently quite large) tensor shapes when run in sequence with other tests.

thanks for the find, makes sense!

Summary:

Removes hypothesis to speed these tests up, as these tests were flagged as top slow
tests in CI. At the same time, combines the fbgemm and qnnpack test
cases together for better reuse.

Test Plan:

```
python test/test_quantization.py TestQuantizedOps.test_hardswish
python test/test_quantization.py TestQuantizedOps.test_qhardsigmoid
```

Reviewers:

Subscribers:

Tasks:

Tags:

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

[ghstack-poisoned]
vkuzo added a commit that referenced this pull request May 12, 2020
Summary:

Removes hypothesis to speed these tests up, as these tests were flagged as top slow
tests in CI. At the same time, combines the fbgemm and qnnpack test
cases together for better reuse.

Test Plan:

```
python test/test_quantization.py TestQuantizedOps.test_hardswish
python test/test_quantization.py TestQuantizedOps.test_qhardsigmoid
```

Reviewers:

Subscribers:

Tasks:

Tags:

ghstack-source-id: 85abe95
Pull Request resolved: #38256
@facebook-github-bot
Copy link
Copy Markdown
Contributor

This pull request has been merged in ff76de8.

@facebook-github-bot facebook-github-bot deleted the gh/vkuzo/63/head branch May 17, 2020 14:18
laurentdupin pushed a commit to laurentdupin/pytorch that referenced this pull request Apr 24, 2026
Summary:
Pull Request resolved: pytorch#38256

Removes hypothesis to speed these tests up, as these tests were flagged as top slow
tests in CI. At the same time, combines the fbgemm and qnnpack test
cases together for better reuse.

Test Plan:
```
python test/test_quantization.py TestQuantizedOps.test_hardswish
python test/test_quantization.py TestQuantizedOps.test_qhardsigmoid
```

Imported from OSS

Differential Revision: D21506831

fbshipit-source-id: 9ff70e4ec7ae30b6948fe808878f0187e631f4d8
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.

5 participants