File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed
paddle/fluid/framework/details Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -55,6 +55,7 @@ std::unique_ptr<SSAGraph> MultiDevSSAGraphBuilder::Build(
55
55
const ProgramDesc &program) const {
56
56
auto graph = new SSAGraph ();
57
57
SSAGraph &result = *graph;
58
+ std::unordered_set<std::string> og_has_bc;
58
59
result.vars_ .resize (places_.size ());
59
60
60
61
bool is_forwarding = true ;
@@ -123,8 +124,10 @@ std::unique_ptr<SSAGraph> MultiDevSSAGraphBuilder::Build(
123
124
if (!is_forwarding) {
124
125
auto var_names = op->OutputArgumentNames ();
125
126
for (auto &og : var_names) {
126
- if (grad_names_.count (og) != 0 ) { // is param grad
127
- // Insert NCCL AllReduce Op
127
+ 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);
128
131
#ifdef PADDLE_WITH_CUDA
129
132
result.ops_ .emplace_back (
130
133
new NCCLAllReduceOpHandle (local_scopes_, places_, *nccl_ctxs_));
You can’t perform that action at this time.
0 commit comments