diff --git a/paddle/fluid/distributed/collective/reducer.cc b/paddle/fluid/distributed/collective/reducer.cc index 63071139a5f4093bd1ce1f09abf1aa5ab17b74f3..defc84fbe3d9cfd1b81b78cdb87cd52d86a6fd67 100644 --- a/paddle/fluid/distributed/collective/reducer.cc +++ b/paddle/fluid/distributed/collective/reducer.cc @@ -821,9 +821,9 @@ void EagerReducer::MarkVarReady(const size_t var_index, auto &group = groups_[group_index]; auto &group_tensor = group.dense_tensors_[inside_group_index]; - const auto length = group.length_[inside_group_index]; if (!group.is_sparse_) { + const auto length = group.length_[inside_group_index]; if (is_used_var) { auto *autograd_meta = tensors_[var_index].get_autograd_meta(); auto &grad_tensor =