TreeWalker: Avoiding redundant work across rows and trees Shopify built TreeWalker, a Rust inference engine for gradient-boosted tree ensembles that shares decisions on fixed features and reuses repeated tests across trees, and measured it scoring the company's delivery-date prediction model 3.96× faster than its current delivery evaluator with the same training, trees, and results. Shopify's delivery prediction system uses a discrete-time hazard model to forecast the conditional probability of a package arriving on each future date, scoring one row per time horizon through the same tree ensemble while shipment facts such as weight and carrier stay fixed. The speedup matters because checkout must score multiple shipping methods per order within a small latency budget, and repeating identical tree decisions for every date in each forecast consumed that budget. When you buy something online, whether it's a gift for an approaching birthday or a spare part to fix a leaky faucet, you want to know how soon it will arrive. That delivery estimate can determine whether you decide to place the order and which shipping option you choose. Shopify uses machine learning models to predict delivery dates, with estimates showing up in many places: in agentic search results, on product pages, at checkout, and in the Shop app. Those ML models need to produce accurate and fast estimates so that merchants and their buyers can continue to rely on Shopify’s checkout speed. Our main delivery prediction system uses a discrete-time hazard model to forecast the conditional probability of a package arriving on each future date: “given that it didn't arrive on Monday, what's the chance it will arrive on Tuesday?” Those conditional probabilities give us the distribution we use to predict a delivery date or date range. One forecast scores several related rows, one for each time horizon, through the same tree ensemble. Shipment facts like weight and carrier stay fixed while the horizon and calendar features change. At checkout, we score multiple shipping methods for an order. Each method needs a delivery-date forecast, and those forecasts have to fit inside a small latency budget. Repeating the same tree decisions for every date in each forecast eats into that budget. We built TreeWalker to make those repeated delivery predictions faster . Our Rust inference engine for tree ensembles shares decisions on fixed features and reuses repeated tests across trees. In internal model-scoring measurements, TreeWalker scored our delivery model 3.96× faster than our current delivery evaluator with the same training, trees, and results. To see how, let’s start with what a tree does. A decision tree follows questions to a score The model’s input is a row of features : values like the carrier, package weight, or recipient's location. A decision tree turns those inputs into an output by following a sequence of tests. Starting at the root, it asks a question, follows the matching branch, and repeats until it reaches a leaf , which holds an output value. Here’s a trivial example. This model just looks at the feature called horizon . An input with a horizon of two days takes the “yes” branch to a leaf score of −0.25; a horizon of eight takes “no” to +0.25. Later tests can refine either branch. Training chooses the tests, thresholds, and leaf values from examples. Prediction follows those learned choices. Move the horizon to see which score the tree contributes. Gradient Boosted Decision Tree GBDT systems like LightGBM and XGBoost combine many such trees into an ensemble called a forest . In the boosted models we discuss here, each tree contributes a leaf score to the row’s running total. The model combines that total with its base score and applies its output transformation. For binary-logistic models, a sigmoid transforms the score into a probability. Inference can involve hundreds of short tree walks for each row. Evaluating many related rows independently repeats those walks , even when their answers agree. A small delivery forecast you can trace This interactive example asks the same kind of question as our delivery model: for one package, what is the chance it arrives on each of the next twelve dates, conditional on not having arrived earlier? Each date gets a prediction row. We use a small teaching model so you can see each decision and leaf contribution; our delivery model has many more trees. The demo shows raw leaf sums rather than probabilities so that every contribution is visible. For one fictional package, the twelve candidate delivery dates run from July 4 through July 15. The horizon gives a date’s position in that forecast first through twelfth , and day of month locates it on the calendar 4–15 . Moving the forecast across a month boundary changes the calendar values without changing the horizon numbers. | Fixed across the twelve rows | Changes with the candidate date | |---|---| | Carrier A; package weight 2 kg | Horizon: 1–12; day of month: 4–15 | We call these rows a group . Constant features have identical values throughout it; varying features may differ. The producer supplies this grouping and equality guarantee—it's a natural property of how the rows are built. The forecast date advances, but the package does not change its carrier or weight as we ask about later dates. The explainer uses a forest of three small trees. All begin by checking whether the carrier is A and the package weighs more than 1 kg. Trees A and B then ask whether the forecast horizon is at most six days. Tree A asks further questions about weight and day of month; Tree B reaches its leaves. Tree C uses a nine-day horizon threshold. We chose the thresholds and leaf scores so you can follow each step. Prepare shared answers, then follow occupied branches TreeWalker can resolve the matching prefix once for this group and reuse its outcome in all three trees. Every row has Carrier A and a 2 kg weight. There is no reason to rediscover those answers separately for every forecast date. Repeated questions about varying values create another opportunity. Trees A and B both ask whether the horizon is at most six days. TreeWalker prepares the matching set once for the group, from horizons 1–6, and lets both trees reuse it. Press Play to follow each forecast date through the forest. Switch to “With TreeWalker” and replay, or jump directly to Split and Unsplit. Numbered balls are date rows; balls moving together share a mask. Tap a result to inspect its running sum. Change the first forecast date to July 23 to turn the day-of-month shortcut into a real split. Playback shows execution order, not elapsed time. At Tree A’s horizon test, the group divides into two occupied subsets. Horizons 1–6 reach “weight 3 kg.” The package weighs 2 kg, so one comparison sends all six rows to a −0.5 leaf. Sharing continues even below the point where other rows took a different branch. Horizons 7–12 reach “day of month ≤ 15.” Their dates are July 10–15, so the calendar days differ but every row answers “yes.” TreeWalker retains that subset, skips the empty sibling, and continues without a recursive branch. We call this the unsplit shortcut . Change the first forecast date to July 23. The later horizons now cover July 29–August 3. July 29–31 answer “no” and reach a +0.25 leaf; August 1–3 answer “yes” and reach a +0.5 leaf. The model and twelve-day horizon are unchanged. The current group determines whether this node actually splits execution. Tree B reuses the prepared six-day horizon answer, adding −0.25 to early rows and +0.25 to later rows. Tree C uses a separately prepared answer to “horizon ≤ 9,” adding +0.25 or −0.25. In the July 4 forecast, horizons 1–6 finish at −0.5, horizons 7–9 at +1, and horizons 10–12 at +0.5. Each date keeps its own running total, which becomes final only after all three trees contribute. The demo stops at the leaf sum so we can see every addition. Grouped traversal makes the same 36 leaf additions and keeps the same separate total for every date, but it saves work on the way to those leaves. The model’s base score and output transformation not shown apply to these totals as usual. This is an application of partial evaluation https://raspi.itu.dk/people/sestoft/pebook/ : specializing a computation using inputs already known to be shared, then continuing with the work that depends on varying inputs. We keep the learned tests and leaf contributions. Training does not change. Make sharing cheaper than repeating the work We put a lot of effort into a Rust execution module that respected the reality of modern CPUs: compact representations, making good use of L2 cache, and minimizing branching. A naïve implementation of TreeWalker's ideas—for example, copying lists of rows at each decision point—would be slower than plain ol' LightGBM. To track subsets of rows, TreeWalker instead uses a row mask : one bit records whether each row is active. Intersecting the active mask with a predicate’s prepared mask selects the matching rows. The remaining active rows take the other branch. Original row positions stay intact, so results go back to the correct outputs. A prepared mask describes the whole group, and a node operates on its current subset. In the July 4 forecast, the “day of month ≤ 15” mask includes all twelve rows, but Tree A reaches that node with only horizons 7–12. Intersecting the prepared mask with that current subset prevents earlier rows from re-entering the branch. At model load time, TreeWalker identifies repeated predicates and matching prefixes. For each input group, it sorts values once per varying numeric feature and sweeps the distinct thresholds to construct reusable predicate masks. A question repeated across hundreds of trees can then reuse the same prepared answer. Sorting, sweeping, and mask storage are real costs, especially for small groups. In practice, this effort is often worthwhile, but not universally. The remaining traversal benefits from compact nodes and a layout that places a preferred child next to its parent. That improves locality and lets execution continue in a loop along that path. Wider groups need more mask words, and reaching a leaf still requires adding its contribution to every active row’s output. Sharing removes repeated decisions, but it cannot remove the outputs we asked for. Existing tree-inference systems attack other costs. lleaves https://github.com/siboehm/lleaves compiles LightGBM models to machine code, while TL2cgen https://tl2cgen.readthedocs.io/en/latest/ generates compiled prediction code from tree ensembles. Compilation reduces execution overhead. Group-aware evaluation additionally asks which work can be shared across inputs. Measuring the benefit In our published TreeWalker paper https://arxiv.org/abs/2610.03939 , we evaluate two public survival datasets, SUPPORT and FLCHAIN, plus Expedia hotel-search sessions for click-through rate CTR . We compare grouped execution with TreeWalker’s own independent-row full walk , using the same model representation and layout. This comparison isolates the grouped execution strategy, including its preparation costs. On SUPPORT and FLCHAIN, the survival sweep shows how the benefit grows across eight forecast widths, from roughly parity for one row to 7.7–9.1× at 104–128 rows . The points below are measured speedups. Dashed curves are a theorem-informed fit , calibrated to the same points. The fit makes the amortization story visible. The paper’s theorem separates visited split nodes, per-row leaf writes, and the work of preparing predicate masks. Sharing spreads some costs over more rows; output writes and preparation remain. To turn that structure into a smooth latency curve, we approximate each evaluator’s time as a fixed cost plus a per-row cost. Their ratio gives S G = G + c / a + bG , where G is group width. We calibrate the three positive coefficients separately for each series using all eight measurements, giving every point equal weight in log speedup. This is a descriptive fit, not an independent prediction from the theorem. It approximates sorting, threshold sweeping, and wider-mask costs over the plotted range rather than modeling each separately. We stop each curve at its last measured width. The largest pointwise discrepancy is about 6.5%; that describes fit error on these same observations, not accuracy on a new model or machine. These are single-core model-scoring measurements on an Intel Xeon Platinum 8581C. Our Arm results use Google Axion. We time complete groups in microseconds, summarize repeated blocks by the median of their medians, and divide full-walk latency by grouped latency. The timed evaluator uses shared predicate precomputation and ordinary floating-point accumulation, with exact-sum mode disabled. The final experiment archive https://github.com/Shopify/treewalker/tree/neurips2026-final records the protocol, code, and measurements. These measurements concern model scoring, rather than end-to-end service latency. A second workload tests the cost of varying more inputs. We create 128 what-if variants of each UCI credit record and score them with one LightGBM model. Increasing the selected perturbation dimensions from one to eight lowers the speedup over full walk from 15.2× to 8.1× on Intel , and from 9.2× to 6.2× on Arm . Setup can outweigh sharing. Across the broader 712-configuration campaign, grouped traversal loses to its own full walk in 33 Intel configurations and 78 Arm configurations, concentrated in small groups. Compiled engines also win subsets: TL2cgen is faster in 122 of the 712 Intel configurations. The useful comparison for an application includes the engine it already uses. Look for groups your workload already creates Fast delivery forecasts motivated TreeWalker. By sharing decisions across related rows and across trees, it scored our delivery model 3.96× faster than our current evaluator in internal measurements. The same shape of work appears in other places. Take search. A relevance or click-through-rate model may score every result for one query. The user and query context stay fixed while each result has its own attributes. Walking every result independently repeats tests on that shared context; TreeWalker can reuse those answers and still return a separate score for each result. The Expedia hotel-search sessions in our paper test this pattern. Scenario analysis creates another natural group when it varies a few inputs and holds the rest fixed. We’ve open-sourced TreeWalker https://github.com/Shopify/treewalker , our Rust inference engine for tree ensembles. It brings group-aware inference to models trained with LightGBM and XGBoost, without changing training. If your application already produces related predictions, whether they’re delivery dates, search results, or what-if variants, TreeWalker can use that structure to avoid repeating the same decisions and reduce model scoring time.