-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor split evaluator using device-wide Scan primitive #7197
base: master
Are you sure you want to change the base?
Changes from all commits
b100e8e
26244f6
ac530a5
b32a634
09880b3
11c8bcd
115b649
71a5fb7
0931023
41a9a38
18d0daf
6cfac2f
bb904be
1242a7c
d26414e
ce86fdc
7b8bf95
e7ac53e
ac9c79b
cd98c39
c96bb6a
eadb3ce
7edef3c
447503d
1077d5d
b954d21
013c733
035ed20
d8b7d75
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
#define EVALUATE_SPLITS_CUH_ | ||
#include <xgboost/span.h> | ||
#include "../../data/ellpack_page.cuh" | ||
#include "../../common/device_helpers.cuh" | ||
#include "../split_evaluator.h" | ||
#include "../constraints.cuh" | ||
#include "../updater_gpu_common.cuh" | ||
|
@@ -24,11 +25,87 @@ struct EvaluateSplitInputs { | |
common::Span<const float> min_fvalue; | ||
common::Span<const GradientSumT> gradient_histogram; | ||
}; | ||
|
||
struct EvaluateSplitsHistEntry { | ||
uint32_t node_idx; | ||
uint32_t hist_idx; | ||
bool forward; | ||
}; | ||
|
||
template <typename GradientSumT> | ||
struct ScanElem { | ||
uint32_t node_idx; | ||
uint32_t hist_idx; | ||
int32_t findex{-1}; | ||
float fvalue{std::numeric_limits<float>::quiet_NaN()}; | ||
bool is_cat{false}; | ||
bool forward{true}; | ||
GradientSumT gpair{0.0, 0.0}; | ||
GradientSumT partial_sum{0.0, 0.0}; | ||
GradientSumT parent_sum{0.0, 0.0}; | ||
}; | ||
|
||
template <typename GradientSumT> | ||
struct ScanValueOp { | ||
EvaluateSplitInputs<GradientSumT> left; | ||
EvaluateSplitInputs<GradientSumT> right; | ||
TreeEvaluator::SplitEvaluator<GPUTrainingParam> evaluator; | ||
|
||
using ScanElemT = ScanElem<GradientSumT>; | ||
|
||
__device__ ScanElemT MapEvaluateSplitsHistEntryToScanElem( | ||
EvaluateSplitsHistEntry entry, | ||
EvaluateSplitInputs<GradientSumT> split_input); | ||
__device__ ScanElemT | ||
operator() (EvaluateSplitsHistEntry entry); | ||
}; | ||
|
||
template <typename GradientSumT> | ||
struct ScanOp { | ||
EvaluateSplitInputs<GradientSumT> left, right; | ||
TreeEvaluator::SplitEvaluator<GPUTrainingParam> evaluator; | ||
|
||
using ScanElemT = ScanElem<GradientSumT>; | ||
|
||
__device__ ScanElemT operator() (ScanElemT lhs, ScanElemT rhs); | ||
}; | ||
|
||
template <typename GradientSumT> | ||
struct ReduceElem { | ||
GradientSumT partial_sum{0.0, 0.0}; | ||
GradientSumT parent_sum{0.0, 0.0}; | ||
float loss_chg{std::numeric_limits<float>::lowest()}; | ||
int32_t findex{-1}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
uint32_t node_idx{0}; | ||
float fvalue{std::numeric_limits<float>::quiet_NaN()}; | ||
bool is_cat{false}; | ||
DefaultDirection direction{DefaultDirection::kLeftDir}; | ||
}; | ||
|
||
template <typename GradientSumT> | ||
struct ReduceValueOp { | ||
EvaluateSplitInputs<GradientSumT> left, right; | ||
TreeEvaluator::SplitEvaluator<GPUTrainingParam> evaluator; | ||
|
||
using ScanElemT = ScanElem<GradientSumT>; | ||
using ReduceElemT = ReduceElem<GradientSumT>; | ||
|
||
__device__ ReduceElemT operator() (ScanElemT e); | ||
}; | ||
|
||
template <typename GradientSumT> | ||
dh::device_vector<ReduceElem<GradientSumT>> | ||
EvaluateSplitsGenerateSplitCandidatesViaScan( | ||
TreeEvaluator::SplitEvaluator<GPUTrainingParam> evaluator, | ||
EvaluateSplitInputs<GradientSumT> left, | ||
EvaluateSplitInputs<GradientSumT> right); | ||
|
||
template <typename GradientSumT> | ||
void EvaluateSplits(common::Span<DeviceSplitCandidate> out_splits, | ||
TreeEvaluator::SplitEvaluator<GPUTrainingParam> evaluator, | ||
EvaluateSplitInputs<GradientSumT> left, | ||
EvaluateSplitInputs<GradientSumT> right); | ||
|
||
template <typename GradientSumT> | ||
void EvaluateSingleSplit(common::Span<DeviceSplitCandidate> out_split, | ||
TreeEvaluator::SplitEvaluator<GPUTrainingParam> evaluator, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,7 +32,13 @@ void CompareJSON(Json l, Json r) { | |
|
||
for (auto const& kv : l_obj) { | ||
ASSERT_NE(r_obj.find(kv.first), r_obj.cend()); | ||
CompareJSON(l_obj.at(kv.first), r_obj.at(kv.first)); | ||
if (kv.first == "default_left" || kv.first == "split_conditions") { | ||
auto const& l_arr = get<Array const>(l_obj.at(kv.first)); | ||
auto const& r_arr = get<Array const>(r_obj.at(kv.first)); | ||
ASSERT_EQ(l_arr.size(), r_arr.size()); | ||
} else { | ||
CompareJSON(l_obj.at(kv.first), r_obj.at(kv.first)); | ||
} | ||
Comment on lines
+35
to
+41
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change allows two models to differ in |
||
} | ||
break; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bst_node_t
.