Data & MLOps
MLOps and deployment
Learn MLOps and deployment: 40 practice questions and answers with an interactive quiz — from the offline AI Learning app.
Questions & Answers
Tap a question to reveal its answer. Written for self-study and interview preparation.
What is the primary purpose of a model registry in an MLOps pipeline?
A model registry is a centralized store that versions trained models along with their metadata, lineage, and stage transitions (e.g., Staging, Production, Archived). It enables governance, reproducibility, and controlled promotion/rollback of models across environments, decoupling training from deployment.
In a canary deployment for an ML model, what is being tested?
A canary deployment routes a small percentage of live traffic to the new model version while the majority continues hitting the current version. It validates the new model's behavior and performance on real traffic with limited blast radius before a full rollout.
How does shadow (dark) deployment differ from canary deployment?
In shadow deployment, the new model receives a copy of live production traffic but its predictions are not returned to users—only logged for comparison. Unlike canary, it carries zero user-facing risk because the candidate model never serves real responses.
What is concept drift, and how does it differ from data (covariate) drift?
Data drift is a change in the input feature distribution P(X), while concept drift is a change in the relationship between inputs and target P(Y|X). Concept drift degrades model accuracy even when inputs look statistically similar, and typically requires retraining with fresh labels rather than just monitoring inputs.
Which statistical test is commonly used to detect data drift on a continuous numerical feature?
The Kolmogorov-Smirnov (KS) test compares the empirical cumulative distribution functions of the reference and current data to detect distribution shift in continuous features. The Population Stability Index (PSI) and Wasserstein distance are also common alternatives.
What problem does a feature store solve in production ML systems?
A feature store provides a centralized, versioned repository of features with consistent definitions shared between training and serving, eliminating train/serve skew. It typically has an offline store (for batch training) and a low-latency online store (for real-time inference), backed by the same transformation logic.
What is train/serve skew and what is a common cause?
Train/serve skew is a discrepancy between how features are computed during training versus serving, leading to degraded online performance despite good offline metrics. A common cause is duplicated, divergent transformation code paths (e.g., pandas in training, hand-written Java/SQL at serving) or different data freshness.
When would you choose batch inference over online (real-time) inference?
Batch inference is preferred when predictions are not needed instantly, inputs are available in bulk, and you can amortize compute (e.g., nightly churn scoring, recommendation precomputation). It is cheaper and simpler to scale, whereas online inference is required when latency is user-facing and inputs arrive on demand.
What is the role of a model serving framework like Triton, TorchServe, or KServe?
A serving framework wraps trained models behind a standardized inference API and handles concerns like batching, GPU scheduling, multi-model hosting, versioning, and autoscaling. It lets teams deploy models as scalable network services without rebuilding serving infrastructure per model.
What is dynamic (server-side) request batching in model serving and why is it useful?
Dynamic batching collects multiple incoming inference requests within a short time window and runs them as a single batched forward pass. It dramatically improves GPU throughput and utilization at the cost of slight added latency, which is configurable via a max batch size and timeout.
Why is post-training quantization (e.g., INT8) used in model deployment?
Quantization reduces weights/activations from FP32/FP16 to lower-precision integers, shrinking model size and memory bandwidth while speeding up inference on supported hardware. It trades a small, usually acceptable accuracy drop for major latency and cost reductions, and is widely used for edge and LLM serving.
What is the difference between horizontal pod autoscaling based on CPU vs. custom metrics for ML serving?
CPU-based autoscaling reacts to CPU utilization, which is a poor proxy for GPU-bound or latency-sensitive inference workloads. Custom/external metrics (e.g., requests-per-second, GPU utilization, queue depth, p99 latency) scale on signals that actually reflect inference load, giving more responsive and accurate scaling.
What does DVC (Data Version Control) provide that Git alone does not?
DVC versions large datasets and model artifacts by storing lightweight metafiles in Git while pushing the actual large files to remote object storage (S3, GCS). This gives reproducible data/model lineage tied to code commits without bloating the Git repository with binaries.
In MLflow, what is the difference between the Tracking server and the Model Registry?
MLflow Tracking logs experiments—parameters, metrics, and artifacts for individual runs. The Model Registry is a separate component that catalogs registered model versions, manages stage transitions, and enables governance/approval workflows on top of logged models.
What is the purpose of a champion/challenger setup in production ML?
The champion is the current production model serving traffic, while one or more challengers are evaluated against it (via shadow or A/B traffic) on live data. If a challenger outperforms the champion on agreed metrics, it is promoted, enabling continuous, evidence-based model improvement.
Why are health checks (readiness vs. liveness probes) important for model serving on Kubernetes?
A liveness probe restarts a container that has become unresponsive, while a readiness probe controls whether a pod receives traffic—critical because a model may need time to load weights into memory/GPU before it can serve. Without a proper readiness probe, traffic is routed to pods that aren't yet ready, causing errors.
What is the key advantage of containerizing an ML model with Docker for deployment?
Containerization packages the model with its exact runtime, libraries, and system dependencies into a portable, reproducible image. This eliminates 'works on my machine' issues and ensures consistent behavior across dev, staging, and production environments.
What is a key risk of using `latest` as the image tag for a production model deployment?
Using `latest` makes deployments non-deterministic and irreproducible—different nodes or future pulls may fetch different image contents, breaking rollbacks and auditing. Production should pin immutable, versioned tags (or digests) so the exact artifact is always known.
In a CI/CD pipeline for ML (CT - continuous training), what triggers an automated retraining run?
Continuous training can be triggered by schedules, the arrival of sufficient new labeled data, or monitoring signals such as detected drift or a performance drop below an SLA threshold. The retrained model then passes automated validation gates before promotion.
What is the difference between A/B testing and an interleaving experiment for model evaluation?
A/B testing splits users into groups, each seeing a single model's output, and compares aggregate metrics. Interleaving mixes results from both models within a single user's response and attributes engagement per item, yielding higher statistical sensitivity with less traffic—popular in ranking/search.
What is model lineage and why does it matter for governance?
Model lineage is the end-to-end record linking a deployed model to the code, data, features, hyperparameters, and environment used to produce it. It is essential for reproducibility, auditing, debugging regressions, and meeting regulatory requirements (e.g., explaining a model's provenance).
What is the 'cold start' problem in serverless model deployment (e.g., AWS Lambda)?
A cold start is the latency incurred when a new function instance must initialize—loading the runtime and the (often large) model into memory—before serving the first request. It makes serverless poorly suited to large models or strict tail-latency SLAs unless mitigated with provisioned concurrency or smaller models.
Why is p99 latency often a more important SLA metric than mean latency for inference services?
Mean latency hides the tail of slow requests, while p99 (the 99th percentile) captures the worst-case experience that real users hit during spikes, GC pauses, or batching delays. Optimizing tail latency directly protects user experience and downstream timeout budgets.
What is the purpose of a 'rollback' strategy in model deployment, and how is blue-green deployment used for it?
A rollback restores a previously known-good model when a new one causes errors or metric regressions. Blue-green deployment keeps the old (blue) and new (green) versions running simultaneously and switches traffic via the router; if green fails, traffic instantly reverts to blue with near-zero downtime.
In LLMOps, why is prompt versioning important and how does it differ from model versioning?
Prompt templates materially change LLM behavior, so they must be versioned, tested, and tied to evaluation results just like model weights. Prompt versioning tracks the externalized instruction/template (and its variables) independently from the underlying model version, since either can change and affect outputs.
What is KV cache and why does it matter for LLM serving efficiency?
The KV cache stores the key and value tensors of previously generated tokens so the model avoids recomputing attention over the full sequence at each decoding step. It is central to autoregressive throughput but consumes large GPU memory that grows with batch size and context length, making its management (e.g., PagedAttention) a key serving optimization.
What does continuous batching (in-flight batching) add over static batching for LLM inference?
Continuous batching adds and removes sequences from the running batch at the token level as requests finish or arrive, rather than waiting for the whole batch to complete. This keeps the GPU saturated despite highly variable generation lengths, greatly improving throughput versus static batching.
When deploying a RAG system, what is a common operational reason retrieval quality degrades over time?
The vector index becomes stale as the underlying knowledge base changes—new documents aren't indexed, deleted ones remain, or embeddings were generated by an older embedding model. Operationally this requires an incremental indexing/re-embedding pipeline and monitoring of retrieval relevance.
What is the trade-off of an HNSW index vs. a flat (brute-force) index in a production vector database?
HNSW gives sub-linear approximate nearest-neighbor search with very low latency at scale, but uses more memory and returns approximate results tunable via parameters (ef, M). A flat index is exact but scans all vectors, making it accurate yet too slow/expensive for large corpora.
What is the purpose of input/output validation (e.g., with Pydantic) at a model serving endpoint?
Schema validation rejects malformed or out-of-range requests before they reach the model, preventing crashes, silent garbage predictions, and security issues from untrusted input. It also enforces a stable contract between clients and the service, surfacing breaking changes early.
from pydantic import BaseModel, Field
class PredictRequest(BaseModel):
age: int = Field(ge=0, le=120)
income: float = Field(ge=0)
features: list[float] = Field(min_length=10, max_length=10)What is the difference between monitoring model performance with proxy metrics vs. ground-truth metrics in production?
Ground-truth metrics (e.g., accuracy, AUC) require labels that often arrive with delay or not at all, so they can't be computed immediately. Proxy/operational metrics—prediction distribution, drift, confidence, business KPIs—are available in real time and act as early warning signals until labels materialize.
Why might you deploy a model with feedback/label logging built into the inference path?
Logging the exact inputs, model version, and predictions (and later joining delayed ground-truth labels) creates the dataset needed to measure live performance, detect drift, debug failures, and assemble training data for retraining. Without this closed loop, you cannot reliably evaluate or improve the deployed model.
What is the main reason GPU utilization can be low even when an inference server is under heavy load?
Low GPU utilization under load usually signals a bottleneck elsewhere—CPU-bound pre/post-processing, small un-batched requests, data loading/network I/O, or Python GIL contention—so the GPU sits idle waiting for work. Fixing it involves batching, offloading preprocessing, or increasing concurrency to keep the GPU fed.
What does the term 'model decay' refer to, and what is the standard mitigation?
Model decay (staleness) is the gradual decline in a deployed model's performance over time as the world drifts away from the training distribution. The standard mitigation is a monitored retraining strategy—scheduled or trigger-based continuous training on fresh data with automated validation before redeployment.
Why is pickling (Python `pickle`) often discouraged for sharing production model artifacts?
Pickle is insecure (it can execute arbitrary code on load) and brittle across library/Python versions, so a model pickled in one environment may fail to load in another. Safer, more portable formats like ONNX, SavedModel, TorchScript, or safetensors are preferred for cross-environment deployment.
What advantage does exporting a model to ONNX provide for deployment?
ONNX is a framework-agnostic intermediate representation that lets a model trained in PyTorch/TensorFlow run on optimized runtimes (ONNX Runtime, TensorRT) across diverse hardware. This decouples training framework from serving stack and often unlocks graph optimizations and faster inference.
In an ML CI pipeline, what is the purpose of a model validation/quality gate before deployment?
A quality gate automatically checks a new model against thresholds—minimum metric performance, no regression versus the current production model, fairness/slice checks, and inference latency—before allowing promotion. It prevents shipping models that pass training but would degrade production behavior.
What is the benefit of multi-model serving (co-locating several models on one server/GPU)?
Multi-model serving packs multiple models onto shared compute, improving hardware utilization and cost-efficiency for many low-traffic models that would otherwise each waste a dedicated GPU. Frameworks load/unload models on demand and route requests, at the cost of more complex memory management and noisy-neighbor risk.
What is the purpose of a model card in responsible MLOps?
A model card is standardized documentation describing a model's intended use, training data, performance across relevant subgroups, limitations, and ethical considerations. It supports transparency, governance, and informed decisions by downstream users and auditors about whether/how to use the model.
Why is idempotency important when designing a retraining or deployment pipeline?
An idempotent pipeline produces the same end state when a step is retried, which is essential because distributed jobs frequently fail and re-run. Without idempotency, retries can duplicate data, create conflicting model versions, or double-promote artifacts, causing inconsistent and irreproducible deployments.
Related topics in Data & MLOps
Put it into practice with AI Learning
This topic — and hundreds more — comes from our free, offline AI Learning app. Practice Q&A, quizzes and cheat sheets anywhere, no account needed.
- Free
- No account
- Works offline