At Snowflake, we offer an end-to-end ML platform that helps thousands of customers productionize their ML workflows. Customers like Coinbase, Zscaler and Cloudbeds have reduced time to production to a fraction of what it was. When we started building our ML capabilities, we wanted to build a modern, integrated platform that delivered faster speed at lower cost without the legacy tech debt weighing down other providers. In this post, we share why we chose Ray as our foundation, how we built custom optimizations into our managed Ray service and how those enhancements drive faster performance and, therefore, lower costs for our customers.
Why Snowflake chose Ray for Snowflake ML
Most distributed computing frameworks were built for data processing: split a large data set and run the same function on every piece in parallel before combining the results. ML training doesn’t work that way. There are several different kinds of work happening at once: preparing data, updating the model state and saving progress. Each needs different resources and must pass data to the others continuously, not just once at the end.
Ray is an open source framework that was built for distributing modern ML workloads that have parallel steps with different resource needs and high inter-node communication. Instead of organizing a job as a fixed sequence of steps, it organizes it as independent pieces running concurrently. Short-lived pieces, like saving a checkpoint, run as tasks. Long-running pieces, like the trainer and data loader, run as actors, which keep their state in memory for the life of the job. Each piece gets exactly the resources it needs: a GPU for the trainer, CPU cores for the data loader, and I/O bandwidth and storage for the checkpointer.
That structure is what keeps training efficient. The data loader prepares the next batch while the trainer is still working on the current one. When both actors run on the same machine, the loader sends the batch through shared memory, avoiding any serialization overhead. That way, the trainer never waits, so the GPU you’re paying for stays busy.
The same idea scales when training extends beyond a single node. In data-parallel training, each GPU holds a copy of the model and trains on its own shard of the data. After each batch, all the GPUs combine their gradients in an AllReduce step so every copy applies the same update and all the model replicas stay in sync. Because Ray’s trainers are persistent actors that keep running between batches, the model weights and gradients stay in GPU memory the whole time. The exchange itself runs over NVIDIA's NCCL library, which moves gradients directly between GPUs without passing them through Python or a central driver process. At scale, training is limited by the network, not by Ray. That's what success looks like: Ray gets out of the way, and adding GPUs makes training faster instead of adding overhead.
Data parallelism — partition a data set and apply the same function — is straightforward in Ray. But Ray also expresses the concurrent, stateful, heterogeneous coordination that ML requires: Data loading, training and checkpointing compose as actors with explicit dependencies and direct communication, not as stages in a rigid DAG. Teams get faster iteration and lower compute costs because they stop working around a paradigm designed for ETL and start building on one designed for ML.
How we made Ray even better on Snowflake
While Ray is our foundation, the Ray experience in Snowflake ML is significantly different from the open source baseline. We have invested in server-side optimizations for data loading, stage sharding, disk caching and memory optimization to enable better performance and cost for our end users.
Efficient data loading
In distributed ML training, the bottleneck is often not the training itself. Instead, it's how fast data can reach the workers. When you run your training workloads on Snowflake ML using Snowpark Container Services (SPCS), we provide a set of enhancements that extend Ray’s data loading capabilities and maximize the data throughput from Snowflake to your compute.
If your data is hosted on a Snowflake stage, listing them is implemented as a SQL query rather than a filesystem call, making it more time-consuming than the equivalent operation on standard object storage. OSS Ray’s data loading pipeline has a planning phase that lists and samples files for schema inference, and then a separate execution phase that reads the data. This works well for standard filesystems where listing and downloading are cheap, stateless operations, but not for a stage. Snowflake ML addresses this with custom Datasources that collapse these phases into a single list operation Because Ray workers in SPCS are persistent and co-located within the Snowflake network perimeter (unlike the ephemeral, any-node workers that OSS Ray assumes), each worker reliably handles both the planning and data phases for its assigned files. This makes a thread-local file cache effective: Files read during planning are already resident for the execution phase. While these optimizations decrease the load time for any type of data, they are most effective for workloads with a large number of small files, such as computer vision and document processing, where per-file overhead rather than bytes transferred defines the load time.
Unstructured training data for ML workloads may reside in object storage outside Snowflake. For these situations, Snowflake ML’s stage file system improves upon OSS Ray’s data transfer by keeping a pooled HTTP connection per worker, so reads reuse TCP connections instead of renegotiating TLS per file.
Iceberg reads optimization
For Apache Iceberg™ tables, Snowflake ML's SFIcebergDatasource gives SPCS workers a more direct read path to training data. The Snowflake Horizon Catalog holds the Iceberg metadata, and workers use it to locate and read the underlying Parquet files without routing the load through a SQL scan. The standard SQL path requires a warehouse to materialize the full data set before it reaches the workers; the catalog-driven path reads from storage directly. On internal tests with tables from 20 million to 1 billion rows using two to 20 nodes, this read path improved read times with a median speed increase of 2.2x while eliminating warehouse compute cost. Even when the warehouse could serve the query from its result cache, the direct path was still faster in 19 of 20 configurations.

Stage sharding
The optimizations above improve data loading when files are large enough that data transfer dominates per-request overhead. Unstructured ML data sets often look different: a computer vision or audio data set might store each training sample as a separate file, leaving a stage with hundreds of thousands of small objects. At that scale, per-file overhead — connection setup, request roundtrip, metadata handling — becomes the bottleneck, not the bytes being transferred.
Stage sharding addresses this offline, before training begins. Snowflake ML packs the small files into a small number of large Arrow IPC shards stored back on the stage. During training, Ray assigns one shard per task. Each worker reads a single large sequential object rather than thousands of small random ones, reducing the number of storage requests the job makes by orders of magnitude. Arrow IPC is a columnar, zero-copy format: Workers read directly into memory without a deserialization step, so data arrives at the trainer with no additional CPU overhead.
Disk caching
No matter where your data resides, you should only transfer it once whenever possible. In Snowflake ML, disk caching is enabled by default and requires no configuration to get started. When you use any of the Snowflake ML data sources, subsequent reads of the same data are read from disk rather than over the network, which can be 10-14x faster than fetching data from a stage. This is useful for multiepoch training where the same data is re-used for every epoch and for training multiple models on the same data set, such as in hyperparameter optimization jobs.
Memory optimization
The data loading improvements above primarily benefit deep learning workloads. For tabular ML where XGBoost remains the most common model type, the bottleneck is memory, not coordination between tasks. Snowflake ML addresses this directly by introducing a distributed trainer that automatically downcasts columns to less precision, making the training matrix held by each worker ~2x smaller than it would be on the raw input without changing the accuracy. It bypasses pandas entirely to free up compute, uses only quantile values for calculating the DMatrix (further reducing peak memory) and evicts idle data loading tasks once all the data is in memory.
Performance and cost benefits on Snowflake
The data movement and memory optimizations that we just discussed aren’t only theoretical. We’ve validated them on two TPCx-AI benchmarks covering XGBoost and PyTorch and saw results of up to 2.5x speedup for distributed PyTorch training and 1.8x for distributed XGBoost compared to Apache Spark™ on Databricks. In production, our customers directly see performance and cost benefits.
Attentive is a marketing and customer engagement platform that trained a recommendation model on 3.2 billion rows in two and a half hours instead of eight, with infrastructure costs down 30%.

Snowflake ML gives you managed Ray with no learning curve
While Ray is powerful, self-hosting and managing distributed Ray clusters in production introduces operational, security and financial overhead. Like many distributed systems, managing Ray in production is its own project. The head node is a single point of failure that can take down the whole cluster with it. And, when a job finishes or fails, the cluster doesn’t clean itself up, leaving resources billable but idle. And, in open source Ray, any process that can reach the head node can submit jobs, and the dashboard is unauthenticated by default.

Snowflake ML runs on top of SPCS as the underlying compute infrastructure, which is built on a fully managed and enterprise-ready version of Ray. Since Ray runs inside the Snowflake perimeter, the existing network policies and role-based access control (RBAC) that protect and govern your data apply to Ray as well; there is no separate Ray security configuration to manage. And with SPCS managing the Ray cluster’s lifecycle, the cluster is automatically torn down when a job completes, leaving no idle resources in your account.
Handling the infrastructure is only half the barrier to putting Ray into production.

Even when infrastructure is fully managed, native Ray forces data science teams to spend valuable time learning a new programming model and making complex performance-tuning tradeoffs instead of focusing on building ML models. For complex use cases, a baseline level of understanding of Ray is insufficient to maximize performance.
Snowflake ML provides a set of higher-level APIs that allow teams to write the same Python they already know while running it on a fully managed Ray cluster.
- Distributed trainers for XGBoost and LightGBM use Ray behind the scenes while users have a familiar .fit() interface that operates on dataframes.
- The ManyModelTrainer allows users to specify a partition column and a training function per partition. Ray distributes training across these partitions without the user ever seeing or managing the cluster.
- For moving data between Snowflake tables, stages, and data sets and SPCS compute, data scientists can use the ShardedDataConnector class, which distributes data loading tasks across workers.
- For hyperparameter optimization, Snowflake spreads training runs across a Ray cluster.
- ML Jobs allow users to submit any Python training script, and Snowflake handles the provisioning, execution and teardown of the Ray cluster. This allows teams to use familiar packages like PyTorch in a distributed environment with minimal code changes.
With these capabilities, Zscaler compressed multiday engineering tasks to a few hours. Teams can scale from a single node to a distributed cluster with no management overhead and minimal code changes.
Many teams already run Spark for distributed data processing, so it's worth addressing directly why Spark doesn't carry the ML training workload. Spark is excellent at what it was designed for, but the same qualities that make it fast for data pipelines make it a poor fit for training.
Spark: A tool for a different job
Apache Spark is built around a pattern common in data engineering: read data from storage, apply the same function to every partition in parallel and write the results back out. A job compiles into a sequence of stages, and all tasks in a stage must finish before the next stage begins. Within a stage, workers are isolated and never communicate with one another. That design is why Spark is fast for ingestion and transformation, where each partition can be processed independently. ML training breaks that assumption, because the workers have to communicate with each other throughout the job.
In data-parallel training, the gradients must be synchronized across all workers after every mini-batch. A training run that processes 100 epochs with 1,000 batches per epoch performs 100,000 gradient synchronizations. In Spark, each one is a stage boundary, and every exchange has to pass through the driver, Spark’s central coordinator. This structure costs Spark in two separate ways. First, every exchange pays the overhead of serializing gradients and routing them through the driver. Second, since each stage is a barrier, no worker can move on until every worker has finished. Faster workers sit idle waiting for stragglers, and nothing can prefetch the next batch in the meantime. In Ray’s more flexible model, the data loader keeps preparing batches while the trainers synchronize, so the GPUs stay busy.
These are not theoretical problems that Spark’s ecosystem has ignored. Spark added Barrier Execution Mode for gang-scheduled tasks, and PySpark’s TorchDistributor can launch distributed training jobs on Spark executors. But these features are revealing: They work by ceding control. TorchDistributor does not use Spark’s compute model for training. It uses Spark to allocate resources, then launches a standard PyTorch distributed process that communicates via NCCL. Spark becomes a resource manager, not a compute framework. The training itself runs outside of Spark’s execution model because Spark’s execution model cannot express it. As a result, the Spark cluster is left doing the work of a resource allocator — adding overhead and cost, but none of the compute value Spark provides for data workloads. Therefore, the right tool for ML training workloads is one whose execution model was designed for it, and that’s why we built Snowflake ML on Ray.

Conclusions
ML training needs different kinds of work running at once, state that persists across iterations and workers that communicate directly. Ray’s architecture supports all three, which makes it the right foundation for Snowflake ML. On top of the structural advantages, Snowflake handles the cluster management, speeds up data loading from Snowflake and provides familiar APIs, so teams get Ray's performance without having to become distributed-systems experts.
For teams considering moving to a distributed training architecture, Ray’s architecture removes the ceiling of operating on a single node and allows larger data sets, larger models and faster experiments. And running Ray on Snowflake, through Snowflake ML, reduces the operational overhead of cluster management, improves data transfer speeds onto the cluster and lowers the distributed-systems expertise needed to use Ray effectively.
To try Snowflake ML today, check out documentation, try a guided quickstart from Snowflake CoCo or check out our webpage for additional resources.

