ó
    CC˜j/  ã                   ó†  • S SK r 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  S SKJ	r	  S SK
Jr  \R                  " S5      r\R                  " 5       r\R                   " S5      r\R%                  \5        \R'                  \5        \R)                  \R*                  5        S\l        S	\S
\4S jrS\S
\4S jr " S S5      rg)é    N)Údatetime)Úgethostname)ÚAny)ÚStrobelightCLIFunctionProfilerÚ!strobelight_compile_time_profilerzB%(name)s, line %(lineno)d, %(asctime)s, %(levelname)s: %(message)sFÚurlÚreturnc                 ó  • U n [         R                  " SU /S[         R                  S9nUR                  S:X  a  UR                  R                  S5      nU$ ! [         a*  n[        R                  S[        U5      5         S nAU$ S nAff = f)NÚfburlT)Úcapture_outputÚstdinr   zutf-8z)URL shortening failed: %s, using long URL)
Ú
subprocessÚrunÚDEVNULLÚ
returncodeÚstdoutÚdecodeÚ	ExceptionÚloggerÚwarningÚrepr)r   Ú	short_urlÚresultÚes       Ú¶C:\Users\johnn\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.13_qbz5n2kfra8p0\LocalCache\local-packages\Python313\site-packages\torch/_strobelight/compile_time_profiler.pyÚ	get_fburlr      sˆ   € Ø€IðMÜ—’Ø�cˆN¨4´z×7IÑ7Iñ
ˆð ×Ñ Ó!ØŸ™×,Ñ,¨WÓ5ˆIð Ðøô ó MÜ�‰ÐBÄDÈÃG×LÐLØÐûðMús   „AA Á
BÁ!BÂBÚ
identifierc                 ó  • 0 S/ _SS_S/ /_S/ /_SSS/_S	S
_SSSSU  S3/S.//_S/ _SS_S/ _SS_SS_SS_SS_S/ _SS_S/ _SS S!S"S#S#S$.// SS%SS&S'S(S).
EnS*nS+nU[         R                  " U5      -   U-   n[        U5      $ ),NÚaggregateListÚaggregation_fieldÚasync_stack_completeÚb_constraintsÚc_constraintsÚcolsÚnamespace_idÚnamespace_process_idÚcompareÚnoneÚconstraintsÚsample_tagsÚallz["z"])ÚcolumnÚopÚvalueÚderivedColsÚendÚnowÚenumColsÚ
filterModeÚDEFAULTÚhideEmptyColumnsÚfalseÚignoreGroupByInComparisonÚis_timeseriesÚ
mappedColsÚmetricÚcountÚ	modifiersÚweightÚtrueÚpy_async_stackÚedgeÚ0)Údimr-   ÚparamÚanchorÚ1z-30 dayszAmerica/Los_Angelesi'  )
ÚorderÚ
order_descÚparam_dimensionsÚpurposesÚreturn_remainderÚsamplingRatioÚshould_pivotÚstartÚtimezoneÚtopz`https://www.internalfb.com/intern/scuba/query/?dataset=pyperf_experimental/on_demand&drillstate=z8&view=GraphProfilerView&&normalized=1726332703&pool=uber)ÚjsonÚdumpsr   )r   Ú
scuba_jsonÚscuba_url_prefixÚscuba_url_suffÚlong_urls        r   Úget_strobelight_urlrV   *   s_  € ð Ø˜ð àÐ3ð ð 	˜"˜ð ð 	˜"˜ð	 ð
 	�Ð!7Ð8ð ð 	�6ð ð 	Ø%¨UÀÀ:À,ÈbÐ>QÐ=RÑSÐTð
ð ð 	�rð ð 	ˆuð ð 	�Bð ð 	�ið ð 	˜Gð ð 	$ Wð ð  	˜ð! ð" 	�bð# ð$ 	�'ð% ð& 	�Rð' ð( Øà$¨F¸SÈCÑPð
ð Ø#ØØØØ)Øò? €JðB zÐØO€NØ¤$§*¢*¨ZÓ"8Ñ8¸>ÑI€HÜ�XÓÐó    c                   ó^  • \ rS rSr% Sr\\S'   Sr\\S'   Sr\\S'   Sr	\
\S'   Sr\
\S'   \R                  R                  S	5      r\S
-  \S'   S
r\S
-  \S'   S
r\S
-  \S'   S
r\S
-  \S'   \" \R                  R                  SS5      5      r\\S'   \" \R                  R                  SS5      5      r\\S'   \" \" \R                  R                  SS5      5      5      r\\S'   \S\4S j5       r\\4S\SS
4S jj5       r\S$S j5       r\S$S j5       r\S\S\S \S!\S\4
S" j5       rS#r g
)%ÚStrobelightCompileTimeProfileréR   r   Úsuccess_profile_countÚfailed_profile_countÚignored_profile_runsFÚinside_profile_compile_timeÚenabledÚ COMPILE_STROBELIGHT_FRAME_FILTERNÚframe_id_filterr   Úcurrent_phaseÚprofilerÚ$COMPILE_STROBELIGHT_MAX_STACK_LENGTHiô  Úmax_stack_lengthÚ$COMPILE_STROBELIGHT_MAX_PROFILE_TIMEi  Úmax_profile_timeÚCOMPILE_STROBELIGHT_SAMPLE_RATEg    ÐcAÚsample_eachr	   c                 ó@   • SSK Jn  [        UR                  5       5      $ )Nr   )ÚCompileContext)Útorch._guardsrk   ÚstrÚcurrent_trace_id)Úclsrk   s     r   Ú	get_frameÚ(StrobelightCompileTimeProfiler.get_frameo   s   € å0ä�^×4Ñ4Ó6Ó7Ð7rW   Úprofiler_classc                 ó   • U R                   (       a  [        R                  S5        g [        R                  S5        U[        L a0  SS KnUR                  S5      (       d  [        R                  S5        g SU l         U R                  5         U" U R                  U R                  U R                  U R                  S[        R                  R                  S[        R                  R                  S	S
5      5      -   U R                  1S9U l        g )Nz2compile time strobelight profiling already enabledz*compile time strobelight profiling enabledr   Ústrobeclientzostrobeclient not found, can't enable compile time strobelight profiling, seemslike you are not on a FB machine.Tzpt2-profiler/ÚUSERÚUSERNAMEÚ )ri   Úmax_profile_duration_secÚstack_max_lenÚasync_stack_max_lenÚrun_user_namer*   )r_   r   Úinfor   ÚshutilÚwhichÚ	_cls_initri   rg   re   ÚosÚenvironÚgetr   rc   )ro   rr   r}   s      r   ÚenableÚ%StrobelightCompileTimeProfiler.enableu   sË   € à�;�;Ü�K‰KÐLÔMØä�‰Ð@ÔAàÔ;Ò;Ûà—<‘< ×/Ñ/Ü—‘ð8ôð àˆŒØ�‰Œñ
 &ØŸ™Ø%(×%9Ñ%9Ø×.Ñ.Ø #× 4Ñ 4Ø)Ü�j‰j�n‰n˜V¤R§Z¡Z§^¡^°JÀÓ%CÓDñEàŸ™Ð(ñ
ˆ�rW   c                 ó<  • SR                  [        R                  " 5       R                  S5      [        R
                  " 5       [        5       S9U l        [        R                  SU R                  5        [        R                  S[        U R                  5      5        g )Nz{date}{pid}{hostname}z%Y-%m-%d-%H:%M:%S)ÚdateÚpidÚhostnamez%Unique sample tag for this run is: %sz?URL to access the strobelight profile at the end of the run: %s)Úformatr   r1   Ústrftimer€   Úgetpidr   r   r   r|   rV   ©ro   s    r   r   Ú(StrobelightCompileTimeProfiler._cls_init—   sl   € à0×7Ñ7Ü—’“×(Ñ(Ð)<Ó=Ü—	’	“Ü “]ð 8ð 
ˆŒô 	�‰Ð;¸S¿^¹^ÔLÜ�‰ØMÜ §¡Ó/õ	
rW   c                 ót   • [         R                  SU R                  U R                  U R                  -   5        g )NzG%s strobelight success runs out of %s non-recursive compilation events.)r   r|   r[   r\   rŒ   s    r   Ú
_log_statsÚ)StrobelightCompileTimeProfiler._log_stats¥   s.   € ä�‰ØUØ×%Ñ%Ø×%Ñ%¨×(@Ñ(@Ñ@õ	
rW   ÚfuncÚ
phase_nameÚargsÚkwargsc                 óX  ^^^• S[         4UUU4S jjnU R                  (       d  U" 5       $ U R                  c  [        R	                  S5        g U R                  5       nU R                  (       a?  U =R                  S-  sl        [        R                  SUUU R                  U5        U" 5       $ U R                  bR  [        R                  " U R                  U5      S LnU(       d(  [        R                  SUU R                  5        U" 5       $ SU l        X l	        [        R                  SU5        U R                  R                  " T/TQ70 TD6nU R                  R                  b  U =R                  S-  sl        OU =R                   S-  sl        U R#                  5         S	U l        U$ )
Nr	   c                  ó   >• T" T 0 TD6$ )N© )r“   r‘   r”   s   €€€r   ÚskipÚAStrobelightCompileTimeProfiler.profile_compile_time.<locals>.skip²   s   ø€ Ù˜Ð( Ñ(Ð(rW   zprofiler is not seté   z~profile_compile_time is requested for phase: %s, frame %s, while already in running phase: %s,frame %s, recursive call ignoredz7profiling frame %s is skipped due to frame_id_filter %sTzprofiling frame %sF)r   r_   rc   r   Úerrorrp   r^   r]   r|   rb   ra   ÚreÚmatchÚprofileÚprofile_resultr[   r\   r�   )	ro   r‘   r’   r“   r”   r˜   Úframe_idÚ
should_runÚwork_results	    ` ``    r   Úprofile_compile_timeÚ3StrobelightCompileTimeProfiler.profile_compile_time®   sb  ú€ ð	)”c÷ 	)ñ 	)ð �{�{Ù“6ˆMà�<‰<ÑÜ�L‰LÐ.Ô/Øà—=‘=“?ˆà×*×*Ø×$Ò$¨Ñ)Õ$Ü�K‰Kð3àØØ×!Ñ!Øôñ “6ˆMà×ÑÑ*ÜŸš #×"5Ñ"5°xÓ@ÈÐLˆJÞÜ—‘ØMØØ×'Ñ'ôñ
 “v�à*.ˆÔ'Ø&ÔÜ�‰Ð(¨(Ô3Ø—l‘l×*Ò*¨4ÐA°$ÒA¸&ÑAˆà�<‰<×&Ñ&Ñ2Ø×%Ò%¨Ñ*Ö%à×$Ò$¨Ñ)Õ$à�‰ÔØ*/ˆÔ'ØÐrW   r—   )r	   N)!Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__r[   ÚintÚ__annotations__r\   r]   r^   Úboolr_   r€   r�   r‚   ra   rm   r   rb   rc   r   re   rg   Úfloatri   Úclassmethodrp   r   rƒ   r   r�   r£   Ú__static_attributes__r—   rW   r   rY   rY   R   sž  ‡ Ø!"Ð˜3Ó"Ø !Ð˜#Ó!Ø !Ð˜#Ó!Ø(-Ð Ó-Ø€GˆTÓð #%§*¡*§.¡.Ð1SÓ"T€O�S˜4‘ZÓTð "€J��d‘
Ó!à $€M�3˜‘:Ó$à€Hˆc�D‰jÓáØ
�
‰
�‰Ð=¸sÓCóÐ�có ñ  Ø
�
‰
�‰Ð=¸wÓGóÐ�có ñ Ùˆb�j‰j�n‰nÐ>ÀÓDÓEó€K�ó ð ð8˜#ó 8ó ð8ð
 Ø*Hñ 
 Cð 
ÈTô 
ó ð
ðB ó
ó ð
ð ó
ó ð
ð ð1Øð1Ø$'ð1Ø03ð1Ø?Bð1à	ó1ó ó1rW   rY   )rP   Úloggingr€   rœ   r   r   Úsocketr   Útypingr   Ú(torch._strobelight.cli_function_profilerr   Ú	getLoggerr   ÚStreamHandlerÚconsole_handlerÚ	FormatterÚ	formatterÚsetFormatterÚ
addHandlerÚsetLevelÚINFOÚ	propagaterm   r   rV   rY   r—   rW   r   Ú<module>r½      s¿   ðó Û Û 	Û 	Û Ý Ý Ý å Sð 
×	Ò	Ð>Ó	?€à×'Ò'Ó)€Ø×ÒØHó€	ð × Ñ ˜YÔ 'à × Ñ �/Ô "Ø ‡��—‘Ô Ø€Ô ð�3ð ˜3ô ð% Cð %¨Cô %÷PNò NrW   