This article explains how to deploy and scale machine learning inference in Snowflake using Model Registry and Snowpark Container Services, eliminating the need for external container management and enabling GPU-accelerated inference directly within Snowflake.
As machine learning models grow in complexity—particularly those involving deep learning and GPU-based inference—organizations are looking for ways to operationalize these models without the burden of managing container infrastructure. Traditionally, deploying such models required building Docker containers, pushing them to registries, and orchestrating them in external environments—introducing friction, delays, and infrastructure overhead. With the advent of Model Serving in Snowflake via Snowpark Container Services (SPCS), teams can now deploy and scale externally trained models without ever writing Dockerfiles or managing containers manually. Snowflake handles the underlying container orchestration, letting data scientists focus solely on their models and inference logic.
In this blog, we demonstrate how to deploy and scale machine learning inference in Snowflake using externally trained ML models. We will explore how Snowflake Model Registry and Model Serving enable easy deployment of custom inference solutions on Snowpark Container Services (SPCS), abstracting away the complexity of container management.
With Model Serving in SPCS, we can now deploy use cases with models requiring GPU compute or high inferencing parallelism directly within Snowflake without having to worry about the underlying infrastructure. Some of such use cases are listed below:
Inference is a big part of any Data Science / Machine Learning workflow.
Snowflake now offers two powerful options for running ML inference: traditional Warehouse-based inferencing and the new Model Serving via SPCS. Let's explore the scenarios where to use each approach based on model complexity, performance needs, and integration requirements:
Model Serving via SPCS enables seamless model deployment, eliminating the need for external tools like VSCode or PyCharm for Python-stored procedures. Developers can build, test, and deploy models directly in Snowflake without manually building and pushing Docker containers, reducing development cycles and operational overhead.
Other key benefits include:
SPCS also supports both batch and real-time inferencing, ensuring efficient scaling and minimal inference latency. By integrating model deployment within Snowflake, machine learning workloads become more efficient, streamlined, and scalable.
For customers, this results in faster and more reliable access to model-driven insights, as inferencing is directly integrated with their data in Snowflake. There is no need to move data between platforms, reducing security risks and operational overhead. Additionally, this simplifies compliance and governance, as all processing remains within Snowflake's environment.
From a competitive perspective, SPCS provides an advantage over traditional cloud-based model deployment solutions that require additional infrastructure and complex integrations. By consolidating model deployment and inferencing within Snowflake, organizations can reduce costs and complexity while improving the performance and accessibility of AI-driven applications.
Navigate to the Models tab in the snowsight UI:
Inference Services tab in the snowsight UI:
Below shows the detailed view of a selected model from the registry.
Next, let's check out the details of the inference service associated with a model version.
Finally, let's take a look at the files associated with a model version.
Model Registry UI is a friendly and one stop shop for all things related to Model management and associated metadata.
By combining Snowpark Container Services and Model Registry, Snowflake ML enables seamless execution of GPU-based inference for ML models, regardless of where they were built. This approach:
Leverage Snowflake's capabilities to unlock the full potential of your machine learning workflows.
Have questions or want to explore how this solution can work for your organization?
Feel free to reach out to us at appsupport@kipi.ai — we're here to help!
Deploy a Hugging Face sentence transformer for GPU-powered inference using Snowflake Notebook:
!pip install sentence_transformers snowflake-ml-python==1.7.5from snowflake.ml.registry import registry
from sentence_transformers import SentenceTransformer
from snowflake.snowpark.context import get_active_sessionmodel_name = "<model_name>"
image_repo_name = "<snowflake_image_repository_name>"
cp_name = "<compute_pool_name>"
num_spcs_nodes = "<number_of_nodes>"
spcs_instance_family = "<compute_pool_instance_family>"
service_name = "<service_name>"
current_database = session.get_current_database().replace('"', "")
current_schema = session.get_current_schema().replace('"', "")
extended_image_repo_name = f"{current_database}.{current_schema}.{image_repo_name}"
extended_service_name = f'{current_database}.{current_schema}.{service_name}'session = get_active_session()
reg = registry.Registry(session=session)embed_model = SentenceTransformer('sentence-transformers/all-MiniLM-L6-v2', token=False)input_data = [
"This is the first sentence.",
"Here's another sentence for testing.",
"The quick brown fox jumps over the lazy dog.",
"I love coding and programming.",
"Machine learning is an exciting field.",
"Python is a popular programming language.",
"I enjoy working with data.",
"Deep learning models are powerful.",
"Natural language processing is fascinating.",
"I want to improve my NLP skills.",
]
embeddings = embed_model.encode(input_data)
print(embeddings)_ = reg.log_model(
embed_model,
model_name=model_name,
sample_input_data=input_data,
pip_requirements=["sentence-transformers", "torch", "transformers"])Required parameters are:# Get the logged model
m = reg.get_model(model_name)
version_df = m.show_versions()
version_df.head(100)# Select the model based on version
last_version_name = version_df['name'].iloc[-1]
pip_model = m.version(last_version_name)
pip_modelsession.sql(f"show compute pools").show()
session.sql(f"alter compute pool if exists {cp_name} stop all").collect()
session.sql(f"drop compute pool if exists {cp_name}").collect()
session.sql(f"create compute pool {cp_name} min_nodes={num_spcs_nodes} max_nodes={num_spcs_nodes} instance_family={spcs_instance_family} auto_resume=True auto_suspend_secs=300").collect()
session.sql(f"describe compute pool {cp_name}").show()session.sql(f"create or replace image repository {extended_image_repo_name}").collect()pip_model.create_service(
service_name=extended_service_name,
service_compute_pool=cp_name,
image_repo=extended_image_repo_name,
gpu_requests="1",
max_instances=int(num_spcs_nodes))Required parameters are:pip_model.list_services()session.sql(f"SELECT VALUE:status::VARCHAR as SERVICESTATUS, VALUE:message::VARCHAR as SERVICEMESSAGE FROM TABLE(FLATTEN(input => parse_json(system$get_service_status('{service_name}')), outer => true)) f").show(100)session.sql(f"SELECT {KIPI_EMBEDDING_SERVICE}!encode('This is a test sentence.')")# Run on SPCS
pip_model.run(input_data, function_name="encode", service_name=service_name)Required parameters: