UserDefinedRoleMaker

class paddle.fluid.incubate.fleet.base.role_maker. UserDefinedRoleMaker ( current_id=0, role=1, worker_num=0, server_endpoints=None ) [source]

UserDefinedRoleMaker is designed for worker and server assignment under manual. Typically, a worker and a server node will be appointed on each physical node, It can be assign by user.

is_worker ( )

return is_worker() of current process

is_server ( )

return is_server() of current process

is_first_worker ( )

Check whether the node is the first instance of worker. :returns:

True if this is the first node of worker,

False if not.

System Message: WARNING/2 (/usr/local/lib/python3.8/site-packages/paddle/fluid/incubate/fleet/base/role_maker.py:docstring of paddle.fluid.incubate.fleet.base.role_maker.UserDefinedRoleMaker.is_first_worker, line 6)

Block quote ends without a blank line; unexpected unindent.

Return type

bool

worker_index ( )

Get current worker id.

Returns

node id

Return type

int

server_index ( )

Get current server id.

Returns

node id

Return type

int

worker_num ( )

Get current total worker number.

Returns

worker number

Return type

int

all_gather ( input )

all gather between trainers and pservers

Parameters

input (int|float) – input value

Returns

return a list of values

all_reduce_worker ( input, output, mode='sum' )

all reduce between trainers if current role is TRAINER, only support array of one dim.

Parameters
  • input (list/numpy.array) – array of one dim

  • output (list/numpy.array) – array of one dim

  • mode (str) – “sum” or “min” or “max”

barrier_all ( )

barrier between trainers if current role is PSERVER

barrier_worker ( )

barrier between trainers if current role is TRAINER

get_pserver_endpoints ( )

return pserver endpoints

get_trainer_endpoints ( )

return trainer endpoints