Reduce inference latency of a large gradient boosted tree ensemble without losing accuracy

Quick Overview

Asks how to cut serving latency for a gradient boosted model with thousands of deep trees while keeping its accuracy. Tests where tree ensemble inference cost comes from, model shrinking, compiled predictors, batching and safe rollout of each change.

Reduce inference latency of a large gradient boosted tree ensemble without losing accuracy

Role: Machine Learning Engineer

Category: Machine Learning

Difficulty: hard

Interview Round: Other

A production gradient boosted model with thousands of deep trees is too slow to serve. How would you reduce its inference latency while preserving accuracy? ```hint Where the time goes Write down what one prediction costs in terms of the number of trees and their depth, then ask whether the model is even the slowest part of the request. ``` ```hint Two kinds of fix Some fixes change the model and need an accuracy check. Others run the same trees faster and should return the same predictions. ``` ### Clarifying Questions to Ask - What is the latency target (p50 or p99), what is the current number, and is the model served one request at a time or in batches? - Which library trained the model (XGBoost, LightGBM, CatBoost), and what runtime serves it today? - How much accuracy loss is acceptable, and on which metric? - What hardware is available at serving time: how many CPU cores, and is a GPU an option? ### What a Strong Answer Covers - How inference cost scales with the number of trees and their depth, and why the whole request should be profiled before the model is changed. - Ways to shrink the ensemble, and how each one is checked against held-out metrics. - Ways to run the same trees faster: compiled predictors, tree structure, a leaner runtime. - Serving changes such as batching, multithreading and removing per-request overhead. - How a change is validated before full rollout (offline metrics, shadow traffic, an A/B test). ### Follow-up Questions - If distilling into a smaller model costs a little AUC, how would you decide whether the latency gain is worth it? - How would you confirm that a compiled predictor returns the same scores as the original model? - Profiling shows that feature fetching takes most of the p99. What would you change? - How do many shallow trees and fewer deep trees differ in latency and memory behavior?

Overview: Asks how to cut serving latency for a gradient boosted model with thousands of deep trees while keeping its accuracy. Tests where tree ensemble inference cost comes from, model shrinking, compiled predictors, batching and safe rollout of each change.

PracHub logo
General
Nov 24, 2026
hardMachine Learning EngineerOtherMachine Learning
0
0

A production gradient boosted model with thousands of deep trees is too slow to serve. How would you reduce its inference latency while preserving accuracy?

Clarifying Questions to Ask Guidance

  • What is the latency target (p50 or p99), what is the current number, and is the model served one request at a time or in batches?
  • Which library trained the model (XGBoost, LightGBM, CatBoost), and what runtime serves it today?
  • How much accuracy loss is acceptable, and on which metric?
  • What hardware is available at serving time: how many CPU cores, and is a GPU an option?

What a Strong Answer Covers Guidance

  • How inference cost scales with the number of trees and their depth, and why the whole request should be profiled before the model is changed.
  • Ways to shrink the ensemble, and how each one is checked against held-out metrics.
  • Ways to run the same trees faster: compiled predictors, tree structure, a leaner runtime.
  • Serving changes such as batching, multithreading and removing per-request overhead.
  • How a change is validated before full rollout (offline metrics, shadow traffic, an A/B test).

Follow-up Questions Guidance

  • If distilling into a smaller model costs a little AUC, how would you decide whether the latency gain is worth it?
  • How would you confirm that a compiled predictor returns the same scores as the original model?
  • Profiling shows that feature fetching takes most of the p99. What would you change?
  • How do many shallow trees and fewer deep trees differ in latency and memory behavior?