§
    N�’jË'  ã                   ó  — U d dl Z d dlZd dlZd dlZd dlmZ d dlmZ d dlm	Z	 d dl
Z
d dlmZ dgZ e j        e¦  «        Zd a ej        ¦   «         Zdefd„Z e¦   «         r$e
j                             ¦   «         s ed¦  «        ‚ e¦   «         rñ ee
j        j        d	¦  «        Zd dlZd dlmc mZ  d d
l!m"Z" d dl#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z:m;Z;m<Z<m=Z=m>Z>m?Z?m@Z@mAZA er
d dl#mBZBmCZCmDZD ddlEmFZFmGZGmHZH ddlFT ddlGmIZI ddlJmKZK ddlLmMZM eeNe"eOeOf         ddf         ePd<   eg d¢z  ZeeFj        z   eGj        z   Z	 	 	 	 dd„ZQd„ ZReIjS        dddddfd„ZTeFjU        d„ ¦   «         ZVdS dS )é    N)Ú	Generator)Ú	timedelta)ÚurlparseÚis_availableÚreturnc                  ó6   — t          t          j        d¦  «        S )NÚ	_rpc_init)ÚhasattrÚtorchÚ_C© ó    úLC:\Projects\DSCons\.venv\Lib\site-packages\torch\distributed\rpc\__init__.pyr   r      s   € Ý•5”8˜[Ñ)Ô)Ð)r   z*Failed to initialize torch.distributed.rpcÚ _TensorPipeRpcBackendOptionsBase)ÚStore)Ú_cleanup_python_rpc_handlerÚ_DEFAULT_INIT_METHODÚ_DEFAULT_RPC_TIMEOUT_SECÚ)_delete_all_user_and_unforked_owner_rrefsÚ_destroy_rref_contextÚ_disable_jit_rref_pickleÚ'_disable_server_process_global_profilerÚ_enable_jit_rref_pickleÚ&_enable_server_process_global_profilerÚ_get_current_rpc_agentÚ_invoke_remote_builtinÚ_invoke_remote_python_udfÚ_invoke_remote_torchscriptÚ_invoke_rpc_builtinÚ_invoke_rpc_python_udfÚ_invoke_rpc_torchscriptÚ_is_current_rpc_agent_setÚ_reset_current_rpc_agentÚ_rref_context_get_debug_infoÚ_set_and_start_rpc_agentÚ_set_profiler_node_idÚ_set_rpc_timeoutÚ_UNSET_RPC_TIMEOUTÚenable_gil_profilingÚget_rpc_timeoutÚPyRRefÚRemoteProfilerManagerÚRpcAgentÚRpcBackendOptionsÚ
WorkerInfo)Ú_DEFAULT_NUM_WORKER_THREADSr   ÚTensorPipeAgenté   )ÚapiÚbackend_registryÚ	functions)Ú*)ÚBackendType)ÚTensorPipeRpcBackendOptions)Ú_server_process_global_profileÚrendezvous_iterator)Úinit_rpcr7   r8   éÿÿÿÿc           	      ó*  — t           j                             d¦  «         |�)t          |t          j        ¦  «        st          d¦  «        ‚|�$t          |t          ¦  «        st          d¦  «        ‚|€~|�|t
          D ]5}t          |t          t	          j	        |¦  «        ¦  «        ¦  «        r|} nŒ6t          d|› �¦  «        ‚|t
          j
        k    rt                               dd|i¦  «         |€t
          j
        }|€t	          j	        |¦  «        }|st          j        ||¦  «        }n4t          j        |j        ||¬¦  «        at%          t"          ¦  «        \  }}}|                     t)          |j        ¬	¦  «        ¦  «         t,          5  t          j        t1          d
t2          › �¦  «        |¦  «        }t2          dz  addd¦  «         n# 1 swxY w Y   t5          j        |¦  «         t9          |¦  «         t;          ||| |||¦  «         dS )ak  
        Initializes RPC primitives such as the local RPC agent
        and distributed autograd, which immediately makes the current
        process ready to send and receive RPCs.

        Args:
            name (str): a globally unique name of this node. (e.g.,
                ``Trainer3``, ``ParameterServer2``, ``Master``, ``Worker1``)
                Name can only contain number, alphabet, underscore, colon,
                and/or dash, and must be shorter than 128 characters.
            backend (BackendType, optional): The type of RPC backend
                implementation. Supported values is
                ``BackendType.TENSORPIPE`` (the default).
                See :ref:`rpc-backends` for more information.
            rank (int): a globally unique id/rank of this node.
            world_size (int): The number of workers in the group.
            rpc_backend_options (RpcBackendOptions, optional): The options
                passed to the RpcAgent constructor. It must be an agent-specific
                subclass of :class:`~torch.distributed.rpc.RpcBackendOptions`
                and contains agent-specific initialization configurations. By
                default, for all agents, it sets the default timeout to 60
                seconds and performs the rendezvous with an underlying process
                group initialized using ``init_method = "env://"``,
                meaning that environment variables ``MASTER_ADDR`` and
                ``MASTER_PORT`` need to be set properly. See
                :ref:`rpc-backends` for more information and find which options
                are available.
        ztorch.distributed.init_rpcNz0Argument backend must be a member of BackendTypezEArgument rpc_backend_options must be an instance of RpcBackendOptionsz$Could not infer backend for options zéRPC was initialized with no explicit backend but with options corresponding to %(backend)s, hence that backend will be used instead of the default BackendType.TENSORPIPE. To silence this warning pass `backend=%(backend)s` explicitly.Úbackend)ÚrankÚ
world_size)ÚsecondsÚrpc_prefix_r2   )r   r   Ú_log_api_usage_onceÚ
isinstancer4   r7   Ú	TypeErrorr.   ÚtypeÚconstruct_rpc_backend_optionsÚ
TENSORPIPEÚloggerÚwarningÚdistÚ_create_store_from_optionsÚ
rendezvousÚinit_methodr:   ÚnextÚset_timeoutr   Úrpc_timeoutÚ_init_counter_lockÚPrefixStoreÚstrÚ_init_counterÚdist_autogradÚ_initr&   Ú_init_rpc_backend)Únamer>   r?   r@   Úrpc_backend_optionsÚcandidate_backendÚstoreÚ_s           r   r;   r;   ]   s¨  € õF 	Œ×$Ò$Ð%AÑBÔBÐBØÐ¥zØÕ%Ô1ñ(
ô (
Ðõ ÐNÑOÔOÐOàÐ*µ:ØÕ!2ñ4
ô 4
Ð*õ ØWñô ð ð
 ˆ?Ð2Ð>Ý%0ð ð Ð!ÝØ'ÝÝ(ÔFØ-ñô ñô ñô ð 	ð 0�GØ�Eð	õ  ØPÐ;NÐPÐPñô ð ð �+Ô0Ò0Ð0Ý—’ðEð  Ð(ñô ð ð ˆ?Ý!Ô,ˆGàÐ&å"2Ô"PØñ#ô #Ðð
 ð 	4õ Ô3Ð4GÈÑNÔNˆEˆEõ #'¤/Ø#Ô/°dÀzð#ñ #ô #Ðõ Õ2Ñ3Ô3‰KˆE�1�aà×Ò�)Ð,?Ô,KÐLÑLÔLÑMÔMÐMõ  ð 	ð 	åÔ$¥SÐ)Fµ}Ð)FÐ)FÑ%GÔ%GÈÑOÔOˆEÝ˜QÑˆMð	ð 	ð 	ñ 	ô 	ð 	ð 	ð 	ð 	ð 	ð 	øøøð 	ð 	ð 	ð 	õ 	Ô˜DÑ!Ô!Ð!å˜dÑ#Ô#Ð#å˜' 5¨$°°jÐBUÑVÔVÐVÐVÐVs   Æ5GÇGÇGc                 óB  — | t           j        |t          j        |t          |t
          j        |t
          j        t          d ¦  «        f|t          i}| 	                    ¦   «         D ]:\  }}t          ||¦  «        s%t          d|› d|› dt          |¦  «        › �¦  «        ‚Œ;d S )Nz	Argument z must be of type z but got type )r4   r7   rK   r   rT   ÚnumbersÚIntegralrF   r.   ÚitemsrD   ÚRuntimeError)	r>   r\   rY   r?   r@   rZ   Útype_mappingÚargÚarg_types	            r   Ú_validate_rpc_argsrf   Ô   sµ   € àÕ%Ô1Ø•4”:Ø•#Ø•'Ô"à�Ô)­4°©:¬:Ð6ØÕ!2ð
ˆð *×/Ò/Ñ1Ô1ð 	ð 	‰MˆC�Ý˜c 8Ñ,Ô,ð Ý"ØY ÐYÐY°hÐYÐYÍdÐSVÉiÌiÐYÐYñô ð ðð	ð 	r   c                 óÄ   — t          | |||||¦  «         t          ¦   «         rt          d¦  «        ‚t          j        | |||||¬¦  «        }t          j        |¦  «         d S )NzRPC is already initialized)r\   rY   r?   r@   rZ   )rf   r"   rb   r4   Úinit_backendr3   Ú_init_rpc_states)r>   r\   rY   r?   r@   rZ   Ú	rpc_agents          r   rX   rX   ä   s~   € õ 	˜7 E¨4°°zÐCVÑWÔWÐWå$Ñ&Ô&ð 	=ÝÐ;Ñ<Ô<Ð<õ %Ô1ØØØØØ!Ø 3ð
ñ 
ô 
ˆ	õ 	Ô˜YÑ'Ô'Ð'Ð'Ð'r   c                  óÞ   — t          ¦   «         } |                      t          j        ¦   «                              ¦   «         ¦  «         |                      t          j        ¦   «         ¦  «         | S )N)r$   Úupdater3   r   Úget_debug_inforV   Ú_get_debug_info)Úinfos    r   rn   rn   ý   sT   € å+Ñ-Ô-ˆØ�Š•CÔ.Ñ0Ô0×?Ò?ÑAÔAÑBÔBÐBØ�Š•MÔ1Ñ3Ô3Ñ4Ô4Ð4Øˆr   )Nr<   NN)WÚloggingÚosÚ	threadingÚwarningsÚcollections.abcr   Údatetimer   Úurllib.parser   r   Útorch.distributedÚdistributedrK   Ú__all__Ú	getLoggerÚ__name__rI   rU   ÚLockrR   Úboolr   r   r	   rb   r
   Ú_distributed_rpcÚ_is_tensorpipe_availabler_   Útorch.distributed.autogradÚautogradrV   Útorch._C._distributed_c10dr   Útorch._C._distributed_rpcr   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   r   r1   Ú r3   r4   r5   r7   Úoptionsr8   Úserver_process_global_profilerr9   ÚtupleÚintÚ__annotations__r;   rf   rH   rX   Ú_require_initializedrn   r   r   r   ú<module>r‹      s0  ðà €€€€Ø 	€	€	€	Ø Ð Ð Ð Ø €€€Ø %Ð %Ð %Ð %Ð %Ð %Ø Ð Ð Ð Ð Ð Ø !Ð !Ð !Ð !Ð !Ð !à €€€Ø  Ð  Ð  Ð  Ð  Ð  ð Ð
€ð 
ˆÔ	˜8Ñ	$Ô	$€ð €Ø#�Y”^Ñ%Ô%Ð ð*�dð *ð *ð *ð *ð €<�>„>ð E˜%œ(×,Ò,Ñ.Ô.ð EØ
ˆ,ÐCÑ
DÔ
DÐDð €<�>„>ð bØ&˜wØŒÔ!Ð#Eñ ô  Ðð €N€N€Nà6Ð6Ð6Ð6Ð6Ð6Ð6Ð6Ð6Ø0Ð0Ð0Ð0Ð0Ð0ðð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ðB  ð 
ð	
ð 	
ð 	
ð 	
ð 	
ð 	
ð 	
ð 	
ð 	
ð 	
ð 3Ð2Ð2Ð2Ð2Ð2Ð2Ð2Ð2Ð2ØÐÐÐØ-Ð-Ð-Ð-Ð-Ð-Ø4Ð4Ð4Ð4Ð4Ð4ØNÐNÐNÐNÐNÐNà" 5¨°°S¨Ô#9¸4ÀÐ#EÔFÐFÐFÑFàÐIÐIÐIÑI€Gà˜œÑ#Ð&6Ô&>Ñ>€Gð ØØØ ðuWð uWð uWð uWðnð ð ð" Ô&ØØØØØ ð(ð (ð (ð (ð2 	Ôðð ñ Ôðð ð ð}bð br   