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

[FEA] Use nogil wherever possible when making calls to libcuml #6271

Open
jcrist opened this issue Jan 28, 2025 · 2 comments
Open

[FEA] Use nogil wherever possible when making calls to libcuml #6271

jcrist opened this issue Jan 28, 2025 · 2 comments
Labels
Cython / Python Cython or Python issue feature request New feature or request

Comments

@jcrist
Copy link
Member

jcrist commented Jan 28, 2025

Currently long running cuml calls that dispatch into libcuml don't release the GIL. For example, a call to UMAP.fit will block any other python threads, preventing the python interpreter from doing other work while it waits for the libcuml call to return.

A use case I had recently was starting a logger for system resources as a background thread to run while UMAP.fit was running. Since the fit call doesn't release the GIL, the background thread never gets to run until the fit call returns, defeating the purpose.

If there's a known reason why we don't release the GIL in these calls, we should document that somewhere. And if there isn't, then I'd argue that we should try and release it in more places.

@jcrist
Copy link
Member Author

jcrist commented Jan 28, 2025

Looking through the codebase, it looks like we do release the GIL for some but not all estimators. I'd propose that we should probably be more uniform here, and if any shouldn't release the GIL we should add a comment next to the cdef as to why not.

@cjnolet
Copy link
Member

cjnolet commented Jan 28, 2025

I was about to respond with "I thought we were using nogil everywhere" but then I looked at a few of the estimators and realized it was never added to those. I definitely think we should create a feature request out of this issue and strive to use nogil everywhere possible.

@jcrist jcrist changed the title Should long running cuml calls release the GIL? Use nogil wherever possible when making calls to libcuml Jan 28, 2025
@jcrist jcrist added feature request New feature or request Cython / Python Cython or Python issue labels Jan 28, 2025
@jcrist jcrist changed the title Use nogil wherever possible when making calls to libcuml [FEA] Use nogil wherever possible when making calls to libcuml Jan 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Cython / Python Cython or Python issue feature request New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants