MLOps on Snowflake

MLOps is the set of practices that makes machine learning repeatable, governed, and scalable in production. A production-ready workflow makes every model version traceable to the code, data, features, and evaluation results that produced it. Promotions pass automated checks and an explicit approval, and production models are observable, reproducible, and reversible.

On Snowflake, every stage of this workflow runs next to your governed data: data validation, feature engineering, training, experiment tracking, model management, inference, and monitoring. You can build these workflows directly, or use agentic ML with Snowflake CoCo to generate and run the code from natural-language prompts.

Snowflake ML capabilities for MLOps

The following table maps each step of an MLOps workflow to the Snowflake features that support it:

Pipeline stepSnowflake featureWhat it does
Data validationData quality monitoring, virtual warehousesData metric functions (DMFs) run scheduled checks for row counts, null rates, freshness, duplicates, and custom rules. Warehouses run SQL and Snowpark validation code.
Feature engineeringFeature Store, dynamic tablesThe Feature Store manages entities and versioned feature views defined in SQL or Python. Feature views refresh incrementally as dynamic tables to a target lag.
Online feature servingOnline feature servingFeature views configured with OnlineStoreType.POSTGRES serve the latest values per entity key from a Snowflake Postgres-backed online store with low latency.
Training dataDatasetsImmutable, versioned snapshots of training data. Datasets generated from the Feature Store are point-in-time correct.
TrainingML Jobs, stored proceduresML Jobs run Python on the Container Runtime on CPU or GPU compute pools. Stored procedures run Python on warehouses.
Experiment trackingExperimentsExperiments group runs and store their parameters, metrics, artifacts, and logged models for comparison.
Model managementModel RegistryModels are schema-level objects with versions, metrics, metadata, aliases, and a default version.
Batch inferenceNative batch inference, Batch Inference JobsNative batch inference calls model methods from SQL or Snowpark on a warehouse or SPCS service. Batch Inference Jobs run asynchronous, distributed inference on compute pools.
Real-time inferenceReal-time inference, gatewaysDeploys a model version as a Snowpark Container Services (SPCS) service with HTTPS endpoints. A gateway provides a stable URL and splits traffic across versions.
MonitoringModel monitors, alertsMonitors compute drift, volume, and performance from stored inference data. Performance metrics require ground-truth labels. Alerts evaluate conditions on a schedule and notify or act.
OrchestrationTasks, task graphsScheduled or triggered units of work, chained into DAGs with dependencies, retries, and finalizers.
LineageML LineageTraces source data through feature views, Datasets, model versions, and deployed services.
GovernanceAccess control, workload identity federationRole-based access control (RBAC) governs data, features, models, services, and compute. Workload identity federation lets CI/CD systems authenticate with short-lived OIDC tokens.

Get started

MLOps maturity grows by adding automation and control to a repeatable workflow. Find the level that describes your team today, and use the next level as your target:

LevelWhat it looks likeWhat to add on Snowflake
0: ManualModels are trained in notebooks and handed off as artifacts. Deployment, monitoring, and retraining are manual and hard to audit.Register every model in the Model Registry, and train on versioned Datasets.
1: Automated trainingA scheduled pipeline validates data, refreshes features, trains, evaluates, and registers each version.A task graph for the training pipeline, Feature Store feature views, and experiment tracking. See Steps in an ML pipeline.
2: Automated deliveryCode and configuration flow through CI/CD. Automated gates run before release, production requires approval, rollouts are controlled, monitoring is continuous, and rollback is fast.Separate environments, Git-based deployment, gated promotion, gateways, and model monitors. See Promotion patterns: model vs. code and Operate models in production.

Core architectural and operational decisions

Before you build MLOps workflows on Snowflake, decide how to align them with your security policies, data governance requirements, and infrastructure needs. These decisions define how environments are isolated, where training and inference run, how models are promoted, and how much human oversight is required before a production release:

DecisionOptionsChoose based on
Environment isolationSeparate databases in one account, or separate accountsChoose separate accounts when you need stronger isolation of data, users, and spend. See Isolate environments.
Where training runsPromote the model (train in STAGE), or promote the code (train in PROD)Whether non-production environments can read production data.
Training computeML Jobs on compute pools, or stored procedures on warehousesUse ML Jobs for GPUs, distributed training, or custom packages. Use stored procedures for smaller CPU workloads that fit a warehouse.
InferenceNative batch inference, Batch Inference Jobs, or real-time inferenceData volume, latency requirements, and runtime needs. See Model deployment.
Model promotionAutomated, champion vs. challenger (compare a new candidate version, the challenger, with the current production version, the champion), human-in-the-loop, or hybridRisk tolerance, regulatory requirements, and required level of oversight before release.

Set up environments

Isolate environments

Most DevOps teams promote code through separate development, test, and production environments. Apply the same pattern to MLOps so that experiments, validation, and production workloads stay isolated from each other.

A typical setup uses three environments: DEV, STAGE, and PROD (or a similar naming convention, such as SANDBOX, QA, and PRODUCTION, with more or fewer environments as needed). Each environment serves a distinct purpose:

  • DEV: Data scientists explore data, build features, and train experimental models. Changes here never affect production.
  • STAGE: CI/CD runs the pipeline. Candidate models and pipeline changes are tested, gated, and validated before release.
  • PROD: Approved models serve batch and real-time traffic and are monitored.

Each environment gets its own database, warehouses, and compute pools, and writes only to its own database. Because Feature Store and Model Registry objects live in schemas, each environment also gets its own feature store and registry. Separate compute keeps experiments from competing with production workloads.

Choose an isolation level

  • Logical isolation: Each environment is a separate database in one account. This is the simplest setup to manage.
  • Physical isolation: Each environment is a separate Snowflake account. Use database replication to make approved models and features available in the production account.

Choose a data access pattern

Decide where each environment reads its source data from. Choose the pattern that fits your data governance policy:

  • Read production data: DEV and STAGE read production source data through read-only grants. Data scientists train and validate on the same data that production uses, but can’t modify it.
  • Read environment-local data: Each environment reads only from its own database. DEV and STAGE use sampled, masked, or synthetic copies of production data. Use this pattern when policy prevents non-production environments from accessing production data.

Reference architecture

The following diagram shows a baseline end-to-end example with CI/CD integration. Each environment has its own database, and DEV and STAGE read production source data through read-only grants. Adapt it to the isolation level and data access pattern that you choose.

Reference architecture showing Git and CI/CD deploying to DEV, STAGE, and PROD environments, each with its own database, warehouse, compute pool, and Feature Store, with governance controls applied across all environments.

Assign roles and privileges

Each persona maps to one or more roles per environment. In smaller teams, one person can hold several personas, but keep the production deployment role separate from human development roles:

PersonaOwnsTypical changesTypical access
Business ownerThe decision the model supports, the success metric, and the minimum production thresholdAcceptance criteria and decision policyRead access to monitoring results and release evidence
Data engineerSource pipelines, data quality, and feature freshnessTransformations, data metric functions, refresh schedulesWrite access to source and feature schemas in DEV; deploys through CI/CD
Data scientistFeature semantics, training code, experiments, and evaluation criteriaFeature definitions, training code, evaluation logic, notebooksCreate privileges in DEV schemas; read-only access to STAGE and PROD
ML engineerPipelines, CI/CD, serving, and monitoringTask graphs, deployment code, monitors, compute choices, traffic weightsWrite access through the CI/CD deployment role; USAGE on compute pools
Model approverThe decision to release a version to productionApprove or reject a release; request a rollbackApproval rights in the CI/CD system; read access to evidence
Platform administratorAccounts, roles, policies, compute, budgets, and repository controlsEnvironment setup, grants, network policies, branch protectionAdministrative roles; manages the CI/CD service identity

For model objects:

  • Grant OWNERSHIP on a model only to its owning role, which in STAGE and PROD should be the CI/CD deployment role.
  • Grant USAGE to roles that run warehouse inference, and READ to roles that deploy or copy versions. For more information, see Model Registry.
  • Grant access to real-time endpoints through the service’s service roles, not through model ownership.
  • To manage a gateway, a role needs CREATE GATEWAY on the schema, BIND SERVICE ENDPOINT on the account, and USAGE on the target service endpoints.

Secure the environments

  • Apply least-privilege roles separately in DEV, STAGE, and PROD, and use a separate deployment identity per environment.
  • Protect production branches, and require approval for production changes.
  • Use network policies and private connectivity where required to restrict where users, applications, and CI/CD can connect from.
  • Don’t embed credentials in code, notebooks, or CI/CD configuration.

Deploy with CI/CD

Keep every artifact that defines your ML system in Git, including training code, model definitions, feature definitions, orchestration configuration, infrastructure, and gateway specifications. Define Snowflake resources, such as databases, schemas, roles, warehouses, compute pools, tasks, and services, as code with DCM projects, SQL scripts, or Terraform. Use Snowflake Git integration to run version-controlled SQL and Python files directly from your repository.

Automate testing and deployment across DEV, STAGE, and PROD with a CI/CD platform such as GitHub Actions or Azure Pipelines, instead of making manual changes. Run automated quality gates on pull requests, run a final validation in STAGE, and release to PROD after approval or on a scheduled release cycle. Require explicit sign-off for production promotions, and configure connection controls and protection rules for each environment, for example with GitHub Environments. This keeps every release traceable, reproducible, and reversible.

A typical automated deployment pipeline performs these steps:

  • Packages shared modules as Python libraries and uploads them to an artifact repository, if required.
  • Stages application code, or syncs the repository through Snowflake Git integration.
  • Deploys the task graph by running its DAG definition.
  • Triggers a test run of the deployed task graph to validate the pipeline.

Authenticate CI/CD runners with workload identity federation, so that they use short-lived OIDC tokens instead of long-lived service account secrets.

Promotion patterns: model vs. code

A model version reaches production in one of two ways. You can promote the model: train and validate a version outside production, then copy that exact version into PROD. Or you can promote the code: release the training pipeline to PROD and train the version there. Both patterns use the same quality gates and the same approval step. They differ in where training runs, which data it reads, and what moves between environments.

Promote the model

STAGE trains and validates the candidate, and PROD receives the exact version that passed validation. The artifact you serve is the artifact you tested, and training runs once per release.

STAGE needs read access to production data, either through read-only grants or a replicated copy. After approval, CI/CD copies the version into the production registry. Use CREATE MODEL ... FROM MODEL for a new model, or ALTER MODEL ... ADD VERSION … FROM MODEL for an existing one. The version’s metrics and metadata move with it. If your environments are separate accounts, first replicate the source model to the production account.

Note

Grant the production role read access on future models in the STAGE schema, or have the STAGE role grant access to the production role when it creates each model. Otherwise, the promotion commands fail.

-- Copy the version validated in STAGE into PROD
ALTER MODEL ML_PROD.ML.FRAUD_DETECTOR ADD VERSION V2
  FROM MODEL ML_STAGE.ML.FRAUD_DETECTOR VERSION V2;
ALTER MODEL ML_PROD.ML.FRAUD_DETECTOR SET DEFAULT_VERSION = V2;

Promote the code

The training pipeline is the release. STAGE runs the pipeline on non-production or sampled data to prove that the code works; it doesn’t produce the production model. After approval, CI/CD deploys the pipeline to PROD, where it trains the candidate on production data.

In PROD, the pipeline registers each new version without changing the default version and assigns it a challenger alias. The gate compares the challenger with the current default version, which is the champion. After approval, CI/CD makes the challenger the default version.

-- Label the version trained in PROD as the challenger
ALTER MODEL ML_PROD.ML.FRAUD_DETECTOR VERSION V2 SET ALIAS = challenger;
-- After approval, make it the default version
ALTER MODEL ML_PROD.ML.FRAUD_DETECTOR SET DEFAULT_VERSION = V2;

Because the production version doesn’t exist until the pipeline runs in PROD, the gate and approval in PROD are the final check before serving.

Compare the patterns

The following table compares the two promotion patterns:

AspectPromote the modelPromote the code
Where training runsSTAGEPROD
STAGE dataRead-only production data or a replicated copyNon-production, sampled, or synthetic data
What moves to PRODThe validated model versionThe pipeline code
Who writes to the PROD registryCI/CD, copying a versionThe PROD pipeline, registering versions
Choose whenSTAGE can read production data, and you want to serve exactly the artifact you validatedPolicy keeps production data in PROD, or the data is too large to copy

You can use different patterns for different models. Record the pattern with each release, because it determines where retraining runs and which role writes to the production registry.

Release workflow

Each release moves through four phases:

PhasePromote the modelPromote the code
1. DevelopA data scientist works on a feature branch and runs the full pipeline in DEV.Same as promote the model.
2. ReviewA pull request triggers linting, unit tests, and code review. Merging to main deploys to STAGE.Same as promote the model.
3. Validate in STAGECI/CD trains the candidate, compares it with the production champion, and validates scoring and monitoring.CI/CD runs the pipeline on non-production data to validate the code, scoring, and monitoring.
4. Release to PRODThe approver reviews the evidence. CI/CD copies the exact validated version, updates serving and monitoring, and tags the release in Git.CI/CD deploys the pipeline. PROD trains and gates the challenger; after approval, CI/CD makes it the default version and updates serving and monitoring.

Record the Git commit and release identifier in the model version’s metadata in the Model Registry.

The following diagram shows how each persona moves a change through Git, GitHub Actions, and the Snowflake environments during a release:

Git workflow across the develop, review, validate in STAGE, and release to PROD phases, showing the actions of the data scientist, ML engineer, GitHub Actions, and model approver, and the DEV, STAGE, and PROD databases.

Steps in an ML pipeline

The steps in an ML pipeline vary by use case. The following steps describe a typical supervised-learning pipeline and the Snowflake services that support each step. Adapt them to your use case, for example by adding steps for data labeling, hyperparameter tuning, or batch scoring.

Feature engineering

Validate source data, compute features, and assemble a point-in-time-correct training dataset.

Use data metric functions to check source data for schema, row counts, null rates, freshness, and acceptable ranges before you compute features.

The Feature Store keeps training and serving consistent:

  • Offline: Each feature view is a dynamic table that refreshes to a target lag. Generating a training Dataset joins features as of each label’s timestamp, so the model never trains on values that weren’t yet known.
  • Online: The same feature view can sync its latest values per entity key to the online store, which a real-time service reads at request time. Requires snowflake-ml-python 2.5 or later.

Because training and serving use one feature view definition, you avoid training-serving skew. Define feature views in Git, version them, and register them in each environment through CI/CD. For design patterns and temporal features, see the Snowflake Feature Store Implementation Guide.

Model training

Run training where it fits the workload. Use ML Jobs for GPUs, distributed training, or custom packages, and use stored procedures on a warehouse for smaller CPU workloads.

Log each training run with experiment tracking so that you can compare runs, then log the selected model to the Model Registry. Logging the model inside the run links the version to the run’s parameters and metrics. Training on a Dataset links the version to its features through ML Lineage.

Model evaluation

Register each candidate as a new version in the Model Registry, linked to its Dataset, feature views, experiment run, and Git commit, without changing the default version. Then compare it with the current default version and evaluate the release gates.

Run automated checks before a version can be promoted:

  • Code quality, unit tests, and integration tests.
  • Source-data schema, volume, null-rate, range, and freshness checks.
  • Feature-view and label freshness checks.
  • Training reproducibility and experiment metadata checks.
  • Candidate quality against minimum thresholds. For the first release, when no champion exists, use the thresholds agreed with the business owner.
  • Champion-versus-candidate comparison on business and technical metrics.
  • Batch-scoring and monitoring smoke tests.
  • Security checks for roles, services, endpoints, and network configuration.

Implement each gate as a task in the task graph. When a task fails, downstream tasks don’t run, so a failed gate stops the version from being promoted. Use data metric functions for data quality expectations, and store evaluation metrics on each version in the Model Registry so the gate can compare the candidate with the default version.

Automated gates provide evidence; they don’t replace the production decision. Keep the gate results, approval record, release identifier, and Git commit as the release audit trail. For higher-risk use cases, attach a model card or equivalent review record.

Model deployment

Deployment is the last stage of the pipeline. After the gates pass and the release is approved, CI/CD promotes the version by using the pattern you chose in Promotion patterns: model vs. code, and then sets it as the default version. Batch pipelines that call the default version pick it up automatically. For real-time inference, deploy a service for the new version and shift traffic to it through the gateway.

Use the following table to choose an inference option:

OptionUse whenRuns on
Native batch inferenceScoring fits a SQL workflow, such as a task, dynamic table, or dbt modelA warehouse, or an SPCS model service
Batch Inference JobsLarge or unstructured datasets, custom environments, or GPUsAsynchronous jobs on compute pools; results written to a stage
Real-time inferenceApplications need low-latency predictions per requestAn SPCS service on a CPU or GPU compute pool, behind a gateway

Promote a model used for warehouse inference

When a model serves only warehouse inference, promotion is a Model Registry change: no service or gateway update is needed. Point callers at the production version either through the default version, which callers that don’t name a version use, or through a production alias named explicitly in their SQL. Because a version can have only one alias, moving the alias takes several statements. Run them as one CI/CD step, verify with SHOW VERSIONS IN MODEL, and roll back by moving the alias to the previous version.

Batch inference

Schedule scoring with a task that runs against the production feature view and writes predictions to a governed table. Store the model version, feature view version, and scoring timestamp with each prediction so results stay traceable and can feed a model monitor.

Real-time inference

Deploy each production model version as its own real-time inference service on a CPU or GPU compute pool that scales between a minimum and maximum number of instances. Put a gateway in front of the services to give clients one stable URL and split traffic by weight for canary and blue-green rollouts. Shadow traffic (preview) mirrors requests to a challenger without returning its predictions to clients.

If the model needs current feature values at request time, map an online-enabled feature view to the model method with feature_sources_per_function. Clients then send only entity IDs, and the service looks up the remaining features from the online store.

After the new service is healthy, shift a share of traffic to it through the gateway. The following example sends 10% of requests to V2:

ALTER GATEWAY ML_PROD.ML.FRAUD_DETECTOR_GATEWAY FROM SPECIFICATION $$
spec:
  type: traffic_split
  split_type: custom
  targets:
  - type: endpoint
    value: ML_PROD.ML.FRAUD_DETECTOR_V1!inference
    weight: 90
  - type: endpoint
    value: ML_PROD.ML.FRAUD_DETECTOR_V2!inference
    weight: 10
$$;

Use service logs and metrics to debug latency and errors. Enable inference log autocapture to record requests and responses for monitoring and future training data.

Orchestrate your ML pipeline

Run the pipeline with an orchestrator such as Snowflake task graphs, scheduled notebooks, or an external orchestrator such as Airflow, with one task per step. Keep step code separate from orchestration and environment configuration, so that the same pipeline runs in every environment with parameters supplied by CI/CD. An orchestration framework provides the following advantages:

  • Fault tolerance and reliability through automatic retries and failure isolation.
  • Observability with run history, real-time status, and alerts.
  • Scheduling and coordination for complex dependency graphs and various triggers.
  • Operational hygiene with version control integration and configuration management.

Operate models in production

Monitor

Monitor more than model accuracy. The following table lists the signals to monitor and the Snowflake features that track them:

SignalSnowflake feature
Prediction quality, once labels arriveModel monitors
Feature drift, prediction drift, and input distributionsModel monitors
Inference volumeModel monitors
Service latency, errors, and availabilityService logs and metrics, gateway monitoring
Feature and label freshness; batch completenessData metric functions
Cost of warehouses, compute pools, and servicesBudgets, Account Usage views

Create a model monitor for each production model version. A monitor reads inference data and computes volume metrics and drift relative to a baseline. When ground-truth labels are available, it also computes performance metrics. Results appear in Snowsight. When you promote a new version, create its monitor as part of the release. Use alerts to check these metrics on a schedule and notify the owning team. Each alert should link to the affected model version, data window, and release.

For real-time services behind a gateway, a gateway model monitor tracks performance and drift across all target versions, so you can compare versions during an A/B test or canary rollout.

Ground-truth labels usually arrive after scoring. Join them to the prediction table in a view, and point the monitor at that view. The baseline enables drift metrics, and the label column enables performance metrics:

CREATE MODEL MONITOR ML_PROD.ML.FRAUD_DETECTOR_V2_MONITOR WITH
  MODEL = ML_PROD.ML.FRAUD_DETECTOR VERSION = 'V2' FUNCTION = 'predict'
  SOURCE = ML_PROD.ML.FRAUD_PREDICTIONS_WITH_LABELS
  BASELINE = ML_PROD.ML.FRAUD_BASELINE
  TIMESTAMP_COLUMN = SCORED_AT
  ID_COLUMNS = ('TXN_ID')
  PREDICTION_SCORE_COLUMNS = ('FRAUD_SCORE')
  ACTUAL_CLASS_COLUMNS = ('IS_FRAUD')
  WAREHOUSE = ML_PROD_WH
  REFRESH_INTERVAL = '1 hour'
  AGGREGATION_WINDOW = '1 day';

Decide when to retrain

Retrain on one or more triggers:

  • A fixed schedule, such as weekly or monthly.
  • A change to code, features, or a data source.
  • A drift, freshness, or performance alert.
  • A business event that changes the target population or decision policy.

A trigger produces a candidate; it doesn’t bypass validation and approval. Under promote-the-model, the candidate is produced in STAGE. Under promote-the-code, training runs in PROD. Schedule retraining with a task on a cron schedule, or use a triggered task to start training when new data arrives. An alert can notify the model owner or, where your privilege model allows, start the training task graph. Each retrain registers a new version without changing the default version.

Roll back

Treat rollback as a tested workflow, not an emergency-only procedure:

  • Batch: Set the previous approved version as the default version in the Model Registry, together with its compatible feature view version.
  • Real-time: Route 100% of gateway traffic back to the previous version’s service.

The following example rolls back a batch model to version V1:

ALTER MODEL ML_PROD.ML.FRAUD_DETECTOR SET DEFAULT_VERSION = V1;

Record the rollback reason, operator, model version, feature view version, and Git commit.

Operational considerations

  • Cost: Set auto-suspend on warehouses and compute pools, scaling limits on services, and budgets per environment or workload. Review usage by environment with Account Usage views.
  • Scale: Separate compute for interactive development, training, batch inference, and real-time serving, so that one workload doesn’t starve another.
  • Reliability: Make pipelines idempotent, write to explicit output locations, and write completion markers before downstream steps consume results.
  • Reproducibility: Pin package and runtime versions, retain Dataset versions, and record configuration with every run.
  • Disaster recovery: Use database replication for databases that hold models, features, and pipelines. Keep gateway specifications and deployment configuration in Git.
  • Data retention: Set retention policies for training data, inference logs, experiment artifacts, model versions, and audit evidence.
  • Access review: Periodically review roles, service roles, CI/CD identities, network policies, and model access.