-
Notifications
You must be signed in to change notification settings - Fork 205
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
base: master
Are you sure you want to change the base?
Conversation
const std::string& neg_prompt, | ||
bool do_classifier_free_guidance | ||
) { | ||
py::gil_scoped_release rel; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
Ticket: CVS-161082