
    ȅi
                         % 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J	r	  SS/r
\ R                  " \5      r\ R                  \S'   Sq\S-  \S'   Sq\R$                  S-  \S'   SS	\S
\SS4S jjrSS jrg)    N)_WorkerServer)get_ranktcpstore_clientstart_debug_serverstop_debug_serverlogger_WORKER_SERVER_DEBUG_SERVER_PROCportworker_portreturnc                    [         b   S5       e[        b   S5       e[        R                  SU 5        [	        5       n[        SU5      q [        5       nUR                  SU 3S[        R                  " 5        S[         R                   35        SS	KJn  US:X  a+  [        R                  " X@4S
S9q[        R                  5         gg)a  
Start the debug server stack on all workers. The frontend debug server is
only started on rank0 while the per rank worker servers are started on all
ranks.

This server provides an HTTP frontend that allows for debugging slow and
deadlocked distributed jobs across all ranks simultaneously. This collects
data such as stack traces, FlightRecorder events, and performance profiles.

This depends on dependencies which are not installed by default.

Dependencies:
- Jinja2
- aiohttp

WARNING: This is intended to only be used in trusted network environments.
The debug server is not designed to be secure and should not be exposed to
the public internet. See SECURITY.md for more details.

WARNING: This is an experimental feature and may change at any time.

Args:
    port (int): The port to start the frontend debug server on.
    worker_port (int): The port to start the worker server on. Defaults to 0, which
        will cause the worker server to bind to an ephemeral port.
Nzdebug server already startedz Starting debug server on port %dz::rankzhttp://:r   )mainT)targetargsdaemon)r	   r
   r   infor   r   r   setsocketgethostnamer   !torch.distributed.debug._frontendr   multiprocessingProcessstart)r   r   storeRANKr   s        Z/home/james-whalen/.local/lib/python3.13/site-packages/torch/distributed/debug/__init__.pyr   r      s    : !A#AA!%E'EE%
KK2D9E"45N:D	IITFmwv'9'9';&<An>Q>Q=RST6qy,44gd
 	  "	     c                      [         c   e[        c   e[        R                  S5        [         R	                  5         [        R                  5         [         R                  5         SqSq g)zG
Shutdown the debug server and stop the frontend debug server process.
NzStopping debug server)r
   r	   r   r   	terminateshutdownjoin r    r   r   r   H   sX     )))%%%
KK'(  "Nr    )ie  r   )r   N)loggingr   r   !torch.distributed.debug._handlerstorchtorch._C._distributed_c10dr   torch.distributed.debug._storer   r   __all__	getLogger__name__r   Logger__annotations__r	   r
   r   intr   r   r%   r    r   <module>r1      s       ) 4 D 
 !**84 4'+$ +59 O++d2 9/#S /#s /#4 /#dr    