From e1f9f80df2f3e1d700c8912c43d30ecc6fdfcfc3 Mon Sep 17 00:00:00 2001 From: Jiaming Yuan Date: Mon, 10 Oct 2022 16:12:37 +0800 Subject: [PATCH] Use gpu predictor for get csr test. (#8323) --- .../test_device_quantile_dmatrix.py | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/tests/python-gpu/test_device_quantile_dmatrix.py b/tests/python-gpu/test_device_quantile_dmatrix.py index 60f3a2f74..2c3a7a760 100644 --- a/tests/python-gpu/test_device_quantile_dmatrix.py +++ b/tests/python-gpu/test_device_quantile_dmatrix.py @@ -1,13 +1,14 @@ -import numpy as np -import xgboost as xgb -import pytest import sys -from hypothesis import given, strategies, settings -from scipy import sparse + +import numpy as np +import pytest +from hypothesis import given, settings, strategies + +import xgboost as xgb sys.path.append("tests/python") -import testing as tm import test_quantile_dmatrix as tqd +import testing as tm class TestDeviceQuantileDMatrix: @@ -107,9 +108,8 @@ class TestDeviceQuantileDMatrix: @settings(print_blob=True, deadline=None) def test_to_csr(self, n_samples, n_features, sparsity) -> None: import cupy as cp - X, y = tm.make_sparse_regression( - n_samples, n_features, sparsity, False - ) + + X, y = tm.make_sparse_regression(n_samples, n_features, sparsity, False) h_X = X.astype(np.float32) csr = h_X @@ -130,10 +130,12 @@ class TestDeviceQuantileDMatrix: np.testing.assert_equal(h_ret.indptr, d_ret.indptr) np.testing.assert_equal(h_ret.indices, d_ret.indices) - booster = xgb.train({"tree_method": "gpu_hist"}, dtrain=d_m) + booster = xgb.train( + {"tree_method": "gpu_hist", "predictor": "gpu_predictor"}, dtrain=d_m + ) np.testing.assert_allclose( booster.predict(d_m), booster.predict(xgb.DMatrix(d_m.get_data())), - atol=1e-6 + atol=1e-6, )