Debugging and Performance Optimization Questions
Finding and fixing what is wrong or slow: systematic debugging strategies, reading stack traces, profiling to locate hotspots, and optimizing execution time and memory. Covers reasoning from symptom to root cause and measuring before optimizing, including runtime, memory, and profiling analysis. Tests how a candidate operates on code they did not write.
Given an ML model where a single critical function is the bottleneck, describe a safe refactoring plan to optimize that function. Include how you'd write microbenchmarks, preserve backward compatibility, add tests, and roll out the change to production with minimal risk.
Explain how to use memory-mapped files (mmap or numpy.memmap) to handle very large datasets too big for RAM, and discuss the trade-offs, concurrency issues, and when to prefer memory-mapping over chunked streaming or a database-backed solution.
A legacy ML system uses many small Python processes launched per request causing high process spawn overhead. Propose refactor options (process pool, persistent worker, async server) and detail how you would benchmark and migrate with minimal downtime and risk.
Design a low-overhead monitoring and logging strategy for detecting performance regressions in production ML inference: which metrics to collect (latency histograms, CPU/GPU utilization, memory), sampling vs full logs, and alerting rules for early detection without too many false positives.
Implement or describe a numerically stable computation for the log-sum-exp operation used in softmax computations. Explain why naive implementation is unstable and show the stabilized formula. Also state how this affects backprop and gradient calculations.
Unlock Full Question Bank
Get access to all Debugging and Performance Optimization interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.