Bad Performance with default_observer for quantization
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 17.9k
- Forks
- 7.3k
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 13
Description
❓ Questions and Help
Please note that this issue tracker is not a help form and this issue will be closed.
We have a set of listed resources available on the website. Our primary means of support is our discussion forum:
I tried to quantize mobilenet v2 from float model file.
I found defaut_observer is used for activation in QConfig.
https://github.com/pytorch/vision/blob/master/torchvision/models/quantization/utils.py#L27
I got bad imagenet classification accuracy with this configuration.
https://pytorch.org/docs/stable/quantization.html
Here, the following configuration is recommended.
qconfig = torch.quantization.get_default_qconfig('qnnpack')
this uses HistogramObserver.
qconfig = QConfig(activation=HistogramObserver.with_args(reduce_range=False),
weight=default_weight_observer)
When I changed default observer to HistogramObserver, I got much better accuracy.
I think the following configuration should be changed as recommended in official docs.
https://github.com/pytorch/vision/blob/master/torchvision/models/quantization/utils.py#L27
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at torchvision/models/quantization/utils.py around line 27 and compare its activation observer with the documented qconfig using HistogramObserver. Check the MobileNetV2 quantization configuration and the linked quantization documentation, then verify that the observer change produces the expected accuracy improvement.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- computer-vision, machine-learning
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100