-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
[fleet_executor] Parse rank_to_ip map on cpp side and start message bus. #37126
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
0bdb5e7
add ip parser
FeixLiu 7de2cea
adapt singlton
FeixLiu 02ef4fe
update vlog
FeixLiu 2cbf78b
modify structure
FeixLiu b99bcf8
add IsInit interface for message bus
FeixLiu e50b9bf
some update
FeixLiu ffb1028
correct typo
FeixLiu 4da3d10
add todo
FeixLiu b771580
fix typo
FeixLiu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
|
@@ -13,6 +13,7 @@ | |
// limitations under the License. | ||
|
||
#include "paddle/fluid/distributed/fleet_executor/fleet_executor.h" | ||
#include "paddle/fluid/distributed/fleet_executor/message_bus.h" | ||
#include "paddle/fluid/distributed/fleet_executor/runtime_graph.h" | ||
#include "paddle/fluid/framework/program_desc.h" | ||
|
||
|
@@ -31,6 +32,40 @@ FleetExecutor::~FleetExecutor() { | |
|
||
void FleetExecutor::Init(const paddle::framework::ProgramDesc& program_desc) { | ||
// Compile and Initialize | ||
InitMessageBus(); | ||
} | ||
|
||
void FleetExecutor::InitMessageBus() { | ||
std::stringstream ss; | ||
ss << "\nThe DNS table of the message bus is: \n"; | ||
int64_t cur_rank = exe_desc_.cur_rank(); | ||
std::unordered_map<int64_t, int64_t> interceptor_id_to_rank; | ||
std::unordered_map<int64_t, std::string> rank_to_addr; | ||
std::string addr; | ||
for (const auto& rank_info : exe_desc_.cluster_info()) { | ||
int64_t rank = rank_info.rank(); | ||
std::string ip_port = rank_info.ip_port(); | ||
ss << rank << "\t->\t" << ip_port << "\n"; | ||
// TODO(Yuang): replace the first 'rank' with real interceptor id | ||
interceptor_id_to_rank.insert(std::make_pair(rank, rank)); | ||
rank_to_addr.insert(std::make_pair(rank, ip_port)); | ||
if (rank == cur_rank) { | ||
addr = ip_port; | ||
} | ||
} | ||
PADDLE_ENFORCE_NE( | ||
addr, "", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 单卡可以保留成空 |
||
platform::errors::NotFound( | ||
"Current rank is %s, which ip_port cannot be found in the config.", | ||
cur_rank)); | ||
VLOG(3) << "Current rank is " << cur_rank << " and the ip_port is " << addr | ||
<< "."; | ||
VLOG(3) << "The number of ranks are " << interceptor_id_to_rank.size() << "."; | ||
VLOG(5) << ss.str(); | ||
MessageBus& message_bus_instance = MessageBus::Instance(); | ||
if (!message_bus_instance.IsInit()) { | ||
message_bus_instance.Init(interceptor_id_to_rank, rank_to_addr, addr); | ||
} | ||
} | ||
|
||
void FleetExecutor::Run() { | ||
|
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
message_bus我觉得逻辑应该只保留rank_to_addr的,interceptor_id_to_rank的逻辑应该给carrier,解耦开。这个可以之后再讨论修改