How does the define-by-run search space model in frameworks like Optuna differ from static search space definitions?

Quick Overview

Asks how define-by-run hyperparameter search spaces, as in Optuna, compare with search spaces declared up front as a fixed structure. Tests reasoning about conditional and variable-length spaces, how samplers handle them, and the practical pitfalls of each approach.

How does the define-by-run search space model in frameworks like Optuna differ from static search space definitions?

Role: Machine Learning Engineer

Category: Machine Learning

Difficulty: medium

Interview Round: Other

How does the define-by-run search space model in frameworks like Optuna differ from static search space definitions? ```hint Picture a conditional space Try to tune a network whose number of layers is itself a hyperparameter, with a separate width for each layer. How would you write that space as one fixed data structure, and how would you write it as ordinary Python? ``` ```hint Think about the sampler If a parameter exists in some trials and not in others, what does a model-based sampler such as TPE have to do with that history? ``` ### What a Strong Answer Covers - When the search space is defined in each approach, with examples of static definitions - How each handles conditional and variable-length spaces - What is lost when the space is only known by running trials: inspection, enumeration, grid search - How samplers deal with parameters that appear in only some trials - Pitfalls when the objective's parameters change during a study ### Follow-up Questions - How would you run grid search over an objective written in define-by-run style? - What do the `multivariate` and `group` options of Optuna's TPE sampler change for a conditional space? - The search space has to change halfway through a long study. How do you keep the results trustworthy?

Overview: Asks how define-by-run hyperparameter search spaces, as in Optuna, compare with search spaces declared up front as a fixed structure. Tests reasoning about conditional and variable-length spaces, how samplers handle them, and the practical pitfalls of each approach.

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

How does the define-by-run search space model in frameworks like Optuna differ from static search space definitions?

What a Strong Answer Covers Guidance

  • When the search space is defined in each approach, with examples of static definitions
  • How each handles conditional and variable-length spaces
  • What is lost when the space is only known by running trials: inspection, enumeration, grid search
  • How samplers deal with parameters that appear in only some trials
  • Pitfalls when the objective's parameters change during a study

Follow-up Questions Guidance

  • How would you run grid search over an objective written in define-by-run style?
  • What do the multivariate and group options of Optuna's TPE sampler change for a conditional space?
  • The search space has to change halfway through a long study. How do you keep the results trustworthy?