Skip to content

Commit 95fd456

Browse files
authored
Merge branch 'dmlc:release_3.1.0' into release_3.1.0
2 parents f2424de + 33a0296 commit 95fd456

32 files changed

+401
-171
lines changed

.github/workflows/jvm_tests.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ jobs:
7777
- description: "MacOS (Intel)"
7878
script: ops/pipeline/build-jvm-macos-intel.sh
7979
libname: libxgboost4j_intel.dylib
80-
runner: macos-13
80+
runner: macos-15-intel
8181
steps:
8282
- uses: actions/checkout@v4
8383
with:
@@ -132,12 +132,12 @@ jobs:
132132
strategy:
133133
fail-fast: false
134134
matrix:
135-
os: [windows-latest, macos-13]
135+
os: [windows-latest, macos-15-intel]
136136
steps:
137137
- uses: actions/checkout@v4
138138
with:
139139
submodules: 'true'
140-
- uses: actions/setup-java@v4
140+
- uses: actions/setup-java@v5
141141
with:
142142
distribution: 'temurin'
143143
java-version: '8'
@@ -152,7 +152,7 @@ jobs:
152152
key: ${{ runner.os }}-m2-${{ hashFiles('./jvm-packages/pom.xml') }}
153153
restore-keys: ${{ runner.os }}-m2-${{ hashFiles('./jvm-packages/pom.xml') }}
154154
- name: Test XGBoost4J (Core) on macos
155-
if: matrix.os == 'macos-13'
155+
if: matrix.os == 'macos-15-intel'
156156
run: |
157157
cd jvm-packages
158158
mvn test -B -pl :xgboost4j_2.12 -Duse.openmp=OFF
@@ -205,7 +205,7 @@ jobs:
205205
SCALA_VERSION: ${{ matrix.scala_version }}
206206

207207
deploy-jvm-packages:
208-
name: Deploy JVM packages to S3 (${{ matrix.variant.name }})
208+
name: Deploy JVM packages to S3 (${{ matrix.variant.name }}, Scala ${{ matrix.scala_version }})
209209
needs: [build-jvm-gpu, build-test-jvm-packages, test-jvm-packages-gpu]
210210
runs-on:
211211
- runs-on

.github/workflows/python_tests.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
strategy:
2121
fail-fast: false
2222
matrix:
23-
os: [macos-13, windows-latest, ubuntu-latest]
23+
os: [macos-15-intel, windows-latest, ubuntu-latest]
2424
steps:
2525
- uses: actions/checkout@v4
2626
with:
@@ -32,13 +32,13 @@ jobs:
3232
- name: Install extra package for MacOS
3333
run: |
3434
mamba install -c conda-forge llvm-openmp
35-
if: matrix.os == 'macos-13'
35+
if: matrix.os == 'macos-15-intel'
3636
- name: Build and install XGBoost
3737
run: bash ops/pipeline/test-python-sdist.sh
3838

3939
python-tests-on-macos:
40-
name: Test XGBoost Python package on macos-13
41-
runs-on: macos-13
40+
name: Test XGBoost Python package on macos-15-intel
41+
runs-on: macos-15-intel
4242
timeout-minutes: 60
4343
steps:
4444
- uses: actions/checkout@v4

.github/workflows/python_wheels_macos.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
fail-fast: false
2626
matrix:
2727
include:
28-
- os: macos-13
28+
- os: macos-15-intel
2929
platform_id: macosx_x86_64
3030
- os: macos-14
3131
platform_id: macosx_arm64

R-package/R/xgb.cv.R

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,6 @@
7676
#' - `nfeatures`: Number of features in training data.
7777
#' - `folds`: The list of CV folds' indices - either those passed through the `folds`
7878
#' parameter or randomly generated.
79-
#' - `best_iteration`: Iteration number with the best evaluation metric value
80-
#' (only available with early stopping).
8179
#'
8280
#' Plus other potential elements that are the result of callbacks, such as a list `cv_predict` with
8381
#' a sub-element `pred` when passing `prediction = TRUE`, which is added by the [xgb.cb.cv.predict()]
@@ -92,18 +90,23 @@
9290
#'
9391
#' cv <- xgb.cv(
9492
#' data = dtrain,
95-
#' nrounds = 3,
93+
#' nrounds = 20,
94+
#' early_stopping_rounds = 1,
9695
#' params = xgb.params(
9796
#' nthread = 2,
9897
#' max_depth = 3,
9998
#' objective = "binary:logistic"
10099
#' ),
101100
#' nfold = 5,
102-
#' metrics = list("rmse","auc")
101+
#' metrics = list("rmse","auc"),
102+
#' prediction = TRUE
103103
#' )
104104
#' print(cv)
105105
#' print(cv, verbose = TRUE)
106106
#'
107+
#' # Callbacks might add additional attributes, separated by the name of the callback
108+
#' cv$early_stop$best_iteration
109+
#' head(cv$cv_predict$pred)
107110
#' @export
108111
xgb.cv <- function(params = xgb.params(), data, nrounds, nfold,
109112
prediction = FALSE, showsd = TRUE, metrics = list(),

R-package/man/xgb.cv.Rd

Lines changed: 7 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

include/xgboost/linalg.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -591,13 +591,13 @@ auto MakeTensorView(Context const *ctx, Order order, common::Span<T, ext> data,
591591

592592
template <typename T, typename... S>
593593
auto MakeTensorView(Context const *ctx, HostDeviceVector<T> *data, S &&...shape) {
594-
auto span = ctx->IsCUDA() ? data->DeviceSpan() : data->HostSpan();
594+
auto span = ctx->IsCPU() ? data->HostSpan() : data->DeviceSpan();
595595
return MakeTensorView(ctx->Device(), span, std::forward<S>(shape)...);
596596
}
597597

598598
template <typename T, typename... S>
599599
auto MakeTensorView(Context const *ctx, HostDeviceVector<T> const *data, S &&...shape) {
600-
auto span = ctx->IsCUDA() ? data->ConstDeviceSpan() : data->ConstHostSpan();
600+
auto span = ctx->IsCPU() ? data->ConstHostSpan() : data->ConstDeviceSpan();
601601
return MakeTensorView(ctx->Device(), span, std::forward<S>(shape)...);
602602
}
603603

@@ -647,13 +647,13 @@ auto MakeVec(T *ptr, size_t s, DeviceOrd device = DeviceOrd::CPU()) {
647647

648648
template <typename T>
649649
auto MakeVec(HostDeviceVector<T> *data) {
650-
return MakeVec(data->Device().IsCUDA() ? data->DevicePointer() : data->HostPointer(),
650+
return MakeVec(data->Device().IsCPU() ? data->HostPointer() : data->DevicePointer(),
651651
data->Size(), data->Device());
652652
}
653653

654654
template <typename T>
655655
auto MakeVec(HostDeviceVector<T> const *data) {
656-
return MakeVec(data->Device().IsCUDA() ? data->ConstDevicePointer() : data->ConstHostPointer(),
656+
return MakeVec(data->Device().IsCPU() ? data->ConstHostPointer() : data->ConstDevicePointer(),
657657
data->Size(), data->Device());
658658
}
659659

@@ -759,7 +759,7 @@ class Tensor {
759759
for (auto i = D; i < kDim; ++i) {
760760
shape_[i] = 1;
761761
}
762-
if (device.IsCUDA()) {
762+
if (!device.IsCPU()) {
763763
data_.SetDevice(device);
764764
data_.ConstDevicePointer(); // Pull to device;
765765
}
@@ -788,11 +788,11 @@ class Tensor {
788788
shape_[i] = 1;
789789
}
790790
auto size = detail::CalcSize(shape_);
791-
if (device.IsCUDA()) {
791+
if (!device.IsCPU()) {
792792
data_.SetDevice(device);
793793
}
794794
data_.Resize(size);
795-
if (device.IsCUDA()) {
795+
if (!device.IsCPU()) {
796796
data_.DevicePointer(); // Pull to device
797797
}
798798
}

ops/script/release_artifacts.py

Lines changed: 20 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -109,36 +109,22 @@ def make_python_sdist(
109109
dist_dir = outdir / "dist"
110110
dist_dir.mkdir(exist_ok=True)
111111

112-
# Build sdist for `xgboost-cpu`.
113-
with DirectoryExcursion(ROOT):
114-
make_pyproject(use_suffix="cpu", require_nccl_dep="na")
115-
with DirectoryExcursion(ROOT / "python-package"):
116-
subprocess.run(["python", "-m", "build", "--sdist"], check=True)
117-
sdist_name = (
118-
f"xgboost_cpu-{release}{rc}{rc_ver}.tar.gz"
119-
if rc
120-
else f"xgboost_cpu-{release}.tar.gz"
121-
)
122-
src = DIST / sdist_name
123-
subprocess.run(["twine", "check", str(src)], check=True)
124-
dest = dist_dir / sdist_name
125-
shutil.move(src, dest)
126-
127-
# Build sdist for `xgboost`.
128-
with DirectoryExcursion(ROOT):
129-
make_pyproject(use_suffix="na", require_nccl_dep="cu12")
130-
131-
with DirectoryExcursion(ROOT / "python-package"):
132-
subprocess.run(["python", "-m", "build", "--sdist"], check=True)
133-
sdist_name = (
134-
f"xgboost-{release}{rc}{rc_ver}.tar.gz"
135-
if rc
136-
else f"xgboost-{release}.tar.gz"
137-
)
138-
src = DIST / sdist_name
139-
subprocess.run(["twine", "check", str(src)], check=True)
140-
dest = dist_dir / sdist_name
141-
shutil.move(src, dest)
112+
# Build sdist for `xgboost-cpu`, `xgboost`.
113+
for suffix, nccl_dep in [("cpu", "na"), ("na", "na")]:
114+
with DirectoryExcursion(ROOT):
115+
make_pyproject(use_suffix=suffix, require_nccl_dep=nccl_dep)
116+
with DirectoryExcursion(ROOT / "python-package"):
117+
subprocess.run(["python", "-m", "build", "--sdist"], check=True)
118+
pkg_name = "xgboost" if suffix == "na" else f"xgboost_{suffix}"
119+
sdist_name = (
120+
f"{pkg_name}-{release}{rc}{rc_ver}.tar.gz"
121+
if rc
122+
else f"{pkg_name}-{release}.tar.gz"
123+
)
124+
src = DIST / sdist_name
125+
subprocess.run(["twine", "check", str(src)], check=True)
126+
dest = dist_dir / sdist_name
127+
shutil.move(src, dest)
142128

143129
# Build stub package `xgboost-cu12`.
144130
with DirectoryExcursion(ROOT):
@@ -166,6 +152,9 @@ def download_python_wheels(branch: str, commit_hash: str, outdir: Path) -> None:
166152
"macosx_10_15_x86_64",
167153
"macosx_12_0_arm64",
168154
]
155+
cu13_platforms = [
156+
"manylinux_2_28_x86_64",
157+
]
169158
minimal_platforms = [
170159
"win_amd64",
171160
"win_arm64",
@@ -179,6 +168,7 @@ def download_python_wheels(branch: str, commit_hash: str, outdir: Path) -> None:
179168
for pkg_name, platforms in [
180169
("xgboost", full_platforms),
181170
("xgboost_cpu", minimal_platforms),
171+
("xgboost_cu13", cu13_platforms),
182172
]:
183173
src_filename_prefix = f"{pkg_name}-{args.release}-py3-none-"
184174
target_filename_prefix = f"{pkg_name}-{args.release}-py3-none-"

plugin/sycl/common/host_device_vector.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
#include "../device_manager.h"
1818
#include "../data.h"
19+
#include "../predictor/node.h"
1920

2021
namespace xgboost {
2122
template <typename T>
@@ -405,6 +406,7 @@ template class HostDeviceVector<FeatureType>;
405406
template class HostDeviceVector<Entry>;
406407
template class HostDeviceVector<bst_idx_t>;
407408
template class HostDeviceVector<uint32_t>; // bst_feature_t
409+
template class HostDeviceVector<sycl::predictor::Node>;
408410

409411
} // namespace xgboost
410412

plugin/sycl/common/linalg_op.cc

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/**
2+
* Copyright 2021-2025, XGBoost Contributors
3+
* \file linalg_op.h
4+
*/
5+
6+
#include "../data.h"
7+
#include "../device_manager.h"
8+
9+
#include "../../../src/common/optional_weight.h" // for OptionalWeights
10+
#include "xgboost/context.h" // for Context
11+
12+
#include <sycl/sycl.hpp>
13+
14+
namespace xgboost::sycl::linalg {
15+
16+
void SmallHistogram(Context const* ctx, xgboost::linalg::MatrixView<float const> indices,
17+
xgboost::common::OptionalWeights const& weights,
18+
xgboost::linalg::VectorView<float> bins) {
19+
sycl::DeviceManager device_manager;
20+
auto* qu = device_manager.GetQueue(ctx->Device());
21+
22+
qu->submit([&](::sycl::handler& cgh) {
23+
cgh.parallel_for<>(::sycl::range<1>(indices.Size()),
24+
[=](::sycl::id<1> pid) {
25+
const size_t i = pid[0];
26+
auto y = indices(i);
27+
auto w = weights[i];
28+
AtomicRef<float> bin_val(const_cast<float&>(bins(static_cast<std::size_t>(y))));
29+
bin_val += w;
30+
});
31+
}).wait();
32+
}
33+
34+
void VecScaMul(Context const* ctx, xgboost::linalg::VectorView<float> x, double mul) {
35+
sycl::DeviceManager device_manager;
36+
auto* qu = device_manager.GetQueue(ctx->Device());
37+
38+
qu->submit([&](::sycl::handler& cgh) {
39+
cgh.parallel_for<>(::sycl::range<1>(x.Size()),
40+
[=](::sycl::id<1> pid) {
41+
const size_t i = pid[0];
42+
const_cast<float&>(x(i)) *= mul;
43+
});
44+
}).wait();
45+
}
46+
} // namespace xgboost::sycl::linalg
47+
48+
namespace xgboost::linalg::sycl_impl {
49+
void VecScaMul(Context const* ctx, xgboost::linalg::VectorView<float> x, double mul) {
50+
xgboost::sycl::linalg::VecScaMul(ctx, x, mul);
51+
}
52+
} // namespace xgboost::linalg::sycl_impl
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*!
2+
* Copyright by Contributors 2017-2025
3+
*/
4+
#include <sycl/sycl.hpp>
5+
6+
#include "../../../src/common/optional_weight.h"
7+
8+
#include "../device_manager.h"
9+
10+
namespace xgboost::common::sycl_impl {
11+
double SumOptionalWeights(Context const* ctx, OptionalWeights const& weights) {
12+
sycl::DeviceManager device_manager;
13+
auto* qu = device_manager.GetQueue(ctx->Device());
14+
15+
const auto* data = weights.Data();
16+
double result = 0;
17+
{
18+
::sycl::buffer<double> buff(&result, 1);
19+
qu->submit([&](::sycl::handler& cgh) {
20+
auto reduction = ::sycl::reduction(buff, cgh, ::sycl::plus<>());
21+
cgh.parallel_for<>(::sycl::range<1>(weights.Size()), reduction,
22+
[=](::sycl::id<1> pid, auto& sum) {
23+
size_t i = pid[0];
24+
sum += data[i];
25+
});
26+
}).wait_and_throw();
27+
}
28+
29+
return result;
30+
}
31+
} // namespace xgboost::common::sycl_impl

0 commit comments

Comments
 (0)