Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into redesign-jvm
Browse files Browse the repository at this point in the history
  • Loading branch information
wbo4958 committed Sep 9, 2024
2 parents cbb5268 + bba6aa7 commit 44ac4d6
Show file tree
Hide file tree
Showing 22 changed files with 240 additions and 166 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ jobs:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
submodules: 'true'
- uses: actions/setup-python@39cd14951b08e74b54015e9e001cdefcf80e669f # v5.1.1
- uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5.2.0
with:
python-version: "3.10"
architecture: 'x64'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/python_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ jobs:
submodules: 'true'

- name: Set up Python 3.10
uses: actions/setup-python@39cd14951b08e74b54015e9e001cdefcf80e669f # v5.1.1
uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5.2.0
with:
python-version: "3.10"

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/r_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ jobs:
key: ${{ runner.os }}-r-${{ matrix.config.r }}-7-${{ hashFiles('R-package/DESCRIPTION') }}
restore-keys: ${{ runner.os }}-r-${{ matrix.config.r }}-7-${{ hashFiles('R-package/DESCRIPTION') }}

- uses: actions/setup-python@39cd14951b08e74b54015e9e001cdefcf80e669f # v5.1.1
- uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5.2.0
with:
python-version: "3.10"
architecture: 'x64'
Expand Down
6 changes: 5 additions & 1 deletion python-package/xgboost/dask/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1568,14 +1568,15 @@ def inplace_predict( # pylint: disable=unused-argument

async def _async_wrap_evaluation_matrices(
client: Optional["distributed.Client"],
device: Optional[str],
tree_method: Optional[str],
max_bin: Optional[int],
**kwargs: Any,
) -> Tuple[DaskDMatrix, Optional[List[Tuple[DaskDMatrix, str]]]]:
"""A switch function for async environment."""

def _dispatch(ref: Optional[DaskDMatrix], **kwargs: Any) -> DaskDMatrix:
if _can_use_qdm(tree_method):
if _can_use_qdm(tree_method, device):
return DaskQuantileDMatrix(
client=client, ref=ref, max_bin=max_bin, **kwargs
)
Expand Down Expand Up @@ -1776,6 +1777,7 @@ async def _fit_async(
params = self.get_xgb_params()
dtrain, evals = await _async_wrap_evaluation_matrices(
client=self.client,
device=self.device,
tree_method=self.tree_method,
max_bin=self.max_bin,
X=X,
Expand Down Expand Up @@ -1865,6 +1867,7 @@ async def _fit_async(
params = self.get_xgb_params()
dtrain, evals = await _async_wrap_evaluation_matrices(
self.client,
device=self.device,
tree_method=self.tree_method,
max_bin=self.max_bin,
X=X,
Expand Down Expand Up @@ -2067,6 +2070,7 @@ async def _fit_async(
params = self.get_xgb_params()
dtrain, evals = await _async_wrap_evaluation_matrices(
self.client,
device=self.device,
tree_method=self.tree_method,
max_bin=self.max_bin,
X=X,
Expand Down
7 changes: 4 additions & 3 deletions python-package/xgboost/sklearn.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,9 @@ def _check_rf_callback(
)


def _can_use_qdm(tree_method: Optional[str]) -> bool:
return tree_method in ("hist", "gpu_hist", None, "auto")
def _can_use_qdm(tree_method: Optional[str], device: Optional[str]) -> bool:
not_sycl = (device is None) or (not device.startswith("sycl"))
return tree_method in ("hist", "gpu_hist", None, "auto") and not_sycl


class _SklObjWProto(Protocol): # pylint: disable=too-few-public-methods
Expand Down Expand Up @@ -1031,7 +1032,7 @@ def _duplicated(parameter: str) -> None:

def _create_dmatrix(self, ref: Optional[DMatrix], **kwargs: Any) -> DMatrix:
# Use `QuantileDMatrix` to save memory.
if _can_use_qdm(self.tree_method) and self.booster != "gblinear":
if _can_use_qdm(self.tree_method, self.device) and self.booster != "gblinear":
try:
return QuantileDMatrix(
**kwargs, ref=ref, nthread=self.n_jobs, max_bin=self.max_bin
Expand Down
5 changes: 4 additions & 1 deletion python-package/xgboost/spark/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1028,7 +1028,10 @@ def _train_booster(
context = BarrierTaskContext.get()

dev_ordinal = None
use_qdm = _can_use_qdm(booster_params.get("tree_method", None))
use_qdm = _can_use_qdm(
booster_params.get("tree_method", None),
booster_params.get("device", None),
)
verbosity = booster_params.get("verbosity", 1)
msg = "Training on CPUs"
if run_on_gpu:
Expand Down
10 changes: 4 additions & 6 deletions src/common/compressed_iterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,11 @@ class CompressedBufferWriter {
static size_t CalculateBufferSize(size_t num_elements, size_t num_symbols) {
constexpr int kBitsPerByte = 8;
size_t compressed_size = static_cast<size_t>(std::ceil(
static_cast<double>(detail::SymbolBits(num_symbols) * num_elements) /
kBitsPerByte));
static_cast<double>(detail::SymbolBits(num_symbols) * num_elements) / kBitsPerByte));
// Handle atomicOr where input must be unsigned int, hence 4 bytes aligned.
size_t ret =
std::ceil(static_cast<double>(compressed_size + detail::kPadding) /
static_cast<double>(sizeof(unsigned int))) *
sizeof(unsigned int);
size_t ret = std::ceil(static_cast<double>(compressed_size + detail::kPadding) /
static_cast<double>(sizeof(std::uint32_t))) *
sizeof(std::uint32_t);
return ret;
}

Expand Down
Loading

0 comments on commit 44ac4d6

Please sign in to comment.