Fix float8 zero scale quantization - #4714
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/ao/4714
Note: Links to docs will display an error until the docs builds have been completed. ❗ 1 Active SEVsThere are 1 currently active SEVs. If your PR is affected, please view them below: This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
Hi @Rajioba1! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
|
I do not have permission to apply upstream labels from the fork. Could a maintainer please add the appropriate module label? I believe module: core fits this quant primitive / Float8Tensor change. |
|
I have signed the CLA |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
Summary
Fixes #4713.
Float8Tensor.from_hp currently produces NaN qdata and NaN dequantized output for all-zero tensors because _choose_scale_float8 returns a zero scale for zero blocks. The later affine float8 quantization path divides 0 by 0.
This clamps the amax value to a small positive floor before dividing by the float8 max, matching the nearby floatx scale helper pattern.
Test Plan