Compare commits

...

3 Commits

Author SHA1 Message Date
Jiaming Yuan
e7decb9775 [R] release 1.5.0.2 (#7452)
* [R] release 1.5.0.2

* Add cmake list to r build ignore.
2021-11-19 21:39:38 +08:00
Jiaming Yuan
1920118bcb [backport] [CI] Install igraph as binary. (#7417) (#7447) 2021-11-18 16:35:04 +08:00
Jiaming Yuan
2032547426 Fix R CRAN failures. (#7404) (#7441)
* Remove hist builder dtor.

* Initialize values.

* Tolerance.

* Remove the use of nthread in col maker.
2021-11-17 18:34:53 +08:00
9 changed files with 37 additions and 28 deletions

View File

@@ -3,7 +3,7 @@ name: XGBoost-R-Tests
on: [push, pull_request] on: [push, pull_request]
env: env:
R_PACKAGES: c('XML', 'igraph', 'data.table', 'ggplot2', 'DiagrammeR', 'Ckmeans.1d.dp', 'vcd', 'testthat', 'lintr', 'knitr', 'rmarkdown', 'e1071', 'cplm', 'devtools', 'float', 'titanic') R_PACKAGES: c('XML', 'data.table', 'ggplot2', 'DiagrammeR', 'Ckmeans.1d.dp', 'vcd', 'testthat', 'lintr', 'knitr', 'rmarkdown', 'e1071', 'cplm', 'devtools', 'float', 'titanic')
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
jobs: jobs:
@@ -40,6 +40,11 @@ jobs:
install.packages(${{ env.R_PACKAGES }}, install.packages(${{ env.R_PACKAGES }},
repos = 'http://cloud.r-project.org', repos = 'http://cloud.r-project.org',
dependencies = c('Depends', 'Imports', 'LinkingTo')) dependencies = c('Depends', 'Imports', 'LinkingTo'))
- name: Install igraph on Windows
shell: Rscript {0}
if: matrix.config.os == 'windows-latest'
run: |
install.packages('igraph', type='binary')
- name: Run lintr - name: Run lintr
run: | run: |
@@ -83,6 +88,11 @@ jobs:
install.packages(${{ env.R_PACKAGES }}, install.packages(${{ env.R_PACKAGES }},
repos = 'http://cloud.r-project.org', repos = 'http://cloud.r-project.org',
dependencies = c('Depends', 'Imports', 'LinkingTo')) dependencies = c('Depends', 'Imports', 'LinkingTo'))
- name: Install igraph on Windows
shell: Rscript {0}
if: matrix.config.os == 'windows-2016'
run: |
install.packages('igraph', type='binary', dependencies = c('Depends', 'Imports', 'LinkingTo'))
- uses: actions/setup-python@v2 - uses: actions/setup-python@v2
with: with:
@@ -91,7 +101,7 @@ jobs:
- name: Test R - name: Test R
run: | run: |
python tests/ci_build/test_r_package.py --compiler="${{ matrix.config.compiler }}" --build-tool="${{ matrix.config.build }}" python tests/ci_build/test_r_package.py --compiler='${{ matrix.config.compiler }}' --build-tool='${{ matrix.config.build }}'
test-R-CRAN: test-R-CRAN:
runs-on: ubuntu-latest runs-on: ubuntu-latest
@@ -115,7 +125,7 @@ jobs:
- name: Install system packages - name: Install system packages
run: | run: |
sudo apt-get update && sudo apt-get install libcurl4-openssl-dev libssl-dev libssh2-1-dev libgit2-dev pandoc pandoc-citeproc sudo apt-get update && sudo apt-get install libcurl4-openssl-dev libssl-dev libssh2-1-dev libgit2-dev pandoc pandoc-citeproc libglpk-dev
- name: Cache R packages - name: Cache R packages
uses: actions/cache@v2 uses: actions/cache@v2
@@ -130,6 +140,7 @@ jobs:
install.packages(${{ env.R_PACKAGES }}, install.packages(${{ env.R_PACKAGES }},
repos = 'http://cloud.r-project.org', repos = 'http://cloud.r-project.org',
dependencies = c('Depends', 'Imports', 'LinkingTo')) dependencies = c('Depends', 'Imports', 'LinkingTo'))
install.packages('igraph', repos = 'http://cloud.r-project.org', dependencies = c('Depends', 'Imports', 'LinkingTo'))
- name: Check R Package - name: Check R Package
run: | run: |

View File

@@ -4,3 +4,4 @@
^.*\.Rproj$ ^.*\.Rproj$
^\.Rproj\.user$ ^\.Rproj\.user$
README.md README.md
CMakeLists.txt

View File

@@ -1,8 +1,8 @@
Package: xgboost Package: xgboost
Type: Package Type: Package
Title: Extreme Gradient Boosting Title: Extreme Gradient Boosting
Version: 1.5.0.1 Version: 1.5.0.2
Date: 2021-10-13 Date: 2021-11-19
Authors@R: c( Authors@R: c(
person("Tianqi", "Chen", role = c("aut"), person("Tianqi", "Chen", role = c("aut"),
email = "tianqi.tchen@gmail.com"), email = "tianqi.tchen@gmail.com"),

View File

@@ -228,7 +228,7 @@ if (grepl('Windows', Sys.info()[['sysname']]) ||
X <- 10^runif(100, -20, 20) X <- 10^runif(100, -20, 20)
if (capabilities('long.double')) { if (capabilities('long.double')) {
X2X <- as.numeric(format(X, digits = 17)) X2X <- as.numeric(format(X, digits = 17))
expect_identical(X, X2X) expect_equal(X, X2X, tolerance = float_tolerance)
} }
# retrieved attributes to be the same as written # retrieved attributes to be the same as written
for (x in X) { for (x in X) {

View File

@@ -211,7 +211,7 @@ struct Entry {
*/ */
struct BatchParam { struct BatchParam {
/*! \brief The GPU device to use. */ /*! \brief The GPU device to use. */
int gpu_id; int gpu_id {-1};
/*! \brief Maximum number of bins per feature for histograms. */ /*! \brief Maximum number of bins per feature for histograms. */
int max_bin{0}; int max_bin{0};
/*! \brief Hessian, used for sketching with future approx implementation. */ /*! \brief Hessian, used for sketching with future approx implementation. */

View File

@@ -49,10 +49,10 @@ class SimpleDMatrix : public DMatrix {
MetaInfo info_; MetaInfo info_;
// Primary storage type // Primary storage type
std::shared_ptr<SparsePage> sparse_page_ = std::make_shared<SparsePage>(); std::shared_ptr<SparsePage> sparse_page_ = std::make_shared<SparsePage>();
std::shared_ptr<CSCPage> column_page_; std::shared_ptr<CSCPage> column_page_{nullptr};
std::shared_ptr<SortedCSCPage> sorted_column_page_; std::shared_ptr<SortedCSCPage> sorted_column_page_{nullptr};
std::shared_ptr<EllpackPage> ellpack_page_; std::shared_ptr<EllpackPage> ellpack_page_{nullptr};
std::shared_ptr<GHistIndexMatrix> gradient_index_; std::shared_ptr<GHistIndexMatrix> gradient_index_{nullptr};
BatchParam batch_param_; BatchParam batch_param_;
bool EllpackExists() const override { bool EllpackExists() const override {

View File

@@ -109,10 +109,9 @@ class ColMaker: public TreeUpdater {
interaction_constraints_.Configure(param_, dmat->Info().num_row_); interaction_constraints_.Configure(param_, dmat->Info().num_row_);
// build tree // build tree
for (auto tree : trees) { for (auto tree : trees) {
Builder builder( CHECK(tparam_);
param_, Builder builder(param_, colmaker_param_, interaction_constraints_, tparam_,
colmaker_param_, column_densities_);
interaction_constraints_, column_densities_);
builder.Update(gpair->ConstHostVector(), dmat, tree); builder.Update(gpair->ConstHostVector(), dmat, tree);
} }
param_.learning_rate = lr; param_.learning_rate = lr;
@@ -154,12 +153,12 @@ class ColMaker: public TreeUpdater {
class Builder { class Builder {
public: public:
// constructor // constructor
explicit Builder(const TrainParam& param, explicit Builder(const TrainParam &param, const ColMakerTrainParam &colmaker_train_param,
const ColMakerTrainParam& colmaker_train_param,
FeatureInteractionConstraintHost _interaction_constraints, FeatureInteractionConstraintHost _interaction_constraints,
const std::vector<float> &column_densities) GenericParameter const *ctx, const std::vector<float> &column_densities)
: param_(param), colmaker_train_param_{colmaker_train_param}, : param_(param),
nthread_(omp_get_max_threads()), colmaker_train_param_{colmaker_train_param},
ctx_{ctx},
tree_evaluator_(param_, column_densities.size(), GenericParameter::kCpuId), tree_evaluator_(param_, column_densities.size(), GenericParameter::kCpuId),
interaction_constraints_{std::move(_interaction_constraints)}, interaction_constraints_{std::move(_interaction_constraints)},
column_densities_(column_densities) {} column_densities_(column_densities) {}
@@ -238,7 +237,7 @@ class ColMaker: public TreeUpdater {
// setup temp space for each thread // setup temp space for each thread
// reserve a small space // reserve a small space
stemp_.clear(); stemp_.clear();
stemp_.resize(this->nthread_, std::vector<ThreadEntry>()); stemp_.resize(this->ctx_->Threads(), std::vector<ThreadEntry>());
for (auto& i : stemp_) { for (auto& i : stemp_) {
i.clear(); i.reserve(256); i.clear(); i.reserve(256);
} }
@@ -451,8 +450,9 @@ class ColMaker: public TreeUpdater {
// start enumeration // start enumeration
const auto num_features = static_cast<bst_omp_uint>(feat_set.size()); const auto num_features = static_cast<bst_omp_uint>(feat_set.size());
#if defined(_OPENMP) #if defined(_OPENMP)
CHECK(this->ctx_);
const int batch_size = // NOLINT const int batch_size = // NOLINT
std::max(static_cast<int>(num_features / this->nthread_ / 32), 1); std::max(static_cast<int>(num_features / this->ctx_->Threads() / 32), 1);
#endif // defined(_OPENMP) #endif // defined(_OPENMP)
{ {
auto page = batch.GetView(); auto page = batch.GetView();
@@ -553,7 +553,8 @@ class ColMaker: public TreeUpdater {
virtual void SyncBestSolution(const std::vector<int> &qexpand) { virtual void SyncBestSolution(const std::vector<int> &qexpand) {
for (int nid : qexpand) { for (int nid : qexpand) {
NodeEntry &e = snode_[nid]; NodeEntry &e = snode_[nid];
for (int tid = 0; tid < this->nthread_; ++tid) { CHECK(this->ctx_);
for (int tid = 0; tid < this->ctx_->Threads(); ++tid) {
e.best.Update(stemp_[tid][nid].best); e.best.Update(stemp_[tid][nid].best);
} }
} }
@@ -609,7 +610,7 @@ class ColMaker: public TreeUpdater {
const TrainParam& param_; const TrainParam& param_;
const ColMakerTrainParam& colmaker_train_param_; const ColMakerTrainParam& colmaker_train_param_;
// number of omp thread used during training // number of omp thread used during training
const int nthread_; GenericParameter const* ctx_;
common::ColumnSampler column_sampler_; common::ColumnSampler column_sampler_;
// Instance Data: current node position in the tree of each instance // Instance Data: current node position in the tree of each instance
std::vector<int> position_; std::vector<int> position_;

View File

@@ -115,9 +115,6 @@ bool QuantileHistMaker::UpdatePredictionCache(
} }
} }
template <typename GradientSumT>
QuantileHistMaker::Builder<GradientSumT>::~Builder() = default;
template <typename GradientSumT> template <typename GradientSumT>
template <bool any_missing> template <bool any_missing>

View File

@@ -204,7 +204,6 @@ class QuantileHistMaker: public TreeUpdater {
new HistogramBuilder<GradientSumT, CPUExpandEntry>} { new HistogramBuilder<GradientSumT, CPUExpandEntry>} {
builder_monitor_.Init("Quantile::Builder"); builder_monitor_.Init("Quantile::Builder");
} }
~Builder();
// update one tree, growing // update one tree, growing
virtual void Update(const GHistIndexMatrix& gmat, virtual void Update(const GHistIndexMatrix& gmat,
const ColumnMatrix& column_matrix, const ColumnMatrix& column_matrix,