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.
Problem
The native CPU blockwise kernels read codebook and absmax pointers as contiguous float arrays. A valid strided codebook or scale tensor therefore produces different values from its contiguous copy. This also affects restored quantized weights and CPU Adam8bit state whose metadata is stored in views.
Changes
Make the codebook contiguous before CPU quantization, and make the codebook and scales contiguous before CPU dequantization. These are local kernel arguments: caller tensors and QuantState metadata retain their original values, storage and identity. Already contiguous metadata, including nonzero storage offsets, keeps the existing path.
Add tests for FP16, BF16 and FP32, strided/offset metadata, partial blocks, caller-provided quantization outputs, saved quantized weights used in a linear layer, and four actual Adam8bit training steps.
Validation
Native CPU source build and tests, source
11527a20279abe05140c9c154eefedba854acbdb:git diff --checkpassed.Ubuntu 24.04, Python 3.12, PyTorch 2.14.0+cpu. Built the repository's native CPU extension with CMake; no replacement kernel or numerical stub was used. The tests compare actual encoded values, decoded values, saved-weight linear outputs and optimizer continuation.
This is limited to CPU blockwise metadata handling. The existing LUT discretization and unsupported CPU
dequantize_blockwise.outoverload are unchanged; final fixtures exercise exact interior values and the supported dequantization entry point. GPU execution and model-quality improvements are not claimed.