Clean up arglist for choose_qparams_affine_with_min_max#3808
Conversation
Remove preserve_zero and zero_point_domain parameters from choose_qparams_affine_with_min_max and keep only the code path for preserve_zero=True and zero_point_domain=ZeroPointDomain.INT, similar to other cleanups in the file. Fixes pytorch#3747
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/ao/3808
Note: Links to docs will display an error until the docs builds have been completed. ⏳ No Failures, 2 PendingAs of commit dec9c9b with merge base a996516 ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
thanks, can you check if the tests and all users of e.g. tutorials/calibration_flow/awq_like.py tutorials/calibration_flow/gptq_like.py tutorials/calibration_flow/static_quant.py ao/test/quantization/test_observer.py Line 43 in 0a5638a |
The cleaned-up choose_qparams_affine_with_min_max now always returns a tensor zero_point, so observers that use ZeroPointDomain.NONE (e.g., for float8 symmetric quantization) need to post-process the result to return None for zero_point. This maintains backward compatibility for: - AffineQuantizedMinMaxObserver.calculate_qparams() - AffineQuantizedMSEObserver.loss_fn() - AffineQuantizedMSEObserver.calculate_qparams() Refs pytorch#3747
|
Thanks for the review @jerryzh168! I checked the files you mentioned: Tutorials work correctly: tutorials/calibration_flow/awq_like.py - Uses AffineQuantizedMinMaxObserver without preserve_zero or zero_point_domain I pushed a fix that handles ZeroPointDomain.NONE in the observers by setting zero_point=None after calling the simplified choose_qparams_affine_with_min_max. This maintains backward compatibility while keeping the function clean. The observers still accept zero_point_domain in their constructors, but choose_qparams_affine_with_min_max no longer needs those parameters. |
I think we probably need to add some assert to make sure the also thanks for checking all these tests |
Per @jerryzh168 review: 1. Add deprecation warnings in AffineQuantizedObserverBase.__init__ when preserve_zero != True or zero_point_domain != ZeroPointDomain.INT 2. Remove ZeroPointDomain.NONE handling from observer methods - callers should use 'scale, _ = calculate_qparams()' to ignore zero_point 3. Update tests to remove ZeroPointDomain.NONE usage and ignore zero_point where not needed (symmetric quantization) Refs pytorch#3747
|
Pushed a commit addressing both points:
|
|
Hi @jerryzh168 |
| Mostly same as :func:`~torchao.quantization.quant_primitives.choose_qparams_affine`. with one | ||
| difference: instead of passing in `input` Tensor and use that to calculate min_val/max_val | ||
| and then scale/zero_point, we pass in min_val/max_val directly | ||
| min_val (torch.Tensor): minimum values derived from calibration data |
There was a problem hiding this comment.
nit: might be better to revert this change so we don't duplicate docs I think
jerryzh168
left a comment
There was a problem hiding this comment.
LGTM, thanks for the fix! please revert the doc change for choose_qparams_affine_with_min_max to not duplicate the docs
- Revert documentation changes in choose_qparams_affine_with_min_max to avoid duplication - Restore ZeroPointDomain.NONE handling in observers for float8 symmetric quantization - Add zero_point_domain=ZeroPointDomain.NONE to TestLinearObserver tests - Fix unused import warning and test failures Refs pytorch#3747
|
@jerryzh168! 👋 Thanks for the review! I've addressed all the feedback and fixed the CI failures: Changes Made:
What Changed: All local linter checks pass:
The CI checks don't seem to have started yet. Could you help trigger a rerun? Thanks! |
|
Could you please add the appropriate PR label? The "PR Label Check" was one of the CI failures. Thanks! |
|
@mohammed-saalim I added the label, but want to check, do you also have permission to add labels? |
|
Thanks @jerryzh168! All checks have passed now! Regarding label permissions - no, I don't have permission to add labels. As a first-time contributor to the repo, I only have read/write access to my fork. |
choose_qparams_affine_with_min_max
Fixes #3747
This PR removes preserve_zero and
zero_point_domainparameters from choose_qparams_affine_with_min_max, keeping only the code path forpreserve_zero=Trueandzero_point_domain=ZeroPointDomain.INT, similar to other cleanups in the file (using _choose_qparams_affine as reference).Changes
zero_point_domainparameter (always INT now)