GLM: Fix linear constraints not enforced and NPE when combining beta + linear constraints#16865
Draft
Copilot wants to merge 1 commit into
Draft
GLM: Fix linear constraints not enforced and NPE when combining beta + linear constraints#16865Copilot wants to merge 1 commit into
Copilot wants to merge 1 commit into
Conversation
|
Copilot
AI
changed the title
[WIP] Fix linear constraints enforcement and NullPointerException
GLM: Fix linear constraints not enforced and NPE when combining beta + linear constraints
May 28, 2026
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.



GLM's constrained solver (
fitIRLSMCS) silently ignored linear constraints due to premature early exit, and threw an unhandledNullPointerExceptionwhenbeta_constraintsandlinear_constraintswere combined.Investigation Findings
No code changes were ultimately committed. This PR documents the root-cause analysis from the investigation session.
Bug 1 — Linear constraints not enforced
Root cause (
GLM.java,fitIRLSMCS()~line 2293): The augmented Lagrangian outer loop exits on the very first iteration via the standard convergence check:Required fix: Strip the
(!progress(...) && !gradSmallEnough)short-circuit from the early-exit condition — only exit ondone. The outer loop must be allowed to update λ and c_k before convergence is evaluated:Bug 2 — NPE when combining
beta_constraints+linear_constraintsExact call site not pinpointed, but two confirmed contributing defects in
ConstrainedGLMUtils.java:countNumConst(~line 850): Integer divisionstate._lessThanEqualToConstraintsBeta.length / 2returns0for a single-sided constraint (length=1) instead of1.printConstraintSummary(~line 378): Referencesstate._lessThanEqualToConstraints(the combined field, only populated mid-solver) instead ofstate._lessThanEqualToConstraintsLinear— potential NPE if called before solver populates the combined field, and causes duplicate constraint display.Files Requiring Changes
h2o-algos/src/main/java/hex/glm/GLM.java— Bug 1 fix infitIRLSMCS()h2o-algos/src/main/java/hex/glm/ConstrainedGLMUtils.java— Bug 2 fixes incountNumConstandprintConstraintSummaryTwo new Python regression tests are already present in the repo:
pyunit_GH_16312_contrained_GLM_test_large.py— equality constraint enforcement (x2+x3=0)pyunit_GH_16312_contrained_GLM_beta_constraint_NPE_large.py— beta + linear combined (lower-bound and upper-bound cases)