← Back to Pull requests

Keep the global configuration unchanged when an update is rejected #12817

Closed
unknown closed this pull request without merging on Nov 09, 2026 09:33 UTC
View on GitHub
unknown unknown commented on Nov 09, 2026 06:09 UTC
Author

XGBSetGlobalConfig writes new values into the global configuration before validating them. When validation fails, the call returns an error but the rejected values stay in place:

import xgboost as xgb

try:
    xgb.set_config(verbosity=4)
except xgb.core.XGBoostError as e:
    print(e)  # value 4 for Parameter verbosity exceed bound [0,3]
print(xgb.get_config()["verbosity"])  # 4

It's worse with use_cuda_async_pool on a machine without a usable GPU, for example the PyPI wheel on a CPU-only host. The rejected flag stays set, so every later set_config / config_context call fails, including the context the sklearn estimators enter when verbosity is set:

try:
    with xgb.config_context(use_cuda_async_pool=True):
        pass
except xgb.core.XGBoostError:
    pass
xgb.XGBRegressor(n_estimators=2, verbosity=0).fit(X, y)  # raises the same error

config_context can't restore the previous configuration either, because the failure happens while entering it.

This PR applies the update to a copy of the configuration and commits it only after validation passes; nthread is applied after validation as well. Valid updates behave as before. A Python test checks that a rejected set_config / config_context leaves get_config() unchanged; it fails without the fix.

Tested on Linux x86_64 with a CPU build of master: tests/python/test_config.py, test_basic.py, test_callback.py, test_openmp.py and test_with_sklearn.py pass (except test_sklearn_plotting, which needs the Graphviz executable), and pre-commit and mypy pass on the changed files. I didn't run the C++ gtests; TEST(CAPI, XGBGlobalConfig) only checks return codes and error messages.

Diff: 214 lines (+160 / -54) across 2 files Reviewer: RAMitchell Review duration: 204m
All Vouch review confidence checks passed
Residual risk 0.24 = Change Risk (0.60) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.60 · 214 lines diff across 2 files
0.60
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
0.17
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
60%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.321
Shallow Review Depth shallow_review_depth
0.289
Sensitive Paths sensitive_paths
0.060
Real PR Conversation Timeline
1 comments
"Review active on #12817"
general weight: 0.35
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 60.5% reviewed sensitive_module
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 59.8% (MEDIUM) · Higher = larger blast radius
59.8%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 60.5% · Lower = rushed or shallow review
60.5%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 23.6% · Safe to merge
23.6%
Repository