Repository navigation
Conversation
Make dtype conversion of parent models update the activation dtype for 8-bit and 4-bit embeddings, including already quantized weights. Signed-off-by: Afloat <ShuffleMonkey@163.com>
Signed-off-by: Afloat <ShuffleMonkey@163.com>
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.
Summary
Quantized embeddings store their output dtype when they are constructed. Converting a containing model with
.half(),.bfloat16(),.float(), or.to(dtype=...)currently leaves that attribute unchanged. An embedding constructed in float32 consequently still returns float32 after the next linear layer has been converted, and the model fails with a dtype mismatch.Add a shared embedding base that updates the output dtype after a successful module conversion. The existing 8-bit and 4-bit dequantization paths consume the updated dtype. Packed int8/uint8 weights retain their storage dtype, and the state dictionary format is unchanged.
Validation
Sequential(embedding, linear)models take two SGD steps; outputs, linear gradients, and updated parameters match a floating-point embedding reference built from the dequantized weights.The repository's actual CPU extension was compiled with its CMake CPU backend (AVX2), and loaded with PyTorch 2.14.0+cpu. These results cover default packed int8/uint8 storage; floating-point packed 4-bit storage conversions are a separate existing issue.
Exact production head:
879f512b0d014cb53c3cacb6817803c92e09e75d.https://github.com/Afloat16/bitsandbytes/actions/runs/43307725418