Skip to content

Dask 2025.4.0 compatibility #6576

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

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

Conversation

TomAugspurger
Copy link
Contributor

This fixes several failures with newer versions in Dask observed at rapidsai/dask-upstream-testing#44. Most came down to unnecessarily wrapping Future objects in Delayed.

Comment on lines +308 to +312
model_delayed = self._get_internal_model()
if not isinstance(model_delayed, (Future, Delayed)):
model_delayed = dask.delayed(
model_delayed, pure=True, traverse=False
)
Copy link
Contributor

Choose a reason for hiding this comment

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

That seems like a somewhat inefficient implementation. Can we instead modify _get_internal_model() to always return a Future or Delayed?

Comment on lines +159 to +164
sizes = [
(worker_address, result)
for worker_address, result in zip(
worker_addresses, results, strict=True
)
]
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
sizes = [
(worker_address, result)
for worker_address, result in zip(
worker_addresses, results, strict=True
)
]
sizes = list(zip(
worker_addresses, results, strict=True
))

Comment on lines +41 to +44
if not isinstance(part, (Delayed, Future)):
part = dask.delayed(part)
return da.from_delayed(
dask.delayed(part), shape=shape, meta=cp.zeros((1)), dtype=dtype
part, shape=shape, meta=cp.zeros((0,) * len(shape), dtype=dtype)
Copy link
Contributor

Choose a reason for hiding this comment

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

This function is called once within the entire code base. Maybe we can ensure that it returns a Delayed or Future?

@csadorf csadorf added Dask / cuml.dask Issue/PR related to Python level dask or cuml.dask features. non-breaking Non-breaking change labels Apr 23, 2025
@TomAugspurger
Copy link
Contributor Author

Several failures are from functions like tree_reduce, which seems to accept and return either dask.delayed.Delayed objects or Futures:

def tree_reduce(objs, func=sum):
. If anyone has context on whether that flexibility is needed I'd be interested in hearing it. Otherwise, it'd be worth simplifying things to only accept Futures (it kind of seems like cuml assumes distributed is available, at least in the tests I'm looking at currently, cuml/python/cuml/cuml/tests/dask/test_dask_tfidf.py::test_tfidf_transformer[False-True-True-l1-base_case])

@csadorf
Copy link
Contributor

csadorf commented Apr 23, 2025

Several failures are from functions like tree_reduce, which seems to accept and return either dask.delayed.Delayed objects or Futures:

def tree_reduce(objs, func=sum):

. If anyone has context on whether that flexibility is needed I'd be interested in hearing it. Otherwise, it'd be worth simplifying things to only accept Futures

The initial dask implementation is relatively old so it's possible that some if its implementation paradigms are outdated. Maybe @cjnolet would be able to comment on this?

(it kind of seems like cuml assumes distributed is available, at least in the tests I'm looking at currently, cuml/python/cuml/cuml/tests/dask/test_dask_tfidf.py::test_tfidf_transformer[False-True-True-l1-base_case])

I think transiently through the dask-ml dependency.

Also, to be clear: we should implement any non-trivial improvements in a follow-up since this PR is needed to resolve immediate incompatibilites!

@TomAugspurger
Copy link
Contributor Author

Also, to be clear: we should implement any non-trivial improvements in a follow-up since this PR is needed to resolve immediate incompatibilites!

FYI, I don't expect this PR to have any effect on CI one way or the other. My hope is that the changes here are compatible both the current version of dask used in CI (2025.2.0) and the one we're targeting next (2025.4.0). If there are dask issues causing CI failures currently I'd be happy to look. But glancing through the output at https://github.com/rapidsai/cuml/actions/runs/14624947486/job/41035364221?pr=6576, I don't see the actual test failure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Cython / Python Cython or Python issue Dask / cuml.dask Issue/PR related to Python level dask or cuml.dask features. non-breaking Non-breaking change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants