brief contents
PART 1 BASIC CONCEPTS AND BACKGROUND ..............................1
1 ■ Introduction to distributed machine learning systems 3
PART 2 PATTERNS OF DISTRIBUTED MACHINE
LEARNING SYSTEMS .....................................................15
2 ■ Data ingestion patterns 17
3 ■ Distributed training patterns 41
4 ■ Model serving patterns 66
5 ■ Workflow patterns 90
6 ■ Operation patterns 114
PART 3 BUILDING A DISTRIBUTED MACHINE LEARNING WORKFLOW...............................................................135
7 ■ Project overview and system architecture 137
8 ■ Overview of relevant technologies 155
9 ■ A complete implementation 187
简要目录
第 1 部分 基本概念和背景 ................................................1
1 ■ 分布式机器学习系统简介 3
第 2 部分 分布式机器的模式
学习系统................................................ .....15
2 ■ 数据摄取模式 17
3 ■ 分布式训练模式 41
4 ■ 模型服务模式 66
5 ■ 工作流模式 90
6 ■ 操作模式 114
第 3 部分 构建分布式机器学习工作流................................................ ......135
7 ■ 项目概述和系统架构 137
8 ■ 相关技术概述 155
9 ■ 完整的实施 187
contents
preface xi
acknowledgments xiii
about this book xv
about the author xviii
about the cover illustration xix
PART 1—BASIC CONCEPTS AND BACKGROUND....................1
1 Introduction to distributed machine learning systems 3
1.1 Large-scale machine learning 4
The growing scale 4
■ What can we do? 5
1.2 Distributed systems 7
What is a distributed system? 7
■ The complexity and patterns 7
1.3 Distributed machine learning systems 8
What is a distributed machine learning system? 8
■ Are there similar patterns? 9
■ When should we use a distributed machine learning system? 10
■ When should we not use a distributed machine learning system? 11
1.4 What we will learn in this book 11
目录
序言 xi
致谢 xiii
关于这本书 xv
关于作者 xviii
关于封面插图 xix
第 1 部分 — 基本概念和背景................................................1
1 分布式机器学习系统简介 3
1.1 大规模机器学习 4
规模不断扩大 4
■ 我们能做什么? 5
1.2 分布式系统 7
什么是分布式系统? 7
■ 复杂性和模式 7
1.3 分布式机器学习系统 8
什么是分布式机器学习系统? 8
■ 有类似的模式吗? 9
■ 什么时候应该使用分布式机器学习系统? 10
■ 什么时候不应该使用分布式机器学习系统? 11
1.4 我们将在本书中学到什么 11
PART 2—PATTERNS OF DISTRIBUTED MACHINE LEARNING SYSTEMS............................................15
2 Data ingestion patterns 17
2.1 What is data ingestion? 18
2.2 The Fashion-MNIST dataset 19
2.3 Batching pattern 22
■ The problem: Performing expensive operations for Fashion MNIST dataset with limited memory 22
■ The solution 23
■ Discussion 26
■ Exercises 27
2.4 Sharding pattern: Splitting extremely large datasets among multiple machines 28
■ The problem 28
■ The solution 29
■ Discussion 32
■ Exercises 35
2.5 Caching pattern 35
■ The problem: Re-accessing previously used data for efficient multiepoch model training 36
■ The solution 36
■ Discussion 38
Exercises 40
2.6 Answers to exercises 40
3 Distributed training patterns 41
3.1 What is distributed training? 42
3.2 Parameter server pattern: Tagging entities in 8 million
YouTube videos 43
The problem 45 ■ The solution 45 ■ Discussion 50
Exercises 51
3.3 Collective communication pattern 51
The problem: Improving performance when parameter servers become
a bottleneck 53 ■ The solution 53 ■ Discussion 59
Exercises 60
3.4 Elasticity and fault-tolerance pattern 60
The problem: Handling unexpected failures when training with
limited computational resources 61 ■ The solution 61
Discussion 64 ■ Exercises 64
3.5 Answers to exercises 64
4 Model serving patterns 66
4.1 What is model serving? 67
4.2 Replicated services pattern: Handling the growing
number of serving requests 68
The problem 70 ■ The solution 70 ■ Discussion 73
Exercises 74
4.3 Sharded services pattern 74
The problem: Processing large model serving requests with highresolution
videos 75 ■ The solution 76 ■ Discussion 78
Exercises 79
4.4 The event-driven processing pattern 79
The problem: Responding to model serving requests based
on events 82 ■ The solution 82 ■ Discussion 87
Exercises 88
4.5 Answers to exercises 88
5 Workflow patterns 90
5.1 What is workflow? 91
5.2 Fan-in and fan-out patterns: Composing complex machine
learning workflows 95
The problem 96 ■ The solution 96 ■ Discussion 101
Exercises 102
5.3 Synchronous and asynchronous patterns: Accelerating
workflows with concurrency 102
The problem 103 ■ The solution 103 ■ Discussion 106
Exercises 107
5.4 Step memoization pattern: Skipping redundant workloads
via memoized steps 107
The problem 108 ■ The solution 109 ■ Discussion 111
Exercises 112
5.5 Answers to exercises 112
6 Operation patterns 114
6.1 What are operations in machine learning systems? 115
6.2 Scheduling patterns: Assigning resources effectively
in a shared cluster 117
The problem 118 ■ The solution 118 ■ Discussion 125
Exercises 126
6.3 Metadata pattern: Handle failures appropriately to
minimize the negative effect on users 126
The problem 127 ■ The solution 128 ■ Discussion 132
Exercises 133
6.4 Answers to exercises 134
PART 3—BUILDING A DISTRIBUTED MACHINE
LEARNING WORKFLOW .....................................135
7 Project overview and system architecture 137
7.1 Project overview 138
Project background 138 ■ System components 139
7.2 Data ingestion 140
The problem 140 ■ The solution 142 ■ Exercises 144
7.3 Model training 144
The problem 145 ■ The solution 145 ■ Exercises 147
7.4 Model serving 147
The problem 147 ■ The solution 148 ■ Exercises 150
7.5 End-to-end workflow 150
The problems 151 ■ The solutions 151 ■ Exercises 153
7.6 Answers to exercises 154
8 Overview of relevant technologies 155
8.1 TensorFlow: The machine learning framework 156
The basics 156 ■ Exercises 162
8.2 Kubernetes: The distributed container orchestration
system 162
The basics 163 ■ Exercises 168
8.3 Kubeflow: Machine learning workloads on
Kubernetes 169
The basics 172 ■ Exercises 176
8.4 Argo Workflows: Container-native workflow engine 176
The basics 178 ■ Exercises 185
8.5 Answers to exercises 185
9 A complete implementation 187
9.1 Data ingestion 188
Single-node data pipeline 189 ■ Distributed data pipeline 191
9.2 Model training 191
Model definition and single-node training 192 ■ Distributed
model training 195 ■ Model selection 200
9.3 Model serving 202
Single-server model inference 202 ■ Replicated model servers 207
9.4 The end-to-end workflow 209
Sequential steps 210 ■ Step memoization 214
index 219
第 2 部分——分布式机器学习系统模式................................................. ...15
2 数据摄取模式 17
2.1 什么是数据摄取? 18
2.2 Fashion-MNIST 数据集 19
2.3 批处理模式 22
问题:为时尚行业执行昂贵的操作
内存有限的 MNIST 数据集 22 ■ 解决方案 23
讨论 26 ■ 练习 27
2.4 分片模式:分割超大数据集
多台机器之间 28
问题 28 ■ 解决方案 29 ■ 讨论 32
练习 35
2.5 缓存模式 35
问题:重新访问以前使用的数据以实现高效的多时期
模型训练 36 ■ 解决方案 36 ■ 讨论 38
练习 40
2.6 习题答案 40
3 分布式训练模式 41
3.1 什么是分布式训练? 42
3.2 参数服务器模式:标记800万个实体
YouTube 视频 43
问题 45 ■ 解决方案 45 ■ 讨论 50
练习 51
3.3集体沟通模式51
问题:当参数服务器变得
瓶颈 53 ■ 解决方案 53 ■ 讨论 59
练习 60
3.4 弹性和容错模式 60
问题:训练时处理意外失败
有限的计算资源 61 ■ 解决方案 61
讨论 64 ■ 练习 64
3.5 练习答案 64
4 示范服务模式 66
4.1 什么是模型服务? 67
4.2 复制服务模式:处理不断增长的服务
服务请求数 68
问题 70 ■ 解决方案 70 ■ 讨论 73
练习 74
4.3 分片服务模式 74
问题:以高分辨率处理大型模型服务请求
视频 75 ■ 解决方案 76 ■ 讨论 78
练习79
4.4 事件驱动处理模式 79
问题:响应基于模型的服务请求
事件 82 ■ 解决方案 82 ■ 讨论 87
练习 88
4.5 练习答案 88
5 工作流程模式 90
5.1 什么是工作流程? 91
5.2 扇入扇出模式:组成复杂机器
学习工作流程 95
问题 96 ■ 解决方案 96 ■ 讨论 101
练习102
5.3 同步和异步模式:加速
并发工作流程 102
问题 103 ■ 解决方案 103 ■ 讨论 106
练习107
5.4 步骤记忆化模式:跳过冗余工作负载
通过记忆的步骤107
问题 108 ■ 解决方案 109 ■ 讨论 111
练习112
5.5 习题答案 112
6 操作模式 114
6.1 机器学习系统中的操作是什么? 115
6.2 调度模式:有效分配资源
在共享集群中 117
问题 118 ■ 解决方案 118 ■ 讨论 125
练习126
6.3 元数据模式:适当处理故障
尽量减少对用户的负面影响 126
问题 127 ■ 解决方案 128 ■ 讨论 132
练习133
6.4练习答案134
第 3 部分 — 构建分布式机器
学习工作流程................................................................135
7 项目概述和系统架构 137
7.1 项目概述 138
项目背景 138 ■ 系统组成 139
7.2 数据摄取140
问题 140 ■ 解决方案 142 ■ 练习 144
7.3模型训练144
问题 145 ■ 解决方案 145 ■ 练习 147
7.4 模型服务 147
问题 147 ■ 解决方案 148 ■ 练习 150
7.5 端到端工作流程 150
问题 151 ■ 解决方案 151 ■ 练习 153
7.6练习答案154
8 相关技术概述 155
8.1 TensorFlow:机器学习框架 156
基础知识 156 ■ 练习 162
8.2 Kubernetes:分布式容器编排
系统162
基础知识 163 ■ 练习 168
8.3 Kubeflow:机器学习工作负载
库伯内斯 169
基础知识 172 ■ 练习 176
8.4 Argo Workflows:容器原生工作流引擎 176
基础知识 178 ■ 练习 185
8.5 练习答案 185
9 完整的实施 187
9.1 数据摄取188
单节点数据管道 189 ■ 分布式数据管道 191
9.2模型训练191
模型定义和单节点训练 192 ■ 分布式
模型训练 195 ■ 模型选择 200
9.3 模型服务202
单服务器模型推理 202 ■ 副本模型服务器 207
9.4 端到端工作流程209
连续步骤 210 ■ 步骤记忆化 214
索引 219