Scaling AI workloads with Ray distributed infrastructure

Ray provides a unified framework for scaling Python and AI applications from local machines to large clusters using core abstractions like Tasks and Actors. Ray Serve enables efficient LLM deployment through multi-node parallelism and multi-LoRA serving on shared…

Scaling AI workloads with Ray distributed infrastructure

Ray provides a unified framework to scale Python and AI applications from a single laptop to a large cluster. The system consists of a core distributed runtime and a set of AI Libraries designed for various workloads, including Scalable Datasets (Data), Distributed Training (Train), Scalable Hyperparameter Tuning (Tune), Scalable Reinforcement Learning (RLlib), and Scalable and Programmable Serving (Serve). The architecture relies on core abstractions: stateless functions executed in the cluster known as Tasks, stateful worker processes known as Actors, and immutable values accessible across the cluster known as Objects. This design allows for the scaling of code from a local machine to a cluster or Kubernetes environment without requiring new infrastructure. I find that the ability to scale the same code from a laptop to a massive cluster is a clear advantage. The framework runs on any machine, cluster, cloud provider, or Kubernetes. You can define a simple hello world application, run it locally, and query it over HTTP. Users can even serve a pre-trained Hugging Face Transformers model, such as a sentiment analysis model that takes a text string as input and returns if the text was POSITIVE or NEGATIVE.

LLM deployment and optimization

Ray Serve LLM deploys large language models in production using distributed, multi-node primitives. It provides an OpenAI-compatible API for chat, completions, and embeddings. To handle intensive compute requirements, the system uses parallelism strategies like tensor, pipeline, expert, and data parallel attention. It also scales the prefill and decode phases independently through prefill-decode disaggregation. Custom request routing includes prefix-aware routing to achieve higher cache hit rates. For those of you already familiar with standard inference, the multi-LoRA serving on a shared base model is a significant efficiency gain. The system is engine-agnostic and supports backends such as vLLM and SGLang. It manages resource loads by adjusting the number of replicas for a model and uses request batching to take advantage of efficient vectorized operations. This approach allows for dynamic scaling to handle request loads while saving cost. Many large language model applications combine prompt preprocessing, vector database lookups, LLM API calls, and response validation. Ray Serve handles these steps as a single module. It also supports streaming responses for chatbot-like applications.

Feature Specification
API Compatibility OpenAI-compatible
Parallelism Tensor, Pipeline, Expert, Data
Backends vLLM, SGLang
Resource Management Fractional GPUs, Autoscaling

Programmable composition and ecosystem

Ray Serve avoids the limitations found in many solutions that focus on tensor in, tensor out serving or require defining static graphs in YAML. Instead, it supports multi-model composition through a programmable API where calls to different models look like function calls. Because Ray Serve allows for arbitrary Python code, developers can combine multiple machine learning models, business logic, and expressive HTTP handling using the FastAPI integration to build end-to-end distributed serving applications in a single framework easily. This capability is vital for image processing applications that require multi-stage pipelines consisting of preprocessing, segmentation, and filtering. The framework-agnostic nature allows use with PyTorch, TensorFlow, Keras, Scikit-Learn, and XGBoost. It also integrates with model optimizers like ONNX and TVM, model monitoring systems like Seldon Alibi and Arize, and model registries like MLFlow and Weights and Biases. Users can also connect it to data app UIs like Gradio and Streamlit or Web API frameworks like gRPC. Ray Serve is not tied to any specific machine learning library, but rather provides a general-purpose scalable serving layer. Because it supports fractional GPUs, you can share resources to serve many machine learning models at low cost. You can test models and entire deployment graphs on a local machine before using the Kubernetes Operator to deploy to a cluster. I find Ray Serve insufficient for users needing to manage model lifecycles or visualize performance, as it is a specialized component rather than a full-fledged ML platform. How can developers reconcile this lack of built-in lifecycle management with the need for rapid production deployment?

airtrain.ai
airtrain.ai

The airtrain.ai newsroom covers AI research, models and the tools built on them.

More on this topic

Stay ahead of AI

Get the week's most important AI stories delivered to your inbox every Monday.

No spam. Unsubscribe anytime.

More Stories