ó
    Eñi!(  ã            	       óê  • % S SK JrJr  S SKrS SKrS SKrS SKJ	r	J
r
  S SKJr  S SKJrJrJr  SSKJr  0 q\\\	S	\
\\\\4      4   4   \S
'   SS/rS rS\S\\\4   4S jrS\\\4   S\4S jrS\S\S\S-  4S jrS$S\S\S\4S jjrS r S r!S\4S jr"S\4S jr# S%S\4S jjr$\4S\S\4S jjr%\4S\S\4S  jjr&\" S!\%5        \" S"\&5        \" S#\"5        g! \ a  r\" S5      \eSrCff = f)&é    )ÚurlparseÚ
urlunparsezEurllib cannot be found, urlparse from python2 is no longer supported.N)ÚCallableÚIterator)Ú	timedelta)Ú	FileStoreÚStoreÚTCPStoreé   )Údefault_pg_timeout.Ú_rendezvous_handlersÚregister_rendezvous_handlerÚ
rendezvousc                 óH   • U [         ;   a  [        SU  S35      eU[         U '   g)a�  
Register a new rendezvous handler.

Before we can run collective algorithms, participating processes
need to find each other and exchange information to be able to
communicate. We call this process rendezvous.

The outcome of the rendezvous process is a triplet containing a
shared key/value store, the rank of the process, and the total
number of participating processes.

If none of the bundled rendezvous methods apply to your execution
environment you can opt to register your own rendezvous handler.
Pick a unique name and use the URL scheme to identify it when
calling the `rendezvous()` function.

Args:
    scheme (str): URL scheme to identify your rendezvous handler.
    handler (function): Handler that is invoked when the
        `rendezvous()` function is called with a URL that uses
        the corresponding scheme. It must be a generator function
        that yields the triplet.
zRendezvous handler for z:// already registeredN)r   ÚRuntimeError)ÚschemeÚhandlers     ÚY/home/mande/repo/quber/.venv/lib/python3.13/site-packages/torch/distributed/rendezvous.pyr   r      s.   € ð2 Ô%Ó%ÜÐ4°V°HÐ<RÐSÓTÐTØ#*Ô˜Ò ó    ÚqueryÚreturnc                 ó€   • S [        S U R                  S5      5       5        Vs0 s H  nUS   US   _M     sn$ s  snf )Nc              3   óB   #   • U  H  oR                  S 5      v •  M     g7f)Ú=N)Úsplit)Ú.0Úpairs     r   Ú	<genexpr>Ú!_query_to_dict.<locals>.<genexpr><   s   é € ÐPÒ1O¨—Z‘Z —_�_Ò1Oùs   ‚Ú&r   r   )Úfilterr   )r   r   s     r   Ú_query_to_dictr"   9   sL   € ñ Q´¸¸e¿k¹kÈ#Ó>NÔ1OÔPóâPˆDð 	ˆQ‰��a‘ÒÙPñð ùò s   ¥;Ú
query_dictc                 óö   • [         R                  S:X  a3  U R                  S[        R                  R                  SS5      5      S:H  $ U R                  S[        R                  R                  SS5      5      S:H  $ )NÚwin32Ú	use_libuvÚ	USE_LIBUVÚ0Ú1)ÚsysÚplatformÚgetÚosÚenviron)r#   s    r   Ú_get_use_libuv_from_query_dictr/   @   s[   € ô ‡|�|�wÓà�~‰~˜k¬2¯:©:¯>©>¸+ÀsÓ+KÓLÐPSÑSÐSØ�>‰>˜+¤r§z¡z§~¡~°kÀ3Ó'GÓHÈCÑOÐOr   ÚurlÚrankÚworld_size_optc                 óþ  • [        U 5      nUce  SnUR                  S:X  aR  [        [        R                  R                  SU5      5      n[        [        R                  R                  SU5      5      nOUnUS:w  d	  US:w  d  Uc­  [        UR                  5      nSU;   d  SU;   a  [        SU  S35      eUS:w  a  [        U5      US'   US:w  d  Uc  [        U5      US'   UR                  S	R                  UR                  5        VVs/ s H  u  pxU S
U 3PM     snn5       S9n[        U5      n UR                  [        ;  a  [        SUR                   S35      e[        UR                     " U 40 UD6$ s  snnf )NéÿÿÿÿÚenvÚRANKÚ
WORLD_SIZEr1   Ú
world_sizez	The url: z7 has node-specific arguments(rank, world_size) already.r    r   )r   zNo rendezvous handler for z://)r   r   Úintr-   r.   r,   r"   r   ÚAssertionErrorÚstrÚ_replaceÚjoinÚitemsr   r   r   )	r0   r1   r2   ÚkwargsÚresultr8   r#   ÚkÚvs	            r   Ú_rendezvous_helperrC   I   so  € Ü�c‹]€FØÑØˆ
Ø�=‰=˜EÓ!Ü”r—z‘z—~‘~ f¨dÓ3Ó4ˆDäœRŸZ™ZŸ^™^¨L¸*ÓEÓFˆJøà#ˆ
Øˆrƒz�Z 2Ó%¨Ñ)?Ü# F§L¡LÓ1ˆ
Ø�ZÓ <°:Ó#=Ü Ø˜C˜5Ð WÐXóð ð �2‹:Ü!$ T£ˆJ�vÑØ˜Ó˜~Ñ5Ü'*¨:£ˆJ�|Ñ$Ø—‘Ø—X‘X°j×6FÑ6FÔ6HÔIÒ6H©d¨a !  A a S›zÑ6HÒIÓJÐKð !ð 
ˆô ˜Ó ˆà‡}�}Ô0Ó0ÜÐ7¸¿¹°ÀcÐJÓKÐKÜ §¡Ò.¨sÑ=°fÑ=Ð=ùó Js   Ä	E9r8   c                 ó:  • [        U [        [        45      (       d  [        S[	        U 5       SU  35      e[        U[
        R                  5      (       d  [        SU 35      e[        U[
        R                  5      (       d  [        SU 35      e[        XU40 UD6$ )Nz`url` must be a string. z: z`rank` must be an integer. z!`world_size` must be an integer. )Ú
isinstancer;   Úbytesr   ÚtypeÚnumbersÚIntegralrC   )r0   r1   r8   r?   s       r   r   r   h   sŽ   € Ü�cœC¤˜<×(Ñ(ÜÐ5´d¸3³i°[ÀÀ3À%ÐHÓIÐIä�dœG×,Ñ,×-Ñ-ÜÐ8¸¸Ð?Ó@Ð@ä�j¤'×"2Ñ"2×3Ñ3ÜÐ>¸z¸lÐKÓLÐLä˜c¨Ñ>°vÑ>Ð>r   c                 óN   • [        [        U R                  US 5      5      u  n  nU$ ©N)ÚnextrC   Úinit_method)Úbackend_optionsr1   ÚstoreÚ_s       r   Ú_create_store_from_optionsrQ   u   s'   € ÜÔ)¨/×*EÑ*EÀtÈTÓRÓS�K€Eˆ1ˆaØ€Lr   c                 ó   • [        SU -   5      $ )Nz+Error initializing torch.distributed using )Ú
ValueError©Úmsgs    r   Ú_rendezvous_errorrV   z   s   € ÜÐCÀcÑIÓJÐJr   c              +   ó  #   • S n[        U 5      nUR                  n[        R                  S:X  a^  SS KnUR
                  UR                  -   nUR                  R                  U5      nU(       a  [        R                  R                  U5      nU(       d  U" S5      e[        UR                  5      nSU;  a  U" S5      eSU;  a  U" S5      e[        US   5      n[        US   5      n	[        XI5      n
X¨U	4v •  [        S	5      e7f)
Nc                 ó   • [        SU -   5      $ )Nzfile:// rendezvous: ©rV   rT   s    r   Ú_errorÚ(_file_rendezvous_handler.<locals>._error   s   € Ü Ð!7¸#Ñ!=Ó>Ð>r   r%   r   zpath missingr1   úrank parameter missingr8   úworld size parameter missingz3Unable to perform rerendezvous using file:// method)r   Úpathr*   r+   Úurllib.requestÚnetlocÚrequestÚurl2pathnamer-   Únormpathr"   r   r9   r   r   )r0   r?   rZ   r@   r^   ÚurllibÚ	full_pathr#   r1   r8   rO   s              r   Ú_file_rendezvous_handlerrf   ~   sï   é € ò?ô �c‹]€FØ�;‰;€DÜ
‡|�|�wÓÛà—M‘M F§K¡KÑ/ˆ	Ø�~‰~×*Ñ*¨9Ó5ˆÞä—7‘7×#Ñ# DÓ)ˆDæÙ�^Ó$Ð$Ü §¡Ó-€JØ�ZÓÙÐ-Ó.Ð.Ø˜:Ó%ÙÐ3Ó4Ð4äˆz˜&Ñ!Ó"€DÜ�Z Ñ-Ó.€JÜ�dÓ'€EØ˜
Ð
#Ò#ô ÐLÓ
MÐMùs   ‚DDc                  óZ   • [         R                  R                  SS 5      [        S5      :H  $ )NÚTORCHELASTIC_USE_AGENT_STORET)r-   r.   r,   r;   © r   r   Ú_torchelastic_use_agent_storerj   ž   s!   € Ü�:‰:�>‰>Ð8¸$Ó?Ä3ÀtÃ9ÑLÐLr   c           
      óž   • SUs=::  a  S:  d  O  [        SU S35      e[        5       (       a  [        U UUSUS9$ US:H  n[        U UUUUSUS9$ )	aG  
Smartly creates a c10d Store object on ``rank`` based on whether we need to reuse agent store.

The TCPStore server is assumed to be hosted
on ``hostname:port``.

By default, the TCPStore server uses the asynchronous implementation
``LibUVStoreDaemon`` which utilizes libuv.

If ``torchelastic_use_agent_store()`` is ``True``, then it is assumed that
the agent leader (node rank 0) hosts the TCPStore server (for which the
endpoint is specified by the given ``hostname:port``). Hence
ALL ranks will create and return a TCPStore client (e.g. ``start_daemon=False``).

If ``torchelastic_use_agent_store()`` is ``False``, then rank 0 will host
the TCPStore (with multi-tenancy) and it is assumed that rank 0's hostname
and port are correctly passed via ``hostname`` and ``port``. All
non-zero ranks will create and return a TCPStore client.
r   i   z-port must have value from 0 to 65535 but was Ú.F)Ú	host_nameÚportr8   Ú	is_masterÚtimeoutT)rm   rn   r8   ro   rp   Úmulti_tenantr&   )rS   rj   r
   )Úhostnamern   r1   r8   rp   r&   Ústart_daemons          r   Ú_create_c10d_storert   ¢   sx   € ð. �Õ�uÕÜÐHÈÈÈaÐPÓQÐQä$×&Ñ&äØØØ!ØØñ
ð 	
ð ˜q‘yˆÜØØØ!Ø"ØØØñ
ð 	
r   rp   c              +   ó–  #   • S n[        U 5      nUR                  c  U" S5      e[        UR                  5      nSU;  a  U" S5      eSU;  a  U" S5      e[	        US   5      n[	        US   5      n[        U5      nUR                  c  [        S5      e[        UR                  UR                  XgX5      n	X–U4v •  [        S5      e7f)	Nc                 ó   • [        SU -   5      $ )Nztcp:// rendezvous: rY   rT   s    r   rZ   Ú'_tcp_rendezvous_handler.<locals>._errorÕ   ó   € Ü Ð!6¸Ñ!<Ó=Ð=r   zport number missingr1   r\   r8   r]   zhostname cannot be Nonez3Unable to perform re-rendezvous using tcp:// method)
r   rn   r"   r   r9   r/   rr   r:   rt   r   )
r0   rp   r?   rZ   r@   r#   r1   r8   r&   rO   s
             r   Ú_tcp_rendezvous_handlerry   Ò   sÕ   é € ò>ô �c‹]€FØ‡{�{ÑÙÐ*Ó+Ð+Ü §¡Ó-€JØ�ZÓÙÐ-Ó.Ð.Ø˜:Ó%ÙÐ3Ó4Ð4äˆz˜&Ñ!Ó"€DÜ�Z Ñ-Ó.€JÜ.¨zÓ:€Ià‡�ÑÜÐ6Ó7Ð7äØ�‰˜Ÿ™ d¸ó€Eð ˜
Ð
#Ò#ô ÐLÓ
MÐMùs   ‚CC	c              +   ó¤  ^^#   • S mU4S jmS[         S[         4U4S jjn[        U 5      n[        UR                  5      nSU;   a  [	        US   5      nO[	        U" S5      5      nSU;   a  [	        US   5      nO[	        U" S	5      5      nU" S
5      n[	        U" S5      5      n	[        U5      n
[        X‰XgX5      nX¶U4v •  [        S5      e7f)Nc                 ó   • [        SU -   5      $ )Nzenv:// rendezvous: rY   rT   s    r   rZ   Ú'_env_rendezvous_handler.<locals>._errorõ   rx   r   c                 ó   >• T" SU  S35      $ )Nzenvironment variable z expected, but not setri   )ÚvarrZ   s    €r   Ú
_env_errorÚ+_env_rendezvous_handler.<locals>._env_errorø   s   ø€ ÙÐ-¨c¨UÐ2HÐIÓJÐJr   Úenv_varr   c                 óf   >• [         R                  R                  U S 5      nU(       d  T" U 5      eU$ rK   )r-   r.   r,   )r�   Úenv_valr   s     €r   Ú_get_env_or_raiseÚ2_env_rendezvous_handler.<locals>._get_env_or_raiseû   s*   ø€ Ü—*‘*—.‘. ¨$Ó/ˆÞÙ˜WÓ%Ð%àˆNr   r1   r6   r8   r7   ÚMASTER_ADDRÚMASTER_PORTz3Unable to perform re-rendezvous using env:// method)r;   r   r"   r   r9   r/   rt   r   )r0   rp   r?   r„   r@   r#   r1   r8   Úmaster_addrÚmaster_portr&   rO   r   rZ   s               @@r   Ú_env_rendezvous_handlerrŠ   ò   sÝ   ùé € ò>õKð¤3ð ¬3÷ ô �c‹]€FÜ §¡Ó-€Jð �ÓÜ�:˜fÑ%Ó&‰äÑ$ VÓ,Ó-ˆà�zÓ!Ü˜ LÑ1Ó2‰
äÑ*¨<Ó8Ó9ˆ
á# MÓ2€KÜÑ'¨Ó6Ó7€KÜ.¨zÓ:€IäØ $°Gó€Eð ˜
Ð
#Ò#ô ÐLÓ
MÐMùs   „CCÚtcpr5   Úfile)r4   r4   )T)'Úurllib.parser   r   ÚImportErrorÚerH   r-   r*   Úcollections.abcr   r   Údatetimer   Útorch.distributedr   r	   r
   Ú	constantsr   r   Údictr;   Útupler9   Ú__annotations__Ú__all__r   r"   Úboolr/   rC   r   rQ   rV   rf   rj   rt   ry   rŠ   ri   r   r   Ú<module>r™      s›  ððß1ó Û 	Û 
ß .Ý ç 8Ñ 8å )ð TVÐ �d˜3 ¨¨h°u¸UÀCÈ¸_Ñ7MÑ.NÐ)NÑ OÐOÑPÓ Uà(¨,Ð
7€ò+ð@˜#ð  $ s¨C x¡.ô ðP¨t°C¸°H©~ð PÀ$ô Pð>˜Cð > sð >¸CÀ$¹Jô >ñ>
?�Cð 
?˜sð 
?°Sõ 
?òò
KðN #ô Nð@M tô Mð
 :>ñ-
à
õ-
ðb $6ñNØ	ðNØ õNðB $6ñ-NØ	ð-NØ õ-Nñ` ˜EÐ#:Ô ;Ù ˜EÐ#:Ô ;Ù ˜FÐ$<Õ =øðA	 ó Ù
ØOóàðûðús   ‚C ÃC2Ã$	C-Ã-C2