Handle the new device parameter in dask and demos. (#9386)
* Handle the new `device` parameter in dask and demos. - Check no ordinal is specified in the dask interface. - Update demos. - Update dask doc. - Update the condition for QDM.
This commit is contained in:
@@ -81,13 +81,6 @@ void XGBBuildInfoDevice(Json *p_info) {
|
||||
} // namespace xgboost
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
void DeprecatedFunc(StringView old, StringView since, StringView replacement) {
|
||||
LOG(WARNING) << "`" << old << "` is deprecated since" << since << ", use `" << replacement
|
||||
<< "` instead.";
|
||||
}
|
||||
} // anonymous namespace
|
||||
|
||||
XGB_DLL int XGBuildInfo(char const **out) {
|
||||
API_BEGIN();
|
||||
xgboost_CHECK_C_ARG_PTR(out);
|
||||
@@ -328,7 +321,7 @@ XGB_DLL int XGDeviceQuantileDMatrixCreateFromCallback(DataIterHandle iter, DMatr
|
||||
int nthread, int max_bin,
|
||||
DMatrixHandle *out) {
|
||||
API_BEGIN();
|
||||
DeprecatedFunc(__func__, "1.7.0", "XGQuantileDMatrixCreateFromCallback");
|
||||
LOG(WARNING) << error::DeprecatedFunc(__func__, "1.7.0", "XGQuantileDMatrixCreateFromCallback");
|
||||
*out = new std::shared_ptr<xgboost::DMatrix>{
|
||||
xgboost::DMatrix::Create(iter, proxy, nullptr, reset, next, missing, nthread, max_bin)};
|
||||
API_END();
|
||||
@@ -432,7 +425,7 @@ XGB_DLL int XGDMatrixCreateFromCSREx(const size_t *indptr, const unsigned *indic
|
||||
const bst_float *data, size_t nindptr, size_t nelem,
|
||||
size_t num_col, DMatrixHandle *out) {
|
||||
API_BEGIN();
|
||||
DeprecatedFunc(__func__, "2.0.0", "XGDMatrixCreateFromCSR");
|
||||
LOG(WARNING) << error::DeprecatedFunc(__func__, "2.0.0", "XGDMatrixCreateFromCSR");
|
||||
data::CSRAdapter adapter(indptr, indices, data, nindptr - 1, nelem, num_col);
|
||||
*out = new std::shared_ptr<DMatrix>(DMatrix::Create(&adapter, std::nan(""), 1));
|
||||
API_END();
|
||||
@@ -496,7 +489,7 @@ XGB_DLL int XGDMatrixCreateFromCSCEx(const size_t *col_ptr, const unsigned *indi
|
||||
const bst_float *data, size_t nindptr, size_t, size_t num_row,
|
||||
DMatrixHandle *out) {
|
||||
API_BEGIN();
|
||||
DeprecatedFunc(__func__, "2.0.0", "XGDMatrixCreateFromCSC");
|
||||
LOG(WARNING) << error::DeprecatedFunc(__func__, "2.0.0", "XGDMatrixCreateFromCSC");
|
||||
data::CSCAdapter adapter(col_ptr, indices, data, nindptr - 1, num_row);
|
||||
xgboost_CHECK_C_ARG_PTR(out);
|
||||
*out = new std::shared_ptr<DMatrix>(DMatrix::Create(&adapter, std::nan(""), 1));
|
||||
@@ -1347,7 +1340,7 @@ XGB_DLL int XGBoosterGetModelRaw(BoosterHandle handle, xgboost::bst_ulong *out_l
|
||||
raw_str.resize(0);
|
||||
|
||||
common::MemoryBufferStream fo(&raw_str);
|
||||
DeprecatedFunc(__func__, "1.6.0", "XGBoosterSaveModelToBuffer");
|
||||
LOG(WARNING) << error::DeprecatedFunc(__func__, "1.6.0", "XGBoosterSaveModelToBuffer");
|
||||
|
||||
learner->Configure();
|
||||
learner->SaveModel(&fo);
|
||||
|
||||
@@ -3,10 +3,18 @@
|
||||
*/
|
||||
#include "error_msg.h"
|
||||
|
||||
#include <sstream> // for stringstream
|
||||
|
||||
#include "../collective/communicator-inl.h" // for GetRank
|
||||
#include "xgboost/logging.h"
|
||||
|
||||
namespace xgboost::error {
|
||||
std::string DeprecatedFunc(StringView old, StringView since, StringView replacement) {
|
||||
std::stringstream ss;
|
||||
ss << "`" << old << "` is deprecated since" << since << ", use `" << replacement << "` instead.";
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
void WarnDeprecatedGPUHist() {
|
||||
auto msg =
|
||||
"The tree method `gpu_hist` is deprecated since 2.0.0. To use GPU training, set the `device` "
|
||||
@@ -34,8 +42,9 @@ void WarnDeprecatedGPUId() {
|
||||
if (logged) {
|
||||
return;
|
||||
}
|
||||
LOG(WARNING) << "`gpu_id` is deprecated in favor of the new `device` parameter: "
|
||||
<< "device = cpu/cuda/cuda:0";
|
||||
auto msg = DeprecatedFunc("gpu_id", "2.0.0", "device");
|
||||
msg += " E.g. device=cpu/cuda/cuda:0";
|
||||
LOG(WARNING) << msg;
|
||||
logged = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
#include <cinttypes> // for uint64_t
|
||||
#include <limits> // for numeric_limits
|
||||
#include <string> // for string
|
||||
|
||||
#include "xgboost/base.h" // for bst_feature_t
|
||||
#include "xgboost/logging.h"
|
||||
@@ -86,5 +87,7 @@ void WarnManualUpdater();
|
||||
void WarnDeprecatedGPUId();
|
||||
|
||||
void WarnEmptyDataset();
|
||||
|
||||
std::string DeprecatedFunc(StringView old, StringView since, StringView replacement);
|
||||
} // namespace xgboost::error
|
||||
#endif // XGBOOST_COMMON_ERROR_MSG_H_
|
||||
|
||||
@@ -690,19 +690,20 @@ class LearnerConfiguration : public Learner {
|
||||
stack.pop();
|
||||
auto const &obj = get<Object const>(j_obj);
|
||||
|
||||
for (auto const &kv : obj) {
|
||||
for (auto const& kv : obj) {
|
||||
if (is_parameter(kv.first)) {
|
||||
auto parameter = get<Object const>(kv.second);
|
||||
std::transform(parameter.begin(), parameter.end(), std::back_inserter(keys),
|
||||
[](std::pair<std::string const&, Json const&> const& kv) {
|
||||
return kv.first;
|
||||
});
|
||||
std::transform(
|
||||
parameter.begin(), parameter.end(), std::back_inserter(keys),
|
||||
[](std::pair<std::string const&, Json const&> const& kv) { return kv.first; });
|
||||
} else if (IsA<Object>(kv.second)) {
|
||||
stack.push(kv.second);
|
||||
} else if (kv.first == "metrics") {
|
||||
} else if (IsA<Array>(kv.second)) {
|
||||
auto const& array = get<Array const>(kv.second);
|
||||
for (auto const& v : array) {
|
||||
stack.push(v);
|
||||
if (IsA<Object>(v) || IsA<Array>(v)) {
|
||||
stack.push(v);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user