CertNote/ Commute Study Notes
Roadmap
KOEN
CLF-C02 · FoundationalCloud Practitioner - Foundational
DVA-C02 · AssociateDeveloper - Associate
SAA-C03 · AssociateSolutions Architect - Associate
SOA-C02 · AssociateCloudOps Engineer - Associate
SAP-C02 · ProfessionalSolutions Architect - Professional
DOP-C02 · ProfessionalDevOps Engineer - Professional
Linux Master 2 · 2급KAIT Linux Master - Level 2
SCS-C03 · SpecialtySecurity - Specialty
Linux Master 1 · 1급KAIT Linux Master - Level 1
MLA-C01 · AssociateMachine Learning Engineer - Associate
AIF-C01 · FoundationalAI Practitioner - Foundational
DEA-C01 · AssociateData Engineer - Associate
MLS-C01 · SpecialtyMachine Learning - Specialty
  • Week 1
    • 1.The ML Lifecycle (from a Specialty Perspective)
    • 2.Data Storage for ML: S3, EFS, FSx for Lustre, and Data Formats
    • 3.Data Ingestion: Kinesis, Glue, Batch vs. Streaming
    • 4.Data Labeling: SageMaker Ground Truth, Active Learning, Label Quality
    • 5.Week 1 Comprehensive Review: ML Overview & Data Engineering 1
  • Week 2
  • Week 3
  • Week 4
  • Week 5
  • Week 6
  • Week 7
  • Week 8
  • Week 9
  • Week 10
  • Week 11
    • 1.Model Monitoring: SageMaker Model Monitor and Drift Response
    • 2.MLOps: SageMaker Pipelines, Model Registry, CI/CD
    • 3.ML Security: IAM Execution Roles, VPC Isolation, KMS Encryption
    • 4.Operations & Cost: Cost Optimization, Logging/Audit, Disaster Recovery
    • 5.Week 11 Comprehensive Review: Monitoring, MLOps, Security, Operations
  • Week 12
SQLD · 개발자SQL Developer (SQLD)

© CertNote · 주간랩스

  • About
  • Changelog
  • Contact
  • Terms
  • Privacy
← MLS-C01/Week 11/Day 2

Based on the MLS-C01 exam guide·Report an error

MLS-C01· AssociateWeek 11 · Day 2~29 min read

Day 2 - MLOps: SageMaker Pipelines, Model Registry, CI/CD

📌 Key Takeaways

  • Even if you detect drift, operations fall apart when retraining is manual. MLOps means defining processing → training → evaluation → registration → deployment as code so that it is repeatable and traceable.
  • SageMaker Pipelines links Steps into a DAG. Steps come in kinds such as Processing, Training, Tuning, Condition, RegisterModel, and Transform.
  • ConditionStep is the quality gate. "If the evaluation AUC is below the threshold, do not register" prevents a bad model from being promoted automatically.
  • Model Registry manages versions, approval status, and lineage. A model is registered as PendingManualApproval, and only once approved does it become Approved, which lets deployment automation continue.
  • SageMaker Projects automatically provisions two repositories (ModelBuild and ModelDeploy) plus a CodePipeline CI/CD flow, and deploys safely with Blue/Green, Canary, Linear, and Shadow strategies.

The 3 Problems MLOps Solves

Running a model once in a notebook and deploying it by hand from the console gives you no reproducibility, no traceability, and no collaboration.

ProblemWhat happens in manual MLMLOps solutionAWS components
Reproducibility"How did we build that model last month?" — nobody knowsFix the workflow as code so the same code + the same data → the same resultSageMaker Pipelines
GovernanceThere is no record of which data was used for training or who approved itAccumulate versions, metrics, approval status, and lineage in one placeModel Registry, Lineage
AutomationRetraining and deployment depend on people, so they are delayed and error-proneCommits and events trigger training and deploymentProjects, CodePipeline, EventBridge

💡 Concept: The three problems are not independent. Without reproducibility, governance records are meaningless, and without governance gates, automation just deploys bad models faster. Automation is safe only when the gates are already in place.

SageMaker Pipelines: ML Workflows as a DAG

Pipelines connects Steps into a directed acyclic graph (DAG). A dependency between Steps is created automatically when one Step's output (properties) is referenced as another Step's input.

Main Step Types

StepWhat it doesTypical use
ProcessingStepRuns a Processing JobPreprocessing, feature engineering, model evaluation
TrainingStepRuns a Training JobModel training
TuningStepRuns a Hyperparameter Tuning JobSearching for the best hyperparameters
TransformStepRuns a Batch TransformLarge-scale offline inference
CreateModelStepCreates a Model object from the training artifactsPreparing for deployment or batch transform
RegisterModel (step collection)Registers a model package in Model RegistryVersion management and entry into the approval gate
ConditionStepConditional branching (if_steps/else_steps)Quality gate
FailStepExplicitly fails the pipelineMarks the run as stopped when criteria are not met
LambdaStepInvokes a Lambda functionShort custom logic, notifications, external APIs
CallbackStepHands off to an external system via SQS and waits for a responseHuman review, integration with in-house systems
QualityCheckStep / ClarifyCheckStepChecks quality and bias baselinesPreventing drift and fairness regressions
EMRStepRuns a Spark job on EMRLarge-scale distributed preprocessing

Pipeline DAG

[ParameterString input_data]
        │
        ▼
 ┌───────────────┐    ┌──────────────┐    ┌────────────────┐
 │ ProcessingStep│──▶ │ TrainingStep │──▶ │ ProcessingStep │
 │  "Preprocess" │    │   "Train"    │    │   "Evaluate"   │
 └───────────────┘    └──────────────┘    └────────┬───────┘
   train/val/test        model.tar.gz        evaluation.json
                                                   │
                                                   ▼
                                        ┌──────────────────────┐
                                        │  ConditionStep       │
                                        │  AUC >= 0.80 ?       │
                                        └───┬──────────────┬───┘
                                    if_steps│              │else_steps
                                            ▼              ▼
                                   ┌─────────────┐   ┌───────────┐
                                   │RegisterModel│   │ FailStep  │
                                   └──────┬──────┘   └───────────┘
                                          ▼
                        [Model Registry] PendingManualApproval
                                          │ approve (Approved)
                                          ▼
                      [EventBridge] ─▶ [ModelDeploy CodePipeline] ─▶ endpoint

Definition Code

from sagemaker.workflow.pipeline import Pipeline
from sagemaker.workflow.steps import ProcessingStep, TrainingStep
from sagemaker.workflow.condition_step import ConditionStep
from sagemaker.workflow.conditions import ConditionGreaterThanOrEqualTo
from sagemaker.workflow.functions import JsonGet
from sagemaker.workflow.parameters import ParameterString, ParameterFloat
 
input_data   = ParameterString(name="InputData", default_value="s3://bucket/raw/")
auc_threshold = ParameterFloat(name="AucThreshold", default_value=0.80)
 
step_process = ProcessingStep(name="Preprocess", processor=sklearn_proc, ...)
step_train   = TrainingStep(name="Train", estimator=xgb, ...)
step_eval    = ProcessingStep(name="Evaluate", processor=eval_proc,
                              property_files=[eval_report], ...)
 
# Register only when the evaluation metric is at or above the threshold
cond = ConditionGreaterThanOrEqualTo(
    left=JsonGet(step_name=step_eval.name, property_file=eval_report,
                 json_path="metrics.auc.value"),
    right=auc_threshold,
)
step_cond = ConditionStep(name="AUCThreshold", conditions=[cond],
                          if_steps=[step_register], else_steps=[step_fail])
 
pipeline = Pipeline(
    name="churn-pipeline",
    parameters=[input_data, auc_threshold],
    steps=[step_process, step_train, step_eval, step_cond],
)
pipeline.upsert(role_arn=role)
pipeline.start()
Condition classWhat it checks
ConditionGreaterThanOrEqualTo / ConditionLessThanOrEqualToWhether the metric is at or above / at or below the threshold
ConditionEquals / ConditionInWhether the value matches / is in the allowed list
ConditionNot / ConditionOrNegating a condition / combining several conditions
  • Parameterization: ParameterString, ParameterInteger, and ParameterFloat inject input paths, thresholds, and instance types at execution time. You can re-run without changing code.
  • Caching: Attaching CacheConfig(enable_caching=True, expire_after="30d") to a Step skips re-running a Step with identical input, saving time and cost.
  • Passing evaluation metrics: Declare the JSON written by the evaluation Step as a PropertyFile, read a specific path with JsonGet, and feed it into the condition.

ConditionStep is the heart of the MLOps quality gate. As in "if the evaluation AUC is below 0.80, do not register," it keeps a bad model from flowing into production automatically. On the exam, a stem such as "automatically block deployment of a model that does not meet the criteria" maps to the combination of ConditionStep + the Model Registry approval gate.

Model Registry: Versions and Approval Governance

A trained model is registered in a Model Package Group as a version (Model Package).

from sagemaker.workflow.step_collections import RegisterModel
 
step_register = RegisterModel(
    name="RegisterModel",
    estimator=xgb,
    model_data=step_train.properties.ModelArtifacts.S3ModelArtifacts,
    content_types=["text/csv"], response_types=["text/csv"],
    inference_instances=["ml.m5.large"],
    transform_instances=["ml.m5.large"],
    model_package_group_name="churn-models",
    approval_status="PendingManualApproval",   # approval gate
    model_metrics=model_metrics,               # attach evaluation metrics to the version
)
churn-models (Model Package Group)
├── v1  Approved                (in production)
├── v2  Rejected                (did not meet evaluation criteria)
└── v3  PendingManualApproval   (awaiting review)

Approval State Transitions

TransitionTriggerResult
(new registration) → PendingManualApprovalDefault setting of RegisterModelNot a deployment target. Awaiting review
PendingManualApproval → ApprovedApproval by the owner or an automatic ruleA Model Package State Change event fires → triggers the deployment pipeline
PendingManualApproval → RejectedMetrics not met or a risk judgmentNot deployed; only a record remains
Approved → RejectedA problem is found in productionBlocks new deployments. Roll back to the previous Approved version
Rejected → ApprovedRe-review or issue resolvedBecomes deployable again
  • The status is changed with the UpdateModelPackage API (or the Studio UI). Because the status change itself becomes an event, approval is the deployment trigger.
  • A pipeline can register directly with approval_status="Approved", but that removes human review, so it is not recommended in regulated environments.

Lineage and Rollback

[Dataset S3] ─▶ [Processing Job] ─▶ [Training Job] ─▶ [Model Package v3]
   Artifact          Action             Action            Artifact
      └──────── Tracked end to end through Associations (links) ────────┘
 
Rollback: v3 → Rejected , v1 → Approved  ─▶ ModelDeploy redeploys v1
  • Lineage Tracking automatically links data, processing, training, and models using Artifacts/Actions/Contexts and Associations. This lets you answer "which data was the model that produced this prediction trained on, and who approved its deployment?"

Model Registry is the center of lineage, tying together "which model artifact came from which training job, metrics, and data." The approval status (Approved/Rejected/Pending) is the switch with which a person or automation enforces governance, and a rollback is done not as a new deployment but as a redeployment of the previous Approved version.

SageMaker Projects and CI/CD

SageMaker Projects is an MLOps template that automatically provisions two repositories and the pipelines.

┌──── ModelBuild repo (pipelines/ , tests/) ────┐
│ git push ─▶ CodePipeline ─▶ CodeBuild         │
│                └─▶ SageMaker Pipeline run      │
│                       └─▶ Model Registry entry │
└───────────────────────────────────────────────┘
                 │ approval (Approved) event
                 ▼
┌──── ModelDeploy repo (CloudFormation templates) ──┐
│ EventBridge ─▶ CodePipeline                       │
│     ├─▶ Deploy Staging endpoint                   │
│     ├─▶ Manual approval stage                     │
│     └─▶ Deploy Production endpoint                │
└───────────────────────────────────────────────────┘
ServiceRoleWhat it does in this flow
CodeCommit / GitSource repositoryVersion control for the pipeline definition and deployment templates
CodeBuildRuns builds and testsRuns the pipeline definition, unit and data validation tests
CodePipelineOrchestrationConnects source → build → deploy stages and inserts manual approval stages
CloudFormationIaC deploymentCreates and updates endpoints and endpoint configurations as code
EventBridgeEvent routingReceives the model approval event and starts the ModelDeploy pipeline
Model RegistryGovernanceControls whether to deploy through the approval status
# buildspec.yml excerpt (CodeBuild)
phases:
  build:
    commands:
      - python pipelines/run_pipeline.py --module-name pipelines.churn.pipeline
      - python -m pytest tests/    # code and data validation tests

⚠️ Pitfall: Attaching CI/CD does not create a gate. You need three layers of gates in place for automation to be safe: ConditionStep (model quality), Model Registry approval (a person or policy), and Staging validation.

Comparing Deployment Strategies

You do not send a new model to all traffic at once. SageMaker endpoints support gradual deployment.

StrategyTraffic flowRollback speedUser impactWhen to use
Blue/Green (All-at-once)Prepare a new fleet, then switch 100% at onceFast (the old fleet is kept for a baking period)All users if there is a problemThe default safe deployment. When the change is already validated
CanaryOnly a small share (e.g., 10%) goes to the new fleet → switch after validationVery fast (only a few are reverted)A few users onlyWhen minimizing risk is the top priority
LinearIncrease by a fixed percentage over several stepsFast (stop the step and revert)Grows gradually per stepWhen you move on after checking metrics at each step
RollingReplace instances sequentially in batchesMedium (revert the progress made)Users on the batch that was replacedReplacing a large fleet cost-efficiently
ShadowCopies production traffic to the new model and discards its responsesImmediate (not live use)NoneWhen you only want pre-validation with real traffic
A/B (Production Variant)Distributes traffic by weight across variants on one endpointImmediate by adjusting weightsDifferent models for different groupsWhen you want to compare the performance of two models in practice
  • Blue/Green, Canary, Linear, and Rolling are endpoint update methods, while A/B and Shadow are simultaneous operation and comparison methods. Their purposes differ.
  • In the deployment configuration, attach CloudWatch alarms for automatic rollback. If the error rate or latency exceeds the threshold, the endpoint reverts to the previous configuration.

Stem Clue → Answer Mapping

Stem clueAnswer to chooseWhy
"If the evaluation metric does not meet the criteria, do not register and stop"ConditionStep (+FailStep)A quality gate that compares the metric to a threshold and branches
"Track which model was trained on which data, with fast rollback"Model Registry (+Lineage)Manages versions, approval status, and lineage
"What is the default approval status of a newly registered model?"PendingManualApprovalNot a deployment target until reviewed
"When approved, the deployment pipeline must run automatically"EventBridge → CodePipelineRoutes the model package state change event
"Set up build and deploy repos and CI/CD from a template at once"SageMaker ProjectsAutomatic ModelBuild/ModelDeploy provisioning + IaC deployment
"Validate with a small amount of traffic first, then expand"CanaryGradual switchover that minimizes exposure
"Compare the performance of two models with real traffic"A/B (Production Variant) weighted distributionServe and compare simultaneously on one endpoint
"Pre-validate with real traffic without affecting users"Shadow deploymentCopies traffic and does not return the responses
"It is wasteful to re-run the same preprocessing Step every time"Step caching with CacheConfigSkips re-running a Step with identical input
"Reuse by changing input paths and thresholds on each run"Pipeline ParametersInjected at execution time without editing the definition
"Manual deployment from a notebook is enough"Wrong answer choiceBreaks reproducibility and governance

Pipeline Review Checklist

  • Is the evaluation Step's metric connected to the condition through PropertyFile and JsonGet?
  • Is the ConditionStep's else_steps non-empty and does it explicitly signal failure?
  • Does the approval status at registration match the organization's policy (manual/automatic)?
  • Is a CloudWatch alarm for automatic rollback attached to the deployment strategy?

In the next post, we cover ML security, which underpins all of these pipelines: IAM execution roles, VPC isolation, and KMS encryption.

📖 Glossary

  • MLOps: An operating approach that ties data processing, training, evaluation, registration, and deployment together with code and automation so that they are repeatable and traceable.
  • DAG (directed acyclic graph): A structure in which Steps are connected by arrows and there are no cycles. It defines what runs before what.
  • Step: The smallest execution unit of a pipeline. Its types are fixed, such as processing, training, tuning, condition, and registration.
  • ConditionStep: A Step that compares a value such as an evaluation metric against a condition and splits the execution path. It is the core of the quality gate.
  • PropertyFile / JsonGet: The mechanism that pulls a specific metric value out of the JSON result left by an evaluation Step and feeds it into a condition.
  • Model Package Group: A box that collects model versions for the same purpose. Versions v1, v2, … accumulate inside it.
  • PendingManualApproval: The default approval status of a new model version. Until it passes review and becomes Approved, it is not a deployment target.
  • Lineage: The chain of linked records running from data → processing → training → model. It is the basis for auditing, reproduction, and rollback.
  • SageMaker Projects: An MLOps template that creates the ModelBuild/ModelDeploy repositories and the CI/CD pipelines in one go.
  • Production Variant / Shadow deployment: A Production Variant is the unit that splits weights within a single endpoint to serve multiple models at once, used for A/B comparison. Shadow deployment is a validation method that copies real traffic to the new model but does not return its responses to users.

📝 Practice Questions

Click a choice to reveal the answer and explanation.

Question 1

In a SageMaker Pipeline, you want to stop the pipeline without registering the model in the Model Registry if the trained model's validation AUC is below 0.75. Which component should you use?

Question 2

A problem occurred with the production model, and you want to quickly roll back to a previous version and track "which model is currently trained on which data." Which SageMaker feature is MOST appropriate?

Question 3

You want to release a new model to production by first sending only a small amount of real traffic to confirm there are no problems, and then gradually increasing the share. Which deployment strategy is MOST appropriate?

Question 4

What is the MOST accurate description of the core value of the MLOps templates provided by SageMaker Projects?

Question 5

What is the typical default approval status of a newly registered model version in the Model Registry, and what does it mean?

PreviousModel Monitoring: SageMaker Model Monitor and Drift ResponseWeek 11 · Day 1Next ML Security: IAM Execution Roles, VPC Isolation, KMS EncryptionWeek 11 · Day 3

Official references

  • MLS-C01 official exam page(opens in a new tab)
  • Amazon SageMaker AI documentation(opens in a new tab)
  • AWS CodePipeline documentation(opens in a new tab)
  • Amazon EventBridge documentation(opens in a new tab)

On this page

  • Key Takeaways
  • The 3 Problems MLOps Solves
  • SageMaker Pipelines: ML Workflows as a DAG
  • Main Step Types
  • Pipeline DAG
  • Definition Code
  • Model Registry: Versions and Approval Governance
  • Approval State Transitions
  • Lineage and Rollback
  • SageMaker Projects and CI/CD
  • Comparing Deployment Strategies
  • Stem Clue → Answer Mapping
  • Pipeline Review Checklist
  • Glossary
  • Practice Questions