Fix extrema calculation in MCMC split-range and node-constant helpers - #425
Open
dwachsmuth wants to merge 1 commit into
Open
Fix extrema calculation in MCMC split-range and node-constant helpers#425dwachsmuth wants to merge 1 commit into
dwachsmuth wants to merge 1 commit into
Conversation
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.
Hello,
I bumped into this issue in the course of a modelling project involving many thousands of model fits. I had GPT 6 Astra get to the bottom of the problem; it found the issue and proposed the solution, and I've verified that it works, at least on my local machine.
Here's the issue, solution and reprex:
VarSplitRange()can return an inverted interval for a varying numeric feature: observations visited in order3, 2, 1produce[1, DBL_MIN]instead of[1, 3].MCMCGrowTreeOneIter()then returns without proposing a split because the upper bound is below the lower bound. Negative features can instead get an upper bound near zero even when all observations are strictly negative.There are two causes:
numeric_limits<double>::min()is the smallest positive normalized double, and theif/else ifextrema update prevents an observation from updating both bounds. The latter also makes results depend on iteration order.NodeNonConstant()andNodesNonConstantAfterSplit()use the same patterns and can misclassify varying positive or constant nonpositive features.This patch initializes maxima with
lowest()and updates both extrema independently in all three helpers. It preserves their signatures and existing control flow, including the child-constant combination logic. Three deterministic GoogleTest cases exercise ranges and constant checks over permutations of small positive, negative, mixed-sign, constant and singleton inputs. They call the real helpers withForestDatasetandForestTracker; no stochastic model fit is needed.Minimal reproduction (also covered by
SamplerExtrema.RangeIsIndependentOfOrderAndSign):Validation on macOS ARM64 with Apple Clang, C++17 and OpenMP disabled:
[1, 2.2250738585072014e-308](exit 1) to
[1, 3](exit 0).