Skip to content

Commit e1cea8c

Browse files
committed
follow comments
1 parent 430a911 commit e1cea8c

21 files changed

+25
-33
lines changed

doc/design/refactor/distributed_architecture.md renamed to doc/design/dist_refactor/distributed_architecture.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,9 @@ The IR for PaddlePaddle after refactoring is called a `Block`, it specifies the
5252

5353
The user can not directly specify the parameter update rule for the parameter server in the Python module, since the parameter server does not use the same computation definition as the trainer. Instead, the update rule is baked inside the parameter server. The user can not specify the update rule explicitly.
5454

55-
This could be fixed by making the parameter server run the same computation definition as the trainer (the user's Python module). For a detailed explanation, refer to this document -
56-
[Design Doc: Operation Graph Based Parameter Server](./parameter_server.md)
55+
This could be fixed by making the parameter server also run an IR, which can be different to the trainer side
56+
For a detailed explanation, refer to this document -
57+
[Design Doc: Parameter Server](./parameter_server.md)
5758

5859
## Distributed Training Architecture
5960

@@ -113,7 +114,7 @@ Below are the steps that are followed :
113114
distributed training program:
114115
1. Parse configurations from `RemoteExecutor`.
115116
1. Determine the type of distributed program, can be DataParallelism, ModelParallelism or Streaming.
116-
1. Partition the `ProgramDesc` according to type and add `send` / `recv` OP pair on the boundaries. For
117+
1. Partition the `ProgramDesc` according to type and add `send` / `recv` OP pair on the boundaries. Take
117118
DataParallelism type for example, it removes the optimization operators and add a `send` OP to the
118119
"trainer" role, then add the optimization operators to the parameter server role within the `recv` OP.
119120
1. Dispatch the partitioned graph to different `RemoteExecutor` in the cluster.
@@ -129,12 +130,9 @@ log printing.
129130
The Python `RemoteExecutor` is derived from `Executor` class.
130131

131132
```python
132-
run(self,
133-
program=None,
134-
feed=None,
135-
fetch_list=None,
136-
feed_var_name='feed',
137-
fetch_var_name='fetch',
133+
exe = RemoteExecutor(
134+
feed=feeder.feed(data),
135+
fetch_list=[avg_cost],
138136
job_desc=JobDesc(
139137
jobname,
140138
num_trainer,
@@ -145,6 +143,10 @@ run(self,
145143
cpu_per_pserver,
146144
mem_per_pserver
147145
))
146+
for data in train_reader():
147+
loss, acc = exe.run(trainer_prog,
148+
feed=feeder.feed(data),
149+
fetch_list=[avg_cost])
148150
```
149151

150152
`JobDesc` object describe the distributed job resource specification to run on
File renamed without changes.

doc/design/refactor/parameter_server.md renamed to doc/design/dist_refactor/parameter_server.md

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Design Doc: Operation Graph Based Parameter Server
1+
# Design Doc: Parameter Server
22

33
## Abstract
44

@@ -10,7 +10,7 @@ different purposes.
1010
## Background
1111

1212
The previous implementations of the parameter server does not run a
13-
subgraph. parameter initialization, optimizer computation, network
13+
fluid sub-program. Parameter initialization, optimizer computation, network
1414
communication and checkpointing are implemented twice on both the
1515
trainer and the parameter server.
1616

@@ -23,18 +23,17 @@ server becomes a natural extension.
2323

2424
## Design
2525

26-
### Graph Converter
26+
### Distributed Transpiler
2727

28-
The *graph converter* converts the user-defined operation (OP) graph
29-
into subgraphs to be scheduled on different nodes with the following
28+
The *Distributed Transpiler* converts the user-defined fluid program
29+
into sub-programs to be scheduled on different nodes with the following
3030
steps:
3131

3232
1. OP placement: the OPs will be placed on different nodes according
3333
to heuristic that minimizes estimated total computation
3434
time. Currently we will use a simple heuristic that puts parameter
3535
varable on parameter server workers and everything else on trainer
3636
workers.
37-
3837
1. Add communication OPs to enable the communication between nodes.
3938

4039
We will need these OPs: *Send*, *Recv*, *Enqueue*, *Dequeue*.
@@ -48,8 +47,8 @@ After converting:
4847

4948
<img src="src/dist-graph.png" width="700"/>
5049

51-
1. The parameter variable W and it's optimizer subgraph are placed on the parameter server.
52-
1. Operators are added to the subgraphs.
50+
1. The parameter variable W and it's optimizer program are placed on the parameter server.
51+
1. Operators are added to the program.
5352
- *Send* sends data to the connected *Recv* operator. The
5453
scheduler on the receive node will only schedule *Recv* operator
5554
to run when the *Send* operator has ran (the *Send* OP will mark
@@ -64,39 +63,30 @@ After converting:
6463
### Benefits
6564

6665
- Model parallelism become easier to implement: it's an extension to
67-
the trainer - parameter server approach. we already have the
68-
communication OPs, but need to extend the graph converter's
69-
placement functionality.
70-
66+
the trainer - parameter server approach. We can have several "Transpilers"
67+
to achieve different goals.
7168
- User-defined optimizer is easier to add - user can now express it as
72-
a subgraph.
73-
69+
a sub-program.
7470
- No more duplication logic inside the trainer and the parameter
7571
server mentioned in the background section.
7672

7773
### Challenges
7874

79-
- It might be hard for the graph converter to cut a general graph
80-
(without any hint for which subgraph is the optimizer). We may need
81-
to label which subgraph inside the OP graph is the optimizer.
82-
8375
- It's important to balance the parameter shards of on multiple
8476
parameter server. If a single parameter is very big (some
8577
word-embedding, fully connected, softmax layer), we need to
8678
automatically partition the single parameter onto different
8779
parameter servers when possible (only element-wise optimizer depends
8880
on the parameter variable).
81+
- In the "Aync SGD" figure, the "W" variable on the parameter server
82+
could be read and wrote concurrently. See
83+
[here](https://github.com/PaddlePaddle/Paddle/pull/6394) for more
84+
details about concurrent program in fluid.
8985

9086
### Discussion
9187

92-
- In the "Aync SGD" figure, the "W" variable on the parameter server
93-
could be read and wrote concurrently, what is our locking strategy?
94-
E.g., each variable have a lock cpp method to be invoked by every
95-
OP, or, have a lock OP.
96-
9788
- Can the Enqueue OP be implemented under our current tensor design
9889
(puts the input tensor into the queue tensor)?
99-
10090
- *Dequeue* OP will have variable numbers of output (depends on the
10191
`min_count` attribute), does our current design support it? (similar
10292
question for the *Add* OP)
Binary file not shown.
Loading

0 commit comments

Comments
 (0)