Skip to content

Commit

Permalink
Limit max_depth to 30 for GPU. (#8098)
Browse files Browse the repository at this point in the history
  • Loading branch information
trivialfis authored Jul 20, 2022
1 parent 8bdea72 commit 5156be0
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/tree/param.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,12 +207,13 @@ struct TrainParam : public XGBoostParameter<TrainParam> {
n_nodes = this->max_leaves * 2 - 1;
} else {
// bst_node_t will overflow.
CHECK_LE(this->max_depth, 31)
<< "max_depth can not be greater than 31 as that might generate 2 ** "
"32 - 1 nodes.";
n_nodes = (1 << (this->max_depth + 1)) - 1;
CHECK_LE(this->max_depth, 30)
<< "max_depth can not be greater than 30 as that might generate 2^31 - 1"
"nodes.";
// same as: (1 << (max_depth + 1)) - 1, but avoids 1 << 31, which overflows.
n_nodes = (1 << this->max_depth) + ((1 << this->max_depth) - 1);
}
CHECK_NE(n_nodes, 0);
CHECK_GT(n_nodes, 0);
return n_nodes;
}
};
Expand Down

0 comments on commit 5156be0

Please sign in to comment.