← Back to Pull requests

[GPU] Zero histograms when they are allocated. #12778

Closed
unknown closed this pull request without merging on Nov 03, 2026 12:29 UTC
View on GitHub
unknown unknown commented on Oct 31, 2026 09:03 UTC
Author

DeviceHistogramStorage::Reset zeroed 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:

  • Reset no longer clears the cache.

  • AllocateHistograms zeroes the new histograms, which are contiguous, with one launch. The overflow buffer is zeroed as before.

  • Every allocated histogram still starts at zero, as before, so callers don't rely on the subtraction trick overwriting anything.

  • The two DeviceHistogramBuilder::AllocateHistograms overloads are merged, with nodes_to_sub defaulting to empty.
  • Validation:

  • New Histogram.ZeroOnAllocate test: fill histograms, reset, reallocate the same memory, and check that they are zero.

  • GPU hist, histogram, evaluator, partitioner, external-memory, multi-target, updater and constraint C++ tests pass (442).

  • Model JSON is identical to master in every benchmark run, and with small max_cached_hist_node values (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

    Diff: 318 lines (+238 / -80) across 3 files Reviewer: chyunsu3 Review duration: 4526m
    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
    0.40
    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.345
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #12778"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    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: 40.4% (MEDIUM) · Higher = larger blast radius
    40.4%
    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: 16.0% · Safe to merge
    16.0%
    Repository