Ë
    ßGìjˆ€  ã                  óR  — d dl mZ d dlmZ d dlZd dlmZ d dlZd dlZd dl	m
Z
 d dlmZ d dlZd dlmZ d dlmZ d d	lmZ d d
lmZ d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d dl m!Z! d dl"Z# ejH                  d ejJ                  dd«      d«      Z& ejN                  d ejP                  dd«      d¬«      Z)dZ* ejV                  e,«       ejZ                  Z- ej\                  e/«      Z0d1d„Z1d „ Z2d2d!„Z3d3d"„Z4d3d#„Z5	 	 	 	 	 	 	 	 	 d4	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d5d$„Z6ejn                  	 	 	 	 	 	 	 	 	 	 d6d%„«       Z8ejn                  	 	 	 	 	 	 	 	 	 	 	 	 d7d&„«       Z9g Z:	 	 d8d'„Z;	 d9	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d:d(„Z<	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d;d)„Z=	 d9	 	 	 	 	 	 	 	 	 	 	 d<d*„Z>	 	 	 	 	 	 	 	 	 	 	 	 d=d+„Z?i e?_@        	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d>d,„ZAi eA_B        	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d?d-„ZCd@d.„ZD	 	 	 	 	 	 	 	 	 	 	 	 dAd/„ZE	 	 	 	 	 	 	 	 	 	 	 	 dBd0„ZFy)Cé    )Úannotations)ÚSequenceN)Úpartial)ÚAny)ÚCallable)Ú	cache_key)Úcompilation_cache)Úconfig)Údistributed)Úlib)Ú
monitoring)Úpath)Úprofiler)Útraceback_util)Úutil)Úmlir)Ú
xla_client)Ú_jax)ÚirÚjax_disable_most_optimizationsÚJAX_DISABLE_MOST_OPTIMIZATIONSFzŽTry not to do much optimization work. This can be useful if the cost of optimization is greater than that of running a less-optimized program.Ú%jax_compiler_detailed_logging_min_opsÚ%JAX_COMPILER_DETAILED_LOGGING_MIN_OPSé
   z¹How big should a module be in MLIR operations before JAX enables detailed compiler logging? The intent of this flag is to suppress detailed logging for small/uninteresting computations.)Úhelpéÿÿÿÿc                 ó   — ~ y)Nr   © )Úbackends    úUC:\Users\Stabi\Downloads\virtual-tryon(1)\venv\Lib\site-packages\jax/_src/compiler.pyÚget_latest_profile_versionr!   K   s   € ØØ	ó    c                óŽ   — |dz  }|dk  r|S | j                   D ])  }|D ]"  }|D ]  }t        ||«      }|dk  sŒ|c c c S  Œ$ Œ+ |S )Né   r   )ÚregionsÚ_walk_operations)ÚopÚkÚregionÚblockÚchild_ops        r    r&   r&   P   sX   € Ø€q�&€!Øˆ‚UØ€HØ—
”
€fÛˆÛˆ(Ü˜X qÓ)ˆØˆq‹5ØŽ(ñ ñ ð ð 
€(r"   c                óT   — t         j                  }t        | j                  |«      dk  S )zBReturns 'true' if detailed logging should be enabled for 'module'.r   )Ú"_COMPILER_DETAILED_LOGGING_MIN_OPSÚvaluer&   Ú	operation)ÚmoduleÚbounds     r    Úuse_detailed_loggingr2   ]   s%   € ä
,×
2Ñ
2€%Ü	˜&×*Ñ*¨EÓ	2°QÑ	6Ð6r"   c                ó¨   — t         j                  j                  rt        j                  nt        j
                  }t        j                  |d| |«       y )Nz5Persistent compilation cache hit for '%s' with key %r)r
   Úlog_compilesr.   ÚloggingÚWARNINGÚDEBUGÚloggerÚlog)Úmodule_namer   Úhit_log_prioritys      r    Úlog_persistent_cache_hitr<   c   s:   € Ü)/×)<Ñ)<×)BÒ)B”g—o’oÜ"Ÿ=™=ð ä‡*�*ÐÐVØ˜)õ%r"   c                óÐ   — t         j                  j                  r$t        j                  «       rt
        j                  nt
        j                  }t        j                  |d| |«       y )Nz6PERSISTENT COMPILATION CACHE MISS for '%s' with key %r)
r
   Úexplain_cache_missesr.   r	   Úis_persistent_cache_enabledr5   r6   r7   r8   r9   )r:   r   Úmiss_log_prioritys      r    Úlog_persistent_cache_missrA   j   sM   € ä!×6Ñ6×<Ò<Ü-×IÑIÔKô —’ô %Ÿ]™]ð ô
 	‡*�*ÐÐ XØ˜)õ%r"   c                óV
  — t        j                  «       }| |_        ||_        |j                  }||_        ||_        t        j                  j                  |_        |�||_
        |r|xs g |_        |xs g |_        |��.t        j                  d| ||«       t        j                   |«      }|j"                  dk(  r|dk(  r	|dd…df   }| |j$                  d   k7  rd}t'        |j)                  || «      «      ‚||j$                  d   k7  rd}t'        |j)                  ||«      «      ‚|j*                  t,        k(  r# t        j.                  d„ t0        g¬«      |«      }t         j2                  j5                  |«      }|j7                  «       | k(  sJ ‚|j9                  «       |k(  sJ ‚||_        t        j<                  j                  |_        t        j>                  j                  |_        t        j@                  t        jB                  j                  «      j                  |_!        t        j@                  t        jD                  j                  «      j                  |_"        |�hd	d
g}|jG                  ddg«       tI        |«      }|D ]#  }||v sŒtK        |||jM                  |«      «       Œ% tO        |jQ                  «       «      |_)        |j                  jT                  }tV        jX                  �tV        jX                  |_-        t\        j                  rd|_/        d|_0        d|_1        t        jd                  j                  sd|_3        t        jh                  j                  }|dkD  r||_5        t        j                  d|«       nftl        |_5        |
€t        jo                  d«       nCtq        |
«      }|dk7  r||_5        t        j                  d|«       nt        js                  d«       |	|_:        tw        jx                  «       �rt{        j|                  t        j~                  j                  xs d«      }t        j€                  j                  xs d}|dk(  sd|v r2|dz  }tƒ        |«      |_B        d|_C        t        j                  d|«       |dk(  sd|v rˆ|dz  }tƒ        |«      |_D        t        j                  d|«       tŠ        jŒ                  jŽ                  dk(  r!t         j�                  j’                  |_J        |S t         j�                  j–                  |_J        |S )aÓ  Returns the compile options to use, as derived from flag values.

  Args:
    num_replicas: Number of replicas for which to compile.
    num_partitions: Number of partitions for which to compile.
    device_assignment: Optional ndarray of jax devices indicating the assignment
      of logical replicas to physical devices (default inherited from
      xla_client.CompileOptions). Must be consistent with `num_replicas` and
      `num_partitions`.
    use_spmd_partitioning: boolean indicating whether to enable SPMD or MPMD
      partitioning in XLA.
    use_auto_spmd_partitioning: boolean indicating whether to automatically
      generate XLA shardings for SPMD partitioner.
    auto_spmd_partitioning_mesh_shape: device mesh shape used to create
      auto_spmd_partitioning search space.
    auto_spmd_partitioning_mesh_ids: device ids used to create
      auto_spmd_partitioning search space.
    env_options_overrides: dict of additional options parsed by the compiler
    fdo_profile: Optional profile for feedback-directed optimization passed to
      XLA.
    detailed_logging: Is this an "interesting" computation about which XLA would
      be wise to log compilation information?
    backend: the client, if available.
  NzKget_compile_options: num_replicas=%s num_partitions=%s device_assignment=%sr$   r   z8device_assignment does not match num_replicas: {} vs {}.z:device_assignment does not match num_partitions: {} vs {}.c                ó   — | j                   S ©N©Úid)Úds    r    Ú<lambda>z%get_compile_options.<locals>.<lambda>¸   s   € °·²r"   )ÚotypesÚexec_time_optimization_effortÚmemory_fitting_effortÚoptimization_levelÚmemory_fitting_levelTFÚrematerializationzSget_compile_options XLA-AutoFDO profile: using JAX XLA profile version %d from flagzGget_compile_options: no backend supplied; disabling XLA-AutoFDO profilezMget_compile_options XLA-AutoFDO profile: using XLA-AutoFDO profile version %dzaget_compile_options XLA-AutoFDO profile: XLA-AutoFDO profile version is 0; this should not happenÚ ÚallÚxla_gpu_kernel_cache_filez!Enabling XLA kernel cache at '%s'Ú%xla_gpu_per_fusion_autotune_cache_dirz%Enabling XLA autotuning cache at '%s')LÚxcÚCompileOptionsÚnum_replicasÚnum_partitionsÚexecutable_build_optionsÚuse_spmd_partitioningÚuse_auto_spmd_partitioningr
   Úuse_shardy_partitionerr.   Úfdo_profileÚ!auto_spmd_partitioning_mesh_shapeÚauto_spmd_partitioning_mesh_idsr8   ÚdebugÚnpÚarrayÚndimÚshapeÚ
ValueErrorÚformatÚdtypeÚobjectÚ	vectorizeÚintÚDeviceAssignmentÚcreateÚreplica_countÚcomputation_countÚdevice_assignmentrJ   rK   ÚEffortLevelrL   rM   ÚextendÚdictÚsetattrÚpopÚlistÚitemsÚenv_option_overridesÚdebug_optionsr   Ú	cuda_pathÚxla_gpu_cuda_data_dirÚ_DISABLE_MOST_OPTIMIZATIONSÚxla_backend_optimization_levelÚ!xla_llvm_disable_expensive_passesÚxla_test_all_input_layoutsÚenable_remat_opt_passÚxla_disable_hlo_passesÚjax_xla_profile_versionÚprofile_versionÚ_NO_PROFILE_DONT_RETRIEVEÚinfor!   ÚerrorÚxla_detailed_loggingr	   r?   ÚpathlibÚPathÚcompilation_cache_dirÚ"persistent_cache_enable_xla_cachesÚstrrQ   Ú2xla_gpu_enable_llvm_module_compilation_parallelismrR   r   Úglobal_stateÚ
process_idÚAutotuneCacheModeÚUPDATEÚ(xla_gpu_experimental_autotune_cache_modeÚREAD)rU   rV   rm   rX   rY   r\   r]   Úenv_options_overridesr[   Údetailed_loggingr   Úcompile_optionsÚbuild_optionsÚmsgÚoverrides_on_build_optionsÚnamerv   r   Úfdo_profile_versionr   Úenabled_flagsÚkernel_cache_pathÚautotune_cache_paths                          r    Úget_compile_optionsrœ   t   sÆ  € ôJ ×%Ñ%Ó'€/Ø!-€/ÔØ#1€/Ô Ø!×:Ñ:€-Ø(=€-Ô%Ø-G€-Ô*Ü)/×)FÑ)F×)LÑ)L€-Ô&ØÐØ +€MÔÙØ6WÒ6]Ð[]€MÔ3Ø4SÒ4YÐWY€MÔ1ØÑ"Ü
‡L�LØUØ�nÐ&7ô9ô Ÿ™Ð!2Ó3Ðð 	×Ñ !Ò#¨.¸AÒ*=Ø+ªA¨t¨GÑ4ÐàÐ(×.Ñ.¨qÑ1Ò1ØF€cÜ�s—z‘zÐ"3°\ÓBÓCÐCàÐ*×0Ñ0°Ñ3Ò3ØH€cÜ�s—z‘zÐ"3°^ÓDÓEÐEà×Ñ¤&Ò(ØDœ"Ÿ,™,¡~¼s¸eÔDØ
óÐä×+Ñ+×2Ñ2Ð3DÓEÐØ×*Ñ*Ó,°Ò<Ð<Ð<Ø×.Ñ.Ó0°NÒBÐBÐBØ(9€OÔ%ä06×0TÑ0T×0ZÑ0Z€-Ô-Ü(.×(DÑ(D×(JÑ(J€-Ô%Ü%+×%7Ñ%7Ü×Ñ×%Ñ%ó&ç	�Eð Ô"ô (.×'9Ñ'9Ü×!Ñ!×'Ñ'ó(ç	�Eð Ô$ð Ð&ð 	(Ð)@ð"BÐà×%Ñ%Ø	Ð5Ð6ôô !Ð!6Ó7ÐÛ*ˆØ	Ð&Ò	&Ü�˜tÐ%:×%>Ñ%>¸tÓ%DÕEð +ô ,0Ð0E×0KÑ0KÓ0MÓ+N€OÔ(à!×:Ñ:×HÑH€-Ü‡]�]ÐÜ*-¯-©-€MÔ'ä ×&Ò&Ø34€MÔ0Ø6:€MÔ3Ø/4€MÔ,ä	×	%Ñ	%×	+Ò	+Ø+>€MÔ(ô #×:Ñ:×@Ñ@ÐØ˜qÒ Ø&=€OÔ#Ü
‡L�Lð >à(õ*ô '@€OÔ#Ø€Ü‡k�kð 3õ 4ô 7°wÓ?ÐØ	 Ò	!Ø*=ˆÔ'Ü�‰ð <à(õ	*ô 	�‰ð Pô 	Qð (8€-Ô$ô ×2Ñ2Õ4ô �<‰<œ×4Ñ4×:Ñ:Ò@¸bÓA€DÜ×=Ñ=×CÑCÒIÀr€Mà˜ÒÐ!<ÀÑ!MØÐ!<Ñ<ÐÜ03Ð4EÓ0F€mÔ-àIM€mÔFÜ‡l�lÐ6Ð8IÔJà˜ÒÐ!HÈMÑ!YØ Ð#JÑJÐÜ<?Ð@SÓ<T€mÔ9Ü‡l�lÐ:Ð<OÔPô 
×	!Ñ	!×	,Ñ	,°Ò	1ÜAC×AUÑAU×A\ÑA\ˆÔ>ð 
Ðô BD×AUÑAU×AZÑAZˆÔ>à	Ðr"   c                ó   — |j                   j                  d   }t        j                  |«      j                  }t        | dd«      rt        j                  |«      }n|}|j                  j                  �St        |j                  j                  «      r4t        j                  d|t        |j                  j                  «      «       	 | j                  |||«      S # t        j                  $ r}t         D ]  } ||«      }	|	€Œ|	|‚ |‚d }~ww xY w)NÚsym_nameÚneeds_str_irTú1Compiling module %s with FDO profile of length %d)r/   Ú
attributesr   Ú
StringAttrr.   Úgetattrr   Úmodule_to_bytecoderW   r[   Úlenr8   r^   ÚcompilerS   ÚXlaRuntimeErrorÚ_XLA_RUNTIME_ERROR_HANDLERS)
r   r0   Úexecutable_devicesÚoptionsrž   r:   Úbuilt_cÚeÚerror_handlerÚhandler_results
             r    Úbackend_compiler¯     sõ   € ð ×Ñ×(Ñ(¨Ñ4€(Ü—‘˜hÓ'×-Ñ-€+ô ˆW�n dÔ+Ü×%Ñ% fÓ-�Gà€Gà×&Ñ&×2Ñ2Ð>Ü
ˆg×.Ñ.×:Ñ:Ô
;Ü
‡L�LØ;ØÜˆG×,Ñ,×8Ñ8Ó9ôðØ�?‰?˜7Ð$6¸Ó@Ð@øÜ	×	Ñ	ò ß4ˆÙ$ QÓ'€nØ	Ñ	#Ø !Ð#ð 5ð €Gûðús   ÃC ÃDÃ.DÄDÄDc                óÚ  — |j                   j                  d   }t        j                  |«      j                  }t        | dd«      rt        j                  |«      }n|}|j                  j                  �St        |j                  j                  «      r4t        j                  d|t        |j                  j                  «      «       	 t        | t        j                  «      r+|r| j!                  ||||¬«      S | j!                  |||¬«      S |r| j#                  ||||¬«      S | j#                  |||¬«      S # t$        j&                  $ r}t(        D ]  }	 |	|«      }
|
€Œ|
|‚ |‚d }~ww xY w)Nrž   rŸ   Tr    )r©   r“   Úhost_callbacks)r©   r“   )r/   r¡   r   r¢   r.   r£   r   r¤   rW   r[   r¥   r8   r^   Ú
isinstancer   ÚCompileOnlyPyClientr¦   Úcompile_and_loadrS   r§   r¨   )r   r0   r©   rª   r±   rž   r:   r«   r¬   r­   r®   s              r    Úbackend_compile_and_loadrµ   B  sˆ  € ð ×Ñ×(Ñ(¨Ñ4€(Ü—‘˜hÓ'×-Ñ-€+ô ˆW�n dÔ+Ü×%Ñ% fÓ-�Gà€Gà×&Ñ&×2Ñ2Ð>Ü
ˆg×.Ñ.×:Ñ:Ô
;Ü
‡L�LØ;ØÜˆG×,Ñ,×8Ñ8Ó9ôð&ô �'œ4×3Ñ3Ô4Ù	Ø�‰ØØ1Ø#Ø)ð	 ó 
ð 	
ð �_‰_Ø
Ð&8È'ð ó Sð Sñ 
Ø×'Ñ'ØØ1Ø#Ø)ð	 (ó 
ð 	
ð ×%Ñ%Ø
Ø/Ø!ð &ó ð øô
 
×	Ñ	ò ß4ˆÙ$ QÓ'€nØ	Ñ	#Ø !Ð#ð 5ð €Gûðús0   Ã0D8 Ã9D8 ÄD8 Ä$D8 Ä8E*ÅE%ÅE%Å%E*c                ó.   — t         j                  | «       y)a‡  Registers a custom exception handler for XLA runtime errors.

  Registering a custom handler allows re-raising a more informative exception
  after encountering an XLARuntimeError.

  Args:
    handler_fn: A function which returns a new exception to replace the original
      XLA runtime error, or None if the original error should be propagated.

  Returns:
    A new exception or None.
  N)r¨   Úappend)Ú
handler_fns    r    Ú"register_xla_runtime_error_handlerr¹   Š  s   € ô ×$Ñ$ ZÕ0r"   c                ó†  — |j                   j                  d   }t        j                  |«      j                  }t        j                  |d«      x}	rt        j                  d|	«       t        |j                  «       D �
ch c]  }
|
j                  ’Œ c}
«      dkD  }t        |j                  «       d„ ¬«      j                  }t        |||| ||||«      \  }}|€t        | ||||«      S t        j                   d«       t#        j$                  «       }t'        |||| |«      \  }}t#        j$                  «       |z
  }|�V|€J ‚t)        ||«       t        j                   d«       t        j*                  d	||z
  «       t        j*                  d
|«       |S t-        j.                  d«       t0        j2                  j                  ra|r_t4        j6                  j8                  �Et        |«      dk(  r7t;        ||«       t=        | ||||t4        j6                  j8                  |||«	      S t;        ||«       t?        | ||||||«      S c c}
w )Nrž   r¦   zDumped the module to %s.r$   c                ó   — | j                   S rD   rE   )Údevices    r    rH   z'compile_or_get_cached.<locals>.<lambda>¯  s   € ¨F¯IªIr"   )Úkeyz1/jax/compilation_cache/compile_requests_use_cachez!/jax/compilation_cache/cache_hitsz-/jax/compilation_cache/compile_time_saved_secz//jax/compilation_cache/cache_retrieval_time_secÚ)compile_after_persistent_compilation_missr   ) r/   r¡   r   r¢   r.   r   Údump_module_to_filer8   r‚   r¥   ÚflattenÚprocess_indexÚminÚ_resolve_compilation_strategyrµ   r   Úrecord_eventÚtimeÚ	monotonicÚ_cache_readr<   Úrecord_event_duration_secsr   Ú
test_eventr
   Úshare_binary_between_hostsr   r‹   ÚclientrA   Ú_compile_and_share_moduleÚ_compile_and_write_cache)r   ÚcomputationÚdevicesr“   r±   r©   Úpgle_profilerrž   r:   Ú	dumped_tor¼   Úis_multi_processÚmin_device_process_idr   Úcache_retrieval_startÚretrieved_executableÚretrieved_compile_timeÚcache_retrieval_times                     r    Úcompile_or_get_cachedrØ   œ  sY  € ð ×"Ñ"×-Ñ-¨jÑ9€(Ü—‘˜hÓ'×-Ñ-€+ä×*Ñ*¨;¸	ÓBÐB€YÐBÜ
‡K�KÐ*¨IÔ6ô 
¨g¯o©oÔ.?Ó
@Ñ.? Fˆ6×ÓÐ.?Ñ
@ÓAÀAÑEð ô Ø‡o�oÓÑ5ôç�Mð ô
  =ØØØØØØØØó	 Ñ€)ˆ_ð ÐÜ#Ø�Ð0°/Øóð ô ×ÑÐMÔNäŸ.™.Ó*ÐÜ1<Ø�9˜o¨wÐ8Jó2LÑ.ÐÐ.äŸ™Ó)Ð,AÑAÐàÐ%Ø!Ð-Ð-Ð-Ü˜[¨)Ô4ä×ÑÐ?Ô@Ü×)Ñ)Ø7ØÐ!5Ñ5ô7ô ×)Ñ)Ø9Ð;OôQð  ÐÜ‡/�/Ð=Ô>ä×'Ñ'×-Ò-Ù
Ü
×
"Ñ
"×
)Ñ
)Ð
5ô ˆnÓ
 Ò
"ä˜k¨9Ô5Ü$ØØØØØÜ× Ñ ×'Ñ'ØØØó
ð 
ô ˜k¨9Ô5Ü#ØØØØØØØóð ùòE As   Á>H>c                óª  — t         j                  j                  xr t         j                  j                  dkD  }t	        t
        || |¬«      }	|st         j                  j                  r6 |	|d¬«      }
t        j                  |«      }|xj                  dgz  c_	        nd }
|} |	|«      }|�–|
�”t        ||
«      rIt         j                  j                  rt        j                  d|› d�«       |�|j                  «        |
|fS t         j                  j                  r%t        ||«      rt        j                  d|› d	�«       |rŒ|j                   j"                  �vt%        |j                   j"                  «      rW|rQt&        j(                  j*                  �7t-        | |||t&        j(                  j*                  |«      |j                   _        |
|fS ||fS )
Nr   )r   rÎ   rÏ   s   pgle profiled)Úoverride_fdo_profile)Úxla_gpu_enable_command_bufferrO   zPGLE-optimized z loaded from compilation cachez)PERSISTENT CACHE MISS for PGLE-optimized z^ despite non-PGLE hit; it may not have been executed enough times when the cache was populated)r
   Úenable_pgler.   Úpgle_profiling_runsr   Ú_get_cache_keyÚcompilation_cache_expect_pgleÚcopyÚdeepcopyru   Ú_is_executable_in_cacher8   r‚   ÚdisableÚwarningsÚwarnrW   r[   r¥   r   r‹   rË   Ú_share_fdo_profiles)rÎ   rÏ   r“   r   rÐ   rÒ   r:   rÓ   Úis_auto_pgle_usedÚget_cache_keyÚpgle_optimized_cache_keyÚfirst_pass_compile_optionsr   s                r    rÃ   rÃ     sÒ  € ô ×Ñ×ÑÒG¤6×#=Ñ#=×#CÑ#CÀaÑ#Gð ô œ.°'Ø&1¸7ôD€-ñ œ&×>Ñ>×DÒDá,¨_ØBRô TÐô "&§¡¨Ó!?ÐØ×3Ò3Ø+ð8ñ Ö3ð  $ÐØ!0Ðñ Ð6Ó7€)àÐÐ7ÐCä˜wÐ(@ÔAÜ	×	-Ñ	-×	3Ò	3Ü�‰�o k ]Ð2PÐQÔRà	Ð	"Ø×ÑÔØ% Ð6Ð6Ü
×
.Ñ
.×
4Ò
4Ü% g¨yÔ9ô ‡m�mÐ?À¸}ð M@ð @ô Añ Ø
×
2Ñ
2×
>Ñ
>Ð
JÜ
ˆo×6Ñ6×BÑBÔ
Cñ œK×4Ñ4×;Ñ;ÐGäØØØØÜ×$Ñ$×+Ñ+Ø!ó	
ð ×.Ñ.Ô:ð $ _Ð4Ð4ð Ð0Ð0Ð0r"   c                óÐ  — t        j                  |«      sy t        j                  j                  rt
        j                  j                  }nt
        j                  j                  }|�&t        j                  | «      } || j                  _        	 t        j                  ||| ||«      S # t        j                  j                   $ r }t"        j%                  d|«       Y d }~y d }~ww xY w)NzKcompile_or_get_cached: unable to generate cache key, skipping the cache: %s)r	   Úis_cache_usedr
   Ú-remove_custom_partitioning_ptr_from_cache_keyr.   Úcache_key_typeÚIgnoreCallbacksÚCUSTOM_PARTITIONINGÚNOrà   rá   rW   r[   rè   rS   Ú_xlar§   r8   rƒ   )rª   r   rÎ   rÏ   rÚ   Úignore_callbacksÚexs          r    rÞ   rÞ   ^  sÉ   € ô 
×	(Ñ	(¨Ô	1ØÜ×9Ñ9×?Ò?Ü%×5Ñ5×IÑIÑä%×5Ñ5×8Ñ8ÐØÐ%Ü�m‰m˜GÓ$€GØ3G€G×$Ñ$Ô0ð
0Ü×*Ñ*ØØØØØóð øô 
�‰×	 Ñ	 ò 0Ü
‡L�Lð +Ø,.÷0ð 0à	ûð0ús   ÂB( Â(C%ÃC Ã C%c                óZ  — | j                   j                  d   }t        j                  |«      j                  }|j
                  j                  }|�t        |«      dk(  r|S d|j
                  _        	 t        j                  | |||t        j                  j                  «      dz   }	|	t$        j&                  v rt$        j&                  |	   S t(        j*                  j                  }t,        j.                  j0                  |k(  r*t         j3                  d||«       |j5                  |	|«       n)t         j3                  d||«       |j7                  |	|«      }|t$        j&                  |	<   |S # t        j                  j                  $ r"}
t         j#                  d|
«       |cY d }
~
S d }
~
ww xY w)Nrž   r   r"   Ú	_fdo_synczYcompile_or_get_cached: unable to generate cache key, skipping the fdo profile sharing: %sz+Module %s. Sharing FDO profile. Process %d.zEModule %s. Waiting for FDO profile which should be set by process %d.)r/   r¡   r   r¢   r.   rW   r[   r¥   r	   rè   rî   rï   ÚALLrS   rò   r§   r8   rƒ   ræ   Úmodules_profilesr
   Ú%share_binary_between_hosts_timeout_msr   r‹   rŒ   r^   Úkey_value_set_bytesÚblocking_key_value_get_bytes)rÎ   rÏ   r“   r   Úglobal_clientÚmin_process_idrž   r:   r[   Úprofile_keyrô   Úshare_timeouts               r    ræ   ræ   |  sŽ  € ð ×"Ñ"×-Ñ-¨jÑ9€(Ü—‘˜hÓ'×-Ñ-€+Ø×8Ñ8×DÑD€+ØÐœC Ó,°Ò1ØÐà9<€/×*Ñ*Ô6ðä×'Ñ'ØØØØÜ×*Ñ*×.Ñ.ó	
ð ñ	ð ð$ Ô'×8Ñ8Ñ8Ü×/Ñ/°Ñ<Ð<ä×>Ñ>×DÑD€-Ü×Ñ×(Ñ(¨NÒ:Ü
‡L�LØ5ØØôð
 ×%Ñ% k°;Õ?ä
‡L�LØOØØôð
  ×<Ñ<Ø�]ó€Kð 7BÔ×&Ñ& {Ñ3Ø	Ðøô= 
�‰×	 Ñ	 ò Ü
‡L�Lð	/à
ôð
 Õûðús   Á34E+ Å+F*ÆF%ÆF*Æ%F*c	           	     óH  — t         j                  j                  }	|t        j                  v rt        j                  |   S t
        j                  j                  |k(  rat        j                  d||«       t        | ||||||«      }
| j                  |
«      }t        j                  |«      }|j                  ||«       nQt        j                  d||«       |j                  ||	«      }t        j                   |«      }| j#                  |||«      }
|
t        j                  |<   |
S )Nz+Process %d compiling and sharing module: %sz&Waiting for module: %s from process %d)r
   rù   r.   rÌ   Úmodules_cacher   r‹   rŒ   r8   r^   rÍ   Úserialize_executabler	   Úcompress_executablerú   rû   Údecompress_executableÚdeserialize_executable)r   rÎ   r©   r“   r±   rü   r:   r   Úfirst_process_idrÿ   Ú
executableÚserialized_executables               r    rÌ   rÌ   ¼  s,  € ô ×>Ñ>×DÑD€-àÔ+×9Ñ9Ñ9Ü$×2Ñ2°9Ñ=Ð=ä×Ñ×(Ñ(Ð,<Ò<Ü
‡L�LÐ>Ø! ;ô0ä)ØØØØØØØó€Jð $×8Ñ8¸ÓDÐÜ-×AÑAØóÐð ×%Ñ% iÐ1FÕGä
‡L�LÐ9¸;Ø!ô#à)×FÑFØ�=óÐô .×CÑCØóÐð ×/Ñ/ØÐ1°?óD€Jð 8BÔ×)Ñ)¨)Ñ4Ø	Ðr"   c                óš   — t        j                  «       }t        | ||||«      }t        j                  «       |z
  }	t        ||	|| ||«       |S rD   )rÅ   rÆ   rµ   Ú_cache_write)
r   rÎ   r©   r“   r±   r:   r   Ú
start_timer  Úcompile_times
             r    rÍ   rÍ   ð  sV   € ô �~‰~Ó€*Ü'Øˆ{Ð.°Àó€*ô —‘Ó! JÑ.€,ÜØ�˜{¨G°ZÀôð 
Ðr"   c           	     óô   — 	 t        j                  | |«      S # t        $ rV}t        j                  j
                  r‚ t        j                  d|› dt        |«      j                  › d|› �«       Y d}~yd}~ww xY w)z<Checks if executable is presented in cache on a given key
  ú6Error reading persistent compilation cache entry for 'ú': ú: NF)
r	   Úis_executable_in_cacheÚ	Exceptionr
   Úraise_persistent_cache_errorsr.   rä   rå   ÚtypeÚ__name__)r   r   rô   s      r    râ   râ     ss   € ðÜ×3Ñ3°G¸YÓGÐGøÜ	ò Ü×+Ñ+×1Ò1ØÜ‡M�MðØˆ;�cœ$˜r›(×+Ñ+Ð,¨B¨r¨dð	4ô5ô ûðús   ‚ ˜	A7¡AA2Á2A7c           	     óø   — 	 t        j                  ||||«      S # t        $ rV}t        j                  j
                  r‚ t        j                  d| › dt        |«      j                  › d|› �«       Y d}~yd}~ww xY w)ziLooks up the `computation` and it's compilation time in the persistent
  compilation cache repository.
  r  r  r  N)NN)
r	   Úget_executable_and_timer  r
   r  r.   rä   rå   r  r  )r:   r   r“   r   r©   rô   s         r    rÇ   rÇ     s   € ð	Ü×4Ñ4Ø�? GÐ-?óAð Aøä	ò Ü×+Ñ+×1Ò1ØÜ‡M�MðØˆ=˜œD ›H×-Ñ-Ð.¨b°°ð	6ô7ô ûðús   ‚ š	A9£AA4Á4A9c           	     óè  — t         j                  j                  r$t        j                  «       rt
        j                  nt
        j                  }t        j                  j                  dk7  rt        j                  |d«       y|rt        j                  |d|«       yt         j                  j                  }||k  rt        j                  |d|||«       yt        j                  d|||«       	 t        j                  | |||t!        |«      «       y# t"        $ rV}t         j$                  j                  r‚ t'        j(                  d|› dt+        |«      j,                  › d	|› �«       Y d}~yd}~ww xY w)
zqWrites the `serialized_computation` and its compilation time to the
  persistent compilation cache repository.
  r   z8Not writing persistent cache entry since process_id != 0NztNot writing persistent cache entry for '%s' because it uses host callbacks (e.g. from jax.debug.print or breakpoint)z]Not writing persistent cache entry for '%s' because it took < %.2f seconds to compile (%.2fs)z2'%s' took at least %.2f seconds to compile (%.2fs)z6Error writing persistent compilation cache entry for 'r  r  )r
   r>   r.   r	   r?   r5   r6   r7   r   r‹   rŒ   r8   r9   Ú&persistent_cache_min_compile_time_secsr^   Úput_executable_and_timerh   r  r  rä   rå   r  r  )	r   Úcompile_time_secsr:   r   r  r±   Úlog_priorityÚmin_compile_timerô   s	            r    r
  r
  %  sT  € ô ×0Ñ0×6Ò6Ü'×CÑCÔEô —/’/ô —}‘}ð ô ×Ñ×(Ñ(¨AÒ-Ü
‡J�Jˆ|ØIôKà
áÜ
‡J�JØð	>Ø?JôLð ä×BÑB×HÑHÐØÐ)Ò)Ü
‡J�JØð	%Ø&1Ð3CØô	ð
 ä
‡L�LØ<ØÐ%Ð'8ô:ð7Ü×-Ñ-Ø�; 
¨G´SÐ9JÓ5KõMøä	ò 7Ü×+Ñ+×1Ò1ØÜ‡M�MðØˆ=˜œD ›H×-Ñ-Ð.¨b°°ð	6÷7ñ 7ûð7ús   Ã/"D Ä	E1ÄAE,Å,E1)r   ú	xc.ClientÚreturnrh   )r0   ú	ir.Moduler  Úbool)r:   r‰   r   r‰   r  ÚNone)	NTFNNNNTN)rU   rh   rV   rh   rX   r!  rY   r!  r\   úlist[int] | Noner]   r#  r‘   zdict[str, str] | Noner[   úbytes | Noner’   r!  r   zxc.Client | Noner  úxc.CompileOptions)
r   r  r0   r   r©   úxc.DeviceListrª   r%  r  zxc.Executable)r   r  r0   r   r©   r&  rª   r%  r±   úSequence[Any]r  úxc.LoadedExecutable)r¸   z0Callable[[xc.XlaRuntimeError], Exception | None]rD   )r   r  rÎ   r   rÏ   ú
np.ndarrayr“   r%  r±   r'  r©   r&  rÐ   úprofiler.PGLEProfiler | Noner  r(  )rÎ   r   rÏ   r)  r“   r%  r   r  rÐ   r*  rÒ   r!  r:   r‰   rÓ   rh   r  z$tuple[str | None, xc.CompileOptions])rª   r%  r   r  rÎ   r   rÏ   r)  rÚ   r$  r  z
str | None)rÎ   r   rÏ   r)  r“   r%  r   r  rü   ú!lib._jax.DistributedRuntimeClientr  r$  )r   r  rÎ   r   r©   r&  r“   r%  r±   r'  rü   r+  r:   r‰   r   r‰   r  rh   r  r(  )r   r  rÎ   r   r©   r&  r“   r%  r±   r'  r:   r‰   r   r‰   r  r(  )r  r!  )r:   r‰   r   r‰   r“   r%  r   r  r©   r&  r  z-tuple[xc.LoadedExecutable | None, int | None])r   r‰   r  Úfloatr:   r‰   r   r  r  r(  r±   r'  r  r"  )GÚ
__future__r   Úcollections.abcr   rà   Ú	functoolsr   r5   rÅ   Útypingr   r   rä   Újax._srcr   rî   r	   r
   r   r   r   r   r…   r   r   r   Újax._src.interpretersr   Újax._src.libr   rS   r   Újax._src.lib.mlirr   Únumpyr_   Ú	bool_flagÚbool_envry   Úint_flagÚint_envr-   r�   Úregister_exclusionÚ__file__rT   Ú	getLoggerr  r8   r!   r&   r2   r<   rA   rœ   Úannotate_functionr¯   rµ   r¨   r¹   rØ   rÃ   rÞ   ræ   rø   rÌ   r  rÍ   râ   rÇ   r
  r   r"   r    Ú<module>r>     sÙ  ðõ" #å $Û Ý Û Û Ý Ý $Û å 0Ý &Ý %Ý  Ý Ý Ý $Ý Ý #Ý Ý &Ý )Ý Ý  Û ð /˜f×.Ñ.Ø$Ø€F‡O�OÐ4°eÓ<ðMóNÐ ð &5 V§_¡_Ø+Ø€F‡N�NÐ:¸BÓ?ð	Aô	&Ð "ð Ð à !€× !Ñ ! (Ô +à×"Ñ"€à	ˆ×	Ñ	˜8Ó	$€óò

ó7ó%ó%ð Ø"&Ø',Ø:>Ø8<Ø37Ø $Ø!Ø $ðfØðfàðfð  ð	fð
 !%ðfð (8ðfð &6ðfð 1ðfð ðfð ðfð ðfð ófðR 
×Ñð!Øð!àð!ð &ð!ð ð	!ð
 ò!ó ð!ðH 
×ÑðAØðAàðAð &ðAð ð	Að
 "ðAð òAó ðAðH !Ð ð1Ø@ó1ð2 37ðZØðZàðZð ðZð 'ð	Zð
 "ðZð &ðZð 0ðZð óZðfM1ØðM1àðM1ð 'ðM1ð ð	M1ð
 0ðM1ð ðM1ð ðM1ð ðM1ð *óM1ðh *.ðØðàðð ðð ð	ð
 'ðð
 3=óð<8Øð8àð8ð 'ð8ð ð	8ð
 5ð8ð ó8ðv (*Ð Ô $ð
.Øð.àð.ð &ð.ð 'ð	.ð
 "ð.ð 5ð.ð ð.ð ð.ð ð.ð ó.ðb +-Ð Ô 'ðØðàðð &ðð 'ð	ð
 "ðð ðð ðð óó(ðØðØ!$ðØ7Hðàðà,9ðð 3óð&/7Ø$)ð/7à!ð/7ð $ð/7ð 2Eð/7ð "/ð	/7ð 48ô	/7r"   