Unify and fix min_child_weight.#12296
Merged
Merged
Conversation
Currently, the CPU hist does a `pre-check` using `IsValid` to prevent a candidate from being evaluated, which is correct. However, the GPU does a post check, which can let a invalid candidate to win the evaluation against other valid candidates, but only to be discarded after evaluation, hence, a bug. The PR centralizes the min child weight handling to the gain calculation.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes inconsistent min_child_weight handling between CPU and GPU tree methods by enforcing the check inside split gain computation (so invalid candidates can’t “win” evaluation and be discarded later), and removes redundant pre-/post-validation in split enumeration/update paths.
Changes:
- Centralize
min_child_weight(+ non-zero Hessian) validation inTreeEvaluator::SplitEvaluator::CalcSplitGain. - Remove CPU Hist-side pre-checks (
IsValid) and GPU-side candidate update checks, relying on-infgain for invalid splits. - Add a focused regression test ensuring consistent split/stat behavior across CPU/GPU updaters.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tests/cpp/tree/test_tree_stat.cc | Adds a regression test covering min_child_weight behavior across multiple updaters (CPU + CUDA). |
| src/tree/updater_gpu_common.cuh | Removes min_child_weight filtering from GPU split-candidate update, preventing post-hoc invalidation patterns. |
| src/tree/split_evaluator.h | Enforces min_child_weight/positive-Hessian validity directly in split gain computation via -inf return. |
| src/tree/hist/evaluate_splits.h | Removes local validity pre-checks and always evaluates candidates, relying on evaluator gating. |
| src/tree/gpu_hist/evaluate_splits.cu | Updates call sites to match the simplified GPU candidate update API. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
RAMitchell
approved these changes
Jul 10, 2026
RAMitchell
left a comment
Member
There was a problem hiding this comment.
Good catch and fix looks good.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently, the CPU hist does a pre-check using
IsValidto prevent a candidate from being evaluated, which is correct.However, the GPU performs a post-check in
ExpandEntry::Updatethat can allow an invalid candidate to win the evaluation over other valid candidates, only to be discarded afterward; hence, a bug.The PR centralizes the handling of min child weight in the gain calculation and removes these pre- and post-checks.