Skip to content

Commit c5b01d0

Browse files
author
Helin Wang
committed
paddle dist architecture (draft)
1 parent 9ab860e commit c5b01d0

9 files changed

+78
-0
lines changed

doc/design/dist/README.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# Distributed Training Design Doc
2+
3+
## Objective
4+
5+
We want Paddle to support training on a general-purpose cluster. The cluster runs Paddle, the Web server (e.g., Nginx), the log collector (e.g., fluentd), the distributed queue service (e.g., Kafka), the log joiner and other data processors written using Storm, Spark, and Hadoop MapReduce on the same cluster. As illustrated in the following graph:
6+
7+
![general purpose cluster](src/arch.png)
8+
9+
This poses new challenges for Paddle,
10+
11+
- Paddle need to be tault tolerant.
12+
- Input training data can be online data from realtime logs, or batched data from distributed file system.
13+
- User needs a simple way to train model on cloud. Complexities such as job scheduling should be hidden from user.
14+
15+
## Training Job
16+
17+
A training job will be created once user asks Paddle cloud to train a model. The training job is made up of different processes that collabratively consume data input and produce a trained model. There are three kind of processes:
18+
19+
- Master process
20+
- Trainer process
21+
- Parameter server process
22+
23+
One training job will only have one master process, typicall multiple trainer and parameter server processes. Their relation is illustrated in the following graph:
24+
25+
![process collabration](src/paddle-on-kubernetes-invited-blog-model-sharding.png)
26+
27+
### Master Process
28+
29+
Master process will:
30+
31+
- keep a list of alive trainers and a list of alive parameter servers and do *health check*,
32+
- if trainer is dead it will update task queue accordingly as mentioned in [task queue](#task-queue).
33+
- if a parameter server is dead or a new parameter server joins, it will broacast this information to all trainers.
34+
- dispatches tasks to trainers. A *task* is a unit of data that a trainer needs to train on, and
35+
- keep track of training progress on the dataset with *task queue*. Typically training will iterate on the dataset for a full pass until it goes into next pass.
36+
37+
#### Task Queue
38+
39+
Master process have three task queues to track training progress as shown in the graph below:
40+
41+
![task queues](src/paddle-task-queues.png)
42+
43+
- Todo queue holds tasks to be dispatched.
44+
- Pending queue holds tasks that are currently training by trainers, and a mapping from trainers to their training tasks.
45+
- Done queue holds tasks that are already trained.
46+
47+
A dataset will be sharded into tasks and dispatched by the master process. The life cycle of a single task is illustrated below:
48+
49+
![task states](src/paddle-task-states.png)
50+
51+
1. When a new pass of training starts, all tasks will be placed in the todo queue.
52+
1. The master process will dispatch few tasks to each trainer at a time, puts them in pending queue and waits for completion.
53+
1. The trainer will work on it's tasks and tell master once a task is completed. The master process will dispatch a new task to that trainer.
54+
1. If a trainer is dead. the master process will move it's tasks back to the todo queue.
55+
1. The master will move completed task to the done queue. When todo queue is empty, master will start a new pass by moving all tasks in done queue to todo queue.
56+
57+
### Trainer Process
58+
59+
Trainer process will train it's current tasks, tell parameter servers it's accumulated gradient, and download latest model from parameter servers.
60+
61+
Trainer holds entire network model while each parameter server hold a shard of model. So trainer needs to communicate will all parameter servers.
62+
63+
Communication involves two parts:
64+
65+
- upload accumulated gradient. Upload can be configured to happen every **n** mini-batches.
66+
- download new model. Download can be configured to happend every **m** mini-batches. **n** and **m** does not need to be equal.
67+
68+
### Parameter Server Process
69+
70+
Parameter server processes hold model together. Since model parameters are sharded and saved on different parameter servers. All parameter servers collabratively form the global view of trained model.
71+
72+
## Fault Tolerant
73+
74+
TODO
75+
76+
## User Interface
77+
78+
TODO

doc/design/dist/src/arch.graffle

3.74 KB
Binary file not shown.

doc/design/dist/src/arch.png

57 KB
Loading
2.88 KB
Binary file not shown.
52.5 KB
Loading
2.95 KB
Binary file not shown.
32.7 KB
Loading
2.23 KB
Binary file not shown.
20 KB
Loading

0 commit comments

Comments
 (0)