Shopify has open-sourced TreeWalker, a Rust inference engine for tree ensembles that avoids repeating the same decisions across related rows. In internal measurements, it scored Shopify’s delivery-date model 3.96 times faster than the evaluator the company uses today. Training, trees and results stay the same.
It works with models trained in LightGBM and XGBoost.
Why delivery estimates are costly to score
Shopify shows delivery dates in agentic search results, on product pages, at checkout and in the Shop app. Its main system is a discrete-time hazard model. It estimates the chance a package arrives on each future date, given that it hasn’t arrived yet.
One forecast therefore scores several related rows, one per time horizon, through the same tree ensemble. The carrier and package weight don’t move between rows, while the horizon and calendar values do. At checkout, every shipping method needs its own forecast, all inside a small latency budget.
A decision tree follows a series of yes-or-no tests down to a leaf score, and boosted models add up hundreds of those walks per row. Scoring twelve dates independently means answering “is the carrier A?” twelve times for the same package.
How TreeWalker shares the work
Rows that come from the same forecast form a group. The system feeding the engine guarantees that some features hold the same value in every row. TreeWalker answers those tests a single time and carries the result into every tree.
Repeated tests on varying values get the same treatment. If two trees both ask whether the horizon is at most six days, the engine prepares that answer once for the group.
Row subsets are tracked with a bit mask, one bit per row. Intersecting the active mask with a prepared mask selects the matching rows, and original positions stay intact. Shopify says copying row lists at each decision would be slower than plain LightGBM.
When a group splits, both occupied branches continue. If every active row answers the same way, an “unsplit shortcut” skips the empty sibling. Each row still gets its own running total, so the model’s output is unchanged. The approach is a form of partial evaluation.
When a model loads, the engine looks for repeated tests and shared opening steps. For each group it sorts each varying numeric feature once, then sweeps its thresholds to build masks that trees can reuse.
What the benchmarks show
Shopify’s paper tests two public survival datasets, SUPPORT and FLCHAIN, plus Expedia hotel-search sessions for click-through rate. It compares grouped execution against TreeWalker’s own row-by-row walk. Speedups go from about parity at one row to 7.7 to 9.1 times at 104 to 128 rows.
The figures are single-core model-scoring numbers on an Intel Xeon Platinum 8581C, with Arm results on Google Axion. They don’t measure end-to-end service latency.
A second test scored 128 what-if variants of each UCI credit record. Speedup fell from 15.2 times to 8.1 times on Intel, and from 9.2 to 6.2 times on Arm, as the number of varied inputs rose from one to eight.
The catch: setup can outweigh the gain. Across 712 configurations, grouped traversal lost to its own full walk in 33 Intel and 78 Arm cases, mostly with small groups. The compiled engine TL2cgen was faster in 122 of the 712 Intel configurations. Shopify’s advice is to compare against the engine you already run.
Where else it could apply
Search ranking is the obvious fit. A relevance or click-through model scores every result for one query, with user and query context fixed and each result’s attributes varying. Scenario analysis, where a few inputs change and the rest are held, creates the same shape.
Compilers like lleaves and TL2cgen cut execution overhead. Group-aware evaluation targets a different cost: work that can be shared across inputs.
Teams that already produce related predictions, such as delivery dates, search results or what-if variants, can try it without retraining. The first thing to measure is group size. Below a handful of rows, a compiled engine may win.
Source: Shopify