← Questions
ML configuration system with inheritance and validation
0
I was asked this
No reports yet. Sign in to say where you were asked it.
An AI/ML design interview question asked in Anthropic's system design round, last asked Apr 2026. It tests ml infra, config management and reproducibility.
Design and partly implement an ML configuration system covering schemas, inheritance and overrides, validation, and reproducibility.
class Field:
def __init__(self, type_, default=..., choices=None, min=None, max=None): ...
class ConfigError(Exception):
def __init__(self, errors): ...
def merge(base, over): ... # dicts merge, lists replace, None deletes
def resolve(name, registry, schema, overrides=()): ... # base chain, CLI overrides, ${refs}, validation
def validate(cfg, schema, prefix=""): ... # -> list of "path: problem"
def config_hash(cfg): ...
Requirements
- Functional: schemas of typed fields with defaults, choices and ranges; configs that inherit from a base chain; command-line overrides;
${path}references; validation that returns every problem aspath: problem; a stable hash of the final config. - Non-functional: deterministic results whatever the order of keys, clear error messages, and configs that can be saved and reproduced exactly.
Clarifying questions
- Can a config inherit from several bases, and in what order do they apply?
- What syntax do overrides use (
a.b=3), and are values parsed as YAML or as strings? - Do references resolve against the final merged config, and is a reference cycle an error?
- Is a key that is not in the schema an error, a warning, or allowed?
- What must the hash include: only values, or the schema version and code version too?
What a strong answer covers
-
mergeas a recursive dict merge where lists replace andNonedeletes a key, with inputs left untouched. -
resolvewalking the base chain root first, applying overrides last, then substituting references with cycle detection, then filling defaults and validating. -
validatecollecting every error (wrong type, missing required field, value out of range or not among the choices, unknown key) with dotted paths, raising oneConfigErrorwith all of them. -
config_hashover a canonical serialization (sorted keys, normalized numbers), so the same config always hashes the same and can name a run. - Tests: a three-level chain, an override of a nested key, a reference to a later-overridden value, a reference cycle, and an error list with several problems.
Follow-ups
- Sweep configurations: expand
lr=[1e-3,3e-4]into several runs. - Save the resolved config with every checkpoint and reload it to resume.
- Migrate old configs when the schema renames a field.
- Compare with an existing library (Hydra, OmegaConf): what would you borrow?
Where it's asked
- Anthropic · System design · Last asked Apr 202655 min · Design discussion, often typed into a shared Google Doc rather than drawn; some rounds let you share any drawing tool · No AI
What it tests
ml infra · config management · reproducibility
Sign in to see the worked answer
The full answer, chapter by chapter, with what interviewers expect at each level. New accounts get 5 credits: each one unlocks a question for good.
What the labs asked this week
A weekly email of what OpenAI, Anthropic and the other top AI labs asked engineers, round by round.
Draw your answer hereBoxes, arrows and notes, saved for you to come back to.Sign in to start drawing
