Capability Manifest: ML Engineering Ops
This blueprint provides the procedural truth for moving AI models from research "experiments" into production-grade systems.
When to Use
This skill should be used when completing tasks related to ml engineering ops.
Process
Follow these procedures to implement the capability:
Procedure 1: Robust Training Loops (Accelerate/DeepSpeed)
- State Management: Use
Acceleratorfrom HuggingFace to handle distributed training, mixed precision (FP16/BF16), and gradient accumulation automatically. - Checkpoint Truth: Always implement the
CheckpointManagerpattern. Save thelatest_checkpoint.ptevery epoch and thebest_model.ptbased on validation metrics. - Distributed Scale: For large models, use DeepSpeed ZeRO-2/3 to shard parameters and optimizer states across multiple GPUs.
Procedure 2: Serving & Inference Excellence
- Containerized Serving: Use
vLLMorTGIfor LLM serving to ensure high throughput and low-latency KV-cache management. - Schema Enforcement: Wrap every model endpoint in a FastAPI Pydantic layer to validate input/output shapes before they hit the weights.
- Health Gates: Implement
/healthand/readyendpoints that verify GPU availability and model loading status.
Procedure 3: Observability (Monitoring & Drift)
- Experiment Tracking: Every training run must be logged to MLflow or Weights & Biases, including hyperparameters, system metrics (GPU util), and loss curves.
- Production Tracing: Use LangSmith or equivalent to trace every inference request. Monitor for "Hallucination" and "Safety" scores at scale.
- Drift Detection: Set up automated evaluations to compare the "Inference Truth" against the "Training Distribution" to detect semantic drift.
Process (Fail-State & Recovery)
| Symptom | Probable Cause | Recovery Operation |
|---|---|---|
| CUDA Out of Memory | Batch size too large or memory leak. | Enable gradient_accumulation_steps; reduce micro-batch size; check for untracked tensors in the loop. |
| NaN Loss | High learning rate or unstable gradients. | Reduce LR; enable Gradient Clipping; verify input normalization. |
| Drift Alert | Model performing poorly on new data. | Trigger the "Fine-Tuning Loop": Collect the failure cases, augment the dataset, and run a versioned fine-tuning job. |
Prerequisites
| Action | Tool / Command |
|---|---|
| Run Training | accelerate launch train.py |
| Serving | python -m vllm.entrypoints.openai.api_server |
| Log Metrics | mlflow server --host 0.0.0.0 |
| Security Audit | pip-audit |
Best Practices
Before deploying:
- Training is reproducible via
pyproject.tomland pinned seeds. - Checkpointing and Resume logic verified.
- Health checks and Pydantic validation active.
- Trace analysis active (LangSmith).