Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix single-client reader parallel #6288

Merged
merged 6 commits into from
Sep 15, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion oneflow/user/data/coco_data_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ limitations under the License.
#include "oneflow/core/persistence/file_system.h"
#include "oneflow/core/persistence/persistent_in_stream.h"
#include "oneflow/core/rpc/include/global_process_ctx.h"
#include "oneflow/core/job/env_desc.h"

namespace oneflow {
namespace data {
Expand All @@ -36,7 +37,7 @@ COCODataReader::COCODataReader(user_op::KernelInitContext* ctx) : DataReader<COC
// NOTE(zwx): COCODataReader is not consistent since attr nd_sbp is empty,
// we assume that it works in DDP
auto nd_sbp_str_vec = ctx->Attr<std::vector<std::string>>("nd_sbp");
if (nd_sbp_str_vec.empty()) {
if (nd_sbp_str_vec.empty() && CHECK_JUST(GlobalMultiClientEnv())) {
parallel_id = GlobalProcessCtx::Rank();
parallel_num = GlobalProcessCtx::WorldSize();
} else {
Expand Down
3 changes: 2 additions & 1 deletion oneflow/user/data/ofrecord_dataset.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ limitations under the License.
#include "oneflow/core/persistence/persistent_in_stream.h"
#include "oneflow/core/job/job_set.pb.h"
#include "oneflow/core/rpc/include/global_process_ctx.h"
#include "oneflow/core/job/env_desc.h"

namespace oneflow {
namespace data {
Expand Down Expand Up @@ -60,7 +61,7 @@ class OFRecordDataset final : public Dataset<TensorBuffer> {
auto nd_sbp_str_vec = ctx->Attr<std::vector<std::string>>("nd_sbp");
// NOTE(zwx): OFRecordDataset is not consistent since attr nd_sbp is empty,
// we assume that it works in DDP
if (nd_sbp_str_vec.empty()) { is_local = true; }
if (nd_sbp_str_vec.empty() && CHECK_JUST(GlobalMultiClientEnv())) { is_local = true; }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OFRecordImageClassificationDataReader 还未迁移到 Multi-Client 下,所以如果这里判断了 is Multi-Client,60 行:if (ctx->op_type_name() == "OFRecordReader") 的特判就可以删掉了?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

主要是 OFRecordImageClassificationDataReader 调用 61 行的 get attr nd_sbp 就会报错了,因为不存在这个 attr。

}
if (is_local) {
parallel_id_ = GlobalProcessCtx::Rank();
Expand Down
3 changes: 2 additions & 1 deletion oneflow/user/kernels/gpt_data_loader_kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
#include "oneflow/user/data/gpt_dataset.h"
#include "oneflow/core/common/nd_index_offset_helper.h"
#include "oneflow/core/rpc/include/global_process_ctx.h"
#include "oneflow/core/job/env_desc.h"

namespace oneflow {

Expand Down Expand Up @@ -73,7 +74,7 @@ class GPTDataLoader final : public OpKernelState {
// NOTE(zwx): GPTDataLoader is not consistent since attr nd_sbp is empty,
// we assume that it works in DDP
auto nd_sbp_str_vec = ctx->Attr<std::vector<std::string>>("nd_sbp");
if (nd_sbp_str_vec.empty()) {
if (nd_sbp_str_vec.empty() && CHECK_JUST(GlobalMultiClientEnv())) {
num_shards_ = GlobalProcessCtx::WorldSize();
shard_index_ = GlobalProcessCtx::Rank();
} else {
Expand Down