Repository navigation
Conversation
klin2024
force-pushed
the
dev/klin/quantstate-nested-offset-dtype
branch
from
November 18, 2026 16:08
4664b7d to
7415026
Compare
QuantState.from_dict rebuilt nested_offset with torch.tensor(float), which follows the global default dtype. Loaders that build models under torch.set_default_dtype(torch.bfloat16) (or float16) therefore got a rounded offset, and every dequantized absmax of a compress_statistics=True weight shifted by the rounding error. Build it with nested_dtype instead. Signed-off-by: Lin, KuanTing <Kuanting.Lin@amd.com>
klin2024
force-pushed
the
dev/klin/quantstate-nested-offset-dtype
branch
from
November 18, 2026 16:15
7415026 to
a91783e
Compare
klin2024
marked this pull request as ready for review
November 18, 2026 16:35
This branch has not been deployed
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.
QuantState.from_dictrebuildsnested_offsetwithtorch.tensor(float(...)), which follows the global default dtype. Loaders that callParams4bit.from_prequantizedundertorch.set_default_dtype(torch.bfloat16)get a rounded offset (0.048583984375instead of0.04863208532333374in one case), which shifts every dequantized absmax of acompress_statistics=Trueweight. On a 32B NF4 text encoder this gave about 0.6% relative output drift versus the model before serialization.Fix: build the offset with the stored
nested_dtype, the dtype it was computed in.The new test round-trips
as_dict/from_dictunder fp16 and bf16 default dtypes and checks that the offset and the dequantized weight are bit-exact. On CPU and CUDA (H100) it fails before the fix (8/8) and passes after.