[GPU] Zero histograms when they are allocated. #12778
All Vouch review confidence checks passed
Residual risk 0.16 = Change Risk (0.40) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.40 · 318 lines diff across 3 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.345
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #12778"
general
weight: 0.35
chyunsu3
DeviceHistogramStorage::Resetzeroed the whole histogram cache before every tree. The cache holds up to 4096 node histograms (more after the buffer doubles), and only grows, so after one deep tree, every later tree zeroes all of it, including the part it never uses.With many features the cache is large. On Fashion-MNIST (784 features) it reaches several GB, and the reset took about 7 ms per tree: 57% of GPU kernel time at depth 18.
This PR zeroes histograms when they are allocated instead of on reset:
Resetno longer clears the cache.AllocateHistogramszeroes the new histograms, which are contiguous, with one launch. The overflow buffer is zeroed as before.DeviceHistogramBuilder::AllocateHistogramsoverloads are merged, withnodes_to_subdefaulting to empty.Validation:
Histogram.ZeroOnAllocatetest: fill histograms, reset, reallocate the same memory, and check that they are zero.max_cached_hist_nodevalues (1, 4, 8, 16) that exercise the overflow buffer, for depthwise, lossguide and multi-output trees.Training time, RTX PRO 6000 Blackwell, median of 3 rotated fresh-process runs:
| Workload | master (s) | this PR (s) | Speedup |
| --- | --- | --- | --- |
| Fashion-MNIST, depth 6 | 0.926 | 0.894 | 1.04× |
| Fashion-MNIST, depth 10 | 1.327 | 1.038 | 1.28× |
| Fashion-MNIST, depth 14 | 2.318 | 1.721 | 1.35× |
| Fashion-MNIST, depth 18 | 3.171 | 1.940 | 1.63× |
| Fashion-MNIST, depth 22 | 3.684 | 2.366 | 1.56× |
| Synthetic 2M × 100, depth 8 / 16 / 24 | | | 1.00× |
| Synthetic 2M × 100 with 5% missing, depth 24 | | | 1.03× |
| Synthetic 2M × 100, 1024 bins, depth 16 | | | 1.00× |
| Covertype, depth 8 / 24 | | | 0.99× / 1.02× |
| Logistic 4M × 64, depth 8 | | | 1.00× |
With fewer features the cache is smaller and the reset was a small share of the time, so the other workloads are unchanged.
Zeroing only the histograms to build, and leaving the subtraction-trick siblings unzeroed, would be about 8% faster again on Fashion-MNIST (1.77× at depth 18). It would rely on those siblings always being overwritten, and on rebuilt siblings never being in the cache, so it isn't done here.
🤖 Generated with Claude Code