/usr/local/lib64/python3.6/site-packages/torch/distributed/launcher/__pycache__
NameSizeModeActions
api.cpython-36.pyc93140644editdlrm
__init__.cpython-36.pyc2770644editdlrm
Edit: /usr/local/lib64/python3.6/site-packages/torch/distributed/launcher/__pycache__/api.cpython-36.pyc (9314B)
3 Eg+)@sfddlZddlZddlmZmZddlmZmZmZm Z m Z m Z m Z m Z ddljjjjZddlmZmZddlmZmZddlmZddlmZddlmZdd l m!Z!dd l"m#Z#dd l$m%Z%e%Z&eGd d d Z'GdddZ(e'ej)dddZ*e ee+dfe ee+dddZ,e!e e e+e e-fdddZ.e'e ee+dfe eee-efdddZ/dS)N) dataclassfield)AnyCallableDictListOptionalUnioncastTuple)eventsmetrics) WorkerSpec WorkerState)LocalElasticAgent)Std)ChildFailedError)RendezvousParameters)parse_rendezvous_endpoint) get_loggerc@seZdZUdZeeedZe dZ e  dZ e  dZ e  e edZee efd ZedZedZed Ze d Zee ejZeeeeeffejZeeeeeffe edZee e fd d Zd S) LaunchConfiga Creates a rendezvous config. Args: min_nodes: Minimum amount of nodes that the user function will be launched on. Elastic agent ensures that the user function start only when the min_nodes amount enters the rendezvous. max_nodes: Maximum amount of nodes that the user function will be launched on. nproc_per_node: On each node the elastic agent will launch this amount of workers that will execute user defined function. rdzv_backend: rdzv_backend to use in the rendezvous (zeus-adapter, etcd). rdzv_endpoint: The endpoint of the rdzv sync. storage. rdzv_configs: Key, value pair that specifies rendezvous specific configuration. rdzv_timeout: Legacy argument that specifies timeout for the rendezvous. It is going to be removed in future versions, see the note below. The default timeout is 900 seconds. rdzv_id: The unique run id of the job (if not passed a unique one will be deduced from run environment - flow workflow id in flow - or auto generated). role: User defined role of the worker (defaults to "trainer"). max_restarts: The maximum amount of restarts that elastic agent will conduct on workers before failure. monitor_interval: The interval in seconds that is used by the elastic_agent as a period of monitoring workers. start_method: The method is used by the elastic agent to start the workers (spawn, fork, forkserver). log_dir: base log directory where log files are written. If not set, one is created in a tmp dir but NOT removed on exit. redirects: configuration to redirect stdout/stderr to log files. Pass a single ``Std`` enum to redirect all workers, or a mapping keyed by local_rank to selectively redirect. tee: configuration to "tee" stdout/stderr to console + log file. metrics_cfg: configuration to initialize metrics. ..note: `rdzv_timeout` is a legacy argument that will be removed in future. Set the timeout via `rdzv_configs['timeout']` Z default_roleZetcd)default_factoryspawnNcCs4d}|jdkr|j|jd<nd|jkr0||jd<dS)Nirtimeout) rdzv_timeout rdzv_configs)selfZdefault_timeoutr"J/usr/local/lib64/python3.6/site-packages/torch/distributed/launcher/api.py __post_init__Ws   zLaunchConfig.__post_init__r) __name__ __module__ __qualname____doc__int min_nodes max_nodesnproc_per_noderun_idstrrole rdzv_endpoint rdzv_backendrdictr rrr max_restartsmonitor_intervalfloat start_methodlog_dirrrNONE redirectsr tee metrics_cfgr$r"r"r"r#rs$ ) rc@s2eZdZdZeeeedfdddZddZ dS)elastic_launcha Launches an torchelastic agent on the container that invoked the entrypoint. 1. Pass the ``entrypoint`` arguments as non ``kwargs`` (e.g. no named parameters)/ ``entrypoint`` can be a function or a command. 2. The return value is a map of each worker's output mapped by their respective global rank. Usage :: def worker_fn(foo): # ... def main(): # entrypoint is a function. outputs = elastic_launch(LaunchConfig, worker_fn)(foo) # return rank 0's output return outputs[0] # entrypoint is a command and ``script.py`` is the python module. ouptuts = elestic_launch(LaunchConfig, "script.py")(args) ouptuts = elestic_launch(LaunchConfig, "python")("script.py") N)config entrypointcCs||_||_dS)N)_config _entrypoint)r!r=r>r"r"r#__init__zszelastic_launch.__init__cGst|j|jt|S)N) launch_agentr?r@list)r!argsr"r"r#__call__szelastic_launch.__call__) r%r&r'r(rr rr.rArEr"r"r"r#r<_sr<)r=returncCs6|j|j|jd}tjdtjjttt tj f|dS)N)r1r-r/z&torch.distributed.elastic.launch_agent)namesourcemetadata) r1r-r/r EventZ EventSourceZAGENTr rr.ZEventMetadataValue)r=rIr"r"r#_construct_events rK)r>rDrFcCsFt|tr|jSt|tr>|tjkr8tdd|DdS|SndSdS)aRetrive entrypoint name with the rule: 1. If entrypoint is a function, use ``entrypont.__qualname__``. 2. If entrypoint is a string, check its value: 2.1 if entrypoint equals to ``sys.executable`` (like "python"), use the first element from ``args`` which does not start with hifen letter (for example, "-u" will be skipped). 2.2 otherwise, use ``entrypoint`` value. 3. Otherwise, return empty string. css|]}|ddkr|VqdS)r-Nr").0argr"r"r# sz'_get_entrypoint_name..rN) isinstancerr%r.sys executablenext)r>rDr"r"r#_get_entrypoint_names   rT)rdzv_parametersrFcCsX|jdkrdS|j}|j}|s(tdt|dd\}}|d krPtd|d||fS) NZstaticzKEndpoint is missing in endpoint. Try to add --master_addr and --master_portr) default_portzport is missing in endpoint: z. Try to specify --master_port)NNrr)backendendpointstrip ValueErrorr)rUrX master_addr master_portr"r"r#_get_addr_and_ports r])r=r>rDrFc Cs|js*ttjj}tjd|||_t||}tjd|d|j d|j d|j d|jd|j d|j d |jd |jd |jd |jd |jdtf|j |j |j|j |j d|j}d}tj|}t|\}} zyt|j|j |t|||j|j|j|j|| d } |jr$tj|jnd} tj| t| |j |jd}|j!} t"j#|j$t%j&| j'rxt(|| j)dn| j*SWnVt(k rYn@t+k r|rt"j#|j$t%j,nt"j#t-|YnXWd|j.XdS)Nz*config has no run_id, generate a new one: zDStarting elastic_operator with launch configs: entrypoint : z min_nodes : z max_nodes : z nproc_per_node : z run_id : z rdzv_backend : z rdzv_endpoint : z rdzv_configs : z max_restarts : z monitor_interval : z log_dir : z metrics_cfg :  )rWrXr-r*r+) r/Zlocal_world_sizer>rD rdzv_handlerr3r4r9r:r[r\)specr6r7)rGfailures)/r-r.uuiduuid4r)loggerwarningrTinfor*r+r,r1r0r r3r4r7r;r rdzv_registryZget_rendezvous_handlerr]rr/tupler9r:r Z MetricsConfigZinitialize_metricsrr6runr recordZget_agent_status_eventrZ SUCCEEDEDZ is_failedrraZ return_values ExceptionZFAILEDrKshutdown) r=r>rDr-Zentrypoint_namerUZagentr_r[r\r`cfgresultr"r"r#rBsb f        rB)0rQrbZ dataclassesrrtypingrrrrrr r r Z-torch.distributed.elastic.rendezvous.registryZ distributedZelasticZ rendezvousregistryrgZtorch.distributed.elasticr r Z*torch.distributed.elastic.agent.server.apirrZ:torch.distributed.elastic.agent.server.local_elastic_agentrZ)torch.distributed.elastic.multiprocessingrZ0torch.distributed.elastic.multiprocessing.errorsrZ$torch.distributed.elastic.rendezvousrZ*torch.distributed.elastic.rendezvous.utilsrZ'torch.distributed.elastic.utils.loggingrrdrr<rJrKr.rTr)r]rBr"r"r"r#s0(      D'