Skip to content

Added support of 2-3 bit symmetric mode to LoRA-QAT - #4158

Open
andreyanufr wants to merge 18 commits into
openvinotoolkit:developfrom
andreyanufr:aanuf/2_3_bit_training
Open

andreyanufr wants to merge 18 commits into
openvinotoolkit:developfrom
andreyanufr:aanuf/2_3_bit_training

Conversation

@andreyanufr

@andreyanufr andreyanufr commented Jul 30, 2026 •

Copy link
Copy Markdown
Collaborator

Changes

  1. LoRA-QAT now support two new modes: CompressWeightsMode.INT3_SYM and CompressWeightsMode.INT2_SYM.

  2. New function repack_weights was added to repack 4-8 bit weights to lower bit representation if possible.

Reason for changes

Support of 2-3 bit in compression in QAT and pytorch backend.

Related tickets

CVS-180191

Tests

In progress.

Weight compression - success

@github-actions github-actions Bot added NNCF OpenVINO Pull requests that updates NNCF OpenVINO API Public API-impacting changes labels Jul 30, 2026
@github-actions github-actions Bot added the documentation Improvements or additions to documentation label Sep 21, 2026
@andreyanufr
andreyanufr marked this pull request as ready for review September 24, 2026 14:57
Copilot AI lite review requested due to automatic review settings September 24, 2026 14:57
@andreyanufr
andreyanufr requested a review from a team as a code owner September 24, 2026 14:57

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.

Copilot review overview

🟡 Changes recommended

Unresolved critical and moderate issues remain in low-bit stripping, OpenVINO repacking, and the example workflow.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 2 High severity · 2 Medium severity · 2 Low severity

Open (6)
What changed in this PR

Adds INT2/INT3 symmetric LoRA-QAT support and OpenVINO weight repacking.

Changes:

  • Adds 2/3-bit quantization mappings and strip validation.
  • Implements and exports repack_weights.
  • Adds tests, models, and a distillation QAT example with documentation.
File Summary and review notes
tests/​openvino/​native/​test_model_repacking.py Adds repacking coverage; assertions should validate graph correctness and numerical equivalence (nit, 2 votes).
tests/​openvino/​native/​models.py Adds a repacking test model.
src/​nncf/​torch/​function_hook/​strip.py 2/3-bit DQ still uses 4-bit decompression and packing (critical, 3 votes).
src/​nncf/​quantization/​quantize_model.py Exposes the repacking API.
src/​nncf/​quantization/​algorithms/​weight_compression/​torch_backend.py Adds INT2/INT3 LoRA quantization mappings.
src/​nncf/​quantization/​algorithms/​weight_compression/​openvino_backend.py Shape heuristic skips valid signed compressed weights, including 1-D tensors (critical, 2 votes).
src/​nncf/​quantization/​algorithms/​weight_compression/​algorithm.py Coordinates repacking; direct print calls should use the project logger (nit, 4 votes).
src/​nncf/​quantization/​__init__.py Exports repack_weights.
src/​nncf/​openvino/​quantization/​quantize_model.py Provides the OpenVINO repacking implementation.
src/​nncf/​__init__.py Exports the public API.
examples/​llm_compression/​torch/​distillation_qat_with_lora_2_3_bit/​requirements.txt Defines example dependencies.
examples/​llm_compression/​torch/​distillation_qat_with_lora_2_3_bit/​README.md Documents the example workflow.
examples/​llm_compression/​torch/​distillation_qat_with_lora_2_3_bit/​main.py Omits gate_proj equalization (moderate, 2 votes), skips meta-device weights (moderate, 3 votes), drops partial accumulation gradients (moderate, 1 vote), and does not return its documented metric (nit, 1 vote).
.ci/​cspell_dict.txt Adds example vocabulary.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +136 to +138
if len(shape) == 1 or shape[-1] == 1:
# Probably zero point
return False, 0, 0
Comment thread src/nncf/torch/function_hook/strip.py
Comment on lines +495 to +497
if w.device.type != "meta":
return w.data
return None
Comment thread src/nncf/quantization/algorithms/weight_compression/algorithm.py Outdated
Comment on lines +34 to +38
repacked_model = nncf.repack_weights(model)

element_types = get_constant_element_types(repacked_model)
assert ov.Type.u3 in element_types, "Expected u3 constant after repacking"
assert ov.Type.u2 in element_types, "Expected u2 constant after repacking"
2) Added arg for deterministic cuda execution. This arg is optional because it can slow down the training.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

API Public API-impacting changes documentation Improvements or additions to documentation NNCF OpenVINO Pull requests that updates NNCF OpenVINO

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants