Skip to content

QuadratureTreeSHAP: shared polynomial construction - #12661

Merged
RAMitchell merged 4 commits into
dmlc:masterfrom
ron-wettenstein:feature/qts-shared-polynomial-construction
Oct 7, 2026
Merged

RAMitchell merged 4 commits into
dmlc:masterfrom
ron-wettenstein:feature/qts-shared-polynomial-construction

Conversation

@ron-wettenstein

@ron-wettenstein ron-wettenstein commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

This PR is split out of #12650 . See that PR for more details, including benchmark results against master for this change and the five related ones.

This PR includes contributions 2, 3, 1 and 6 of #12650. Contributions 2 and 3 are available also in PR #12660. Contributions 1 and 6 change code introduced in 2 and 3 and can not be stand alone. I suggest reviewing and merging #12660 first. I'll then rebase this branch on the new master, and the diff here will show only contributions 1 and 6.
Contribution 1 and 6 are here as they are highly dependent. The change in contribution 1 enables the cleanup in contribution 6.

Contributions 1 and 6 details:

  1. Interaction values reuse the polynomial construction of Shapley values. The interaction values logic builds the shared polynomial (c and H_u in Alg 1 of the paper) once reuses it for each feature pair in the path. Estimated 1.2–2.7× on 1 thread, growing with depth, plus a further 2.7–3.4× at 8 threads. Done in the third commit in this branch.
  2. Cleanup. Removed: QuadraturePathElement, QuadraturePathView, EmptyQuadraturePathState, LiveQuadraturePathState, ForEachPartner, AccumulatePair, ResetPath/PushPathSplit/PopPathSplit. InteractionContributionFormulation and AdditiveContributionFormulation formulations only now include HandleReturn. No speed change. Done in the fourth commit in this branch.

@coderabbitai

coderabbitai Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 37dbde83-aedf-4dc5-8217-022565742a27
📥 Commits

Reviewing files that changed from the base of the PR and between 75c607b and eca6e73.

📒 Files selected for processing (1)
  • src/predictor/interpretability/shap.cc
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/predictor/interpretability/shap.cc

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.


Walkthrough

CPU quadrature TreeSHAP extracts edge terms for each quadrature point. The additive formulation sums these terms. The interaction formulation uses their sum for the split diagonal and cached factors for off-diagonal contributions. The runner invokes formulation hooks during recursion and uses per-thread path-feature buffers.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to eca6e

No actionable issue was found in the inspected contribution and traversal changes; the PR is mergeable after normal checks.

  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@ron-wettenstein ron-wettenstein changed the title Feature/qts shared polynomial construction QuadratureTreeSHAP: shared polynomial construction Oct 6, 2026
ron-wettenstein and others added 2 commits October 6, 2026 22:33
…tions

On each return edge, interactions recomputed the edge's per-point terms for every partner feature.
Build the terms once per edge, as SHAP values do, and weight them by a per-partner factor that is
cached when the partner's path probability changes (Alg. 1 of the QuadratureTreeSHAP paper).

The runner keeps the distinct features of the current path in a fixed per-thread buffer. This also
removes the per-edge duplicate scan and the vector push/pop that limited multi-threaded scaling. The
old path classes are now unused; the next commit removes them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Remove QuadraturePathElement, QuadraturePathView, EmptyQuadraturePathState, LiveQuadraturePathState,
ForEachPartner, AccumulatePair and the ResetPath/PushPathSplit/PopPathSplit hooks, which the previous
commit left unused. The formulations now only implement HandleReturn. No functional change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ron-wettenstein
ron-wettenstein force-pushed the feature/qts-shared-polynomial-construction branch from a660418 to d4fd245 Compare October 6, 2026 20:03
@ron-wettenstein
ron-wettenstein marked this pull request as ready for review October 6, 2026 20:06
@ron-wettenstein

Copy link
Copy Markdown
Contributor Author

@RAMitchell this branch is updated and ready to be reviewed.
After this PR only #12650 remains.

@RAMitchell

Copy link
Copy Markdown
Member

Made a small code style improvement here. Shap/interactions now defined an enterfeature/leavefeature method which is a no-op for shap.

@RAMitchell
RAMitchell merged commit a3bae09 into dmlc:master Oct 7, 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.

2 participants