Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed passing of generation config params to VLM generate. #1180

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

popovaan
Copy link
Contributor

@popovaan popovaan commented Nov 8, 2024

  • Fixed passing of generation config params to VLM generate().
  • Updated generation config params params list in update_config_from_kwargs() method.

Ticket: CVS-157050

@popovaan popovaan marked this pull request as ready for review November 8, 2024 16:19
@github-actions github-actions bot added category: visual language Visual language pipeline category: sampling Sampling / Decoding algorithms category: Python API Python API for GenAI labels Nov 8, 2024
@ilya-lavrenov ilya-lavrenov modified the milestones: 2025.0, 2024.5 Nov 8, 2024
@ilya-lavrenov
Copy link
Contributor

Let' submit fix to 2024.5

@ilya-lavrenov ilya-lavrenov added the bug Something isn't working label Nov 8, 2024
@ilya-lavrenov ilya-lavrenov self-assigned this Nov 8, 2024
src/python/py_utils.hpp Outdated Show resolved Hide resolved
src/python/py_utils.cpp Show resolved Hide resolved
github-merge-queue bot pushed a commit that referenced this pull request Nov 11, 2024
Fixed passing of generation config params to VLM generate.
Port of #1180
@ilya-lavrenov ilya-lavrenov modified the milestones: 2024.5, 2025.0 Nov 11, 2024
@github-actions github-actions bot added category: text to image Text 2 image pipeline category: whisper Whisper pipeline category: GenAI C++ API Changes in GenAI C++ public headers labels Nov 16, 2024
@github-actions github-actions bot added the category: LLM LLM pipeline (stateful, static) label Nov 16, 2024
src/python/py_utils.cpp Show resolved Hide resolved
src/python/py_utils.cpp Show resolved Hide resolved
src/python/py_utils.cpp Outdated Show resolved Hide resolved
src/python/py_utils.cpp Show resolved Hide resolved
src/python/py_utils.cpp Outdated Show resolved Hide resolved
src/python/py_utils.cpp Outdated Show resolved Hide resolved
src/python/py_utils.cpp Outdated Show resolved Hide resolved
@github-actions github-actions bot added the category: tokenizers Tokenizer class or submodule update label Nov 19, 2024
@@ -313,6 +313,9 @@ template <typename T>
T pop_or_default(ov::AnyMap& config, const std::string& key, const T& default_value) {
auto anyopt = pop_option(config, key);
if (anyopt.has_value()) {
if (anyopt.value().empty()) {
return T{};
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why not default_value?
Can you explain, why it is needed now

I guess that's because you switched from exceptions to return ov::Any();, but why?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Almost any property of type list, set, or dict can potentially be empty and we should be able to accept such values. So Ilya suggested to return ov::Any() in bindings and process empty ov::Any() in utils.

Regarding usage of default_value, I tried it locally but tests, that use confing shown below failed, because it is not equivalent to creation of empty container. So I changed to T{}.

'PREFILL_CONFIG': { },
'GENERATE_CONFIG': { }

Copy link
Contributor

@ilya-lavrenov ilya-lavrenov Nov 19, 2024

Choose a reason for hiding this comment

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

but why?

yes, we need somehow to bypass information from python that a container (list, map, set) is empty, but we don't know type of this container (e.g. vector<of what type?>), while in this function we know this type T

maybe it will safer to return T{}; only for containers? because for regular type empty ov::Any is still not expected

src/python/py_utils.cpp Outdated Show resolved Hide resolved
@@ -313,6 +313,9 @@ template <typename T>
T pop_or_default(ov::AnyMap& config, const std::string& key, const T& default_value) {
auto anyopt = pop_option(config, key);
if (anyopt.has_value()) {
if (anyopt.value().empty()) {
return T{};
Copy link
Contributor

@ilya-lavrenov ilya-lavrenov Nov 19, 2024

Choose a reason for hiding this comment

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

but why?

yes, we need somehow to bypass information from python that a container (list, map, set) is empty, but we don't know type of this container (e.g. vector<of what type?>), while in this function we know this type T

maybe it will safer to return T{}; only for containers? because for regular type empty ov::Any is still not expected

@@ -30,10 +30,10 @@ void init_tokenizer(py::module_& m) {
R"(openvino_genai.Tokenizer object is used to initialize Tokenizer
if it's located in a different path than the main model.)")

.def(py::init([](const std::filesystem::path& tokenizer_path, const std::map<std::string, py::object>& properties) {
.def(py::init([](const std::filesystem::path& tokenizer_path, const py::kwargs& kwargs) {
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe we need to keep map for BW compatibility and add warning similar to LLMPipeline?

if (config.size()) {
PyErr_WarnEx(PyExc_DeprecationWarning,
"'config' parameters is deprecated, please use kwargs to pass config properties instead.",
1);
auto config_properties = pyutils::properties_to_any_map(config);
properties.insert(config_properties.begin(), config_properties.end());
}

Co-authored-by: Ilya Lavrenov <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working category: continuous batching Continuous batching category: GenAI C++ API Changes in GenAI C++ public headers category: LLM LLM pipeline (stateful, static) category: Python API Python API for GenAI category: sampling Sampling / Decoding algorithms category: text to image Text 2 image pipeline category: tokenizers Tokenizer class or submodule update category: visual language Visual language pipeline category: whisper Whisper pipeline no-match-files
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants