TreeWalker
3 steps1 pieces3 Sources
TreeWalker is an open-source Rust inference engine developed by Shopify engineers Durmus Karatay and Richard Newman to accelerate grouped tree-ensemble scoring. The tool applies partial evaluation techniques to machine learning workloads where multiple rows share constant feature values, such as delivery date predictions or survival analysis models. By resolving shared-feature decisions once per group using bit-vector masks rather than repeating them for every row, TreeWalker significantly reduces redundant computation.
In internal tests at Shopify, the engine achieved a 3.96× speedup in evaluating their main delivery prediction model compared to their previous evaluator, with identical training data and results. On public datasets like SUPPORT and FLCHAIN, when grouping 128 rows, the speedup reached up to 9.1× on Intel architectures. The system reads standard LightGBM and XGBoost models without requiring changes to the training process.
The core innovation lies in exploiting input-side correlation across rows within a group. While existing fast inference systems optimize per-visit cost (via compilation or vectorization) or per-walk cost (via early termination), they typically treat each row independently. TreeWalker walks each tree once per group, maintaining a row bitmask that partitions at varying splits and skips empty subtrees. This approach is particularly effective when a high percentage of features are constant within a group; in Shopify's factorial-grid benchmarks, this fraction ranged from 48% to 70%.
However, the authors note operational constraints: TreeWalker targets workloads whose request semantics naturally supply grouped rows, such as discrete-time expansion or session-level ranking. It does not construct groups from unstructured batches and offers no advantage when rows share no feature values. Setup costs can also outweigh savings in small or highly varied groups. The code and benchmark harness are available on GitHub under the MIT license.
How it got here
Shopify engineers published a blog post detailing TreeWalker, an open-source Rust engine for tree-ensemble inference that uses partial evaluation to speed up grouped scoring.