Repository navigation
Fix INT8 weight-gradient quantization and CUDA operand layout - #2115
Open
devinhuang2001 wants to merge 1 commit into
Open
devinhuang2001 wants to merge 1 commit into
devinhuang2001 wants to merge 1 commit into
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.
Fixes #2112
MatMul8bitLt.backward scales row-quantized grad_output with column statistics. Use the column-quantized tensor that matches those statistics.
The CUDA path also needs CAt.t() materialized contiguously: its int8 GEMM passes raw pointers and shape-derived leading dimensions without honoring transpose strides. On a T4, correcting only the quantization pair still gives a 1.47 relative weight-gradient error; making the second operand contiguous reduces the single-operator error to 0.0090.
Adds 16 regression cases covering 2D/3D inputs, thresholds 0/6, input gradients enabled/disabled, and both bnb.matmul and Linear8bitLt. The oracle computes grad_output.T @ input in fp32 with deliberately different gradient-column scales.
Validation on Tesla T4, PyTorch 2.11.0+cu130, source baseline a616886 (using the packaged CUDA 13.0 native library):
The full test suite and other accelerator backends were not run.