InterviewStack.io LogoInterviewStack.io

Code Quality, Error Handling, and Defensive Programming Questions

Writing robust, high-quality code that fails safely. Covers defensive programming, input validation, error handling and fault tolerance, logging for diagnosability, and general engineering-quality standards. Includes anticipating failure modes and making code resilient to bad inputs and unexpected states.

HardTechnical
38 practiced

Production just exhausted its error budget due to cascading 5xx errors triggered by a downstream change, and you must ship defensive changes quickly to prevent a repeat. Which mitigations do you prioritize first and why: request timeouts, retries with backoff and jitter, circuit breakers, bulkheads/isolated thread pools, backpressure, or graceful degradation? Explain how you would measure whether each change is actually working.

MediumTechnical
28 practiced

Discuss strict dependency pinning versus flexible version ranges in an ML project: implications for reproducibility, security patches, and build stability, and propose a policy for safely automating dependency updates. Then describe how you would make ML experiments reproducible across a dev workstation, CI, and a multi-GPU cluster: seeding every source of randomness (numpy, framework, system), deterministic-ops flags, containerization, and a small reproducibility checklist/test that validates two runs produce comparable artifacts.

HardTechnical
21 practiced

Describe how to achieve numerical stability specifically for MIXED-PRECISION training across frameworks and GPU generations: dynamic versus static loss scaling, numerically-stable layer implementations (LayerNorm), keeping fp32 master copies of weights/optimizer state, avoiding in-place ops that break autograd, and how you would test that a mixed-precision run is numerically correct.

EasyTechnical
29 practiced

A boundary check validates that a value (an index, an offset, a size) falls within the range the code actually handles correctly, and it routinely catches real production bugs before they cause damage. Pick three DIFFERENT kinds of boundary bugs you've seen or can construct realistically, and for each: describe the bug it would cause if unchecked, the specific defensive check you'd add, and a unit test that would catch a regression if the check were later removed.

That is every published Code Quality, Error Handling, and Defensive Programming question for Machine Learning Engineer so far. Browse the other topics in this category, or practice this one interactively.