Repository navigation
Conversation
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.
Linear8bitLt.to()moves its cached INT8 weights and row scales when called on the layer directly. Moving a parent module uses PyTorch's recursive_applyinstead. After a forward pass,model.to("cpu")can therefore leave both tensors on the GPU even though the layer's weight reports CPU. The row scales returned bystate_dict()are also still on the GPU.Handle cached state during
_applyso direct and parent-module moves share the same path. Keep the INT8 cache aliased to the moved weight when it already holds the quantized data, preserve the scale dtype, and drop input-dependent outlier indices left on the previous device. This extends the direct-layer movement covered by #1769.On an A10, a randomly initialized Qwen3-0.6B checkpoint loaded through Transformers with
BitsAndBytesConfig(load_in_8bit=True, llm_int8_threshold=0.0)had 196 quantized projections. After moving the model to CPU, the base revision retained 441,778,176 bytes (421.3125 MiB) of cached INT8 weights and scales on the GPU. With the fix, all 196 caches and all checkpoint scales moved to CPU. After moving back to GPU, the logits matched the original GPU output exactly. A second CPU forward also exactly reproduced the first CPU result.The regression test exercises a nested layer with both INT8 and retained floating-point weights. Both new cases failed on the base revision and passed on an RTX 3080 and an A10 with the fix. The full
tests/test_linear8bitlt.pyrun on each GPU finished with 55 passed and 2 expected failures.