-
Notifications
You must be signed in to change notification settings - Fork 666
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New sync consistent meta info (#5634)
* rebase * check in gen py * merge master and fix bugs * address pr comments * address pr comments * auto format by CI * rebase * address pr comments * auto format by CI * functional python_arg * reuse ctrl rpc token for avoiding long time timeout waiting. * fix compiler complaints * auto format by CI * auto format by CI * remove unused files * fix return type error on gcc 4.8.5 Signed-off-by: daquexian <daquexian566@gmail.com> * auto format by CI * fix return type error in xrt Signed-off-by: daquexian <daquexian566@gmail.com> * fix tick ibn sbp signature * auto format by CI Co-authored-by: tsai <jackalcooper@gmail.com> Co-authored-by: oneflow-ci-bot <ci-bot@oneflow.org> Co-authored-by: oneflow-ci-bot <69100618+oneflow-ci-bot@users.noreply.github.com> Co-authored-by: daquexian <daquexian566@gmail.com>
- Loading branch information
1 parent
e81dafc
commit 0a44b54
Showing
58 changed files
with
2,345 additions
and
157 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
Copyright 2020 The OneFlow Authors. All rights reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
#include <pybind11/pybind11.h> | ||
#include <pybind11/stl.h> | ||
#include <pybind11/functional.h> | ||
#include "oneflow/api/python/of_api_registry.h" | ||
#include "oneflow/core/thread/consistent_unique_id.h" | ||
#include "oneflow/core/framework/rank_group_rpc_util.h" | ||
#include "oneflow/core/job/rank_group.h" | ||
#include "oneflow/core/job/rank_group_scope.h" | ||
#include "oneflow/core/common/symbol.h" | ||
|
||
namespace py = pybind11; | ||
|
||
namespace oneflow { | ||
|
||
namespace { | ||
|
||
Maybe<void> InitConsistentRpcTokenScope(const std::string& thread_tag, | ||
int64_t thread_consistent_uid, | ||
Symbol<RankGroup> rank_group) { | ||
JUST(SetThisThreadConsistentUniqueId(thread_consistent_uid, thread_tag)); | ||
static thread_local const auto& init_rank_group_scope = | ||
JUST(RankGroupScope::MakeInitialRankGroupScope(rank_group)); | ||
// no unused warning for `init_rank_group_scope`. | ||
(void)(init_rank_group_scope); | ||
return Maybe<void>::Ok(); | ||
} | ||
|
||
Maybe<void> InitConsistentRpcTokenScope(const std::string& thread_tag, | ||
int64_t thread_consistent_uid) { | ||
const auto& rank_group = JUST(RankGroup::DefaultRankGroup()); | ||
JUST(InitConsistentRpcTokenScope(thread_tag, thread_consistent_uid, rank_group)); | ||
return Maybe<void>::Ok(); | ||
} | ||
|
||
void ApiInitDefaultConsistentRpcTokenScope() { | ||
return InitConsistentRpcTokenScope("main", 0).GetOrThrow(); | ||
} | ||
|
||
} // namespace | ||
|
||
ONEFLOW_API_PYBIND11_MODULE("", m) { | ||
m.def("InitDefaultConsistentRpcTokenScope", &ApiInitDefaultConsistentRpcTokenScope); | ||
} | ||
|
||
} // namespace oneflow |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
Copyright 2020 The OneFlow Authors. All rights reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
#include <pybind11/pybind11.h> | ||
#include <pybind11/stl.h> | ||
#include <pybind11/functional.h> | ||
#include "oneflow/api/python/of_api_registry.h" | ||
#include "oneflow/core/framework/rank_group_rpc_util.h" | ||
#include "oneflow/core/job/rank_group.h" | ||
#include "oneflow/core/job/rank_group_scope.h" | ||
#include "oneflow/core/common/symbol.h" | ||
|
||
namespace py = pybind11; | ||
|
||
namespace oneflow { | ||
|
||
namespace { | ||
|
||
Maybe<void> CheckCurrentRankGroupConsistency(int64_t seconds) { | ||
const auto& rank_group = JUST(RankGroupScope::CurrentRankGroup()); | ||
const auto& ctx = JUST(CheckRpcToken(rank_group)); | ||
JUST(RpcUtil::WaitUntilDoneOrTimeout(*ctx, seconds)); | ||
return Maybe<void>::Ok(); | ||
} | ||
|
||
} // namespace | ||
|
||
ONEFLOW_API_PYBIND11_MODULE("", m) { | ||
m.def("check_current_rank_group_consistency", | ||
[](int64_t seconds) { return CheckCurrentRankGroupConsistency(seconds).GetOrThrow(); }); | ||
m.def("check_current_rank_group_consistency", | ||
[]() { return CheckCurrentRankGroupConsistency(60 * 5).GetOrThrow(); }); | ||
} | ||
|
||
} // namespace oneflow |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
Copyright 2020 The OneFlow Authors. All rights reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
#include "oneflow/core/common/flat_shape.h" | ||
#include "oneflow/core/common/shape.h" | ||
|
||
namespace oneflow { | ||
|
||
Maybe<void> FlatShape::Init(const std::shared_ptr<const Shape>& shape) { | ||
CHECK_LE_OR_RETURN(shape->NumAxes(), SHAPE_MAX_AXIS_SIZE); | ||
this->set_num_axes(shape->NumAxes()); | ||
for (int i = 0; i < this->num_axes(); ++i) { *this->mutable_dim()->Mutable(i) = shape->At(i); } | ||
return Maybe<void>::Ok(); | ||
} | ||
|
||
Maybe<void> FlatShape::Check(const std::shared_ptr<const Shape>& shape) const { | ||
CHECK_EQ_OR_RETURN(this->num_axes(), shape->NumAxes()); | ||
for (int i = 0; i < this->num_axes(); ++i) { | ||
CHECK_EQ_OR_RETURN(this->dim().Get(i), shape->At(i)); | ||
} | ||
return Maybe<void>::Ok(); | ||
} | ||
|
||
} // namespace oneflow |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
Copyright 2020 The OneFlow Authors. All rights reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
#ifndef ONEFLOW_CORE_COMMON_FLAT_SHAPE_H_ | ||
#define ONEFLOW_CORE_COMMON_FLAT_SHAPE_H_ | ||
|
||
#include <memory> | ||
#include "oneflow/core/object_msg/flat_msg.h" | ||
#include "oneflow/core/common/maybe.h" | ||
#include "oneflow/core/common/shape_vec.h" | ||
|
||
namespace oneflow { | ||
|
||
class Shape; | ||
|
||
// clang-format off | ||
|
||
FLAT_MSG_BEGIN(FlatShape); | ||
// Methods | ||
OF_PUBLIC Maybe<void> Init(const std::shared_ptr<const Shape>& shape); | ||
OF_PUBLIC Maybe<void> Check(const std::shared_ptr<const Shape>& shape) const; | ||
|
||
// Fields | ||
FLAT_MSG_DEFINE_OPTIONAL(int64_t, num_axes); | ||
FLAT_MSG_DEFINE_REPEATED(int64_t, dim, SHAPE_MAX_AXIS_SIZE); | ||
FLAT_MSG_END(FlatShape); | ||
|
||
// clang-format on | ||
|
||
} // namespace oneflow | ||
|
||
#endif // ONEFLOW_CORE_COMMON_FLAT_SHAPE_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.