Share E-Book
Scan to open this page

Scan with your phone to open this page

AuthorMax Pumperla, Edward Oakes, Richard Liaw

Get started with Ray, the open source distributed computing framework that simplifies the process of scaling compute-intensive Python workloads. With this practical book, Python programmers, data engineers, and data scientists will learn how to leverage Ray locally and spin up compute clusters. You'll be able to use Ray to structure and run machine learning programs at scale. Authors Max Pumperla, Edward Oakes, and Richard Liaw show you how to build machine learning applications with Ray. You'll understand how Ray fits into the current landscape of machine learning tools and discover how Ray continues to integrate ever more tightly with these tools. Distributed computation is hard, but by using Ray you'll find it easy to get started. • Learn how to build your first distributed applications with Ray Core • Conduct hyperparameter optimization with Ray Tune • Use the Ray RLlib library for reinforcement learning • Manage distributed training with the Ray Train library • Use Ray to perform data processing with Ray Datasets • Learn how work with Ray Clusters and serve models with Ray Serve • Build end-to-end machine learning applications with Ray AIR

AI Reading Assistant

Whole-book reading guide from stratified index samples; jump to passages in the text

AI guide
# Learning Ray: A Practical Guide to Distributed Python for Machine Learning ## 【One-Line Pitch】 A hands-on guide for Python programmers, data engineers, and data scientists who want to scale their machine learning workloads from a single laptop to distributed clusters using Ray's unified ecosystem of libraries—covering everything from core distributed computing to training, tuning, and serving models. ## 【Book Arc】 - **Opening (~0%–9%)**: Introduces Ray's three-layer architecture—the core distributed engine, high-level data science libraries (Ray Data, Train, Tune, RLlib, Serve), and the growing ecosystem of integrations. Sets up the book's promise: making distributed Python accessible for ML workloads. - **Early (~9%–28%)**: Walks through each high-level library with first code examples—RLlib for reinforcement learning with a pendulum control problem, Tune for hyperparameter optimization, and Serve for model serving with GPT-2. Establishes the "distributed by construction" design philosophy. - **Early (~28%–38%)**: Explains how Ray acts as a distributed interface over existing tools rather than replacing them—integrating TensorFlow/PyTorch for training, Hyperopt/Optuna for tuning, and Arrow/Spark/Dask for data processing. This "common interface" pattern is a recurring theme. - **Middle (~38%–53%)**: Dives into Ray Core fundamentals, starting with the Python GIL problem and why distributed computing matters. Introduces the `@ray.remote` decorator for turning Python functions into remote tasks, plus blocking vs. non-blocking calls with `ray.get` and `ray.wait`. - **Middle (~53%–end)**: Covers Ray Train for distributed model training (including gradient boosted trees and deep learning), Ray Datasets for data processing with parallel SGD examples, and advanced features like checkpoints, callbacks, and Tune integration. ## 【Key Takeaways】 - **Ray's three-layer design separates concerns** (Early): The core engine handles distributed execution, high-level libraries handle ML-specific tasks, and the ecosystem provides integrations—so you can start with libraries and drop to core only when needed. - **Distributed Python is hard, but Ray makes it approachable** (Early): By leveraging familiar Python tools and providing clean abstractions, Ray lowers the barrier to cluster computing for data scientists who don't want to become distributed systems engineers. - **The GIL is the fundamental reason you need Ray** (Middle): Python's Global Interpreter Lock limits CPU-bound parallelism to a single thread; Ray sidesteps this by distributing tasks across processes and machines rather than threads. - **One decorator changes everything** (Middle): Adding `@ray.remote` to any Python function turns it into a distributed task—the simplest possible entry point into Ray's parallelism model. - **Non-blocking execution matters for real workloads** (Middle): Using `ray.wait` instead of `ray.get` lets you process results as they arrive and handle partial failures, which is critical when tasks take minutes or hours. - **Ray integrates rather than replaces** (Early): Ray Tune unifies HPO tools like Hyperopt and Optuna, Ray Train wraps TensorFlow/PyTorch, and Ray Data builds on Arrow—so you keep your existing toolchain while gaining distribution. - **Hyperparameter search is dramatically faster with Tune** (Early): A grid search that would take 4+ minutes sequentially runs in ~35 seconds on a laptop with Ray's parallelization—and scales to hours-long training runs with more sophisticated methods. ## 【Reading Tips】 - **Skim Chapter 1** for the big picture and library overviews; you'll return to it as a reference when you need to pick the right tool for a task. - **Deep-read Chapter 2** on Ray Core—the GIL discussion and `@ray.remote` examples are foundational for everything that follows. - **Pay attention to the "distributed interface" pattern** (around 38%): it explains why Ray works well with your existing ML stack and how to think about extending it. - **Don't skip the pendulum RLlib example** (around 28%): it's the simplest complete RL workflow and demonstrates the command-line-to-Python-API progression you'll use later. - **The excerpts don't cover Ray Cluster setup or Ray Serve in depth**—if those are your primary interests, you'll need to consult the full book or supplementary documentation. ## 【Coverage Limits】 This guide synthesizes the first ~53% of the book (through Ray Core fundamentals). Later chapters on Ray Train, Ray Datasets, Ray Clusters, Ray Serve, and Ray AIR are referenced but not covered in detail here. ##
Page 4
11 A Distributed Computing Framework 11 A Suite of Data Science Libraries ...
View in text
Page 12
o build and run complex AI applications at scale, and rein‐ forcement learning has been an integral part of Ray from the start. Three Layers: Core, Libraries...
View in text
Excerpt 3
s example was to show you how simple it can be to train and evaluate reinforcement learning tasks with RLlib, using just two command line calls to rllib. Dis...
View in text
Excerpt 4
, consider using an implementa‐ tion different from CPython. CPython is Python’s standard implementation, and if you don’t know that you’re using it, you’re ...
View in text
Excerpt 5
an object store loosely, without really specifying it. Each node of a Ray cluster is equipped with an object store, within that node’s Raylet, and all object...
View in text
Excerpt 6
o implement an algorithm that figures out on its own how to play the game, merely by playing the game repeatedly: observing what’s happening, deciding what t...
View in text
Excerpt 7
and is worth reading for context. Recapping RL Terminology Before we wrap up this chapter, let’s discuss the concepts we’ve encountered in the maze example i...
View in text
Excerpt 8
creates checkpoints of the algorithm automatically for us. From the output of that training script you should see that Ray will write training results to a l...
View in text
Tags
AI categories
PythonBackendCloud Native
ISBN: 1098117166
Publish Year: 2022
Language: English
Pages: 160
File Format: PDF
File Size: 4.0 MB
Text Preview (First 20 pages)
Registered users can read the full content for free

Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.

Generating text preview…