pytorch/test/quantization/core
Tijmen Blankevoort e3b3431c42 Fix for HistogramObserver (#129387)
Summary:
There were two problems with the HistogramObserver:
1. It does not work when someone passes a batch_size 1, tensor_size 1 data-point.
2. The Histogram doesn't seem to actually update if the range of the new x falls within the old one

These issues were both fixed.

On top of this, I greatly simplified the logic for the histogram updating. Now, it doesn't do the downsampling anymore, which saves a ton of memory and code. The accuracy can still be controlled with the upsampling ratio. This ratio was also too high for the accuracy we generally need here, I reduced the default for this.
Also the code is cleaner now, much easier to follow what's happening.

test_histogram_observer_same_inputs was likely wrong - If I pass 0s and 1s to my histogramobserver, I want them to actually count! The current test now thinks it's good to discard and ignore these values.

Test Plan: You can run the included tests.

Differential Revision: D58931336

Pull Request resolved: https://github.com/pytorch/pytorch/pull/129387
Approved by: https://github.com/jerryzh168
2024-07-02 15:41:44 +00:00
..
experimental [Ez][BE]: Enable new stable ruff rules (#129825) 2024-07-02 14:47:10 +00:00
__init__.py
test_backend_config.py
test_docs.py Revert "[BE][Easy] use pathlib.Path instead of dirname / ".." / pardir (#129374)" 2024-06-29 00:47:15 +00:00
test_quantized_functional.py
test_quantized_module.py Add testing and fix weights_only load for quantized types and nn.Parameters with python attrs (#124330) 2024-04-23 04:13:26 +00:00
test_quantized_op.py [Ez][BE]: Enable new stable ruff rules (#129825) 2024-07-02 14:47:10 +00:00
test_quantized_tensor.py [quant] Make per_group and per_token quant match torch.fake_quantize (#125781) 2024-05-14 18:18:54 +00:00
test_top_level_apis.py
test_utils.py
test_workflow_module.py Fix for HistogramObserver (#129387) 2024-07-02 15:41:44 +00:00
test_workflow_ops.py Add testing and fix weights_only load for quantized types and nn.Parameters with python attrs (#124330) 2024-04-23 04:13:26 +00:00