How do inference latency and model memory footprint scale with the number of trees and tree depth?

Quick Overview

Asks how prediction latency and memory use of a tree ensemble grow with the number of trees and the tree depth. It tests complexity reasoning about root-to-leaf walks and node counts, what bounds tree size, and the settings that trade accuracy for serving cost.

How do inference latency and model memory footprint scale with the number of trees and tree depth?

Role: Machine Learning Engineer

Category: Machine Learning

Difficulty: medium

Interview Round: Other

You serve a tree ensemble such as a Random Forest with B trees, each grown to depth d. How do inference latency and model memory footprint scale with the number of trees and tree depth? ```hint One tree first For a single tree, count the nodes one prediction visits and the nodes the tree has to store. ``` ```hint What caps the size A depth limit is one bound on how many leaves a tree can have. Ask what else limits the number of leaves. ``` ### What a Strong Answer Covers - Per-sample prediction cost as a function of the number of trees and the depth. - Memory as a function of node count, and what bounds the node count. - Hardware effects that make deep trees slower than the comparison count alone suggests. - Which settings shrink the model, and what cutting trees or depth costs in accuracy. ### Follow-up Questions - A forest meets its accuracy target but misses its p99 latency budget. What would you change first? - How does a gradient-boosted model with many shallow trees compare in cost with a forest of fewer deep trees? - How does batching many requests together change throughput and per-request latency? - How would you shrink a trained forest without retraining it from scratch?

Overview: Asks how prediction latency and memory use of a tree ensemble grow with the number of trees and the tree depth. It tests complexity reasoning about root-to-leaf walks and node counts, what bounds tree size, and the settings that trade accuracy for serving cost.

General logo
General
Nov 25, 2026
mediumMachine Learning EngineerOtherMachine Learning
0
0

You serve a tree ensemble such as a Random Forest with B trees, each grown to depth d. How do inference latency and model memory footprint scale with the number of trees and tree depth?

What a Strong Answer Covers Guidance

  • Per-sample prediction cost as a function of the number of trees and the depth.
  • Memory as a function of node count, and what bounds the node count.
  • Hardware effects that make deep trees slower than the comparison count alone suggests.
  • Which settings shrink the model, and what cutting trees or depth costs in accuracy.

Follow-up Questions Guidance

  • A forest meets its accuracy target but misses its p99 latency budget. What would you change first?
  • How does a gradient-boosted model with many shallow trees compare in cost with a forest of fewer deep trees?
  • How does batching many requests together change throughput and per-request latency?
  • How would you shrink a trained forest without retraining it from scratch?