Sub topic 17
Guardrails: Cooldowns, Budgets, and Human Approval
This chapter assumes you understand training, validation, deployment, batch or online serving, Python, and basic CI/CD. The focus here is controlling an automated retraining system after a trigger fires.
Why guardrails are necessary
A trigger is a signal, not proof that retraining is needed. A noisy metric, a broken data source, or a sudden traffic change can start many unnecessary jobs. Worse, a bad training dataset can produce a model that passes a superficial check and harms production.
Guardrails limit what the pipeline can do. They should control:
- How often retraining may start.
- How much data and compute one run may consume.
- Which data sources are trusted.
- When a person must approve the result.
- How the system stops or rolls back a suspicious run.
A useful policy separates automatic actions from actions that require review.
| Situation | Automatic action | Human approval |
|---|---|---|
| Scheduled run with valid data | Train and evaluate | Usually no |
| Strong drift with enough new data | Start a bounded run | Depends on risk |
| Failed data validation | Stop the run | Review the data source |
| Challenger improves a low-risk metric | Canary deployment | Optional |
| Challenger changes a high-risk decision | Register only | Required before promotion |
Cooldowns and loop prevention
A cooldown is a minimum time between retraining starts. It prevents one persistent signal from launching repeated jobs. For example, a pipeline might require two days between runs.
Also record the trigger reason, data window, code version, and result of every run. Do not treat a failed run as a successful retraining event. However, repeated failures should still activate an alert and a separate failure limit.
Use additional limits:
- Set a maximum number of runs per day or week.
- Require a minimum number of new, valid records.
- Ignore duplicate events with the same data and code identifiers.
- Stop if the same model version repeatedly fails evaluation.
Budgets and trusted data
A budget can limit CPU hours, GPU hours, memory, storage, or monetary cost. Give each run a maximum duration and resource allocation. If a hyperparameter search reaches its budget without finding an acceptable candidate, stop it and report the result.
Data guardrails are equally important. Accept data only from approved sources and expected time ranges. Reject unexpected schemas, impossible values, extreme row-count changes, and suspicious label distributions. Keep the previous champion available so a failed or poisoned run cannot remove the working model.
Human approval and safe stopping
Require approval when the model affects safety, money, access, or legal decisions. Approval should show the data version, code version, evaluation metrics, fairness checks, estimated cost, and rollout plan. The approver should be able to reject the candidate without deleting artifacts.
The pipeline should fail closed: when validation, evaluation, budget, or approval checks fail, it should not promote the challenger.
Exercise
A drift alert fires three times in one hour, but the policy allows one retraining run every two days. What should the pipeline do?
Show answer
Start at most one eligible run, apply the cooldown to later alerts, record each alert, and investigate whether the monitoring signal or data source is faulty.