Skip to content

Commit de5e56b

Browse files
committed
add og has been broadcasted
1 parent 9565876 commit de5e56b

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

paddle/fluid/framework/details/multi_devices_graph_builder.cc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +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;
5859
result.vars_.resize(places_.size());
5960

6061
bool is_forwarding = true;
@@ -123,8 +124,10 @@ std::unique_ptr<SSAGraph> MultiDevSSAGraphBuilder::Build(
123124
if (!is_forwarding) {
124125
auto var_names = op->OutputArgumentNames();
125126
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);
128131
#ifdef PADDLE_WITH_CUDA
129132
result.ops_.emplace_back(
130133
new NCCLAllReduceOpHandle(local_scopes_, places_, *nccl_ctxs_));

0 commit comments

Comments
 (0)