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

Added GIL release for time consuming methods. #1673

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

popovaan
Copy link
Contributor

@popovaan popovaan commented Feb 4, 2025

Ticket: CVS-161082

@github-actions github-actions bot added category: text to image Text 2 image pipeline category: visual language Visual language pipeline category: whisper Whisper pipeline category: Python API Python API for GenAI labels Feb 4, 2025
const std::string& neg_prompt,
bool do_classifier_free_guidance
) {
py::gil_scoped_release rel;
Copy link
Contributor

Choose a reason for hiding this comment

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

can we use py::call_guard<py::gil_scoped_release>() for such cases to avoid explicit method implementation?
See https://pybind11.readthedocs.io/en/stable/advanced/misc.html#global-interpreter-lock-gil

Copy link
Contributor

Choose a reason for hiding this comment

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

We do not make any python cast inside the function, so look like we can use mentioned by @ilya-lavrenov

@@ -96,7 +96,7 @@ py::object call_vlm_generate(
) {
auto updated_config = *pyutils::update_config_from_kwargs(generation_config, kwargs);
ov::genai::StreamerVariant streamer = pyutils::pystreamer_to_streamer(py_streamer);

py::gil_scoped_release rel;
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure whether only pipe.generate(prompt, images, updated_config, streamer) should release GIL? what's about py::cast ?

CC @as-suvorov do you know?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd guess this is fine. Even though py::cast() returns an object which can be interpreted as a python object, it only belongs to this function until it's returned and not visible to anyone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: Python API Python API for GenAI category: text to image Text 2 image pipeline category: visual language Visual language pipeline category: whisper Whisper pipeline
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants