
    sg                     $   U d dl Z d dlZd dlmZmZmZmZmZ d dlm	Z	 d dl
mZ d dlmc mZ d dlmZ g Zee   ed<    ej(                  e      a ed      Z e	d      Zd	eeef   fd
Zd	eeef   fdZ	 ddeded	eeeef   geeef   f   fdZy)    N)AnyCallableDictListTypeVar)	ParamSpec)uuid4)DCP_LOGGER_NAME__all___T_Preturnc                     i }|j                  dd      }|j                  dd      }|j                  dd      }|j                  dd      }|s|xs |x}rt        |dd      }|t        |      n||d<   t        t               j                        |d<   |r|j
                  j                  |d<   |r|j
                  j                  |d<   |r|j
                  j                  |d<   |S )z0
    Extracts log data from dcp method args
    storage_writerNstorage_readerplannercheckpoint_iduuid)getgetattrstrr	   int	__class____name__)argskwargsmsg_dictr   r   r   r   
serializers           V/var/www/html/venv/lib/python3.12/site-packages/torch/distributed/checkpoint/logger.py_msg_dict_from_dcp_method_argsr       s     H ZZ 0$7NZZ 0$7NjjD)GJJ5MN,LnLjL
OTB ,7M] _
 57;;'HV%3%=%=%F%F!"%3%=%=%F%F!"%//88O    c                 f    t        |i |}|j                  t        j                  | fi |       |S )N)r    updatec10d_logger_get_msg_dict)	func_namer   r   r   s       r   r%   r%   7   s2    -t>v>HOOK--iD8DEOr!   log_exceptionswrapper_kwargsc                 >     dt         t        t        f   f fd}|S )zKThis method decorator logs the start, end, and exception of wrapped events.funcc                      t        j                         dt        j                  dt        j                  dt
        f fd       }|S )Nr   r   r   c                     t        j                  g| i i 	|}d|d<   t        j                         }||d<   |d<   t        j                  |       	  | i |}d|d<   t        j                         }t        j                         |d<   ||z
  |d<   t        j                  |       |S # t        $ r?}r7d|d<   | |d<   t        j                         |d<   t        j                  |        d }~ww xY w)	Nstarteventtimer'   	exceptionerrorendtimes_spent)r%   r   r/   time_ns_dcp_loggerdebugBaseExceptionr1   )
r   r   r   t0resultr1   t1r*   r'   r(   s
          r   wrapperz6_dcp_method_logger.<locals>.decorator.<locals>.wrapperD   s   $ $(D>(DV(DH
 !(HWB!HV)7H%&h't.v. !&HWB#||~HV&(2gH]#h'M ! !(3HW%+0'HW%'+||~HV$%%h/s   B/ /	C78:C22C7)	functoolswrapsr   r   r   r   )r*   r;   r'   r(   s   ` r   	decoratorz%_dcp_method_logger.<locals>.decoratorC   sC    			277 	bii 	B 	 
	@ r!   )r   r   r   )r'   r(   r>   s   `` r   _dcp_method_loggerr?   >   s!    
"R( "H r!   )F)r<   r/   typingr   r   r   r   r   typing_extensionsr   r   r	   torch.distributed.c10d_loggerdistributedr$   -torch.distributed.checkpoint.logging_handlersr
   r   r   __annotations___get_or_create_loggerr5   r   r   r    r%   boolr?    r!   r   <module>rI      s      5 5 '  3 3 I c  0k//@T]t_tCH~ Dc3h  !))47)xB (2r6"223)r!   