Skip to content

Support vector leaf SHAP on GPU#12210

Merged
RAMitchell merged 4 commits into
dmlc:masterfrom
RAMitchell:codex/gpu-vector-leaf-shap
May 14, 2026
Merged

Support vector leaf SHAP on GPU#12210
RAMitchell merged 4 commits into
dmlc:masterfrom
RAMitchell:codex/gpu-vector-leaf-shap

Conversation

@RAMitchell
Copy link
Copy Markdown
Member

What changed

This extends the exact GPU QuadratureTreeSHAP implementation to support vector-leaf trees for both SHAP contributions and SHAP interaction contributions.

The GPU model compression now stores tree topology once and stores leaf outputs separately. For vector-leaf trees, each compressed leaf records an offset into the leaf-value array, and the kernel reads the target-specific value from that array. The per-target work is represented by lightweight compressed-tree task metadata, so split structure, categories, and branch weights are not duplicated in compressed memory.

The shared C++ SHAP test cases now always include the vector-leaf case, and the CUDA multi-target Python tests include a public API regression for multi_output_tree with pred_contribs=True and pred_interactions=True.

Why

CPU SHAP already supports vector-leaf trees. The GPU predictor still rejected vector-leaf models for exact SHAP contributions and interactions. This removes that unsupported path while preserving the existing exact QuadratureTreeSHAP traversal.

Validation

  • git diff --check
  • cmake --build build-cuda --target testxgboost -j35
  • build-cuda/testxgboost --gtest_filter=GPUPredictor.ShapOutputCasesGPU:GPUPredictor.DartShapOutputGPU:GPUPredictor.CompareCPUShap:Predictor.ShapOutputCasesCPU
  • PYTHONPATH=/home/nfs/rorym/xgboost-wt/gpu-vector-leaf-shap/python-package /home/nfs/rorym/anaconda3/bin/conda run -n xgboost python -m pytest tests/python-gpu/test_gpu_multi_target.py::test_shap_multi_output_tree

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends the GPU exact QuadratureTreeSHAP implementation to support vector-leaf (multi-target) trees, enabling pred_contribs=True and pred_interactions=True for multi_output_tree on CUDA and aligning GPU capabilities with existing CPU SHAP support.

Changes:

  • Refactors GPU SHAP model compression to store tree topology once and store leaf outputs in a separate array, with per-target task metadata.
  • Enables GPU exact SHAP contributions and interaction contributions for multi-target (vector-leaf) trees, removing the previous unsupported-path checks.
  • Expands C++ SHAP test coverage to always include vector-leaf cases and adds a CUDA Python regression test for multi_output_tree SHAP outputs.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tests/python-gpu/test_gpu_multi_target.py Adds a regression test validating SHAP contribs/interactions shapes and additivity for multi_output_tree on CUDA.
tests/cpp/predictor/test_shap.h Simplifies SHAP test case builder API to always include vector-leaf cases.
tests/cpp/predictor/test_shap.cu Runs the GPU SHAP output test suite over the unified test-case set (now including vector-leaf).
tests/cpp/predictor/test_shap.cc Always includes a multi-target vector-leaf case in shared SHAP test cases for CPU and GPU.
src/predictor/interpretability/shap.cu Implements vector-leaf support in GPU QuadratureTreeSHAP via new compression layout and target-aware leaf lookup in kernels.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/predictor/interpretability/shap.cu Outdated
Comment thread src/predictor/interpretability/shap.cu
Comment thread src/predictor/interpretability/shap.cu Outdated
Comment thread src/predictor/interpretability/shap.cu
@RAMitchell RAMitchell force-pushed the codex/gpu-vector-leaf-shap branch from 6b16469 to 375b025 Compare May 13, 2026 12:38
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated no new comments.

@RAMitchell RAMitchell marked this pull request as ready for review May 13, 2026 13:49
@RAMitchell RAMitchell merged commit 41591ee into dmlc:master May 14, 2026
84 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants