Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mx FP Quantization About Subnorm #2106

Open
Jzz24 opened this issue Jan 2, 2025 · 0 comments
Open

Mx FP Quantization About Subnorm #2106

Jzz24 opened this issue Jan 2, 2025 · 0 comments

Comments

@Jzz24
Copy link

Jzz24 commented Jan 2, 2025

When quantizing Mx fp, the quantization scales of subnormal and normal values ​​should be different. Why does L394 clip to min_exp? I understand that it should clip to 1.

Looking forward to your reply

if exp_bits != 0:
    private_exp = torch.floor(torch.log2(torch.abs(A) + (A == 0).type(A.dtype)))

    # #The minimum representable exponent for 8 exp bits is -126
    # min_exp = -(2 ** (exp_bits - 1)) + 2
    # private_exp = private_exp.clip(min=min_exp)

    # subnorm and norm part has different scale
    # private_exp >= 1, norm scale
    # private_exp < 1, subnorm scale
    private_exp = private_exp.clip(min=1.0)
else:
    private_exp = None

image

https://github.com/intel/neural-compressor/blob/master/neural_compressor/torch/algorithms/mx_quant/utils.py#L394
Image source

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant