smartyfy.mrindigi.com

AI & Machine Learning Master Course — 187. Retraining and controlled rollout

Smartyfy AI & Machine Learning Master Course

Course ID: smartyfy-ai-ml-master-200

Lesson 187: Retraining and controlled rollout

Prerequisites: Lesson 186. Learning outcome: Define triggers, acceptance gates, shadow tests, rollback, and change records.

Retraining creates a candidate, not an automatic replacement

New labels, a changed operating domain, or a scheduled refresh may justify developing another model. None guarantees that the result should replace the incumbent. A retraining trigger starts an investigation or candidate-building process; promotion requires evidence against predeclared acceptance criteria.

Check the reason for change first. A broken unit conversion calls for repairing the data path. A new population may require revised collection and evaluation. A changing objective may require a new problem definition. Automatically fitting on the latest records can amplify a defective feed or a feedback loop.

Preserve the development boundary

Train candidates using permitted, appropriately matured data. Keep feature availability aligned with prediction time, and prevent labels from the final evaluation from influencing model choices. If a chronological system is refreshed, record the cutoff and which delayed outcomes were available at that time.

Compare the candidate with a relevant incumbent and simple baseline under the same protocol. Include important error slices, calibration or decision costs when relevant, and operational requirements. A small average improvement can be outweighed by a serious regression in an important condition.

Define a bounded tuning budget and acceptance rule before repeatedly examining results. Record unsuccessful candidates as well as the selected one. Otherwise, a report can conceal how much selection occurred against the evaluation data.

Use stages with distinct meanings

Offline evaluation checks a candidate without serving it to users. Shadow operation runs it on a copy of eligible live inputs while the incumbent remains responsible for the primary response. Shadow execution can reveal integration and resource problems, but it still processes data and consumes capacity, so it requires appropriate authorization and controls.

A canary exposes a limited portion of the workload to the candidate. Because it can affect actual decisions, define scope, allocation, guardrails, monitoring, and rollback before starting. A canary is not automatically a randomized causal experiment; comparison quality depends on how traffic is allocated and observed.

Expansion should follow explicit gates rather than elapsed time alone. A quiet short window may simply contain too few cases or no rare failures. State the evidence requirement and observation limitations for each stage.

CPU lab: a supplied improvement still leads to rollback

The standard-library program simulates a release state machine using invented evidence. Incumbent MAE is one and candidate MAE is 0.8, an improvement of 0.2. The illustrative offline gate requires at least 0.05 improvement along with schema, review, and rollback-readiness checks.

The simulated candidate moves from staged to shadow to canary. Canary observations then show p95 latency of 150 milliseconds against a limit of one hundred. Its supplied error rate of one percent is within the two-percent limit, but both conditions are required. The final state is rolled_back.

Run example187.py. No model is fitted, no traffic is routed, and no release occurs. The numbers are fixtures for checking control flow. They demonstrate that favorable offline performance cannot cancel an operational guardrail breach.

incumbent_mae, candidate_mae = 1.0, .8
ready = {'schema': True, 'review': True, 'rollback_rehearsed': True,
         'improvement': incumbent_mae-candidate_mae >= .05}
state = 'staged'
trace = [state]
if all(ready.values()):
    state = 'shadow'; trace.append(state)
shadow = {'parity': True, 'capacity': True}
if state == 'shadow' and all(shadow.values()):
    state = 'canary'; trace.append(state)
observed = {'p95_ms': 150, 'error_rate': .01}
within_limits = observed['p95_ms'] <= 100 and observed['error_rate'] <= .02
if state == 'canary':
    state = 'expanded' if within_limits else 'rolled_back'
    trace.append(state)
assert trace == ['staged','shadow','canary','rolled_back']
print('simulated states', trace)
print('candidate improvement', round(incumbent_mae-candidate_mae, 6))
print('canary limits passed', within_limits)

Prepare rollback as a complete operation

Keep a compatible incumbent artifact, preprocessing configuration, and input/output contract available when policy allows. Test the rollback procedure before depending on it. Reverting only model weights may fail if a new feature producer has changed units or fields.

Identify who can pause or reverse the rollout and how they confirm that the active version changed. Monitor the fallback after switching; an old version can have its own limitations or capacity requirements. Record the time, reason, affected scope, and verification result.

Rollback limits further exposure but may not undo decisions already made. Plan how to identify affected predictions and review downstream consequences when necessary. Correcting the active version and correcting historical outcomes are different responsibilities.

Learn from the candidate without rewriting the evidence

After a failed stage, investigate whether the issue concerns model quality, packaging, resource use, or the workflow. Preserve the original report and add the diagnosis rather than replacing the inconvenient result with a later successful run.

A corrected candidate needs a new version and appropriate retesting. If the previous canary data influenced the correction, acknowledge its role in development and avoid treating it as untouched final evidence. The same principle applies to repeatedly tuning guardrail thresholds until the candidate passes.

For recurring retraining, automate reproducible computation and routine checks while retaining the required approval boundaries. Automation should make evidence more complete and consistent; it should not hide the decision about whether the proposed use remains appropriate.

Four practice questions with worked answers

Practice 1

What is the candidate’s supplied MAE improvement?

Answer: It is 1.0 − 0.8 = 0.2. This exceeds the illustrative minimum improvement 0.05, but the values are supplied fixtures rather than measured training results.

Practice 2

Why does the canary simulation roll back?

Answer: Its p95 latency is 150 milliseconds, above the hundred-millisecond limit. The error-rate check passes, but the policy requires both checks, so latency alone blocks expansion.

Practice 3

Does a successful shadow run prove user outcomes improve?

Answer: No. Shadow execution can test integration and compute behavior without allowing its outputs to control the main response. It does not automatically measure the causal effect of acting on those outputs.

Practice 4

Why might reverting only weights fail?

Answer: The candidate rollout may also have changed preprocessing, schema, feature units, or threshold policy. The incumbent needs its compatible prediction path, and previously affected decisions may still require review.

Five multiple-choice questions

Question 1

What should a retraining trigger initiate?

  • A. Automatic promotion of the next fitted model
  • B. Promotion whenever training loss is lower than the previous run
  • C. A candidate-development and evaluation process

Correct: C. A reason to refresh is not proof that a resulting candidate is better or ready.

Question 2

What distinguishes shadow operation?

  • A. Candidate computation does not control the primary response
  • B. Candidate predictions replace every incumbent decision immediately
  • C. Candidate computation has no data-handling or capacity implications

Correct: A. Shadowing preserves the primary decision path while still requiring controls for copied inputs and resources.

Question 3

Which fact blocks the demonstrated canary?

  • A. The candidate’s supplied MAE is lower than the incumbent’s
  • B. Latency exceeds its declared limit
  • C. The supplied error rate is below its declared limit

Correct: B. The latency guardrail fails even though the other stated comparisons are favorable.

Question 4

When is a canary also a useful causal comparison?

  • A. Whenever its dashboard looks better than last month’s dashboard
  • B. Whenever the candidate receives any small amount of traffic
  • C. When allocation and observation support an appropriate experimental design

Correct: C. Limited exposure alone does not establish randomization or remove confounding.

Question 5

What should happen after tuning a correction using canary failures?

  • A. Erase the failed candidate so only the successful history remains
  • B. Version the correction and reassess with appropriate new evidence
  • C. Treat the same canary cases as untouched final evaluation

Correct: B. Information used for development changes the evidential role of those cases and should remain traceable.

Common pitfalls

Do not confuse retraining with approval, shadow computation with consequence-free processing, small canaries with automatic randomized experiments, or rollback with reversal of every past effect.

Summary

Controlled rollout separates candidate building, offline evidence, shadow checks, limited exposure, and expansion. Explicit guardrails and rehearsed rollback protect the workflow when a promising candidate fails operationally.

Primary sources and further reading