
    9iP,                     l   S SK r 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                  R7                  \R4                  R9                  \5      5      S:X  aN  \R4                  R9                  \R4                  R9                  \R4                  R9                  \5      5      5      rO4\R4                  R9                  \R4                  R9                  \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\S\S\4S jr)S r*S  r+S! r,S" r-S# r.SFS$ jr/SFS% jr0S&\4S' jr1S( r2S\34S) jr4S\34S* jr5S&\S+\S,\S-\4S. jr6SGS\S0\3S\34S1 jjr7S\S\84S2 jr9S\34S3 jr:\ Rv                  S4 5       r<S\	\=\\84      4S5 jr>S6r?S7r@S/rASrBSrCS8\S\	\   4S9 jrDS:\'\\4   S;\E\   S<\S=\84S> jrFS:\'\\4   4S? jrGS@ rHSA rISB rJSC\	\   4SD jrKS\	\   4SE jrLg)H    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    U/var/www/html/land-doc-ocr/venv/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   .   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$   2   s<    	yyrww277#3#3D#9::r   c                     g r    r#   s    r   #prepare_multiprocessing_environmentr'   8       r   c                 @    [         R                  R                  U 5      $ r   )r   r   realpathr#   s    r   resolve_library_pathr+   <   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_errorr3   @   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)r8   r9   r;   r6   r4   s      r   wrapper_functiondcompile_time_strobelight_meta.<locals>.compile_time_strobelight_meta_inner.<locals>.wrapper_functionT   sp    Jvf~/Ets$K$K!%v 2990001FF*'+/5 r   )	functoolswrapsr
   r8   r9   r	   )r6   rA   r4   s   ` r   #compile_time_strobelight_meta_innerJcompile_time_strobelight_meta.<locals>.compile_time_strobelight_meta_innerQ   sE     
	"	BGG 	ryy 	R 	 
#	  r   r   r
   r	   )r4   rE   s   ` r   compile_time_strobelight_metarH   N   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   t   s    HH[(*5r   insightinsight_descriptionc                     g r   r&   )rI   rQ   rR   s      r   add_mlhub_insightrT   x   r(   r   c                 0    [         R                  SU 5        g )Nz%srM   )metricss    r   log_compilation_eventrW   |   s    HHT7r   c                     g r   r&   )graphs    r   upload_graphrZ      r(   r   c                      g r   r&   r&   r   r   +set_pytorch_distributed_envs_from_justknobsr\      r(   r   c                      g r   r&   r9   s    r   log_export_usager_      r(   r   c                      g r   r&   r^   s    r   log_draft_export_usagera      r(   r   c                      g r   r&   r8   r9   s     r   log_trace_structured_eventrd      r(   r   c                      g r   r&   rc   s     r   log_cache_bypassrf      r(   r   apic                     U ng r   r&   )rg   r9   _s      r   log_torchscript_usagerj      s
    A
r   c                      gNFr&   r&   r   r   check_if_torch_exportablerm          r   c                      gNTr&   r&   r   r    export_training_ir_rollout_checkrq          r   c                      grp   r&   r&   r   r   full_aoti_runtime_assertrt      rr   r   type_of_exportexport_outcomeresultc                     XX#4u        ng r   r&   )rg   ru   rv   rw   ri   s        r   !log_torch_jit_trace_exportabilityry      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   rz   s     r   justknobs_checkr|      s	    . Nr   c                     g)z!
Read warning on justknobs_check
r   r&   )rJ   s    r   justknobs_getval_intr~      s     r   c                      grl   r&   r&   r   r   is_fb_unit_testr      rn   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)z
unit: MHz
r   )nvsmizclocks.max.sm:r<   gfx94i  gfx90agfx908i  gfx12gfx11gfx103i  gfx101ix  gfx95iL  )
torchversionhiptriton.testingr   strcudaget_device_propertiesgcnArchNamesplit)r   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      rr   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   c                      grp   r&   r&   r   r   1profiler_allow_cudagraph_cupti_lazy_reinit_cuda12r   !  rr   r   c                  \    S[         [        [        4   S[         [        [        4   4S jn U $ )a  
When we deprecate a function that might still be in use, we make it internal
by adding a leading underscore. This decorator is used with a private function,
and creates a public alias without the leading underscore, but has a deprecation
warning. This tells users "THIS FUNCTION IS DEPRECATED, please use something else"
without breaking them, however, if they still really really want to use the
deprecated function without the warning, they can do so by using the internal
function name.
funcr   c                    U R                   R                  S5      (       d  [        S5      eU R                   SS  n[        R                  U R
                     n[        X!5      (       a  [        SU SUR                    S35      eU R                   SS   S3n[        R                  " U[        SS9" U 5      nXl         S	U R                  ;   a+  U R                  R                  S	S5      S
   S	-   U-   Ul        OXl        [        X!U5        U $ )Nri   z@deprecate must decorate a function whose name starts with a single leading underscore (e.g. '_foo') as the api should be considered internal for deprecation.r<   zCannot create alias 'z' -> symbol already exists in zP.                  Please rename it or consult a pytorch developer on what to doz= is DEPRECATED, please consider using an alternative API(s). )rI   
stacklevel.r   )__name__
startswith
ValueErrorr-   r.   
__module__hasattrRuntimeErrortyping_extensions
deprecatedUserWarning__qualname__rsplitsetattr)r   public_namer1   warning_msgaliass        r   	decoratordeprecated.<locals>.decorator0  s   ((--B 
 mmAB'T__- 6'''}4RSYSbSbRc dO P 
 qr*++hi ",,+!

 % $###!%!2!2!9!9#q!A!!Ds!J[!XE!,U+r   rG   )r   s    r   r   r   %  s0    #R( #Xb"f-= #J r   c                      g)a  
When using elastic agent, if no numa options are provided, we will use these
as the default.

For external use cases, we return None, i.e. no numa binding. If you would like
to use torch's automatic numa binding capabilities, you should provide
NumaOptions to your launch config directly or use the numa binding option
available in torchrun.

Must return None or NumaOptions, but not specifying to avoid circular import.
Nr&   r&   r   r   get_default_numa_optionsr   X  s     r   failc                     g r   r&   )r   s    r   log_triton_buildsr   g  r(   r   c                      g)z4
Allows overriding the binary used for subprocesses
Nr&   r&   r   r   find_compile_subproc_binaryr   k  s     r   )r   N)T)MrC   loggingr   r-   r    r   typingr   r   r   r   r   r   (torch._strobelight.compile_time_profilerr   r	   r
   	getLoggerr   rN   environgetshutilwhichrO   enabler   r"   dirname__file__r   r   r   r   r$   r'   r+   r3   rH   dictrP   rT   rW   rZ   r\   r_   ra   rd   rf   rj   rm   boolrq   rt   ry   r|   r>   r~   r   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   r   r   r&   r   r   <module>r      sx     	 
   3 3 '  S T]t_!::>>-u55<<''\	
 	KL&--/ 77BGGOOH-.(:77??277??277??83L#MNL77??277??8#<=L8C 8C 8*c *c *;C ;C ;	c 	d 	"s "s "

//xB (2r6"223/L6S 6 6c3h 6	 	c 	 							s 
$ $ 	  	#   4s s    B8E#s(O#<      !& 
 # c hsm 
S>9  	S>0f	HSM 	Xc] r   