+
    &j2                         ^ RI t ^RIHtHt ]],          ] P                  ,          tR.t	R R lt
R R ltR R	 lt]'       d   ^ R
IHt M]t ! R R]4      tR# )    N)_is_tensorpipe_available	constantsTensorPipeRpcBackendOptionsc                D    V ^8  d   QhR\         R\        P                  /# )   devicereturn)
DeviceTypetorchr   )formats   "u/Users/jameslopez/projects/CWCArchive/cwc-podcast/.venv/lib/python3.14/site-packages/torch/distributed/rpc/options.py__annotate__r      s      z ell     c                     \         P                  ! V 4      p V P                  R 8w  d   \        RV P                   R24      hV # )cudazA`set_devices` expect a list of CUDA devices, but got device type .)r   r   type
ValueError)r   s   &r   
_to_devicer      sE    \\&!F{{f!;;-q*
 	
 Mr   c                    V ^8  d   QhR\         \        \        3,          R\         \        P                  \        P                  3,          /# )r   
device_mapr	   )dictr
   r   r   )r   s   "r   r   r      s8      Z+,	%,,
$%r   c           	          / p/ pV P                  4        FX  w  r4\        P                  ! V4      \        P                  ! V4      rCWB9   d   \        R V RW$,           RV 24      hWAV&   W2V&   KZ  	  V# )z9`device_map` only supports 1-to-1 mapping, trying to map  and  to )itemsr   r   r   )r   full_device_mapreverse_mapkvs   &    r   _to_device_mapr!      s     9;O46K  "||AQ1!!"5(8QCA  A # r   c                p    V ^8  d   QhR\         \        ,          R\         \        P                  ,          /# )r   devicesr	   )listr
   r   r   )r   s   "r   r   r   '   s(     * *T*- *$u||2D *r   c                 4    \        \        \        V 4      4      # N)r$   mapr   r#   s   &r   _to_device_listr)   '   s    J())r   ) _TensorPipeRpcBackendOptionsBasec                      a a ] tR t^2t oRtR]P                  R]P                  R]P                  RRRRRRR	R/V3R
 lV 3R lllt	V3R lV 3R llt
V3R lR ltRtVtV ;t# )r   a  
The backend options for
:class:`~torch.distributed.rpc.TensorPipeAgent`, derived from
:class:`~torch.distributed.rpc.RpcBackendOptions`.

Args:
    num_worker_threads (int, optional): The number of threads in the
        thread-pool used by
        :class:`~torch.distributed.rpc.TensorPipeAgent` to execute
        requests (default: 16).
    rpc_timeout (float, optional): The default timeout, in seconds,
        for RPC requests (default: 60 seconds). If the RPC has not
        completed in this timeframe, an exception indicating so will
        be raised. Callers can override this timeout for individual
        RPCs in :meth:`~torch.distributed.rpc.rpc_sync` and
        :meth:`~torch.distributed.rpc.rpc_async` if necessary.
    init_method (str, optional): The URL to initialize the distributed
        store used for rendezvous. It takes any value accepted for the
        same argument of :meth:`~torch.distributed.init_process_group`
        (default: ``env://``).
    device_maps (Dict[str, Dict], optional): Device placement mappings from
        this worker to the callee. Key is the callee worker name and value
        the dictionary (``Dict`` of ``int``, ``str``, or ``torch.device``)
        that maps this worker's devices to the callee worker's devices.
        (default: ``None``)
    devices (List[int, str, or ``torch.device``], optional): all local
        CUDA devices used by RPC agent. By Default, it will be initialized
        to all local devices from its own ``device_maps`` and corresponding
        devices from its peers' ``device_maps``. When processing CUDA RPC
        requests, the agent will properly synchronize CUDA streams for
        all devices in this ``List``.
num_worker_threadsrpc_timeoutinit_methoddevice_mapsNr#   _transports	_channelsc                   < V ^8  d   QhRS[ RS[RS[RS[S[S[S[S[3,          3,          R,          RS[S[,          R,          RS[R,          RS[R,          /# )	r   r,   r-   r.   r/   Nr#   r0   r1   )intfloatstrr   r
   r$   )r   __classdict__s   "r   r   (TensorPipeRpcBackendOptions.__annotate__T   s~     
 
  
 	

 
 #tJ
$:;;<tC
 j!D(
 D[
 $;
r   c          	        < Vf   / M-VP                  4        UU	u/ uF  w  rV\        V	4      bK  	  up	pp
Vf   . M
\        V4      p\        SV `  VVVVVV
V4       R # u up	pi r&   )r   r!   r)   super__init__)selfr,   r-   r.   r/   r#   r0   r1   r   r    full_device_mapsfull_device_list	__class__s   &$$$$$$$    r   r:   $TensorPipeRpcBackendOptions.__init__T   sy     " 3>3D3D3FG3F41!^A&&3FG 	
 ")2og6N	
 Hs   Ac                <   < V ^8  d   QhRS[ RS[S[S[3,          /# )r   tor   )r5   r   r
   )r   r6   s   "r   r   r7   o   s%     85 85 85$z:7M2N 85r   c           
       < \        V4      p\        SV `  pW9   d^   VP                  4        FI  w  rVWTV,          9   g   K  WdV,          V,          8w  g   K*  \	        RV RV RWA,          V,           24      h	  \        SV `  W4       R# )a  
Set device mapping between each RPC caller and callee pair. This
function can be called multiple times to incrementally add
device placement configurations.

Args:
    to (str): Callee name.
    device_map (Dict of int, str, or torch.device): Device placement
        mappings from this worker to the callee. This map must be
        invertible.

Example:
    >>> # xdoctest: +SKIP("distributed")
    >>> # both workers
    >>> def add(x, y):
    >>>     print(x)  # tensor([1., 1.], device='cuda:1')
    >>>     return x + y, (x + y).to(2)
    >>>
    >>> # on worker 0
    >>> options = TensorPipeRpcBackendOptions(
    >>>     num_worker_threads=8,
    >>>     device_maps={"worker1": {0: 1}}
    >>> # maps worker0's cuda:0 to worker1's cuda:1
    >>> )
    >>> options.set_device_map("worker1", {1: 2})
    >>> # maps worker0's cuda:1 to worker1's cuda:2
    >>>
    >>> rpc.init_rpc(
    >>>     "worker0",
    >>>     rank=0,
    >>>     world_size=2,
    >>>     backend=rpc.BackendType.TENSORPIPE,
    >>>     rpc_backend_options=options
    >>> )
    >>>
    >>> x = torch.ones(2)
    >>> rets = rpc.rpc_sync("worker1", add, args=(x.to(0), 1))
    >>> # The first argument will be moved to cuda:1 on worker1. When
    >>> # sending the return value back, it will follow the invert of
    >>> # the device map, and hence will be moved back to cuda:0 and
    >>> # cuda:1 on worker0
    >>> print(rets[0])  # tensor([2., 2.], device='cuda:0')
    >>> print(rets[1])  # tensor([2., 2.], device='cuda:1')
z=`set_device_map` only supports 1-to-1 mapping, trying to map r   r   N)r!   r9   r/   r   r   _set_device_map)r;   rA   r   r   curr_device_mapsr   r    r>   s   &&&    r   set_device_map*TensorPipeRpcBackendOptions.set_device_mapo   s    Z )4 7.!'--/,,r6J16M1M$##$#T!E2B2Fq2I1JL  0 	4r   c                0   < V ^8  d   QhRS[ S[,          /# )r   r#   )r$   r
   )r   r6   s   "r   r   r7      s     
0 
04
#3 
0r   c                &    \        V4      V n        R# )a*  
Set local devices used by the TensorPipe RPC agent. When processing
CUDA RPC requests, the TensorPipe RPC agent will properly synchronize
CUDA streams for all devices in this ``List``.

Args:
    devices (List of int, str, or torch.device): local devices used by
        the TensorPipe RPC agent.
N)r)   r#   )r;   r#   s   &&r   set_devices'TensorPipeRpcBackendOptions.set_devices   s     'w/r   r(   )__name__
__module____qualname____firstlineno____doc__rpc_contantsDEFAULT_NUM_WORKER_THREADSDEFAULT_RPC_TIMEOUT_SECDEFAULT_INIT_METHODr:   rE   rI   __static_attributes____classdictcell____classcell__)r>   r6   s   @@r   r   r   2   s     B
 #/"I"I
 *AA	

 (;;
 GK
 ,0
 $(
 "&
 
685 85t
0 
0 
0r   )r    r   r   rP   r3   r5   r   r
   __all__r   r!   r)   torch._C._distributed_rpcr*   objectr    r   r   <module>r\      sS     A 3Y%
(
)"* J'-$A0"B A0r   