ó
    EñiÙ&  ã                   óP  • % S SK r S SKrS SKrS SKrS SKJr  S SKJr  S SKJ	r	  S SK
r
S SKJr  S/r\ R                  " \5      rS q\R&                  " 5       rS\4S jr\" 5       (       a'  \
R.                  R1                  5       (       d  \" S5      e\" 5       (       Ga
  \" \
R.                  R6                  S	5      rS SKrS SKJs  Jr   S S
K!J"r"  S SK#J$r$J%r%J&r&J'r'J(r(J)r)J*r*J+r+J,r,J-r-J.r.J/r/J0r0J1r1J2r2J3r3J4r4J5r5J6r6J7r7J8r8J9r9J:r:J;r;J<r<J=r=J>r>J?r?J@r@JArA  \(       a
  S SK#JBrBJCrCJDrD  SSKEJFrFJGrGJHrH  SSKF7  SSKGJIrI  SSKJJKrK  SSKLJMrM  \\N\"\O\O4   SS4   \PS'   \/ SQ-  r\\FR                  -   \GR                  -   r    SS jrQS rR\IR¦                  SSSSS4S jrT\FRª                  S 5       rVgg)é    N)Ú	Generator)Ú	timedelta)ÚurlparseÚis_availableÚreturnc                  ó6   • [        [        R                  S5      $ )NÚ	_rpc_init)ÚhasattrÚtorchÚ_C© ó    Ú[/home/mande/repo/quber/.venv/lib/python3.13/site-packages/torch/distributed/rpc/__init__.pyr   r      s   € Ü”5—8‘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           	      ó  • [         R                  R                  S5        Ub*  [        U[        R
                  5      (       d  [        S5      eUb   [        U[        5      (       d  [        S5      eUc|  Uby  [
         H5  n[        U[        [        R                  " U5      5      5      (       d  M3  Un  O   [        SU 35      eU[
        R                  :w  a  [        R                  SSU05        Uc  [
        R                  nUc  [        R                  " U5      nU(       d  [        R                  " XB5      nO2[        R                  " UR                   X#S9q[%        ["        5      u  n  nUR'                  [)        UR*                  S	95        [,           [        R.                  " [1        S
[2         35      U5      n[2        S-  qSSS5        [4        R6                  " U5        [9        U5        [;        XXX45        g! , (       d  f       N== f)a›  
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ØÑ¤zØÔ%×1Ñ1÷(
ñ (
ô ÐNÓOÐOàÑ*´:ØÔ!2÷4
ñ 4
ô ØWóð ð
 ‰?Ð2Ñ>ß%0Ð!ÜØ'ÜÜ(×FÒFØ-óó÷ó ð 0�GÙñ &1ô  Ø:Ð;NÐ:OÐPóð ð œ+×0Ñ0Ó0Ü—‘ðEð  Ð(ôð ‰?Ü!×,Ñ,ˆGàÑ&ä"2×"PÒ"PØó#Ðö
 ô ×3Ò3Ð4GÓN‰Eô #'§/¢/Ø#×/Ñ/°dñ#Ðô Ô2Ó3‰KˆE�1�aà×Ñœ)Ð,?×,KÑ,KÑLÔMö  ä×$Ò$¤S¨;´}°oÐ)FÓ%GÈÓOˆEÜ˜QÑˆM÷  ô 	×Ò˜DÔ!ä˜dÔ#ä˜'¨$°jÕV÷  Õús   Æ1G;Ç;
H	c                 óB  • U [         R                  U[        R                  U[        U[
        R                  U[
        R                  [        S 5      4U[        0nUR                  5        H2  u  px[        Xx5      (       a  M  [        SU SU S[        U5       35      e   g )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Ñ1Ø”4—:‘:Ø”#Ø”'×"Ñ"àœ×)Ñ)¬4°«:Ð6ØÔ!2ð
ˆð *×/Ñ/Ö1‰MˆCÜ˜c×,Ó,Ü"Ø ˜uÐ$5°h°Z¸~ÌdÐSVËiÈ[ÐYóð ò 2r   c           	      ó°   • [        XX#XE5        [        5       (       a  [        S5      e[        R                  " U UUUUUS9n[
        R                  " U5        g )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   ã   sY   € ô 	˜7¨4°zÔWä$×&Ñ&ÜÐ;Ó<Ð<ô %×1Ò1ØØØØØ!Ø 3ñ
ˆ	ô 	×Ò˜YÕ'r   c                  óÆ   • [        5       n U R                  [        R                  " 5       R	                  5       5        U R                  [
        R                  " 5       5        U $ )N)r$   Úupdater3   r   Úget_debug_inforV   Ú_get_debug_info)Úinfos    r   rn   rn   ü   sB   € ä+Ó-ˆØ�‰”C×.Ò.Ó0×?Ñ?ÓAÔBØ�‰”M×1Ò1Ó3Ô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‹      s�  ðä Û 	Û Û Ý %Ý Ý !ã Ý  ð Ð
€ð 
×	Ò	˜8Ó	$€ð €Ø—^’^Ó%Ð ð*�dô *ñ ‡>�>˜%Ÿ(™(×,Ñ,×.Ñ.Ù
ÐCÓ
DÐDñ ‡>‚>Ù&Ø�‰×!Ñ!Ð#Eó Ðó ç6Ð6Ý0÷÷ ÷ ÷ ÷ ÷ ÷ ÷ öB  ÷	
ñ 	
÷ 3Ñ2ÜÝ-Ý4ÝNà" 5¨°°S¨Ñ#9¸4ÀÐ#EÑFÓFàÒIÑI€GØ˜Ÿ™Ñ#Ð&6×&>Ñ&>Ñ>€Gð ØØØ ôuWònð" ×&Ñ&ØØØØØ ô(ð2 	×Ññó ñð{ r   