Skip to content

Add pack int2 functions#4112

Closed
AlexanderDokuchaev wants to merge 4 commits into
openvinotoolkit:developfrom
AlexanderDokuchaev:ad/fn_pack_int2
Closed

Add pack int2 functions#4112
AlexanderDokuchaev wants to merge 4 commits into
openvinotoolkit:developfrom
AlexanderDokuchaev:ad/fn_pack_int2

Conversation

@AlexanderDokuchaev

@AlexanderDokuchaev AlexanderDokuchaev commented Jun 23, 2026

Copy link
Copy Markdown
Collaborator

Changes

Add functions for compression to int2: pack_uint2, pack_int2, unpack_uint2, unpack_int2
Move all tests for int4 compression to corresponding file tests/torch/quantization/test_functions.py

Reason for changes

Related tickets

Tests

@github-actions github-actions Bot added the NNCF PT Pull requests that updates NNCF PyTorch label Jun 23, 2026
@AlexanderDokuchaev AlexanderDokuchaev marked this pull request as ready for review June 23, 2026 07:47
@AlexanderDokuchaev AlexanderDokuchaev requested a review from a team as a code owner June 23, 2026 07:47
Copilot AI review requested due to automatic review settings June 23, 2026 07:47

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds bit-packing utilities for 2-bit integer quantization to the PyTorch quantization helpers, and consolidates/extends the test coverage for 2-bit and 4-bit pack/unpack functions.

Changes:

  • Implement pack_uint2, unpack_uint2, pack_int2, unpack_int2 in quantize_functions.py.
  • Expand pack/unpack docstrings for int4/uint4 to document bit layout more clearly.
  • Move and extend pack/unpack tests into tests/torch/quantization/test_functions.py, removing the duplicated int4 pack/unpack tests from the weights-compression test module.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
src/nncf/torch/quantization/quantize_functions.py Adds 2-bit pack/unpack implementations and improves packing docstrings.
tests/torch/quantization/test_functions.py Adds consolidated pack/unpack tests (round-trip, layout, dtype validation).
tests/torch/function_hook/quantization/test_weights_compression.py Removes duplicated int4 pack/unpack tests after consolidation.

Comment thread src/nncf/torch/quantization/quantize_functions.py
Comment thread src/nncf/torch/quantization/quantize_functions.py
Comment thread tests/torch/quantization/test_functions.py

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

Comment thread src/nncf/torch/quantization/quantize_functions.py
Comment thread src/nncf/torch/quantization/quantize_functions.py
Comment thread src/nncf/torch/quantization/quantize_functions.py Outdated
Comment thread src/nncf/torch/quantization/quantize_functions.py Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

NNCF PT Pull requests that updates NNCF PyTorch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants