Fix truncated FP4 constant in Triton dequantize_fp4_tree - #2026
Merged
matthewdouglas merged 3 commits intoJul 29, 2026
Merged
Conversation
The magnitude of the smallest nonzero FP4 level (codes 0b0001/0b1001) was
written as 0.00520833, which rounds to a different float32 (0x3BAAAAA4)
than every other FP4 table in the repository. The CUDA kernel, CPU kernel,
4-bit GEMM LUT, and the get_4bit_type("fp4") Python table all use
1/192 = 0.005208333333 (0x3BAAAAAB). Use the full-precision literal so the
Triton backend agrees with the other backends bit-for-bit.
Fixes bitsandbytes-foundation#2025
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
Member
|
Thanks. This is reasonable. I can merge it if you'll fix the end of line issue from the lint check. |
Contributor
Author
|
Thanks @matthewdouglas! Fixed the missing end-of-file newline that ruff (W292) flagged — should be green now. |
matthewdouglas
merged commit Jul 29, 2026
a2b90e6
into
bitsandbytes-foundation:main
86 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
dequantize_fp4_treein the Triton backend writes the smallest nonzero FP4 magnitude (4-bit codes0b0001/0b1001) as the literal0.00520833. That rounds to0x3BAAAAA4in float32, which is 7 ULP away from the value every other FP4 table in the repo uses:csrc/kernels.cufp4_dequantization_lut0.005208333333f0x3BAAAAABcsrc/gemm_4bit_common.cuhFP4_LUT_F320.005208333333f0x3BAAAAABcsrc/cpu_ops.cppfp4_lut/ AVX-512 LUT0.005208333333f0x3BAAAAABfunctional.pyget_4bit_type("fp4")0.0625 / 120x3BAAAAABbackends/triton/kernels_4bit.py(before)0.005208330x3BAAAAA4The intended value is
1/192(0.0625 / 12: the FP4 subnormal0.0625normalized by the format absmax of 12). This PR restores the full-precision literal so the Triton/XPU path dequantizes codes 1 and 9 bit-for-bit identically to the CUDA and CPU backends.One-character-class change; no behavior change for any other code.
Fixes #2025
🤖 Generated with Claude Code