-
Notifications
You must be signed in to change notification settings - Fork 6k
【paddle.fleet】Update fleetrun & ps-heter #27472
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
Merged
Merged
Changes from 22 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
34bd004
refine fleetrun.ps_launch
MrChengmo 50ada3a
for merge
MrChengmo be70c94
fix
MrChengmo 4efcb9d
update fleet run for multi device support
MrChengmo 1c57d55
ps_graph support ps-gpu
MrChengmo dbbcc43
fix
MrChengmo d3cda7f
fix
MrChengmo 291e159
revert performance code
MrChengmo 5189880
fix
MrChengmo 03a2be6
for merge
MrChengmo d8c4ddb
for merge
MrChengmo e5660af
fix heter save
MrChengmo 369b955
add heter save unittest
MrChengmo 6ddd726
fix unittest
MrChengmo b8e873e
add heter unittest
MrChengmo aafa019
fix unittest
MrChengmo d7bb812
fix unittest & simple code
MrChengmo da6aaee
fix unittest
MrChengmo 578dd7c
update fleetrun
MrChengmo f58a290
fix fleetrun
MrChengmo c987c1f
fix coverage
MrChengmo ed20fea
fix launch barrier
MrChengmo 3236ec2
simple code
MrChengmo f327822
fix role maker
MrChengmo 7fc7c08
add paddlecloud rolemaker unittest
MrChengmo 2cb76b9
rename heter_worker_device_guard
MrChengmo ebab5dd
fix unittest
MrChengmo 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -530,13 +530,6 @@ def _get_heter_worker_endpoint(self): | |
| return self._heter_trainer_endpoints[(self._current_id) % | ||
| self._heter_worker_num()] | ||
|
|
||
| def _get_heter_worker_device(self): | ||
| """ | ||
| Returns: | ||
| string: heter_trainer's device of current node, e.g: CPU/GPU/XPU | ||
| """ | ||
| return self._heter_trainer_device.upper() | ||
|
|
||
|
|
||
| class PaddleCloudRoleMaker(RoleMakerBase): | ||
| def __init__(self, is_collective=False, **kwargs): | ||
|
|
@@ -677,88 +670,86 @@ def _is_heter_worker(self): | |
| return self._role == Role.HETER_WORKER | ||
|
|
||
| def _ps_env(self): | ||
| try: | ||
| # Environment variable PADDLE_PSERVERS_IP_PORT_LIST must be set | ||
| # format: string(ip:port,ip:port), eg. 127.0.0.1:6001,127.0.0.1:6002 | ||
| self._server_endpoints = os.getenv("PADDLE_PSERVERS_IP_PORT_LIST") | ||
|
|
||
| if self._server_endpoints is None: | ||
| # back to non_distributed execution. | ||
| self._server_endpoints = "" | ||
| self._trainers_num = 1 | ||
| self._role = Role.WORKER | ||
| self._current_id = 0 | ||
| self._nodes_num = 1 | ||
| self._heter_trainers_num = 0 | ||
| self._heter_trainer_endpoints = None | ||
| self._non_distributed = True | ||
| return | ||
|
|
||
| self._server_endpoints = self._server_endpoints.split(",") | ||
|
|
||
| self._worker_endpoints = os.getenv("PADDLE_TRAINER_ENDPOINTS") | ||
| if self._worker_endpoints: | ||
| self._worker_endpoints = self._worker_endpoints.split(",") | ||
| else: | ||
| self._worker_endpoints = [] | ||
| # Environment variable PADDLE_PSERVERS_IP_PORT_LIST must be set | ||
| # format: string(ip:port,ip:port), eg. 127.0.0.1:6001,127.0.0.1:6002 | ||
| self._server_endpoints = os.getenv("PADDLE_PSERVERS_IP_PORT_LIST", None) | ||
|
|
||
| trainers_num = int(os.environ["PADDLE_TRAINERS_NUM"]) | ||
| training_role = os.environ["TRAINING_ROLE"] | ||
| if self._server_endpoints is None: | ||
| # back to non_distributed execution. | ||
| self._server_endpoints = "" | ||
| self._trainers_num = 1 | ||
| self._role = Role.WORKER | ||
| self._current_id = 0 | ||
| self._nodes_num = 1 | ||
| self._heter_trainers_num = 0 | ||
| self._heter_trainer_endpoints = None | ||
| self._non_distributed = True | ||
| return | ||
|
|
||
| if training_role not in ["TRAINER", "PSERVER", "HETER_TRAINER"]: | ||
| raise ValueError( | ||
| "TRAINING_ROLE must be PSERVER or TRAINER or HETER_TRAINER, but get {}, please check your environment.". | ||
| format(training_role)) | ||
|
|
||
| # For heter parameter server env setting | ||
| heter_trainer_eplist = os.getenv( | ||
| "PADDLE_HETER_TRAINER_IP_PORT_LIST", None) | ||
| heter_trainer_device = os.getenv("PADDLE_HETER_TRAINER_DEVICE", | ||
| None) | ||
| if heter_trainer_eplist and heter_trainer_device: | ||
| try: | ||
| heter_trainer_eplist = os.environ[ | ||
| "PADDLE_HETER_TRAINER_IP_PORT_LIST"].split(",") | ||
| except: | ||
| raise ValueError( | ||
| "Can not Find PADDLE_HETER_TRAINER_IP_PORT_LIST in env or its format doesn't match the requirement: 'IP:PORT,IP:PORT' ." | ||
| ) | ||
|
|
||
| self._is_heter_parameter_server_mode = True | ||
| heter_trainers_num = len(heter_trainer_eplist) | ||
| current_node_device = heter_trainer_device.upper() | ||
| if current_node_device not in ["CPU", "GPU", "XPU"]: | ||
| raise ValueError( | ||
| "Heter Trainer doesn't support {} device now, please use CPU / GPU / XPU(KunLun)". | ||
| format(heter_trainer_device)) | ||
| self._heter_trainer_device = current_node_device | ||
| else: | ||
| self._is_heter_parameter_server_mode = False | ||
| heter_trainers_num = 0 | ||
|
|
||
| if training_role == "TRAINER": | ||
| role = Role.WORKER | ||
| current_id = int(os.environ["PADDLE_TRAINER_ID"]) | ||
| if len(self._worker_endpoints) > 0: | ||
| self._cur_endpoint = self._worker_endpoints[current_id] | ||
| elif training_role == "PSERVER": | ||
| role = Role.SERVER | ||
| port = os.environ["PADDLE_PORT"] | ||
| ip = os.environ["POD_IP"] | ||
| self._cur_endpoint = ip + ":" + port | ||
| current_id = self._server_endpoints.index(self._cur_endpoint) | ||
| elif training_role == "HETER_TRAINER": | ||
| role = Role.HETER_WORKER | ||
| cur_ip = os.environ["POD_IP"] | ||
| cur_port = os.environ["PADDLE_PORT"] | ||
| curr_endpoint = ":".join([cur_ip, cur_port]) | ||
| current_id = heter_trainer_eplist.index(curr_endpoint) | ||
| else: | ||
| self._server_endpoints = self._server_endpoints.split(",") | ||
|
|
||
| self._worker_endpoints = os.getenv("PADDLE_TRAINER_ENDPOINTS", None) | ||
| if self._worker_endpoints != None: | ||
| self._worker_endpoints = self._worker_endpoints.split(",") | ||
| else: | ||
| self._worker_endpoints = [] | ||
|
|
||
| trainers_num = os.getenv("PADDLE_TRAINERS_NUM", None) | ||
| assert trainers_num != None | ||
| trainers_num = int(trainers_num) | ||
|
|
||
| training_role = os.getenv("TRAINING_ROLE", None) | ||
| assert training_role != None | ||
|
||
|
|
||
| if training_role not in ["TRAINER", "PSERVER", "HETER_TRAINER"]: | ||
| raise ValueError( | ||
| "TRAINING_ROLE must be PSERVER or TRAINER or HETER_TRAINER, but get {}, please check your environment.". | ||
| format(training_role)) | ||
|
|
||
| # For heter parameter server env setting | ||
| heter_trainer_eplist = os.getenv("PADDLE_HETER_TRAINER_IP_PORT_LIST", | ||
| "") | ||
| if heter_trainer_eplist != "": | ||
| try: | ||
| heter_trainer_eplist = os.environ[ | ||
| "PADDLE_HETER_TRAINER_IP_PORT_LIST"].split(",") | ||
| except: | ||
| raise ValueError( | ||
| "TRAINING_ROLE must be PSERVER or TRAINER or HETER_TRAINER") | ||
| except ValueError as e: | ||
| "Can not Find PADDLE_HETER_TRAINER_IP_PORT_LIST in env or its format doesn't match the requirement: 'IP:PORT,IP:PORT' ." | ||
| ) | ||
|
|
||
| self._is_heter_parameter_server_mode = True | ||
| heter_trainers_num = len(heter_trainer_eplist) | ||
| else: | ||
| self._is_heter_parameter_server_mode = False | ||
| heter_trainers_num = 0 | ||
|
|
||
| if training_role == "TRAINER": | ||
| role = Role.WORKER | ||
| current_id = os.getenv("PADDLE_TRAINER_ID", None) | ||
| assert current_id != None | ||
| current_id = int(current_id) | ||
| if len(self._worker_endpoints) > 0: | ||
| self._cur_endpoint = self._worker_endpoints[current_id] | ||
| elif training_role == "PSERVER": | ||
| role = Role.SERVER | ||
| port = os.getenv("PADDLE_PORT", None) | ||
| assert port != None | ||
| ip = os.getenv("POD_IP", None) | ||
| assert ip != None | ||
| self._cur_endpoint = ip + ":" + port | ||
| current_id = self._server_endpoints.index(self._cur_endpoint) | ||
| elif training_role == "HETER_TRAINER": | ||
| role = Role.HETER_WORKER | ||
| cur_port = os.getenv("PADDLE_PORT", None) | ||
| assert cur_port != None | ||
| cur_ip = os.getenv("POD_IP", None) | ||
| assert cur_ip != None | ||
| curr_endpoint = ":".join([cur_ip, cur_port]) | ||
| current_id = heter_trainer_eplist.index(curr_endpoint) | ||
| else: | ||
| raise ValueError( | ||
| "Something wrong with PaddleCloud, please check environment") | ||
| "TRAINING_ROLE must be PSERVER or TRAINER or HETER_TRAINER") | ||
|
|
||
| self._trainers_num = trainers_num | ||
| self._role = role | ||
|
|
||
Oops, something went wrong.
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.
assert 换成raise ValuseError
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.
已修复