Model Deployment and Inference Optimization Questions
Serving trained models efficiently in production. Covers deployment and containerization, real-time and batch serving, latency budgets, throughput and cost optimization, quantization and model compression, and online/real-time learning constraints. Emphasizes meeting production performance targets without sacrificing model quality.
Design a robust HTTP API contract for a text-classification model that supports both single and batched requests, contextual metadata (request_id, user_id), and clear error codes. Provide a JSON example for request and response and recommend timeout and retry semantics for client SDKs.
Compare ONNX Runtime, TensorRT, and OpenVINO as inference runtimes for model deployment. For each, describe typical performance advantages, supported hardware, conversion pain points, and cases when you would choose one over the others for production deployment.
A recent model upgrade has increased tail latency (p99) from 100ms to 300ms for an image-service in production. Describe an end-to-end root-cause analysis plan spanning model, runtime, orchestration, networking, instance sizing, and request routing. Include how you'd use profiling, distributed tracing, synthetic tests, canary rollbacks, and what safety steps you'd take to minimize customer impact during diagnosis.
Write a Dockerfile for a Python ML inference service that uses PyTorch, includes a pre-downloaded model file at /models/model.pt, exposes port 8080, and aims to minimize image size while supporting CPU-only and GPU deployments. Include a multi-stage build that installs dependencies, copies model artifacts, sets a non-root user, and defines a simple healthcheck command. Explain your key choices briefly in comments or a short paragraph.
Implement a lightweight profiling tool (pseudo-code or real Python) that instruments a model's forward pass to measure per-layer latency and peak memory usage. The tool should export a timeline of layer latencies and identify top-3 hotspots (layers with highest time or memory). Explain how you'd integrate this into a CI benchmark to detect regressions.
Unlock Full Question Bank
Get access to all Model Deployment and Inference Optimization interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.