Skip to content

Lora support for VLM Pipeline#3402

Merged
likholat merged 52 commits intoopenvinotoolkit:masterfrom
likholat:lora_for_vlm
Mar 13, 2026
Merged

Lora support for VLM Pipeline#3402
likholat merged 52 commits intoopenvinotoolkit:masterfrom
likholat:lora_for_vlm

Conversation

@likholat
Copy link
Contributor

@likholat likholat commented Feb 26, 2026

Description

Enables LoRa support for VLMPipeline

Continuous Batching case is already supported (because of Continuous Batching Pipeline reusage)

CVS-180080

Documentation

https://likholat.github.io/openvino.genai/

Checklist:

  • This PR follows GenAI Contributing guidelines.
  • Tests have been updated or added to cover the new code.
  • This PR fully addresses the ticket.
  • I have made corresponding changes to the documentation.

Copilot AI review requested due to automatic review settings March 6, 2026 18:16
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds LoRA adapter support to the OpenVINO GenAI VLMPipeline, enabling runtime adapter application while preserving adapter-owned states across generation and chat resets. This also updates benchmarking utilities and adds Python/C++ samples plus README guidance to demonstrate VLM + LoRA usage.

Changes:

  • Integrate LoRA adapter handling into VLMPipeline via adapter extraction from properties and AdapterController application during generation.
  • Extend who-what benchmark VLM loader/model paths to accept adapters/alphas.
  • Add new Python and C++ VLM LoRA samples and document how to run them.

Reviewed changes

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

Show a summary per file
File Description
tools/who_what_benchmark/whowhatbench/model_loaders.py Adds adapter plumbing for VLM GenAI pipeline and PEFT-based LoRA merging for HF visual-text models.
src/cpp/src/visual_language/pipeline_base.hpp Stores an optional AdapterController in the VLM pipeline base for reuse by implementations.
src/cpp/src/visual_language/pipeline.cpp Extracts adapters from properties, initializes/applies AdapterController, and preserves adapter state across resets.
src/cpp/src/lora/adapter.cpp Adds adapter path existence/extension validation for safetensors adapters.
samples/python/visual_language_chat/visual_language_lora.py New Python sample demonstrating VLM generation with and without LoRA adapters.
samples/python/visual_language_chat/README.md Documents the new Python LoRA sample and alpha interpretation.
samples/cpp/visual_language_chat/visual_language_lora.cpp New C++ sample demonstrating VLM generation with and without LoRA adapters.
samples/cpp/visual_language_chat/README.md Documents the new C++ LoRA sample and alpha interpretation.
samples/cpp/visual_language_chat/CMakeLists.txt Builds/installs the new C++ LoRA sample binary.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 6, 2026 19:46
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Contributor

Copilot AI left a comment

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 9 out of 9 changed files in this pull request and generated 4 comments.

@github-actions github-actions bot added the category: GGUF GGUF file reader label Mar 9, 2026
Copilot AI review requested due to automatic review settings March 9, 2026 11:27
@likholat likholat added this to the 2026.1 milestone Mar 9, 2026
Copy link
Contributor

Copilot AI left a comment

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 11 out of 11 changed files in this pull request and generated 4 comments.

Copy link
Contributor

Copilot AI left a comment

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 17 out of 17 changed files in this pull request and generated no new comments.

@likholat likholat requested review from Wovchena and sbalandi March 12, 2026 12:12
Co-authored-by: Vladimir Zlobin <vladimir.zlobin@intel.com>
Copilot AI review requested due to automatic review settings March 12, 2026 13:22
Copy link
Contributor

Copilot AI left a comment

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 17 out of 17 changed files in this pull request and generated 1 comment.

Comment on lines +175 to +181
def apply_peft_adapters(model, adapters, alphas, merged_adapter_name="merged_lora"):
adapters, alphas = normalize_lora_adapters_and_alphas(adapters, alphas)

from peft import PeftModel

adapter_names = ["adapter_0"]
model = PeftModel.from_pretrained(model, adapters[0], adapter_name=adapter_names[0])
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

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

apply_peft_adapters() calls normalize_lora_adapters_and_alphas(), which returns (None, None) when adapters is None, and then immediately indexes adapters[0]. If apply_peft_adapters() is called with adapters=None (easy to do from external callers since this is a utility), it will crash with a TypeError rather than a clear validation error.

Add an explicit check after normalization (e.g., raise ValueError or return the model unchanged) so the function’s behavior is well-defined for None adapters.

Copilot uses AI. Check for mistakes.
Copilot AI review requested due to automatic review settings March 13, 2026 12:16
Copy link
Contributor

Copilot AI left a comment

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 19 out of 19 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (1)

tools/who_what_benchmark/tests/test_cli_vlm.py:3

  • Path is imported but never used in this test module. Unused imports can break linting and add noise; please remove it.
import sys

Copilot AI review requested due to automatic review settings March 13, 2026 14:35
Copy link
Contributor

Copilot AI left a comment

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 19 out of 19 changed files in this pull request and generated 1 comment.

@likholat likholat added this pull request to the merge queue Mar 13, 2026
Merged via the queue into openvinotoolkit:master with commit eb33ce8 Mar 13, 2026
177 of 181 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

category: cmake / build Cmake scripts category: GGUF GGUF file reader category: GH Pages Docs Github Pages documentation category: LLM samples GenAI LLM samples category: LoRA Low rank adapters category: visual language Visual language pipeline category: VLM samples GenAI VLM samples category: WWB PR changes WWB Code Freeze

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants