Ë
    P/æj5  ã                   óN  — d dl Z d dlZd dlmZ d dlmZ d dlmZmZ d dlm	Z	  e j                  d«      Z e j                  «       Z e j                  d«      Zej!                  e«       ej#                  e«       ej%                  e j&                  «       de_         G d	„ d
«      Zy)é    N)Údatetime)Úgethostname)ÚAnyÚOptional)ÚStrobelightCLIFunctionProfilerÚ!strobelight_compile_time_profilerzB%(name)s, line %(lineno)d, %(asctime)s, %(levelname)s: %(message)sFc                   óî  — e Zd ZU dZeed<   dZeed<   dZeed<   dZe	ed<   dZ
e	ed<   dZee   ed	<   dZee   ed
<   dZee   ed<    eej$                  j'                  dd«      «      Zeed<    eej$                  j'                  dd«      «      Zeed<    e eej$                  j'                  dd«      «      «      Zeed<   eefdeddfd„«       Zedd„«       Zedd„«       Zedededededef
d„«       Zy) ÚStrobelightCompileTimeProfilerr   Úsuccess_profile_countÚfailed_profile_countÚignored_profile_runsFÚinside_profile_compile_timeÚenabledNÚ
identifierÚcurrent_phaseÚprofilerÚ$COMPILE_STROBELIGHT_MAX_STACK_LENGTHé   Úmax_stack_lengthÚ$COMPILE_STROBELIGHT_MAX_PROFILE_TIMEi  Úmax_profile_timeÚCOMPILE_STROBELIGHT_SAMPLE_RATEg    ÐcAÚsample_eachÚprofiler_classÚreturnc                 ó  — | j                   rt        j                  d«       y t        j                  d«       |t        u r+dd l}|j                  d«      st        j                  d«       y d| _         | j                  «         || j                  | j                  | j                  | j                  dt        j                  j                  dt        j                  j                  d	d
«      «      z   | j                  h¬«      | _        y )Nz2compile time strobelight profiling already enabledz*compile time strobelight profiling enabledr   Ústrobeclientznstrobeclient not found, cant enable compile time strobelight profiling, seemslike you are not on a FB machine.Tzpt2-profiler/ÚUSERÚUSERNAMEÚ )r   Úmax_profile_duration_secÚstack_max_lenÚasync_stack_max_lenÚrun_user_nameÚsample_tags)r   ÚloggerÚinfor   ÚshutilÚwhichÚ	_cls_initr   r   r   ÚosÚenvironÚgetr   r   )Úclsr   r(   s      úk/root/repos/pocs/video-evals/.venv/lib/python3.12/site-packages/torch/_strobelight/compile_time_profiler.pyÚenablez%StrobelightCompileTimeProfiler.enable2   sÈ   € à�;Š;Ü�K‰KÐLÔMØä�‰Ð@ÔAàÔ;Ñ;Ûà—<‘< Ô/Ü—‘ð8ôð àˆŒØ�‰Œñ &ØŸ™Ø%(×%9Ñ%9Ø×.Ñ.Ø #× 4Ñ 4Ø)Ü�j‰j�n‰n˜V¤R§Z¡Z§^¡^°JÀÓ%CÓDñEàŸ™Ð(ô
ˆ�ó    c                 ó4  — dj                  t        j                  «       j                  d«      t	        j
                  «       t        «       ¬«      | _        t        j                  d| j                  «       t        j                  dd| j                  › d�«       y )Nz{date}{pid}{hostname}z%Y-%m-%d-%H:%M:%S)ÚdateÚpidÚhostnamez%Unique sample tag for this run is: %szZYou can use the following link to access the strobelight profile at the end of the run: %sa*  https://www.internalfb.com/intern/scuba/query/?dataset=pyperf_experimental%2Fon_demand&drillstate=%7B%22purposes%22%3A[]%2C%22end%22%3A%22now%22%2C%22start%22%3A%22-30%20days%22%2C%22filterMode%22%3A%22DEFAULT%22%2C%22modifiers%22%3A[]%2C%22sampleCols%22%3A[]%2C%22cols%22%3A[%22namespace_id%22%2C%22namespace_process_id%22]%2C%22derivedCols%22%3A[]%2C%22mappedCols%22%3A[]%2C%22enumCols%22%3A[]%2C%22return_remainder%22%3Afalse%2C%22should_pivot%22%3Afalse%2C%22is_timeseries%22%3Afalse%2C%22hideEmptyColumns%22%3Afalse%2C%22timezone%22%3A%22America%2FLos_Angeles%22%2C%22compare%22%3A%22none%22%2C%22samplingRatio%22%3A%221%22%2C%22metric%22%3A%22count%22%2C%22aggregation_field%22%3A%22async_stack_complete%22%2C%22top%22%3A10000%2C%22aggregateList%22%3A[]%2C%22param_dimensions%22%3A[%7B%22dim%22%3A%22py_async_stack%22%2C%22op%22%3A%22edge%22%2C%22param%22%3A%220%22%2C%22anchor%22%3A%220%22%7D]%2C%22order%22%3A%22weight%22%2C%22order_desc%22%3Atrue%2C%22constraints%22%3A[[%7B%22column%22%3A%22sample_tags%22%2C%22op%22%3A%22all%22%2C%22value%22%3A[%22[%5C%22z¯%5C%22]%22]%7D]]%2C%22c_constraints%22%3A[[]]%2C%22b_constraints%22%3A[[]]%2C%22ignoreGroupByInComparison%22%3Afalse%7D&view=GraphProfilerView&&normalized=1712358002&pool=uber)
Úformatr   ÚnowÚstrftimer+   Úgetpidr   r   r&   r'   ©r.   s    r/   r*   z(StrobelightCompileTimeProfiler._cls_initR   s}   € à0×7Ñ7Ü—‘“×(Ñ(Ð)<Ó=Ü—	‘	“Ü “]ð 8ó 
ˆŒô 	�‰Ð;¸S¿^¹^ÔLÜ�‰Øhð#ð $'§>¡>Ð"2ð 3HðHõ	
r1   c                 ót   — t         j                  d| j                  | j                  | j                  z   «       y )NzG%s strobelight success runs out of %s non-recursive compilation events.)r&   r'   r   r   r:   s    r/   Ú
_log_statsz)StrobelightCompileTimeProfiler._log_statss   s.   € ä�‰ØUØ×%Ñ%Ø×%Ñ%¨×(@Ñ(@Ñ@õ	
r1   ÚfuncÚ
phase_nameÚargsÚkwargsc                 ó  — | j                   s ||i |¤ŽS | j                  €t        j                  d«       y | j                  r>| xj
                  dz  c_        t        j                  d|| j                  «        ||i |¤ŽS d| _        || _         | j                  j                  |g|¢­i |¤Ž}| j                  j                  �| xj                  dz  c_
        n| xj                  dz  c_        | j                  «        d| _        |S )Nzprofiler is not seté   zjprofile_compile_time is requested for phase: %s while already in running phase: %s, recursive call ignoredTF)r   r   r&   Úerrorr   r   r'   r   ÚprofileÚprofile_resultr   r   r<   )r.   r=   r>   r?   r@   Úwork_results         r/   Úprofile_compile_timez3StrobelightCompileTimeProfiler.profile_compile_time|   sö   € ð �{Š{Ù˜Ð( Ñ(Ð(à�<‰<ÐÜ�L‰LÐ.Ô/Øà×*Ò*Ø×$Ò$¨Ñ)Õ$Ü�K‰KØ|ØØ×!Ñ!ôñ
 ˜Ð( Ñ(Ð(à*.ˆÔ'Ø&ˆÔà*�c—l‘l×*Ñ*¨4ÐA°$ÒA¸&ÑAˆà�<‰<×&Ñ&Ð2Ø×%Ò%¨Ñ*Ö%à×$Ò$¨Ñ)Õ$à�‰ÔØ*/ˆÔ'ØÐr1   )r   N)Ú__name__Ú
__module__Ú__qualname__r   ÚintÚ__annotations__r   r   r   Úboolr   r   r   Ústrr   r   r   r+   r,   r-   r   r   Úfloatr   Úclassmethodr   r0   r*   r<   rG   © r1   r/   r
   r
      se  … Ø!"Ð˜3Ó"Ø !Ð˜#Ó!Ø !Ð˜#Ó!Ø(-Ð Ó-Ø€GˆTÓð !%€J�˜‘Ó$à#'€M�8˜C‘=Ó'à"€Hˆh�s‰mÓ"áØ
�
‰
�‰Ð=¸sÓCóÐ�có ñ  Ø
�
‰
�‰Ð=¸wÓGóÐ�có ñ Ùˆb�j‰j�n‰nÐ>ÀÓDÓEó€K�ó ð Ø*Hñ 
 Cð 
ÈTò 
ó ð
ð> ò
ó ð
ð@ ò
ó ð
ð ðØðØ$'ðØ03ðØ?Bðà	òó ñr1   r
   )Úloggingr+   r   Úsocketr   Útypingr   r   Ú(torch._strobelight.cli_function_profilerr   Ú	getLoggerr&   ÚStreamHandlerÚconsole_handlerÚ	FormatterÚ	formatterÚsetFormatterÚ
addHandlerÚsetLevelÚINFOÚ	propagater
   rQ   r1   r/   ú<module>r`      s•   ðó Û 	Ý Ý ß  å Sð 
ˆ×	Ñ	Ð>Ó	?€à'�'×'Ñ'Ó)€ØˆG×ÑØHó€	ð × Ñ ˜YÔ 'à × Ñ �/Ô "Ø ‡��—‘Ô Ø€Ô ÷Cò Cr1   