-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Small cleanup for histogram routines.
- Extract hist train param from GPU hist. - Make histogram const after construction.
- Loading branch information
1 parent
7579905
commit 5753869
Showing
13 changed files
with
159 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/** | ||
* Copyright 2021-2023, XGBoost Contributors | ||
*/ | ||
#include "param.h" | ||
|
||
#include <string> // for string | ||
|
||
#include "../../collective/communicator-inl.h" // for GetRank, Broadcast | ||
#include "xgboost/json.h" // for Object, Json | ||
#include "xgboost/tree_model.h" // for RegTree | ||
|
||
namespace xgboost::tree { | ||
DMLC_REGISTER_PARAMETER(HistMakerTrainParam); | ||
|
||
void HistMakerTrainParam::CheckTreesSynchronized(RegTree const* local_tree) const { | ||
if (!this->debug_synchronize) { | ||
return; | ||
} | ||
|
||
std::string s_model; | ||
Json model{Object{}}; | ||
int rank = collective::GetRank(); | ||
if (rank == 0) { | ||
local_tree->SaveModel(&model); | ||
} | ||
Json::Dump(model, &s_model, std::ios::binary); | ||
collective::Broadcast(&s_model, 0); | ||
|
||
RegTree ref_tree{}; // rank 0 tree | ||
auto j_ref_tree = Json::Load(StringView{s_model}); | ||
ref_tree.LoadModel(j_ref_tree); | ||
CHECK(*local_tree == ref_tree); | ||
} | ||
} // namespace xgboost::tree |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/** | ||
* Copyright 2021-2023, XGBoost Contributors | ||
*/ | ||
#pragma once | ||
#include "xgboost/parameter.h" | ||
#include "xgboost/tree_model.h" // for RegTree | ||
|
||
namespace xgboost::tree { | ||
struct HistMakerTrainParam : public XGBoostParameter<HistMakerTrainParam> { | ||
bool debug_synchronize; | ||
void CheckTreesSynchronized(RegTree const* local_tree) const; | ||
|
||
// declare parameters | ||
DMLC_DECLARE_PARAMETER(HistMakerTrainParam) { | ||
DMLC_DECLARE_FIELD(debug_synchronize) | ||
.set_default(false) | ||
.describe("Check if all distributed tree are identical after tree construction."); | ||
} | ||
}; | ||
} // namespace xgboost::tree |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.