Reference Architecture: End-to-End AI/ML Pipeline in Snowflake

Jagadishwar Pannala 

Snowflake RBAC Management with Streamlit

1. Executive Summary

Problem: Organizations running AI/ML on Snowflake typically stitch together three disconnected systems: a data pipeline, an ML training environment, and a serving layer. These hand-offs are often brittle, lack lineage, and do not provide unified governance.

Recommended Approach: Use a seven-layer Medallion + MLOps architecture on Snowflake: Bronze (raw), Silver (cleaned), Gold (point-in-time features), Model Training (Snowpark ML), Model Registry, Inference, and Monitoring.

Best Use Cases: Classical ML on structured tabular data, such as churn, fraud, demand forecasting, and risk scoring, where data gravity to Snowflake is high and the team does not have a separate MLOps platform.

Key Outcomes: Reproducible model training with full lineage, governed model promotion workflow, idempotent and observable pipelines, cost-controlled compute, and production-grade failure handling.

What You Can Implement: This reference architecture is actionable end-to-end. Every layer includes SQL patterns, configuration decisions, and operational runbook entries needed to deploy in a real environment.


2. Background

Snowflake's ML ecosystem has matured significantly since 2023. Snowpark ML brings scikit-learn, XGBoost, and LightGBM-compatible model training directly inside Snowflake compute. The Snowflake Model Registry provides versioned model storage with promotion workflows. Cortex offers managed LLM functions for text-based use cases.

Despite this, many Snowflake AI/ML engagements share a common failure pattern: the data engineering and ML teams operate in silos. The data team delivers a Gold-layer table, the ML team trains on an ad hoc extract, and the serving team deploys from a separate artifact store. Each boundary becomes a potential failure point, governance gap, and reproducibility risk.

This architecture collapses those silos into a single governed platform while being honest about Snowflake's limitations. Snowflake is not a GPU training cluster, not a sub-100ms inference engine, and not a replacement for dedicated MLOps tooling in large-scale deep learning contexts.


3. Problem

3.1 Symptoms

  • Models perform well in notebook evaluation but degrade silently within weeks of production deployment.
  • Training pipelines cannot be reproduced because there is no record of which data snapshot, feature version, or hyperparameters produced the current production model.
  • Feature computation logic is reimplemented independently by data engineering, ML engineering, and analytics, creating subtle inconsistencies across copies.
  • There is no alerting on data drift or prediction distribution shift; model degradation is discovered by business stakeholders instead of the engineering team.
  • Snowflake compute costs have no attribution because training and inference jobs run on shared warehouses without tagging or budget controls.

3.2 Impact

Operationally: Model incidents go undetected until downstream business processes produce wrong outputs. Root cause analysis is slow because training artifacts, data snapshots, and feature definitions were never versioned together.

Commercially: A data platform team that cannot demonstrate model lineage or governance will struggle to operate in regulated industries such as financial services and healthcare, or pass a technical due diligence review.


4. Requirements & Assumptions

4.1 Data & SLA

Data Volume: 10M-500M rows per month across source systems, with feature tables up to 50GB.

Freshness / SLA: Batch inference runs daily, typically T+4 hours from source close. Feature store refresh is hourly for high-velocity features and daily for aggregated features.

Environments: Dev, UAT, and Prod with separate Snowflake databases per environment and a shared RBAC role hierarchy.

Training Frequency: Scheduled retraining weekly, or triggered by a drift alert. Ad hoc retraining can be run on demand through Snowflake Tasks or orchestration tools such as Airflow or dbt.

SLA / SLO Definition: Pipelines are expected to maintain a success rate of at least 99.5%, with data freshness within 2x the scheduled interval. Inference should complete within T+4 hours, and drift detection must occur within one cycle delay.

Error Budget: A maximum failure rate of 0.5% per month is allowed. If this threshold is exceeded, it triggers a pipeline freeze followed by root cause analysis.

4.2 Security & Compliance

Data Sensitivity: PII such as customer identifiers and behavioral data. PHI or PCI may apply depending on the client vertical.

Access Model: Snowflake RBAC with functional roles such as ANALYST, ML_ENGINEER, ML_OPS, and PLATFORM_ADMIN. SSO is handled through Okta or Azure AD, with service accounts for pipeline automation.

Regulatory: GDPR right-to-erasure must be handled at the feature store layer. Models trained on PII must be registered with the data classification of their training data.

4.3 Tooling & Constraints

Ingestion / Orchestration: Snowpipe for event-driven ingestion, Fivetran or dbt for ELT, and Apache Airflow or Snowflake Tasks for ML pipeline orchestration.

ML Framework: Snowpark ML for classical ML such as XGBoost, LightGBM, and scikit-learn. External compute such as SageMaker or Vertex AI is used for deep learning or GPU-required workloads.

Constraints: No sub-100ms latency SLAs. Snowflake query latency precludes real-time serving in the request path. Feature computation jobs must carry explicit warehouse size limits and statement timeouts.


5. Recommended Architecture

5.1 High-Level Flow

  • Raw data arrives via Snowpipe or Fivetran into the Bronze layer. This layer is append-only, audit-timestamped, and has no transforms applied.
  • Scheduled Silver transform jobs clean, type, deduplicate, and schema-validate records. Failures route to a dead-letter table instead of becoming silent nulls.
  • Feature engineering jobs compute point-in-time correct aggregates and write versioned snapshots to the Gold Feature Store using Snowflake Dynamic Tables or scheduled Tasks.
  • The model training job locks a feature snapshot ID, performs temporal train/test split, trains via Snowpark ML, logs all artifacts and metrics, and writes to the Model Registry as an experiment.
  • The model evaluation gate checks AUC delta, calibration, and behavioral slice performance. Manual approval is required for Champion promotion.
  • Models are deployed using a staged approach: Shadow, Canary, and Full Production.
  • The batch inference job runs daily and writes predictions with model_version and scored_at to the Gold Inference table. Downstream consumers read from this table, not from the model directly.
  • Monitoring jobs run after each inference cycle to check input feature drift, prediction distribution shift, and delayed label performance.
  • Inference is triggered only after successful feature snapshot creation. Partial failures result in rollback or re-run so downstream consumers never receive incomplete data.

5.1.1 Failure Modes & Recovery

  • Bronze Ingestion Failure: Detect Snowpipe lag above the SLA threshold. Recover by replaying from the stage using file metadata. Guarantee at-least-once ingestion with downstream deduplication.
  • Silver Transform Failure: Detect contract validation failures or job errors. Recover by replaying from the last watermark. Use idempotent MERGE to avoid duplication.
  • Feature Store Failure: Detect Dynamic Table refresh lag above the SLA. Recover with manual REFRESH or backfill from Silver. The risk is feature staleness propagating to inference.
  • Training Failure: Detect missing feature snapshots or timeouts. Recover by restarting with the same snapshot_id to preserve reproducibility.
  • Inference Failure: Detect missing partitions in the predictions table. Recover by re-running inference for the affected batch_id only.
  • Monitoring Failure: Detect missing drift metrics and backfill monitoring queries.

5.2 Architecture Diagram

Snowflake AI/ML Reference Architecture Diagram

5.3 Options

Option A - Fully Native Snowflake ML: Snowpark ML for training and Snowflake Model Registry for serving. Best when the team is Snowflake-native, use cases are classical ML, there is no GPU requirement, and the organization strongly prefers single-platform governance.

Option B - Hybrid (Snowflake Data + External ML): Snowflake acts as the data and feature platform, while SageMaker or Vertex AI handles training and serving. Best when deep learning, GPU training, or existing external MLOps investments are required.

Selection Guide: Choose Option A when Snowflake data gravity is high and model complexity is classical ML. Choose Option B when model complexity exceeds what Snowpark ML supports, or when P99 inference latency below 200ms is required.

When NOT to Use Snowflake ML: Snowflake ML is not suitable for low-latency real-time inference below 200ms, GPU-intensive deep learning workloads, or large-scale training datasets above 100GB. It also may not meet requirements where feature latency must be under one minute.

Recommended Approach: In those scenarios, adopt a hybrid architecture that uses external serving layers for model inference and heavy training workloads while using Snowflake for data processing and feature management.


6. Implementation

6.1 Setup

Snowflake Objects

  • Databases: RAW_DB for Bronze, ANALYTICS_DB for Silver and Gold, and ML_DB for Feature Store, Model Registry, Inference, and Monitoring.
  • Schemas: ML_DB.FEATURE_STORE, ML_DB.MODEL_REGISTRY, ML_DB.INFERENCE, ML_DB.MONITORING, and ML_DB.PIPELINE_OBS.
  • Warehouses: INGEST_WH (XS, auto-suspend 2 minutes), TRANSFORM_WH (S, auto-suspend 2 minutes), ML_TRAIN_WH (M/L, immediate auto-suspend), and INFERENCE_WH (S, auto-suspend 2 minutes).
  • Roles: RAW_READER, TRANSFORM_ENGINEER, ML_ENGINEER, ML_OPS, and PLATFORM_ADMIN using a least-privilege hierarchy.

External Objects

  • S3, ADLS, or GCS stage for Snowpipe landing, with SQS event notification for S3.
  • Snowflake Secrets for external API credentials, with no credentials stored in pipeline code.
  • IAM role with scoped S3 read-only permissions attached to the Snowflake storage integration.
  • Airflow as the primary orchestrator for cross-system workflows, Snowflake Tasks for internal execution, and dbt for transformations.

6.2 Core Build Steps

  • Create database, schema, warehouse, and role hierarchy with grant scripts. Version-control all DDL in Git.
  • Configure Snowpipe with AUTO_INGEST=TRUE on the S3 stage. Validate with SYSTEM$PIPE_STATUS before enabling production traffic.
  • Implement Silver transform as dbt models or Snowflake Tasks. Enforce idempotency through MERGE on natural key, not INSERT. Add schema validation CTE as the first step of every transform.
  • Build the Feature Store using Snowflake Dynamic Tables for declarative, versioned feature computation. Define refresh schedules per feature latency requirement.
  • Write the Snowpark ML training job: lock the feature snapshot, enforce temporal split, train the model, log metrics and artifact to the Model Registry as an experiment.
  • Training Dataset Versioning: Each training job logs a dataset_id composed of feature_snapshot_id and label snapshot, enabling full reproducibility.
  • Configure Model Registry promotion workflow: Experiment, Staging, Champion Candidate, and Production.
  • Deploy the batch inference Task on a daily schedule. Write to ML_DB.INFERENCE.PREDICTIONS with a model_version column.
  • Implement monitoring Tasks for PSI-based drift checks, prediction distribution checks, and delayed label AUC computation. Write results to ML_DB.MONITORING.METRICS.
  • Concurrency Control: Allow only one instance of each pipeline job, enforced through a PIPELINE_STATE table with a job lock flag.

6.3 Configuration Defaults

  • Watermark Strategy: Timestamp-based watermark on the _loaded_at column, with state tracked in a PIPELINE_STATE table.
  • Dedup Keys: Natural business key, such as customer_id + event_date. Use ROW_NUMBER() OVER PARTITION BY in the Silver transform, not at query time.
  • Load Frequency: Bronze is event-driven, Silver runs hourly, Feature Store runs hourly or daily depending on latency, training runs weekly or on drift, and inference runs daily.
  • Error Handling: TRY/CATCH in stored procedures, failures logged to PIPELINE_ERRORS, dead-letter pattern for Bronze schema validation failures, and a maximum of three retries with exponential backoff.
  • Late Arriving Data Handling: Bronze ingests late data without rejection. Silver reprocesses using a 24-48 hour sliding window. Feature Store updates only impacted snapshots.
  • Backfill Strategy: Backfills run using parameterized batch_id runs in an isolated warehouse and are tagged separately for audit and cost tracking.
  • Schema Evolution Policy: Additive nullable columns are accepted automatically. Breaking changes require a contract version bump and validation in the Silver layer.
  • Feature Store Guarantees: Feature snapshots are immutable and versioned. Backfills generate new snapshots rather than overwriting existing data.

7. Validation & Testing

7.1 Data Validation

Row Count Checks: Compare Silver count against Bronze count for the same partition. Alert if the delta is greater than 1%.

Duplicate Checks: Group by business key and expect zero duplicates. Alert if any duplicate rows are found.

Freshness Checks: Check the number of hours since the latest _loaded_at timestamp. Alert if freshness exceeds the SLA threshold.

Schema Drift Detection: Compare column count and type against the registered schema baseline. Additions or type changes route to a schema_changes log table and trigger an alert before the transform proceeds.

Testing Strategy: Unit tests validate SQL logic in dbt, integration tests validate full pipeline execution in UAT, and regression tests compare model performance with previous versions. Promotion is gated until all tests pass.

7.2 Reconciliation

Run a daily reconciliation job comparing Silver record counts against source system record counts for the prior day's cohort. Acceptable tolerance is +/-0.5% for eventually consistent source systems. Any delta outside tolerance triggers a manual investigation workflow.

For the Feature Store, validate that point-in-time joins produce no future-data leakage by asserting that all feature snapshot_dates used in a training example are less than or equal to the event_date of that example.


8. Security & Access

Required Snowflake Permissions: USAGE on warehouse and database, SELECT on source schemas, INSERT/MERGE on target schemas, and CREATE MODEL on ML_DB.MODEL_REGISTRY. Each service account holds only the permissions required for its job.

Secret Management: All credentials are stored in Snowflake Secrets or a preferred vault such as HashiCorp Vault or AWS Secrets Manager. There should be zero plaintext credentials in pipeline code or Git history.

Separation of Duties: ML_ENGINEER can create and read experiments. ML_OPS can promote to Staging and Champion Candidate. PLATFORM_ADMIN can promote to Production. No single role can complete the full promotion workflow without approval from another role.

Auditability: All pipeline jobs are tagged with QUERY_TAG. ACCESS_HISTORY is queried weekly to audit which roles accessed which data. Model Registry maintains full lineage across training data snapshot ID, feature version, model version, and prediction batch.

PII Handling: PII columns are masked in the Silver layer for non-privileged roles using Dynamic Data Masking policies. Raw PII is retained in Bronze with row-level access controls.

Lineage Tracking: Each prediction record captures model_version, feature_snapshot_id, and source_batch_id. A lineage table maps the full flow from source to feature to model to prediction.

Disaster Recovery: Cross-region replication is enabled at the Snowflake account level, with RPO below 1 hour and RTO below 4 hours. Critical assets, including Feature Store, Model Registry, and Predictions tables, are continuously replicated.

Failover Plan: In case of failure, operations switch to the secondary region and pipelines resume using the last recorded watermark state.


9. Performance & Cost

9.1 Performance Considerations

Warehouse Sizing Guidance: Silver transforms use an S warehouse, scaling to M if processing more than 500M rows per day. Feature computation uses M. Model training uses L with STATEMENT_TIMEOUT_IN_SECONDS = 7200. Inference uses S. Start one size smaller and scale up based on query profile.

Query Optimization: Cluster Bronze and Silver tables on _loaded_at for partition pruning. Cluster Feature Store on entity_id and snapshot_date. Use RESULT_CACHE for recurring validation queries. Avoid SELECT * in feature computation.

Training at Scale: Snowpark ML can handle datasets up to roughly 100GB in-warehouse. For larger datasets, use Snowflake external functions to trigger SageMaker training with Snowflake data staged to S3.

9.2 Cost Drivers

  • Compute: ML training warehouse is the highest per-credit cost. Enforce statement timeouts on all training warehouses.
  • Storage: Feature Store snapshots accumulate over time. Drop feature snapshots older than 90 days unless retained for regulatory audit. Retain Bronze tables for 2 years where required.
  • Data Transfer: Egress costs apply if external ML platforms pull data from Snowflake across regions. Stage data in the same cloud region as the training cluster.
  • Tool Licensing: Snowflake Cortex functions are billed per token or per call. Audit usage before enabling Cortex in production and set spend limits.

9.3 Cost Controls

  • Auto-suspend all warehouses: 2-minute idle suspension for interactive warehouses and immediate suspension for batch warehouses after task completion.
  • Use resource monitors with monthly credit limits, NOTIFY_AND_SUSPEND at 80%, and SUSPEND at 100%.
  • Set QUERY_TAG at the start of every pipeline job and produce weekly cost attribution reports by job tag.
  • Process feature computation and inference in daily batches instead of per-row triggers.
  • Tag each pipeline with a cost center and report monthly cost by domain, including feature store, training, and inference.
  • Apply cost guardrails so training jobs have enforced credit limits and pre-termination alerts.

10. Operations & Monitoring

10.1 What to Monitor

  • Pipeline success/failure rate: Every Task and stored procedure logs a completion record to PIPELINE_OBS.JOB_RUNS with status, duration, and row counts in/out.
  • Latency / freshness: Monitor hours since the last successful Silver refresh, Feature Store snapshot, and Inference run.
  • Volume anomalies: Compare Bronze row count against a 14-day rolling average. Alert if daily volume drops more than 20% or spikes more than 50%.
  • Model drift: Track Population Stability Index on each input feature against the training baseline. PSI above 0.1 is a warning; PSI above 0.2 is an alert and triggers retraining evaluation.
  • Prediction distribution shift: Track daily mean and standard deviation of prediction scores. Shifts greater than 2 standard deviations from the 30-day baseline trigger alerts.
  • Cost spikes: Forward Resource Monitor notifications to PagerDuty or Slack. Flag ad hoc queries exceeding credit thresholds for review.

10.2 Alerting

All alerts route to a centralized Snowflake Alert object or Airflow SLA miss callback and forward to Slack or PagerDuty based on severity:

  • P1 immediate: Pipeline completely failed and no predictions were produced for the daily batch.
  • P2 within 2 hours: Model drift alert, data volume anomaly above threshold, or compute budget exceeded.
  • P3 next business day: Schema drift detected, reconciliation delta outside tolerance, or training job duration more than 2x baseline.

10.3 Runbook (Top Issues)

Issue Quick Fix
Snowpipe backlog growing Check SYSTEM$PIPE_STATUS. If paused, resume with ALTER PIPE. Check S3 SQS queue for event delivery errors and validate IAM permissions.
Silver transform row count mismatch Query PIPELINE_ERRORS for failed batches. Inspect the dead-letter table and replay from Bronze using batch_id watermark.
Training job times out Check QUERY_HISTORY for top-consuming queries. Resize ML_TRAIN_WH for the run. If persistent, profile feature computation for joins or missing clustering keys.
Model drift alert triggered Compare current PSI report against the baseline. Inspect source data for upstream changes. If data is correct, trigger ad hoc retraining and do not promote without shadow validation.
Inference table not updated Check Task execution logs. If the Task succeeded but the table is stale, verify the model version is still Active and re-run the inference Task.

11. Common Pitfalls

  • Point-in-time leakage in training data: Using current feature values instead of historical snapshots produces inflated evaluation metrics and models that fail in production.
  • INSERT instead of MERGE in Silver transforms: Duplicate records accumulate silently. Every load job must be idempotent.
  • Promoting models without shadow validation: Shadow mode is not optional. Use at least a 48-hour shadow validation period.
  • No STATEMENT_TIMEOUT on training warehouses: A runaway feature join or cross-join can consume thousands of credits. Set STATEMENT_TIMEOUT_IN_SECONDS = 7200 on ML_TRAIN_WH.
  • Treating Snowflake as a real-time inference engine: Snowflake query P99 is measured in seconds. Use an external serving layer for sub-200ms inference.
  • Coalescing nulls to zero in feature computation: A null in a revenue column is not zero revenue. Encode that distinction explicitly.

12. Variations / Use Cases

  • Customer Churn Prediction: Label events are cancellations. Feature Store aggregates login frequency, support ticket count, and usage metrics. Churn probability is scored daily and consumed by CRM for next-day outreach.
  • Real-Time Fraud Scoring (Hybrid): Snowflake acts as feature store and model registry. Predictions are pre-computed at transaction close. Sub-100ms in-flight scoring requires Redis feature cache and SageMaker endpoint external to Snowflake.
  • Demand Forecasting: Time-series features such as lagged demand and seasonality indicators are computed in Feature Store. Forecasts are written to Gold for supply chain consumption.
  • LLM / RAG on Snowflake Cortex: Snowflake Cortex COMPLETE supports text classification and summarization. Documents can be chunked and embedded, with similarity search through vector distance functions. This is suitable for internal document Q&A, but not for sub-1 second chat applications.

13. Next Steps

  • Run a one-hour Architecture Assessment to map the current ML pipeline against this reference architecture and identify the top three gaps.
  • Review the companion blog, "Snowflake Model Registry: Promotion Workflows and Rollback Patterns in Production", for detailed implementation of the governance layer.
  • Request a Boolean Data Engineering workshop to evaluate whether the use case fits Option A (fully native) or Option B (hybrid) and produce an implementation roadmap.
  • Book a 30-minute technical demo covering a live Snowpark ML training job with Model Registry promotion, shadow deployment, and drift monitoring configured end-to-end.

14. Appendix

  • Design Principles: Immutable data, idempotent pipelines, point-in-time feature correctness, fail-fast validation using data contracts, and end-to-end lineage from source to prediction.
  • Data Lifecycle: Bronze (raw, append-only), Silver (cleaned and validated), Gold (versioned features), followed by Inference and Monitoring.
  • Governance: RBAC-based access control, PII masking with GDPR compliance, full lineage tracking, and enabled audit logging.
  • SLAs: Pipeline success of at least 99.5%, data freshness within defined SLA window, and inference completion within T+4 hours.

Conclusion

This reference architecture provides a production-ready framework for building and operating AI/ML workloads on Snowflake by combining Medallion data architecture with disciplined MLOps practices.

It ensures data integrity and reproducibility through immutable data layers, point-in-time feature engineering, and strict data contracts. It also delivers operational reliability with idempotent pipelines, defined failure handling, and end-to-end monitoring for data quality, drift, and model performance.

The architecture embeds governance and compliance by design, including RBAC, lineage tracking, and auditability, making it suitable for enterprise and regulated environments.

It is optimized for batch-oriented, tabular ML use cases within Snowflake, while clearly defining when a hybrid approach is required for real-time or GPU-intensive workloads.

In summary, this is a practical, deployable blueprint that enables organizations to build scalable, governed, and reliable ML platforms on Snowflake without compromising on enterprise standards.

Jagadishwar Pannala

Associate Data Engineer

Boolean Data Systems




Jagadishwar Pannala is a Data Engineer at Boolean Data Systems, specializing in building scalable data pipelines and modern cloud data platforms. He focuses on data migration and cloud-based data engineering, with expertise in Snowflake, cloud data architectures, and ETL/ELT pipeline development to support reliable and efficient enterprise analytics.

About Boolean Data
Systems

Boolean Data Systems is a Snowflake Premier Partner that implements solutions on cloud platforms. We help enterprises make better business decisions with data and solve real-world business analytics and data challenges.

Global
Head Quarters

USA - Atlanta
3970 Old Milton Parkway,
Suite #200, Alpharetta, GA 30005
Ph. : 770-410-7770
Fax : 855-414-2865

Boolean Data is SOC 2 Type 1 compliant
All rights reserved – Boolean Data Systems