Skip to content

Commit

Permalink
Merge branch 'branch-25.02' into libucx-in-devcontainers
Browse files Browse the repository at this point in the history
  • Loading branch information
jameslamb authored Dec 4, 2024
2 parents 3d56418 + 12fb5a7 commit 125aba0
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 17 deletions.
1 change: 1 addition & 0 deletions conda/environments/all_cuda-118_arch-x86_64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,5 @@ dependencies:
- sysroot_linux-64==2.17
- treelite==4.3.0
- umap-learn==0.5.6
- xgboost>=2.1.0
name: all_cuda-118_arch-x86_64
1 change: 1 addition & 0 deletions conda/environments/all_cuda-125_arch-x86_64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,5 @@ dependencies:
- sysroot_linux-64==2.17
- treelite==4.3.0
- umap-learn==0.5.6
- xgboost>=2.1.0
name: all_cuda-125_arch-x86_64
3 changes: 2 additions & 1 deletion dependencies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,7 @@ dependencies:
- pytest-xdist
- seaborn
- *scikit_learn
- &xgboost xgboost>=2.1.0
- statsmodels
- umap-learn==0.5.6
- pynndescent
Expand All @@ -537,4 +538,4 @@ dependencies:
- pandas
- *scikit_learn
- seaborn
- xgboost
- *xgboost
20 changes: 10 additions & 10 deletions python/cuml/cuml/tests/experimental/test_filex.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def test_fil_classification(
X, y, train_size=0.8, random_state=0
)

model_path = os.path.join(tmp_path, "xgb_class.model")
model_path = os.path.join(tmp_path, "xgb_class.ubj")

bst = _build_and_save_xgboost(
model_path,
Expand Down Expand Up @@ -258,7 +258,7 @@ def test_fil_regression(
X, y, train_size=train_size, random_state=0
)

model_path = os.path.join(tmp_path, "xgb_reg.model")
model_path = os.path.join(tmp_path, "xgb_reg.ubj")
bst = _build_and_save_xgboost(
model_path,
X_train,
Expand Down Expand Up @@ -490,12 +490,12 @@ def test_fil_skl_regression(
np.testing.assert_allclose(fil_preds_opt, fil_preds, atol=1.2e-3)


@pytest.fixture(scope="session", params=["binary", "json"])
@pytest.fixture(scope="session", params=["ubjson", "json"])
def small_classifier_and_preds(tmpdir_factory, request):
X, y = simulate_data(500, 10, random_state=43210, classification=True)

ext = "json" if request.param == "json" else "model"
model_type = "xgboost_json" if request.param == "json" else "xgboost"
ext = "json" if request.param == "json" else "ubj"
model_type = "xgboost_json" if request.param == "json" else "xgboost_ubj"
model_path = str(
tmpdir_factory.mktemp("models").join(f"small_class.{ext}")
)
Expand Down Expand Up @@ -738,7 +738,7 @@ def test_predict_per_tree(
classification=True,
)

model_path = os.path.join(tmp_path, "xgb_class.model")
model_path = os.path.join(tmp_path, "xgb_class.ubj")

xgboost_params = {"base_score": (0.5 if n_classes == 2 else 0.0)}
bst = _build_and_save_xgboost(
Expand All @@ -751,7 +751,7 @@ def test_predict_per_tree(
xgboost_params=xgboost_params,
)
fm = ForestInference.load(model_path, output_class=True)
tl_model = treelite.Model.from_xgboost(bst)
tl_model = treelite.frontend.from_xgboost(bst)
pred_per_tree_tl = treelite.gtil.predict_per_tree(tl_model, X)

with using_device_type(infer_device):
Expand All @@ -773,7 +773,7 @@ def test_predict_per_tree(
assert pred_per_tree.shape == expected_shape
np.testing.assert_almost_equal(sum_by_class, margin_pred, decimal=3)
np.testing.assert_almost_equal(
pred_per_tree, pred_per_tree_tl, decimal=3
pred_per_tree.reshape((n_rows, -1, 1)), pred_per_tree_tl, decimal=3
)
np.testing.assert_almost_equal(
pred_per_tree_opt, pred_per_tree, decimal=3
Expand Down Expand Up @@ -844,7 +844,7 @@ def test_apply(train_device, infer_device, n_classes, tmp_path):
classification=True,
)

model_path = os.path.join(tmp_path, "xgb_class.model")
model_path = os.path.join(tmp_path, "xgb_class.ubj")

xgboost_params = {"base_score": (0.5 if n_classes == 2 else 0.0)}
bst = _build_and_save_xgboost(
Expand All @@ -858,7 +858,7 @@ def test_apply(train_device, infer_device, n_classes, tmp_path):
)

fm = ForestInference.load(
model_path, output_class=True, model_type="xgboost"
model_path, output_class=True, model_type="xgboost_ubj"
)

with using_device_type(infer_device):
Expand Down
12 changes: 6 additions & 6 deletions python/cuml/cuml/tests/test_fil.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2019-2023, NVIDIA CORPORATION.
# Copyright (c) 2019-2024, NVIDIA CORPORATION.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -155,7 +155,7 @@ def test_fil_classification(
X, y, train_size=train_size, random_state=0
)

model_path = os.path.join(tmp_path, "xgb_class.model")
model_path = os.path.join(tmp_path, "xgb_class.ubj")

bst = _build_and_save_xgboost(
model_path,
Expand Down Expand Up @@ -226,7 +226,7 @@ def test_fil_regression(n_rows, n_columns, num_rounds, tmp_path, max_depth):
X, y, train_size=train_size, random_state=0
)

model_path = os.path.join(tmp_path, "xgb_reg.model")
model_path = os.path.join(tmp_path, "xgb_reg.ubj")
bst = _build_and_save_xgboost(
model_path,
X_train,
Expand Down Expand Up @@ -447,12 +447,12 @@ def test_fil_skl_regression(
assert np.allclose(fil_preds, skl_preds, 1.2e-2)


@pytest.fixture(scope="session", params=["binary", "json"])
@pytest.fixture(scope="session", params=["ubjson", "json"])
def small_classifier_and_preds(tmpdir_factory, request):
X, y = simulate_data(500, 10, random_state=43210, classification=True)

ext = "json" if request.param == "json" else "model"
model_type = "xgboost_json" if request.param == "json" else "xgboost"
ext = "json" if request.param == "json" else "ubj"
model_type = "xgboost_json" if request.param == "json" else "xgboost_ubj"
model_path = str(
tmpdir_factory.mktemp("models").join(f"small_class.{ext}")
)
Expand Down
1 change: 1 addition & 0 deletions python/cuml/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ test = [
"seaborn",
"statsmodels",
"umap-learn==0.5.6",
"xgboost>=2.1.0",
] # This list was generated by `rapids-dependency-file-generator`. To make changes, edit ../../dependencies.yaml and run `rapids-dependency-file-generator`.

[project.urls]
Expand Down

0 comments on commit 125aba0

Please sign in to comment.