[Torch] INT2 symmetric decompression support#3971
Draft
ljaljushkin wants to merge 1 commit intoopenvinotoolkit:developfrom
Draft
[Torch] INT2 symmetric decompression support#3971ljaljushkin wants to merge 1 commit intoopenvinotoolkit:developfrom
ljaljushkin wants to merge 1 commit intoopenvinotoolkit:developfrom
Conversation
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.
Changes
INT2SymmetricWeightsDecompressorinnncf/torch/quantization/layers.py:stores signed int2 values [-2, 1] as unsigned uint2 [0, 3] using zero point of 2;
four uint2 values are packed per uint8 byte via
pack_uint2/unpack_uint2.pack_uint2andunpack_uint2functions inquantize_functions.pyforpacking/unpacking 2-bit values in uint8 containers.
strip.pyto handle INT2 decompressor during model stripping withStripFormat.DQ.Reason for changes
Support INT2 (2-bit) symmetric weight compression of PyTorch models in NNCF,
enabling mixed-precision quantization (e.g., average 3-bit with some layers at 2-bit
and others at 4-bit) for LLM compression with distillation-based QAT+LoRA.
Related tickets
([PyTorch FE] u2 decompression subgraph support)
Tests
tests/torch/quantization/test_symmetric_2bit.py— 15 tests coveringQuantizeSymmetric and QuantizeSymmetricTorch at 2-bit: scale conventions,
level count verification, zero-maps-to-zero, gradient flow, input range formulas
tests/torch/function_hook/quantization/test_weights_compression.py::test_pack_uint2—uint2 pack/unpack round-trip
tests/torch/function_hook/quantization/test_weights_compression.py::test_int2_symmetric_weights_decompressor—INT2 decompressor correctness