[breaking] Bump Python requirement to 3.10. (#10434)

- Bump the Python requirement.
- Fix type hints.
- Use loky to avoid deadlock.
- Workaround cupy-numpy compatibility issue on Windows caused by the `safe` casting rule.
- Simplify the repartitioning logic to avoid dask errors.
This commit is contained in:
Jiaming Yuan
2024-07-30 17:31:06 +08:00
committed by GitHub
parent 757aafc131
commit 827d0e8edb
33 changed files with 284 additions and 286 deletions

View File

@@ -20,7 +20,7 @@ class TestQuantileDMatrix:
def test_dmatrix_feature_weights(self) -> None:
import cupy as cp
rng = cp.random.RandomState(1994)
rng = cp.random.RandomState(np.uint64(1994))
data = rng.randn(5, 5)
m = xgb.DMatrix(data)
@@ -146,7 +146,7 @@ class TestQuantileDMatrix:
def test_metainfo(self) -> None:
import cupy as cp
rng = cp.random.RandomState(1994)
rng = cp.random.RandomState(np.uint64(1994))
rows = 10
cols = 3
@@ -170,7 +170,7 @@ class TestQuantileDMatrix:
def test_ref_dmatrix(self) -> None:
import cupy as cp
rng = cp.random.RandomState(1994)
rng = cp.random.RandomState(np.uint64(1994))
self.cputest.run_ref_dmatrix(rng, "gpu_hist", False)
@given(

View File

@@ -66,7 +66,7 @@ def _test_from_cupy(DMatrixT):
def _test_cupy_training(DMatrixT):
np.random.seed(1)
cp.random.seed(1)
cp.random.seed(np.uint64(1))
X = cp.random.randn(50, 10, dtype="float32")
y = cp.random.randn(50, dtype="float32")
weights = np.random.random(50) + 1
@@ -131,7 +131,7 @@ def _test_cupy_metainfo(DMatrixT):
@pytest.mark.skipif(**tm.no_sklearn())
def test_cupy_training_with_sklearn():
np.random.seed(1)
cp.random.seed(1)
cp.random.seed(np.uint64(1))
X = cp.random.randn(50, 10, dtype="float32")
y = (cp.random.randn(50, dtype="float32") > 0).astype("int8")
weights = np.random.random(50) + 1
@@ -210,7 +210,7 @@ class TestFromCupy:
@pytest.mark.skipif(**tm.no_cupy())
def test_qid(self):
rng = cp.random.RandomState(1994)
rng = cp.random.RandomState(np.uint64(1994))
rows = 100
cols = 10
X, y = rng.randn(rows, cols), rng.randn(rows)

View File

@@ -226,7 +226,7 @@ class TestGPUPredict:
cols = 10
missing = 11 # set to integer for testing
cp_rng = cp.random.RandomState(1994)
cp_rng = cp.random.RandomState(np.uint64(1994))
cp.random.set_random_state(cp_rng)
X = cp.random.randn(rows, cols)
@@ -546,7 +546,7 @@ class TestGPUPredict:
rows = 1000
cols = 10
rng = cp.random.RandomState(1994)
rng = cp.random.RandomState(np.uint64(1994))
orig = rng.randint(low=0, high=127, size=rows * cols).reshape(rows, cols)
y = rng.randint(low=0, high=127, size=rows)
dtrain = xgb.DMatrix(orig, label=y)
@@ -576,10 +576,10 @@ class TestGPUPredict:
# boolean
orig = cp.random.binomial(1, 0.5, size=rows * cols).reshape(rows, cols)
predt_orig = booster.inplace_predict(orig)
for dtype in [cp.bool8, cp.bool_]:
X = cp.array(orig, dtype=dtype)
predt = booster.inplace_predict(X)
cp.testing.assert_allclose(predt, predt_orig)
X = cp.array(orig, dtype=cp.bool_)
predt = booster.inplace_predict(X)
cp.testing.assert_allclose(predt, predt_orig)
# unsupported types
for dtype in [