
    [Thz!                     >   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JrJrJ	r	  S SK
Jr  S SKrS SKJr  \	" S5      r\" S5      r\R"                  " \5      r\R(                  R+                  SS5      (       aO  S SKr\R.                  " S	5      (       d  \R1                  S
5        O"\R1                  S5        \R2                  " 5         \R4                  " 5       (       a  SrO\R8                  R;                  \R8                  R=                  \5      5      S:X  aN  \R8                  R=                  \R8                  R=                  \R8                  R=                  \5      5      5      rO4\R8                  R=                  \R8                  R=                  \5      5      rS\ S\ 4S jr!S\ S\ 4S jr"S\ S\ 4S jr#S\ SS4S jr$S\ S\ 4S jr%S r&S\ S\\\\4   /\\\4   4   4S jr'S\ S\ S\(\ \4   4S jr)S r*S r+S r,S  r-S<S! jr.S<S" jr/S#\ 4S$ jr0S% r1S\24S& jr3S#\ S'\ S(\ S)\ 4S* jr4S=S\ S,\2S\24S- jjr5S\ S\64S. jr7S\24S/ jr8\ Rr                  " S5      S0 5       r:S\\;\ \64      4S1 jr<S2r=S3r>S+r?Sr@SrAS4\ S\\    4S5 jrBS6\(\ \4   S7\C\    S8\ S9\64S: jrDS6\(\ \4   4S; jrEg)>    N)AnyCallableOptionalTypeVar)	ParamSpec)StrobelightCompileTimeProfiler_T_PTORCH_COMPILE_STROBELIGHTFstrobeclientzNTORCH_COMPILE_STROBELIGHT is true, but seems like you are not on a FB machine.z8Strobelight profiler is enabled via environment variable sharedpath_componentsreturnc                  L    [         R                  R                  " [        /U Q76 $ N)ospathjointorch_parentr   s    M/var/www/auris/envauris/lib/python3.13/site-packages/torch/_utils_internal.pyget_file_pathr   /   s    77<<777    c                  <    [         R                  R                  " U 6 $ r   )r   r   r   r   s    r   get_file_path_2r   3   s    77<<))r   r   c                     [         R                  " U [         R                  5      (       a  U $ [        R                  " [         R
                  R                  U 5      S9$ )N)suffix)r   accessW_OKtempfilemkdtempr   basenamer   s    r   get_writable_pathr%   7   s<    	yyrww277#3#3D#9::r   c                     g r    r$   s    r   #prepare_multiprocessing_environmentr(   =       r   c                 @    [         R                  R                  U 5      $ r   )r   r   realpathr$   s    r   resolve_library_pathr,   A   s    77D!!r   c                 l    U[         R                  ;   a  [        U  S35      e[        U  SU SU 35      e)Nz5: We could not find the fake impl for this operator. zm: We could not find the fake impl for this operator. The operator specified that you may need to import the 'z'' Python module to load the fake impl. )sysmodulesNotImplementedError)opnamemodulecontexts      r   &throw_abstract_impl_not_imported_errorr4   E   sU    !hKL
 	
 "h GGMh O44;9>
 	
r   
phase_namec                 d   ^  S[         [        [        4   S[         [        [        4   4U 4S jjnU$ )Nfunctionr   c                    >^  [         R                  " T 5      S[        R                  S[        R                  S[
        4U U4S jj5       nU$ )Nargskwargsr   c                     > SU;   a"  [        US   =n[        5      (       a  US-   US'   [        R                  (       d  T" U 0 UD6$ [        R                  " TT/U Q70 UD6$ )Nskip   )
isinstanceintr   enabledprofile_compile_time)r9   r:   r<   r7   r5   s      r   wrapper_functiondcompile_time_strobelight_meta.<locals>.compile_time_strobelight_meta_inner.<locals>.wrapper_functionY   sp    Jvf~/Ets$K$K!%v 2990001FF*'+/5 r   )	functoolswrapsr
   r9   r:   r	   )r7   rB   r5   s   ` r   #compile_time_strobelight_meta_innerJcompile_time_strobelight_meta.<locals>.compile_time_strobelight_meta_innerV   sE     
	"	BGG 	ryy 	R 	 
#	  r   )r   r
   r	   )r5   rF   s   ` r   compile_time_strobelight_metarH   S   s2     2r6" 	"b&	 & /.r   categoryname
parametersc                 2    [         R                  SXU5        g )Nz	%s %s: %rloginfo)rI   rJ   rK   s      r   signpost_eventrP   y   s    HH[(*5r   c                 0    [         R                  SU 5        g )Nz%srM   )metricss    r   log_compilation_eventrS   }   s    HHT7r   c                     g r   r'   )graphs    r   upload_graphrV      r)   r   c                      g r   r'   r'   r   r   +set_pytorch_distributed_envs_from_justknobsrX      r)   r   c                      g r   r'   )r:   s    r   log_export_usagerZ      r)   r   c                      g r   r'   r9   r:   s     r   log_trace_structured_eventr]      r)   r   c                      g r   r'   r\   s     r   log_cache_bypassr_      r)   r   apic                     U ng r   r'   )r`   r:   _s      r   log_torchscript_usagerc      s
    A
r   c                      gNFr'   r'   r   r   check_if_torch_exportablerf          r   c                      g)NTr'   r'   r   r    export_training_ir_rollout_checkri          r   type_of_exportexport_outcomeresultc                     XX#4u        ng r   r'   )r`   rk   rl   rm   rb   s        r   !log_torch_jit_trace_exportabilityro      s     n<JAq!Q
r   Tdefaultc                     U$ )a-  
This function can be used to killswitch functionality in FB prod,
where you can toggle this value to False in JK without having to
do a code push.  In OSS, we always have everything turned on all
the time, because downstream users can simply choose to not update
PyTorch.  (If more fine-grained enable/disable is needed, we could
potentially have a map we lookup name in to toggle behavior.  But
the point is that it's all tied to source code in OSS, since there's
no live server to query.)

This is the bare minimum functionality I needed to do some killswitches.
We have a more detailed plan at
https://docs.google.com/document/d/1Ukerh9_42SeGh89J-tGtecpHBPwGlkQ043pddkKb3PU/edit
In particular, in some circumstances it may be necessary to read in
a knob once at process start, and then use it consistently for the
rest of the process.  Future functionality will codify these patterns
into a better high level API.

WARNING: Do NOT call this function at module import time, JK is not
fork safe and you will break anyone who forks the process and then
hits JK again.
r'   )rJ   rp   s     r   justknobs_checkrr      s	    . Nr   c                     g)z!
Read warning on justknobs_check
r   r'   )rJ   s    r   justknobs_getval_intrt      s     r   c                      gre   r'   r'   r   r   is_fb_unit_testrv      rg   r   c                  `   [         R                  R                  (       d  SSKJn   U " S/5      S   $ [        [         R                  R                  S5      R                  R                  SS5      S   5      nSU;   a  gSU;   a  gS	U;   a  g
SU;   a  gSU;   a  gSU;   a  gSU;   a  gSU;   a  gg)Nr   )nvsmizclocks.max.sm:r=   gfx94i  gfx90agfx908i  gfx12gfx11gfx103i  gfx101ix  gfx95iL  )
torchversionhiptriton.testingrx   strcudaget_device_propertiesgcnArchNamesplit)rx   gcn_archs     r   max_clock_rater      s    ==(o&'**
 uzz77:FFLLSRSTUVWXh!!  !! r   c                      g r   r'   r'   r   r   get_mast_job_name_versionr      rj   r   z	127.0.0.1i<s  profile_pathc                     [        S5        g )Nz1Uploading profile stats (fb-only otherwise no-op))print)r   s    r   #maybe_upload_prof_stats_to_manifoldr     s    	
=>r   eventstacklogger_uuidstart_time_nsc                     g r   r'   )r   r   r   r   s       r   log_chromium_event_internalr     s     r   c                     g r   r'   )r   s    r   record_chromium_event_internalr     s     r   )r   N)T)FrD   loggingr   r.   r!   typingr   r   r   r   typing_extensionsr   r   (torch._strobelight.compile_time_profilerr   r	   r
   	getLogger__name__rN   environgetshutilwhichrO   enable_running_with_deployr   r   r#   dirname__file__r   r   r   r%   r(   r,   r4   rH   dictrP   rS   rV   rX   rZ   r]   r_   rc   rf   boolri   ro   rr   r?   rt   rv   	lru_cacher   tupler   TEST_MASTER_ADDRTEST_MASTER_PORTUSE_GLOBAL_DEPSUSE_RTLD_GLOBAL_WITH_LIBTORCHREQUIRES_SET_PYTHON_MODULEr   listr   r   r'   r   r   <module>r      s6     	 
  3 3 '  S T]t_!::>>-u55<<''\	
 	KL&--/ 	 L	ww12h>wwrwwrwwx7P'QRwwrwwx'@A8C 8C 8*c *c *;C ;C ;	c 	d 	"s "s "

//xB (2r6"223/L6S 6 6c3h 6					s 
$ 	  	#   4s s   T <8E#s(O#<      !& 
 # c hsm 
S>9  	S>r   