Skip to content

Commit

Permalink
Fix cox objective test by using XGBOOST_PARALLEL_STABLE_SORT
Browse files Browse the repository at this point in the history
XGBOOST_PARALLEL_SORT cannot preserve the original order of
equal elements. It causes flaky failure for the cox regression
unittest. Use stable sort to make sure the result is deterministic.

Fix dmlc#7754
  • Loading branch information
hmchen-github committed Mar 25, 2022
1 parent af0cf88 commit 9e07e53
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion include/xgboost/data.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class MetaInfo {
label_order_cache_.resize(labels.Size());
std::iota(label_order_cache_.begin(), label_order_cache_.end(), 0);
const auto& l = labels.Data()->HostVector();
XGBOOST_PARALLEL_SORT(label_order_cache_.begin(), label_order_cache_.end(),
XGBOOST_PARALLEL_STABLE_SORT(label_order_cache_.begin(), label_order_cache_.end(),
[&l](size_t i1, size_t i2) {return std::abs(l[i1]) < std::abs(l[i2]);});

return label_order_cache_;
Expand Down

0 comments on commit 9e07e53

Please sign in to comment.