[MT] Monotonic constraint.#12341
Conversation
There was a problem hiding this comment.
Pull request overview
This PR extends monotonic-constraint handling to multi-output (vector-leaf) training paths by making split-time monotone bounds target-aware, propagating those bounds across splits, and ensuring reduced-gradient bounds don’t incorrectly constrain full-dimensional leaf refresh. It adds/updates C++/CUDA evaluators, training updaters, tests, and documentation to cover the new behavior.
Changes:
- Make
TreeEvaluatormonotone bounds target-aware and add constrained per-target split-weight computation for vector leaves. - Wire monotone-constraint propagation into CPU/GPU multi-target histogram evaluators/updaters, including reduced-gradient leaf refresh behavior.
- Expand unit/integration tests and update docs for vector-leaf monotone constraints and categorical partitioning documentation placement.
Reviewed changes
Copilot reviewed 20 out of 20 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/python/test_monotone_constraints.py | Parametrize parent-gain test across multi-output strategies; tighten type check (is list). |
| tests/python-gpu/test_monotonic_constraints.py | Parametrize GPU parent-gain test across multi-output strategies. |
| tests/cpp/tree/test_split_evaluator.cc | Add multi-target monotone-bound propagation and zero-hessian constrained-gain coverage. |
| tests/cpp/tree/hist/test_evaluate_splits.cc | Update evaluator construction/signatures for target-aware evaluators. |
| tests/cpp/tree/gpu_hist/test_multi_evaluate_splits.cu | Update GPU multi-evaluator initialization/reset API usage in tests. |
| src/tree/updater_quantile_hist.cc | Pass n_targets into HistMultiEvaluator; disable constraints for full leaf refresh under reduced gradients; remove vector-leaf monotone restriction. |
| src/tree/updater_gpu_hist.cuh | Pass n_targets into GPU multi-evaluator; apply splits with host+device candidate spans; disable constraints for full leaf refresh; remove vector-leaf monotone restriction. |
| src/tree/updater_colmaker.cc | Update TreeEvaluator construction with explicit n_targets=1. |
| src/tree/split_evaluator.h | Introduce target-aware bounds storage/indexing; implement constrained split weights for vector leaves; add vector AddSplit propagation; extend evaluator API with use_constraint. |
| src/tree/hist/evaluate_splits.h | Use constrained split weights for vector leaves; propagate bounds after applying split; add n_targets to HistMultiEvaluator; use Evaluator(use_constraint) API. |
| src/tree/gpu_hist/multi_evaluate_splits.cuh | Refactor to unique_ptr<TreeEvaluator>; make reset accept n_targets; add constraint toggle in evaluator access; extend ApplyTreeSplit signature. |
| src/tree/gpu_hist/multi_evaluate_splits.cu | Allocate TreeEvaluator with n_targets; enforce per-target constrained split weights; propagate bounds via AddSplit on applied splits; tighten runtime checks. |
| src/tree/gpu_hist/leaf_sum.cu | Ensure rounding/target dimension consistency; use target-aware CalcWeight. |
| src/tree/gpu_hist/evaluator.cu | Update TreeEvaluator construction to pass n_targets=1. |
| src/tree/gpu_hist/evaluate_splits.cuh | Update GPUHistEvaluator TreeEvaluator construction to pass n_targets=1. |
| python-package/xgboost/testing/multi_target.py | Add reduced-gradient monotone constraint test ensuring leaf refresh isn’t constrained by reduced-coordinate bounds. |
| python-package/xgboost/testing/monotone_constraints.py | Extend parent-gain test helper to handle multi-output strategy and expected gains. |
| doc/tutorials/multioutput.rst | Remove vector-leaf categorical partitioning section (relocated). |
| doc/tutorials/monotonic.rst | Document vector-leaf monotone constraint behavior and reduced-gradient caveat. |
| doc/tutorials/categorical.rst | Add vector-leaf categorical partitioning documentation (moved from multioutput tutorial). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 20 out of 20 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
src/tree/gpu_hist/multi_evaluate_splits.cuh:109
MultiHistEvaluatornow storestree_evaluator_as aunique_ptr, butGetEvaluator()dereferences it without a guard. If a caller accidentally uses the evaluator before callingReset(), this will be a null dereference at runtime; adding an explicitCHECK(tree_evaluator_)makes the contract clear and fails fast.
[[nodiscard]] auto GetEvaluator(bool use_constraint) const {
return tree_evaluator_->GetEvaluator<GPUTrainingParam>(use_constraint);
}
|
|
||
| .. versionadded:: 2.0.0 | ||
|
|
||
| .. note:: |
There was a problem hiding this comment.
there's a similar note at the beginning of the doc.
|
Ref: #9043