-
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] Refine runtime graph #37703
Merged
FeixLiu
merged 4 commits into
PaddlePaddle:develop
from
LiYuRio:dev_refine_runtime_graph
Dec 2, 2021
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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
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
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 |
---|---|---|
|
@@ -682,6 +682,8 @@ def __init__(self, place=None): | |
self._enable_interpreter_core = _is_enable_standalone_executor() | ||
self._executor_cache = _ExecutorCache(self.place) | ||
|
||
self._fleet_executor_cache = None | ||
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. 之后还是改成program_caches、ctc_caches吧 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. 好 |
||
|
||
def _get_scope_cache(self, program_cache_key): | ||
return self.scope_caches.get(program_cache_key, None) | ||
|
||
|
@@ -1960,49 +1962,52 @@ def _run_using_fleet_executor(self, | |
print_period=100, | ||
fetch_handler=None, | ||
use_program_cache=False): | ||
scope, real_fetch_list, trainer_instance = \ | ||
self._prepare_pipeline_ctx(program, dataset, scope, thread, | ||
is_infer, debug, fetch_list, fetch_info, | ||
print_period, fetch_handler, | ||
use_program_cache) | ||
from ..distributed.fleet.proto import fleet_executor_desc_pb2 | ||
from google.protobuf import text_format | ||
cur_rank = os.getenv("PADDLE_TRAINER_ID") | ||
trainer_endpoints_str = os.getenv("PADDLE_TRAINER_ENDPOINTS") | ||
fleet_exe_desc = fleet_executor_desc_pb2.FleetExecutorDesc() | ||
nrank = 1 | ||
if cur_rank and trainer_endpoints_str: | ||
fleet_exe_desc.cur_rank = int(cur_rank) | ||
trainer_endpoints = trainer_endpoints_str.split(',') | ||
for rank, endpoint in enumerate(trainer_endpoints): | ||
if self._fleet_executor_cache is None: | ||
from ..distributed.fleet.proto import fleet_executor_desc_pb2 | ||
from google.protobuf import text_format | ||
cur_rank = os.getenv("PADDLE_TRAINER_ID") | ||
trainer_endpoints_str = os.getenv("PADDLE_TRAINER_ENDPOINTS") | ||
fleet_exe_desc = fleet_executor_desc_pb2.FleetExecutorDesc() | ||
nrank = 1 | ||
if cur_rank and trainer_endpoints_str: | ||
fleet_exe_desc.cur_rank = int(cur_rank) | ||
trainer_endpoints = trainer_endpoints_str.split(',') | ||
for rank, endpoint in enumerate(trainer_endpoints): | ||
rank_info = fleet_executor_desc_pb2.RankInfo() | ||
rank_info.rank = rank | ||
rank_info.ip_port = endpoint | ||
fleet_exe_desc.cluster_info.append(rank_info) | ||
nrank = len(trainer_endpoints) | ||
else: | ||
fleet_exe_desc.cur_rank = 0 | ||
rank_info = fleet_executor_desc_pb2.RankInfo() | ||
rank_info.rank = rank | ||
rank_info.ip_port = endpoint | ||
rank_info.rank = 0 | ||
rank_info.ip_port = '' | ||
fleet_exe_desc.cluster_info.append(rank_info) | ||
nrank = len(trainer_endpoints) | ||
else: | ||
fleet_exe_desc.cur_rank = 0 | ||
rank_info = fleet_executor_desc_pb2.RankInfo() | ||
rank_info.rank = 0 | ||
rank_info.ip_port = '' | ||
fleet_exe_desc.cluster_info.append(rank_info) | ||
logging.warning("Fleet Executor will run on single device only.") | ||
fleet_opt = program._pipeline_opt["fleet_opt"] | ||
if "dist_strategy" in fleet_opt: | ||
fleet_exe_desc.dp_degree = fleet_opt["dist_strategy"]["dp_degree"] | ||
fleet_exe_desc.mp_degree = fleet_opt["dist_strategy"]["mp_degree"] | ||
fleet_exe_desc.pp_degree = fleet_opt["dist_strategy"]["pp_degree"] | ||
if "num_micro_batches" in fleet_opt: | ||
fleet_exe_desc.num_micro_batches = fleet_opt["num_micro_batches"] | ||
num_of_gpu = fleet_exe_desc.dp_degree * fleet_exe_desc.mp_degree * fleet_exe_desc.pp_degree | ||
assert nrank == num_of_gpu, "The number of rank is not equal to the number of gpu." | ||
fleet_exe = core.FleetExecutor(fleet_exe_desc.SerializeToString()) | ||
place = core.Place() | ||
place.set_place(self.place) | ||
fleet_exe.init(program._pipeline_opt["section_program"].desc, scope, | ||
place) | ||
fleet_exe.run() | ||
fleet_exe.release() | ||
logging.warning( | ||
"Fleet Executor will run on single device only.") | ||
fleet_opt = program._pipeline_opt["fleet_opt"] | ||
if "dist_strategy" in fleet_opt: | ||
fleet_exe_desc.dp_degree = fleet_opt["dist_strategy"][ | ||
"dp_degree"] | ||
fleet_exe_desc.mp_degree = fleet_opt["dist_strategy"][ | ||
"mp_degree"] | ||
fleet_exe_desc.pp_degree = fleet_opt["dist_strategy"][ | ||
"pp_degree"] | ||
if "num_micro_batches" in fleet_opt: | ||
fleet_exe_desc.num_micro_batches = fleet_opt[ | ||
"num_micro_batches"] | ||
num_of_gpu = fleet_exe_desc.dp_degree * fleet_exe_desc.mp_degree * fleet_exe_desc.pp_degree | ||
assert nrank == num_of_gpu, "The number of rank is not equal to the number of gpu." | ||
fleet_exe = core.FleetExecutor(fleet_exe_desc.SerializeToString()) | ||
place = core.Place() | ||
place.set_place(self.place) | ||
if scope is None: | ||
scope = global_scope() | ||
fleet_exe.init(program._pipeline_opt["section_program"].desc, scope, | ||
place) | ||
self._fleet_executor_cache = fleet_exe | ||
self._fleet_executor_cache.run() | ||
return None | ||
|
||
def _run_pipeline(self, | ||
|
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.
感觉可以根据pp的degree来判断,以后可以只要1F1B,不要FThenB。可以以后慢慢完善,gradient merge之类的也可以加
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.
好