Fix categorical split evaluation for negative float inputs #247
All Vouch review confidence checks passed
Residual risk 0.16 = Change Risk (0.37) × (1 − Review Confidence (0.57)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.37 · 227 lines diff across 2 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
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.325
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #247"
general
weight: 0.35
chyunsu3
Fix categorical split evaluation for negative float inputs
Fixes #246.
Problem
evaluate_tree_impl(shared HOST DEVICE code) evaluates categoricalsplits with
valid_categories.test(input_val), whereinput_valis afloating-point feature value and
bitset::testtakes an unsignedinteger index. The implicit float-to-unsigned conversion is undefined
behavior for negative values, and the two platforms disagree:
bound check (test false); values in (-1, 0) truncate to 0.
category 0 and takes the wrong tree branch.
On LightGBM models with categorical splits, this makes the GPU engine
return different scores than the CPU engine (and than LightGBM itself)
for any row carrying negative values in a categorical column. Repro
and measurements in #246: a synthetic categorical booster shows
Spearman < 1 between engines, and a large real-world categorical
booster reaches Spearman 0.909 / max delta 0.58 at double precision.
All-numeric models are unaffected.
Fix
Add
categorical_bitset_index, an explicit trunc-toward-zeroconversion with an out-of-range guard ([-1, num_bits) maps like the
x86 behavior, everything else tests false), and use it at both
categorical call sites (in-node bitset and external categorical
storage). NaN handling is unchanged (already guarded by
isnanat thecall sites). Both engines now share the same well-defined semantics,
matching LightGBM's int-cast lookup.
Testing
agreement before vs after (results to be attached from an H200
validation run of a source build with this patch).