Support vector leaf SHAP on GPU#12210
Merged
Merged
Conversation
21c402f to
6b16469
Compare
Contributor
There was a problem hiding this comment.
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_treeSHAP 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.
6b16469 to
375b025
Compare
trivialfis
approved these changes
May 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_treewithpred_contribs=Trueandpred_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 --checkcmake --build build-cuda --target testxgboost -j35build-cuda/testxgboost --gtest_filter=GPUPredictor.ShapOutputCasesGPU:GPUPredictor.DartShapOutputGPU:GPUPredictor.CompareCPUShap:Predictor.ShapOutputCasesCPUPYTHONPATH=/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