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

修改COPY-FROM No.13 distributed #55236

Merged
merged 1 commit into from
Jul 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
41 changes: 41 additions & 0 deletions python/paddle/distributed/fleet/base/role_maker.py
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,30 @@ def _barrier(self, comm_world):


class PaddleCloudRoleMaker(RoleMakerBase):

"""
PaddleCloudRoleMaker is an interface for distributed configuration initialization based on obtaining distributed related information from environment variables.
Examples:
.. code-block:: python
import os
import paddle.distributed.fleet as fleet
os.environ["PADDLE_PSERVER_NUMS"] = "2"
os.environ["PADDLE_TRAINERS_NUM"] = "2"
os.environ["POD_IP"] = "127.0.0.1"
os.environ["PADDLE_PORT"] = "36001"
os.environ["TRAINING_ROLE"] = "PSERVER"
os.environ["PADDLE_PSERVERS_IP_PORT_LIST"] = "127.0.0.1:36001,127.0.0.2:36001"
os.environ["PADDLE_TRAINER_ID"] = "0"
fleet.PaddleCloudRoleMaker(is_collective=False)
"""

def __init__(self, is_collective=False, **kwargs):
super().__init__()
self._is_collective = is_collective
Expand Down Expand Up @@ -1180,6 +1204,23 @@ def _generate_role(self):


class UserDefinedRoleMaker(PaddleCloudRoleMaker):

"""
UserDefinedRoleMaker is an interface for distributed configuration initialization based on obtaining distributed related information from user-defined parameters.
Examples:
.. code-block:: python
import paddle.distributed.fleet as fleet
from paddle.distributed.fleet.base.role_maker import Role
fleet.UserDefinedRoleMaker(
current_id=0,
role=Role.SERVER,
worker_num=2,
server_endpoints=["127.0.0.1:36011", "127.0.0.1:36012"])
"""

def __init__(self, is_collective=False, init_gloo=False, **kwargs):
super().__init__(
is_collective=is_collective, init_gloo=init_gloo, **kwargs
Expand Down
8 changes: 5 additions & 3 deletions python/paddle/distributed/fleet/dataset/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -1279,10 +1279,11 @@ class QueueDataset(DatasetBase):
QueueDataset, it will process data streamly.
Examples:
.. code-block:: python
import paddle
dataset = paddle.distributed.QueueDataset()
.. code-block:: python
import paddle
dataset = paddle.distributed.QueueDataset()
"""

Expand All @@ -1298,6 +1299,7 @@ def init(self, **kwargs):
:api_attr: Static Graph
should be called only once in user's python scripts to initialize setings of dataset instance
"""
super().init(**kwargs)

Expand Down
29 changes: 19 additions & 10 deletions python/paddle/distributed/fleet/fleet.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,11 @@ class Fleet:
Returns:
Fleet: A Fleet instance
Example for collective training:
.. code-block:: python
:name: code-example1
# Example1: for collective training
import paddle
paddle.enable_static()
import paddle.distributed.fleet as fleet
Expand All @@ -122,10 +123,11 @@ class Fleet:
# do distributed training
Example for parameter server training:
.. code-block:: python
:name: code-example2
# Example2: for parameter server training
import paddle
paddle.enable_static()
import paddle.distributed.fleet as fleet
Expand Down Expand Up @@ -195,40 +197,39 @@ def init(
Returns:
None
Examples1:
Examples:
.. code-block:: python
:name: code-example1
import paddle.distributed.fleet as fleet
fleet.init()
Examples2:
.. code-block:: python
:name: code-example2
import paddle.distributed.fleet as fleet
fleet.init(is_collective=True)
Examples3:
.. code-block:: python
:name: code-example3
import paddle.distributed.fleet as fleet
role = fleet.PaddleCloudRoleMaker()
fleet.init(role)
Examples4:
.. code-block:: python
:name: code-example4
import paddle.distributed.fleet as fleet
strategy = fleet.DistributedStrategy()
fleet.init(strategy=strategy)
Examples5:
.. code-block:: python
:name: code-example5
import paddle.distributed.fleet as fleet
strategy = fleet.DistributedStrategy()
fleet.init(log_level = "DEBUG")
Expand Down Expand Up @@ -627,6 +628,14 @@ def barrier_worker(self):
Returns:
None
Examples:
.. code-block:: python
import paddle.distributed.fleet as fleet
fleet.init()
fleet.barrier_worker()
"""
self._role_maker._barrier("worker")

Expand Down