Skip to content
Open
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
7b3ad31
Introduce add_extension to genai.
xipingyan Nov 3, 2025
2f60301
add draft test.
xipingyan Nov 5, 2025
80efe54
Update src/python/openvino_genai/py_openvino_genai.pyi
xipingyan Nov 5, 2025
4a02c8e
Update src/python/openvino_genai/__init__.pyi
xipingyan Nov 5, 2025
31078ab
Update tests/python_tests/test_add_extension.py
xipingyan Nov 5, 2025
281fe8c
Update tests/python_tests/test_add_extension.py
xipingyan Nov 5, 2025
ad64976
Merge branch 'master' into xp/introduce_add_extention_to_genai
xipingyan Nov 5, 2025
e449070
Update src/python/openvino_genai/py_openvino_genai.pyi
xipingyan Nov 5, 2025
4f60a60
Update src/cpp/include/openvino/genai/generation_config.hpp
xipingyan Nov 5, 2025
698e5ec
Update generation_config.hpp
xipingyan Nov 5, 2025
8c56ca8
Update tests/python_tests/test_add_extension.py
xipingyan Nov 5, 2025
c1e0a7c
Update src/python/py_openvino_genai.cpp
xipingyan Nov 5, 2025
57bd6a1
Update tests/python_tests/test_add_extension.py
xipingyan Nov 5, 2025
a4ef9c8
Update tests/python_tests/test_add_extension.py
xipingyan Nov 5, 2025
7260493
Update src/cpp/include/openvino/genai/generation_config.hpp
xipingyan Nov 10, 2025
689b08c
Get tokenizer so path.
xipingyan Nov 10, 2025
12e53a1
Merge branch 'master' into xp/introduce_add_extention_to_genai
xipingyan Nov 10, 2025
072b0b0
Update tests/python_tests/test_add_extension.py
xipingyan Nov 10, 2025
c05b092
Update tests/python_tests/test_add_extension.py
xipingyan Nov 10, 2025
7e1ac0f
Update tests/python_tests/test_add_extension.py
xipingyan Nov 10, 2025
ba86cc4
enable add_extension to vlm pipleline with properties.
xipingyan Nov 11, 2025
4705288
Merge remote-tracking branch 'origin/xp/introduce_add_extention_to_ge…
xipingyan Nov 11, 2025
323e4c2
remove unecessary file
xipingyan Nov 11, 2025
82b65bc
Update src/cpp/src/utils.cpp
xipingyan Nov 11, 2025
3b6391d
Update src/cpp/src/visual_language/pipeline.cpp
xipingyan Nov 11, 2025
0542ae3
Update tests/python_tests/test_vlm_pipeline.py
xipingyan Nov 11, 2025
02d5310
Update tests/python_tests/test_vlm_pipeline.py
xipingyan Nov 11, 2025
97a88fc
Update src/cpp/src/visual_language/pipeline.cpp
xipingyan Nov 11, 2025
200fb05
Remove print.
xipingyan Nov 11, 2025
f49ebb9
Update src/cpp/include/openvino/genai/generation_config.hpp
xipingyan Nov 11, 2025
611c1fb
git pushMerge branch 'xp/introduce_add_extention_to_genai' of https:/…
xipingyan Nov 11, 2025
34499ec
enable llm piple , lots of interleave call, about ContinuousBatchingP…
xipingyan Nov 11, 2025
a92fe1f
add test case of cb and llm
sunxiaoxia2022 Nov 13, 2025
75900d0
change extract_extensions to add_extensions_to_core
sunxiaoxia2022 Nov 14, 2025
bf6bd7f
fix conflict
sunxiaoxia2022 Nov 14, 2025
8a80895
revert some change
sunxiaoxia2022 Nov 14, 2025
85608a0
rm add_extensions_to_core from pipeline_stateful
sunxiaoxia2022 Nov 19, 2025
6fd6b26
revert a small change
sunxiaoxia2022 Nov 19, 2025
3208ed1
revert a change
sunxiaoxia2022 Nov 19, 2025
6e10e60
double quotes
sunxiaoxia2022 Nov 19, 2025
6e673c9
rm add_extensions_to_core from embedding_model and qwen2vl due to bei…
sunxiaoxia2022 Nov 19, 2025
e59ab7c
move add_extensions_to_core before InputsEmbedder
sunxiaoxia2022 Nov 19, 2025
54880e3
add a documentation comment for add_extensions_to_core
sunxiaoxia2022 Nov 19, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/cpp/include/openvino/genai/generation_config.hpp
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please take a different approach.

Introduce a new ov::Property<std::vector<std::string>> that will correspond to ov::Core::add_extension(). If this property is given in pipeline constructor, pass its content to the corresponding ov::Core.

ov::Core should no longer be singleton. Any pipeline that introduces support for add_extension() should manage its own ov::Core. This requires openvinotoolkit/openvino#32738 to be merged. To allow other ov::Core's functions in future, GenAI should introduce a private common function that calls the needed ov::Core's function given properties (it should be only add_extension() at this moment). Every pipeline needs to call this helper.

Don't modify all pipelines at once. Split the changes into multiple PRs.

Let me know if you have other though

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I list all candidates:

ContinuousBatchingPipeline
LLMPipeline
VLMPipeline
WhisperPipeline
Image2ImagePipeline
InpaintingPipeline
SD3Transformer2DModel
T5EncoderModel
Text2ImagePipeline
UNet2DConditionModel
TextEmbeddingPipeline
TextRerankPipeline
Text2SpeechPipeline

So I will prioritize to enable LLMPipeline and VLMPipeline in the first PR.
Other question about test case,
Actually, I don't know how to add appropriate test case, because we need to pass a library(dll or so) path.
What do you think about current enabled test case? Only pass tokenizer library path and check if we can catch any exceptions. @Wovchena

Copy link
Collaborator

Choose a reason for hiding this comment

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

This idea for test is nice. I can't come up with a different test case

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can't get any exception when we pass correct tokenizer library, so I think we can pass a fake path, we can get openvino threw exception log, just check this log, it may be better.

Copy link
Collaborator

Choose a reason for hiding this comment

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

What log are you referring to?

    with pytest.raises(RuntimeError) as exc_info:
        VLMPipeline(models_path, "CPU", properties)

looks correct

Copy link
Contributor Author

Choose a reason for hiding this comment

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

because we pass faked path, so openvino will throw exception with specific log, I just catch this exception and compare this log. so this log is from openvino, if openvino update the threw log, maybe trigger this test fail.
is this reasonable? @Wovchena @sunxiaoxia2022 @peterchen-intel

Copy link
Collaborator

Choose a reason for hiding this comment

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

It's reasonable. There seem to be no other way

Copy link
Collaborator

Choose a reason for hiding this comment

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

There's going to be a discussion with arch team this Monday. I'll update you after that

Copy link
Collaborator

Choose a reason for hiding this comment

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

There's going to be a discussion with arch team this Monday. I'll update you after that

Moved to Wednesday

Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,13 @@ class OPENVINO_GENAI_EXPORTS GenerationConfig {
void validate() const;
};

/**
* @brief Registers an extension to ov::Core object for model with custom op.
* @param library_path Path to the library with ov::Extension.
*/
void OPENVINO_GENAI_EXPORTS add_extension(const std::string& library_path);


/*
* utils that allow to use generate and operator() in the following way:
* pipe.generate(input_ids, ov::genai::max_new_tokens(200), ov::genai::temperature(1.0f),...)
Expand Down
4 changes: 4 additions & 0 deletions src/cpp/src/generation_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -490,5 +490,9 @@ GenerationConfig multinomial() {
return multinomial_config;
}

void add_extension(const std::string& library_path) {
utils::singleton_core().add_extension(library_path);
}

} // namespace genai
} // namespace ov
3 changes: 2 additions & 1 deletion src/python/openvino_genai/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
get_version,
StreamingStatus,
TextStreamer,
TextParserStreamer
TextParserStreamer,
add_extension
)

from .py_openvino_genai import (
Expand Down
3 changes: 2 additions & 1 deletion src/python/openvino_genai/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ from openvino_genai.py_openvino_genai import WhisperPipeline
from openvino_genai.py_openvino_genai import WhisperRawPerfMetrics
from openvino_genai.py_openvino_genai import draft_model
from openvino_genai.py_openvino_genai import get_version
from openvino_genai.py_openvino_genai import add_extension
import os as os
from . import py_openvino_genai
__all__: list[str] = ['Adapter', 'AdapterConfig', 'AggregationMode', 'AutoencoderKL', 'CLIPTextModel', 'CLIPTextModelWithProjection', 'CacheEvictionConfig', 'ChatHistory', 'ChunkStreamerBase', 'ContinuousBatchingPipeline', 'CppStdGenerator', 'DecodedResults', 'DeepSeekR1ReasoningIncrementalParser', 'DeepSeekR1ReasoningParser', 'EncodedResults', 'FluxTransformer2DModel', 'GenerationConfig', 'GenerationFinishReason', 'GenerationResult', 'GenerationStatus', 'Generator', 'Image2ImagePipeline', 'ImageGenerationConfig', 'ImageGenerationPerfMetrics', 'IncrementalParser', 'InpaintingPipeline', 'KVCrushAnchorPointMode', 'KVCrushConfig', 'LLMPipeline', 'Llama3JsonToolParser', 'Llama3PythonicToolParser', 'Parser', 'PerfMetrics', 'Phi4ReasoningIncrementalParser', 'Phi4ReasoningParser', 'RawImageGenerationPerfMetrics', 'RawPerfMetrics', 'ReasoningIncrementalParser', 'ReasoningParser', 'SD3Transformer2DModel', 'Scheduler', 'SchedulerConfig', 'SparseAttentionConfig', 'SparseAttentionMode', 'SpeechGenerationConfig', 'SpeechGenerationPerfMetrics', 'StopCriteria', 'StreamerBase', 'StreamingStatus', 'StructuralTagItem', 'StructuralTagsConfig', 'StructuredOutputConfig', 'T5EncoderModel', 'Text2ImagePipeline', 'Text2SpeechDecodedResults', 'Text2SpeechPipeline', 'TextEmbeddingPipeline', 'TextParserStreamer', 'TextRerankPipeline', 'TextStreamer', 'TokenizedInputs', 'Tokenizer', 'TorchGenerator', 'UNet2DConditionModel', 'VLMPipeline', 'WhisperGenerationConfig', 'WhisperPerfMetrics', 'WhisperPipeline', 'WhisperRawPerfMetrics', 'draft_model', 'get_version', 'openvino', 'os', 'py_openvino_genai']
__all__: list[str] = ['Adapter', 'AdapterConfig', 'AggregationMode', 'AutoencoderKL', 'CLIPTextModel', 'CLIPTextModelWithProjection', 'CacheEvictionConfig', 'ChatHistory', 'ChunkStreamerBase', 'ContinuousBatchingPipeline', 'CppStdGenerator', 'DecodedResults', 'DeepSeekR1ReasoningIncrementalParser', 'DeepSeekR1ReasoningParser', 'EncodedResults', 'FluxTransformer2DModel', 'GenerationConfig', 'GenerationFinishReason', 'GenerationResult', 'GenerationStatus', 'Generator', 'Image2ImagePipeline', 'ImageGenerationConfig', 'ImageGenerationPerfMetrics', 'IncrementalParser', 'InpaintingPipeline', 'KVCrushAnchorPointMode', 'KVCrushConfig', 'LLMPipeline', 'Llama3JsonToolParser', 'Llama3PythonicToolParser', 'Parser', 'PerfMetrics', 'Phi4ReasoningIncrementalParser', 'Phi4ReasoningParser', 'RawImageGenerationPerfMetrics', 'RawPerfMetrics', 'ReasoningIncrementalParser', 'ReasoningParser', 'SD3Transformer2DModel', 'Scheduler', 'SchedulerConfig', 'SparseAttentionConfig', 'SparseAttentionMode', 'SpeechGenerationConfig', 'SpeechGenerationPerfMetrics', 'StopCriteria', 'StreamerBase', 'StreamingStatus', 'StructuralTagItem', 'StructuralTagsConfig', 'StructuredOutputConfig', 'T5EncoderModel', 'Text2ImagePipeline', 'Text2SpeechDecodedResults', 'Text2SpeechPipeline', 'TextEmbeddingPipeline', 'TextParserStreamer', 'TextRerankPipeline', 'TextStreamer', 'TokenizedInputs', 'Tokenizer', 'TorchGenerator', 'UNet2DConditionModel', 'VLMPipeline', 'WhisperGenerationConfig', 'WhisperPerfMetrics', 'WhisperPipeline', 'WhisperRawPerfMetrics', 'add_extension', 'draft_model', 'get_version', 'openvino', 'os', 'py_openvino_genai']
__version__: str
6 changes: 6 additions & 0 deletions src/python/openvino_genai/py_openvino_genai.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -4406,3 +4406,9 @@ def get_version() -> str:
"""
OpenVINO GenAI version
"""
def add_extension(library_path: str) -> None:
"""
Registers an OpenVINO extension from a library path to enable support for models with custom operations.

:param library_path: Path to the extension library to register.
"""
6 changes: 6 additions & 0 deletions src/python/py_openvino_genai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "openvino/genai/llm_pipeline.hpp"
#include "openvino/genai/text_streamer.hpp"
#include "openvino/genai/version.hpp"
#include "openvino/genai/generation_config.hpp"

#include "py_utils.hpp"

Expand All @@ -28,6 +29,7 @@ using ov::genai::StreamingStatus;
using ov::genai::TextStreamer;
using ov::genai::Tokenizer;
using ov::genai::get_version;
using ov::genai::add_extension;

void init_lora_adapter(py::module_& m);
void init_perf_metrics(py::module_& m);
Expand Down Expand Up @@ -88,6 +90,10 @@ PYBIND11_MODULE(py_openvino_genai, m) {
return get_version().buildNumber;
}, get_version().description);

m.def("add_extension", [] (py::str library_path) {
return add_extension(library_path);
});

init_perf_metrics(m);

py::class_<DecodedResults>(m, "DecodedResults", decoded_results_docstring)
Expand Down
14 changes: 14 additions & 0 deletions tests/python_tests/test_add_extension.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright (C) 2023-2025 Intel Corporation
# SPDX-License-Identifier: Apache-2.0


import pytest
import openvino_genai as ov_genai

@pytest.mark.precommit
def test_add_extension():
print(ov_genai.get_version())
# Path to the OpenVINO extension shared library (update as needed).
extension_path = ""
with pytest.raises(Exception):
ov_genai.add_extension(extension_path)
Loading