TreeWalker: Partial Evaluation for Grouped Tree-Ensemble Inference

Durmus U Karatay, Richard NewmanNeurIPS 2026

TL;DR

When scoring tabular data with tree ensembles like XGBoost or LightGBM, rows often arrive in groups that share identical features—think of scoring 50 hotel search results for a single user, or projecting one patient across 100 future time steps. Standard inference engines treat every row like a stranger, redundantly evaluating the same shared features over and over. TreeWalker applies partial evaluation to walk each decision tree just once per group, slicing latency by up to 9× algorithmically (and up to 54× against native frameworks) without changing a single line of model training code.

What Problem Does This Paper Address?

Gradient-boosted decision trees (GBDTs) are the undisputed workhorses of tabular machine learning. Because latency matters in production, engineers have spent years optimizing tree inference along two main axes: making each node visit cheaper (via code compilation or cache-friendly layouts) and making each tree walk shorter (via early termination, like QuickScorer).

Yet both approaches overlook a massive source of wasted work: input-side correlation. In many real-world workloads, a single prediction request expands into a group of $G$ rows where 50% to 70% of the features are completely identical:

  • Search & Ranking: Scoring dozens of items in one session (user and query features are constant; item prices and ratings vary).
  • Discrete-time Survival Analysis: Expanding one patient into $G$ time steps to predict hazard over time (patient covariates are constant; time variables change).
  • Scenario ("What-if") Analysis: Perturbing a handful of variables while holding everything else fixed.

Standard inference engines ignore this structure. If a group has 64 rows, the engine traverses the shared constant features 64 separate times. TreeWalker asks a simple question: Why not share the walk?

Methods

TreeWalker brings a classic programming-languages technique—online partial evaluation—to tree ensembles. In this setup, features that are identical across the group are treated as static, while features that differ across rows are dynamic. Crucially, TreeWalker ingests standard LightGBM and XGBoost models directly—training is completely untouched.

Instead of walking a tree $G$ times for $G$ rows, TreeWalker walks each tree once per group, carrying along a lightweight integer bitmask (e.g., a 64-bit word) where each bit tracks whether a specific row in the group is still active at the current node.

Figure 1: Worked example: a 4-row group with shared x1=2 and varying x5=[2, 4, 7, 9]. (a) Stan- dard inference evaluates x1 ≤3 four times and x5 ≤5 four times. (b) TreeWalker evaluates the constant split once, carries the active-row mask [1111], and partitions it at the varying split into [1100] and [0011] before leaf accumulation.

The traversal unfolds in three phases:

  1. Constant Walk: When a tree node splits on a constant feature, every active row goes the exact same way. TreeWalker evaluates the condition once and steps to the winning child in $O(1)$ time, regardless of group size.
  2. Varying Split & Unsplit Shortcut: When a node splits on a varying feature, TreeWalker partitions the active bitmask into left and right subsets ($m_L$ and $m_R$) and recurses. If either mask is all zeros (say, every hotel in the session costs under \$300), an unsplit shortcut skips that entire empty subtree.
  3. Leaf Accumulation: Upon hitting a leaf, the leaf's prediction value is added to the output array for every set bit in the active mask.

Under the hood, TreeWalker pairs this recursion with forest-level predicate precomputation. Rather than evaluating varying splits on the fly at every node, it sorts each varying feature once per group and sweeps it against deduplicated split thresholds across the entire ensemble to pre-build bitmasks.

Datasets

The authors evaluate TreeWalker across four public benchmarks spanning three distinct grouped-workload archetypes:

  • SUPPORT & FLCHAIN (Survival Analysis): Standard clinical survival datasets discretized into panel format, where each patient expands into swept time horizons ($G$ ranging from 1 up to 1,008 rows), with 57%–70% constant features.
  • Expedia (Click-Through-Rate / Ranking): Hotel search sessions where each session scores between 5 and 37 candidate hotels (48% constant user/context features).
  • UCI Default of Credit Card Clients (Scenario Analysis): A synthetic "what-if" benchmark built on 30,000 credit records, expanding test rows into $G \in \{4, 16, 64, 128\}$ variants by perturbing $k \in \{1, 2, 4, 8\}$ features while holding the remaining $23-k$ constant.

Key Insights and Ideas

  • A New, Composable Optimization Axis: Fast tree inference isn't just about per-visit speed or per-walk depth; it is also about the number of walks. Because partial evaluation reduces $G \cdot T$ walks toward $T$, it sits on an orthogonal axis that can theoretically compose with compilers (like lleaves) or SIMD vectorization.
  • Exact Work Decomposition & Asymptotic Limits: The authors prove a neat structural theorem: per-tree work equals visited constant/varying splits, plus $G$ leaf writes, plus mask-provisioning cost. As group size $G \to \infty$, shared structural overhead vanishes, and per-row work drops cleanly toward the fraction of varying splits along a root-to-leaf path.
  • Forest-Wide Precomputation Pays Off: Ablation studies reveal that precomputing and deduplicating varying feature masks once across all trees is the biggest practical performance driver—disabling precomputation slows Expedia inference by 93%–139%.
  • Better Floating-Point Accuracy for Free: For f32 models, TreeWalker accumulates leaf values in f64, landing closer to an infinitely precise reference than native f32 inference on every audited row.

Key Results

To separate algorithmic gains from C++/Rust data-layout engineering, the authors benchmark TreeWalker against both an internal same-layout full-walk baseline (algorithmic speedup) and external systems like native LightGBM/XGBoost, tl2cgen, and lleaves (system speedup) on Intel Xeon and Arm Neoverse V2 CPUs.

Figure 2: Algorithmic speedup across all (T, L) combinations on Intel, for (a) FLCHAIN (G=16), (b) SUPPORT (G=16), and (c) Expedia (empirical groups). Each cell: arithmetic mean of the two framework-specific speedups. Darker = higher speedup.
  • Algorithmic Speedup: At the reference configuration ($T{=}500$ trees, max depth $L{=}8$, $G{=}16$), TreeWalker is ~3× faster on Intel (2.5–2.9× on Arm) than walking rows independently. At wider horizons ($G{=}128$), this climbs to 7.7–9.1× on Intel (5.5–6.0× on Arm), and hits 17.1× at ~1,000 rows on FLCHAIN.
  • System Speedup: At the reference size on SUPPORT, TreeWalker is 7.1× faster than native LightGBM and 9.0× faster than native XGBoost (combining a ~2.5× data-layout boost with a ~2.9× partial-evaluation boost), peaking at 54× over LightGBM at $T{=}2000, G{=}128$. It also outpaces LLVM-compiled lleaves by 2.1–2.6× at $G{=}128$.
  • Scenario Analysis: Across all 16 $(k, G)$ configurations on both Intel and Arm, TreeWalker wins—reaching 15.2× speedup when perturbing a single feature ($k{=}1, G{=}128$) and 8.1× when perturbing eight ($k{=}8, G{=}128$).

Limitations and Future Work

  • Not for Unstructured Batches: TreeWalker has a strict operational contract: the request itself must supply grouped rows with known constant features. It does not try to discover groups inside random, unstructured batches, and when $G \le 2$ (or up to $G \le 8$ against compiled baselines like tl2cgen/lleaves), bitmask setup overhead makes it slightly slower.
  • CPU-Only & Scalar Scope: The current engine targets latency-critical, single-threaded CPU serving for scalar models; GPU execution and multi-output trees are out of scope.
  • Future Directions: The authors point to natural next steps: supporting hierarchical subgrouping (for batches with partially overlapping constants), composing with QuickScorer to accelerate shallow trees, and caching predicate masks across requests in multi-stage ranking pipelines.

Summary updated

BibTeX
@inproceedings{karatay2026treewalker,
  author = {Durmus U Karatay and Richard Newman},
  title = {{TreeWalker: Partial Evaluation for Grouped Tree-Ensemble Inference}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=gSYbuGjI0V},
}
Figure