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

Avoid default tokenization in Dask #10398

Merged
merged 6 commits into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions python-package/xgboost/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import os
import re
import sys
import uuid
import warnings
import weakref
from abc import ABC, abstractmethod
Expand Down Expand Up @@ -3143,3 +3144,9 @@ def get_split_value_histogram(
UserWarning,
)
return nph_stacked

def __dask_tokenize__(self) -> uuid.UUID:
# TODO: Implement proper tokenization to avoid unnecessary re-computation in
# Dask. However, default tokenzation causes problems after
# https://github.com/dask/dask/pull/10883
return uuid.uuid4()

Choose a reason for hiding this comment

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

Two consecutive calls to tokenize() will return two different values, and this can cause problems. I would advise caching the output: dask/dask#11179 (comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @crusaderky ! The purpose of this PR was to effectively roll back behavior to "match" tokenization before 10883. However, I agree that it makes sense to cache the value.

2 changes: 1 addition & 1 deletion tests/ci_build/Dockerfile.gpu
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ RUN \
mamba create -y -n gpu_test -c rapidsai -c conda-forge -c nvidia \
python=3.10 cudf=$RAPIDS_VERSION_ARG* rmm=$RAPIDS_VERSION_ARG* cudatoolkit=$CUDA_VERSION_ARG \
"nccl>=${NCCL_SHORT_VER}" \
dask=2024.1.1 \
dask \
dask-cuda=$RAPIDS_VERSION_ARG* dask-cudf=$RAPIDS_VERSION_ARG* cupy \
numpy pytest pytest-timeout scipy scikit-learn pandas matplotlib wheel python-kubernetes urllib3 graphviz hypothesis \
"pyspark>=3.4.0" cloudpickle cuda-python && \
Expand Down
2 changes: 1 addition & 1 deletion tests/ci_build/Dockerfile.gpu_dev_ver
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ RUN \
mamba create -y -n gpu_test -c rapidsai-nightly -c conda-forge -c nvidia \
python=3.10 "cudf=$RAPIDS_VERSION_ARG.*" "rmm=$RAPIDS_VERSION_ARG.*" cudatoolkit=$CUDA_VERSION_ARG \
"nccl>=${NCCL_SHORT_VER}" \
dask=2024.1.1 \
dask \
"dask-cuda=$RAPIDS_VERSION_ARG.*" "dask-cudf=$RAPIDS_VERSION_ARG.*" cupy \
numpy pytest pytest-timeout scipy scikit-learn pandas matplotlib wheel python-kubernetes urllib3 graphviz hypothesis \
"pyspark>=3.4.0" cloudpickle cuda-python && \
Expand Down
4 changes: 2 additions & 2 deletions tests/ci_build/conda_env/linux_cpu_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ dependencies:
- scikit-learn
- pandas
- matplotlib
- dask>=2022.6
- distributed>=2022.6
- dask
- distributed
- python-graphviz
- hypothesis>=6.46
- astroid
Expand Down
10 changes: 5 additions & 5 deletions tests/test_distributed/test_gpu_with_dask/test_gpu_with_dask.py
Copy link
Contributor Author

Choose a reason for hiding this comment

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

All changes in this file are related to the recent deprecation of dask_cudf.from_dask_dataframe.

Original file line number Diff line number Diff line change
Expand Up @@ -248,10 +248,10 @@ def test_categorical(self, local_cuda_client: Client) -> None:
import dask_cudf

X, y = make_categorical(local_cuda_client, 10000, 30, 13)
X = dask_cudf.from_dask_dataframe(X)
X = X.to_backend("cudf")

X_onehot, _ = make_categorical(local_cuda_client, 10000, 30, 13, True)
X_onehot = dask_cudf.from_dask_dataframe(X_onehot)
X_onehot = X_onehot.to_backend("cudf")
run_categorical(local_cuda_client, "hist", "cuda", X, X_onehot, y)

@given(
Expand Down Expand Up @@ -383,9 +383,9 @@ def test_dask_classifier(self, model: str, local_cuda_client: Client) -> None:

X_, y_, w_ = generate_array(with_weights=True)
y_ = (y_ * 10).astype(np.int32)
X = dask_cudf.from_dask_dataframe(dd.from_dask_array(X_))
y = dask_cudf.from_dask_dataframe(dd.from_dask_array(y_))
w = dask_cudf.from_dask_dataframe(dd.from_dask_array(w_))
X = dd.from_dask_array(X_).to_backend("cudf")
y = dd.from_dask_array(y_).to_backend("cudf")
w = dd.from_dask_array(w_).to_backend("cudf")
run_dask_classifier(X, y, w, model, "hist", "cuda", local_cuda_client, 10)

def test_empty_dmatrix(self, local_cuda_client: Client) -> None:
Expand Down
Loading