Skip to content

Commit 30adc0b

Browse files
committed
add notation
1 parent de5e56b commit 30adc0b

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

paddle/fluid/framework/details/multi_devices_graph_builder.cc

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ std::unique_ptr<SSAGraph> MultiDevSSAGraphBuilder::Build(
5555
const ProgramDesc &program) const {
5656
auto graph = new SSAGraph();
5757
SSAGraph &result = *graph;
58-
std::unordered_set<std::string> og_has_bc;
58+
std::unordered_set<std::string> og_has_been_broadcast;
5959
result.vars_.resize(places_.size());
6060

6161
bool is_forwarding = true;
@@ -123,11 +123,15 @@ std::unique_ptr<SSAGraph> MultiDevSSAGraphBuilder::Build(
123123

124124
if (!is_forwarding) {
125125
auto var_names = op->OutputArgumentNames();
126+
// Currently, we assume that once gradient is generated, it can be
127+
// broadcast, and each gradient is only broadcast once. But there are no
128+
// other cases, for example, we need to adjust the gradient according to
129+
// the input when we get the gradient, which is not considered at present.
126130
for (auto &og : var_names) {
127131
if (grad_names_.count(og) != 0 &&
128-
og_has_bc.count(og) == 0) { // is param grad
129-
// Insert NCCL AllReduce Op
130-
og_has_bc.insert(og);
132+
og_has_been_broadcast.count(og) == 0) { // is param grad
133+
// Insert NCCL AllReduce Op
134+
og_has_been_broadcast.insert(og);
131135
#ifdef PADDLE_WITH_CUDA
132136
result.ops_.emplace_back(
133137
new NCCLAllReduceOpHandle(local_scopes_, places_, *nccl_ctxs_));

0 commit comments

Comments
 (0)