Skip to content

Torch strip register parametrization and export image-text-to-text models after training. - #4288

Open
andreyanufr wants to merge 15 commits into
openvinotoolkit:developfrom
andreyanufr:aanuf/torch_strip_register_parametrization
Open

andreyanufr wants to merge 15 commits into
openvinotoolkit:developfrom
andreyanufr:aanuf/torch_strip_register_parametrization

Conversation

@andreyanufr

Copy link
Copy Markdown
Collaborator

Changes

  1. Added new option for representation compressed torch model before conversion to OV format. register_parametrization was used.

  2. Changed the export of torch models after training in QAD for 2,3 bits: it is possible to convert some image-text-to-text models after QAD now.

@github-actions github-actions Bot added NNCF PT Pull requests that updates NNCF PyTorch API Public API-impacting changes labels Oct 27, 2026
2) Changed export of torch models to ov in QAD.
2) Added test for new strip.
@andreyanufr andreyanufr changed the title Aanuf/torch strip register parametrization Torch strip register parametrization and export image-text-to-text models after training. Oct 28, 2026
@andreyanufr
andreyanufr marked this pull request as ready for review October 28, 2026 13:04
Copilot AI balanced review requested due to automatic review settings October 28, 2026 13:04
@andreyanufr
andreyanufr requested a review from a team as a code owner October 28, 2026 13:04

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.

🟡 Changes recommended

Export failures can silently reuse stale IR, and missing AWQ activation-scaling hooks can produce incorrect outputs, so exported models may not match the restored checkpoint.

5 open issues
What changed in this PR

Adds parametrization-based weight decompression to NNCF’s PyTorch stripping API and extends the 2/3-bit QAD example to export supported image-text-to-text models to OpenVINO.

Changes:

  • Introduces StripFormat.RP to attach decompressors directly to module weights.
  • Adds multimodal checkpoint restoration, language-model repacking, and INT8 compression of other model components.
  • Adds tests for RP inference, tied weights, in-place stripping, and models without compression hooks.
File Description
tests/​torch/​function_hook/​quantization/​strip/​test_strip_parametrization.py Adds RP stripping and output-equivalence tests.
src/​nncf/​torch/​function_hook/​strip.py Implements parametrization-based weight decompression.
src/​nncf/​parameters.py Exposes and documents StripFormat.RP.
examples/​llm_compression/​torch/​distillation_qad_with_lora_2_3_bit/​main.py Extends QAD export and repacking to supported multimodal models.

Review effort: Balanced

Comment on lines +335 to +337
language_model = extract_causal_lm_from_visual(model)
language_model = load_checkpoint(language_model, ckpt_file)
nncf.strip(language_model, do_copy=False, strip_format=StripFormat.RP)
Comment on lines +344 to +347
try:
export_from_model(model, ir_dir, device="cpu")
except Exception as e:
print(f"Failed to export the model or part of the model, but repacking will still proceed: {e}")

if is_visual:
model = AutoModelForMultimodalLM.from_pretrained(pretrained, device_map="cpu", torch_dtype=torch.float32)
if "gemma" in pretrained.lower():
targets = [
(module, attr_name, decompressor_per_param[param])
for module in model.modules()
for attr_name, param in module.named_parameters(recurse=False)
Comment on lines +54 to +57
CompressWeightsMode.INT4_SYM,
CompressWeightsMode.INT4_ASYM,
CompressWeightsMode.INT8_SYM,
CompressWeightsMode.INT8_ASYM,

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 NNCF PT Pull requests that updates NNCF PyTorch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants