+
    –°³jb  ã                   ó4  € ^ RI t ^ RIt^ RIt^ RIHt ^ RIHt ^ RIHt ^ RI	H
t
 ^ RIHtHtHt ^ RIt^ RIHtHtHtHt  ]! R4      t]P,                  ! ]4      t]
 ! R	 R
]],          4      4       t ! R R]],          4      t ! R R]4      t ! R R4      tR# )é    N)Úabstractmethod)Údefaultdict)ÚCallable)Ú	dataclass)ÚAnyÚGenericÚTypeVar)Ú
_BackendIdÚ_DynamoCacheEntryÚDynamoCacheÚPrecompileCacheEntryÚTc                   ó^   a € ] tR t^t o Rt]V 3R lR l4       tV 3R lR ltV 3R ltRt	V t
R# )	ÚBackendCacheArtifacta  
Represents a single serializable backend artifact from a dynamo backend.
Each BackendCacheArtifact has a key associated with it along with some
serializable content.

Example implementation:

class MyPrecompileCacheArtifact(PrecompileCacheArtifact[MySerializableType]):
    my_field: int

    def after_deserialization(self) -> MySerializableType:
        result = pickle.loads(self.content)
        # Do some extra work post deserialization
        result.my_post_deserialization_function(self.my_field)
        return result
c                ó    <€ V ^8„  d   QhRS[ /# ©é   Úreturn)r   )ÚformatÚ__classdict__s   "€Úa/home/luca/screen-checking/.venv/lib/python3.14/site-packages/torch/_dynamo/precompile_context.pyÚ__annotate__Ú!BackendCacheArtifact.__annotate__2   s   ø€ ÷ ñ ¡qñ ó    c                ó   € R# )z‡
Code to be run after reading raw byte contents from disk.
Generally converts self.content from raw bytes back into its original form.
N© ©Úselfs   &r   Úafter_deserializationÚ*BackendCacheArtifact.after_deserialization1   s   € ñ 	r   c                ó8   <€ V ^8„  d   QhRS[ RS[3,          RR/# )r   Úedit_fn.r   N)r   r   )r   r   s   "€r   r   r   9   s$   ø€ ÷ -ñ -¡X¨c±3¨hÕ%7ð -¸Dñ -r   c                ó4   € V! V P                   4      V n         R# )z$
Edit the contents of the artifact.
N©Úcontent)r   r"   s   &&r   Úedit_contentsÚ"BackendCacheArtifact.edit_contents9   s   € ñ ˜tŸ|™|Ó,ˆŽr   c                ó2   <€ V ^8„  d   Qh/ S[ ;R&   S[;R&   # )r   Úkeyr%   )Ústrr   )r   r   s   "€r   r   r      s   ø‡ ‚ ñ& 
�Hñ' ñ( �Lò) r   r$   N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   r   r&   Ú__annotate_func__Ú__static_attributes__Ú__classdictcell__©r   s   @r   r   r      s/   ø‡ € ñð( ÷ó ð÷-ð -÷= ƒ r   r   c                   ó2   a € ] tR t^@t o V 3R lR ltRtV tR# )ÚEagerCacheArtifactc                ó    <€ V ^8„  d   QhRS[ /# r   )r   )r   r   s   "€r   r   ÚEagerCacheArtifact.__annotate__A   s   ø€ ÷ ñ ¡sñ r   c                ó   € V P                   # ©Nr$   r   s   &r   r   Ú(EagerCacheArtifact.after_deserializationA   s   € Ø�|‰|Ðr   r   N)r+   r,   r-   r.   r   r1   r2   r3   s   @r   r5   r5   @   s   ø‡ € ÷ö r   r5   c                   ó   € ] tR t^EtRtR# )ÚBypassDynamoCacheEntryr   N)r+   r,   r-   r.   r1   r   r   r   r<   r<   E   s   † Ûr   r<   c                   ó  a € ] tR t^It o Rt/ t/ t]V 3R lR l4       t]V 3R lR l4       t	]V 3R lR l4       t
]V 3R lR	 l4       t]V 3R
 lR l4       t]V 3R lR l4       t]V 3R lR l4       t]V 3R lR l4       tV 3R ltRtV tR# )ÚPrecompileContextaÆ  
PrecompileContext is a special CacheArtifactManager for handling precompilation
It uses the same interface as CacheArtifactManager, but handles deserialization differently: instead
of placing each artifact into respective caches, it will stitch all the cache artifacts for a single key
together and place it into a global Precompile Cache.

PrecompileContext has two main portions: dynamo_cache_entries and backend_cache_artifacts.
When saving, PrecompileContext.serialize() will serialize all dynamo cache entries along with any PrecompileCacheArtifacts that
are needed to save those dynamo cache entries.

The following artifact types are supported by PrecompileContext:
 - BundledAOTAutogradCacheArtifact

c                ó   <€ V ^8„  d   QhRR/# )r   r   Nr   )r   r   s   "€r   r   ÚPrecompileContext.__annotate__c   s   ø€ ÷ *ñ *�dñ *r   c                ón   € V P                   P                  4        V P                  P                  4        R # r9   )Ú_backend_artifacts_by_keyÚclearÚ_dynamo_cache_entries)Úclss   &r   rC   ÚPrecompileContext.clearb   s&   € à×%Ñ%×+Ñ+Ô-Ø×!Ñ!×'Ñ'Ö)r   c                ó4   <€ V ^8„  d   QhRS[ S[,          RR/# )r   Úartifactr   N)r   r   )r   r   s   "€r   r   r@   h   s$   ø€ ÷ ñ á&¡sÕ+ðð 
ñr   c                óÖ   € ^ RI Hp V! 4       ;_uu_ 4        \        P                  ! V4      V P                  \        VP                  4      &   RRR4       R#   + '       g   i     R# ; i)zA
Records a backend artifact to be used with dynamo cache entries
)Úno_dispatchN)Útorch.utils._mode_utilsrJ   ÚcopyÚdeepcopyrB   r
   r)   )rE   rH   rJ   s   && r   Úrecord_artifactÚ!PrecompileContext.record_artifactg   s@   € õ 	8á�]�]ÜFJÇmÂmØóGˆC×)Ñ)¬*°X·\±\Ó*BÑC÷ �]�]Š]ús   –7AÁA(	c                ó*   <€ V ^8„  d   QhRS[ RS[RR/# )r   Úcache_entryr)   r   N)r   r*   )r   r   s   "€r   r   r@   z   s%   ø€ ÷ 5ñ 5Ù+ð5Ù25ð5à	ñ5r   c                ó"   € WP                   V&   R # r9   )rD   )rE   rQ   r)   s   &&&r   Úrecord_dynamo_cache_entryÚ+PrecompileContext.record_dynamo_cache_entryy   s   € ð *5×!Ñ! #Ó&r   c                ó>   <€ V ^8„  d   QhRS[ RS[RS[3,          RR/# )r   r)   r"   .r   N)r*   r   r   )r   r   s   "€r   r   r@   €   s+   ø€ ÷ (ñ (¡ð (©h°s¹C°xÕ.@ð (ÀTñ (r   c                óž   € WP                   9  d   \        RV R24      hV P                   \        V4      ,          pVP                  V4       R# )z*
Edit the content of an existing artifact
zKey z not found in artifactsN)rB   ÚAssertionErrorr
   r&   )rE   r)   r"   rH   s   &&& r   Úedit_artifactÚPrecompileContext.edit_artifact   sG   € ð
 ×3Ñ3Ô3Ü  4¨ uÐ,CÐ!DÓEÐEØ×0Ñ0´¸C³ÕAˆØ×Ñ˜wÖ'r   c                óD   <€ V ^8„  d   QhRS[ RS[S[,          R,          /# )r   r)   r   N)r*   r   r   )r   r   s   "€r   r   r@   Š   s+   ø€ ÷ Hñ H©Cð HÑ4HÉÕ4MÐPTÕ4Tñ Hr   c                óL   € V P                   P                  \        V4      R4      # )z;
Return the backend cache artifact with the associated key
N)rB   Úgetr
   )rE   r)   s   &&r   Úserialize_artifact_by_keyÚ+PrecompileContext.serialize_artifact_by_key‰   s!   € ð
 ×,Ñ,×0Ñ0´¸C³À$ÓGÐGr   c                ó~   <€ V ^8„  d   QhRS[ S[S[3,          RS[ S[S[S[,          3,          RS[ S[S[3,          /# )r   Údynamo_entriesÚbackend_artifactsr   )Údictr*   r   r
   r   r   )r   r   s   "€r   r   r@   ‘   sJ   ø€ ÷ ñ Ù™SÑ"3Ð3Õ4ðá¡
Ñ,@ÁÕ,EÐ EÕFðñ 
‰c‘3ˆh�ñr   c                ó   € \        \        4      pV P                  4        F1  w  r4VP                  4       pW5R&   VR,          P	                  V4       K3  	  VP                  4        F%  pVR,          P	                  VP                  4       K'  	  V# )z§
Return a JSON serializable debug dump of all entries in the precompile context
Called in serialize before serialization, and in populate_caches after deserialization
r)   ÚdynamoÚbackends)r   ÚlistÚitemsÚ
debug_infoÚappendÚvaluesr)   )r`   ra   rh   r)   rQ   ÚinforH   s   &&     r   Údump_debug_infoÚ!PrecompileContext.dump_debug_info�   s€   € ô 3>¼dÓ2Cˆ
Ø .× 4Ñ 4Ö 6ÑˆCØ×)Ñ)Ó+ˆDØ�‰KØ�xÕ ×'Ñ'¨Ö-ñ !7ð
 *×0Ñ0Ö2ˆHØ�zÕ"×)Ñ)¨(¯,©,Ö7ñ 3ð Ðr   c                ó6   <€ V ^8„  d   QhRS[ S[S[3,          /# r   )rb   r*   r   )r   r   s   "€r   r   r@   ¦   s   ø€ ÷ ñ ¡T©#©s¨(¥^ñ r   c                óˆ   € V P                  4       w  rVP                  4        F  w  r4\        P                  ! WC4       K  	  V# r9   )Úcreate_cache_entriesrg   r   Úwrite)rE   Úprecompile_cache_entriesrh   r)   Úentrys   &    r   Úsave_to_dynamo_cacheÚ&PrecompileContext.save_to_dynamo_cache¥   s=   € à/2×/GÑ/GÓ/IÑ,Ð Ø2×8Ñ8Ö:‰JˆCÜ×Ò˜eÖ)ñ ;àÐr   c                ób   <€ V ^8„  d   QhRS[ S[S[S[3,          S[S[S[3,          3,          /# r   )Útuplerb   r*   r   r   )r   r   s   "€r   r   r@   ­   s2   ø€ ÷ ;4ñ ;4á	‰t‘CÑ-Ð-Õ.±±S¹#°XµÐ>Õ	?ñ;4r   c           
     ór  aa€ V P                   pV P                  p\        V4      p\        P	                  W4      p\
        P                  ! RVRV/4      o\        P                  P                  RR V3R lRR7       / pVP                  4        F&  w  rg \        P                  ! Wr4      pVe   W…V&   K&  K(  	  WT3#   \         dp   p	\        P                  R	TR
R7       T	p
\
        P                  ! RTR\!        T
4      /4      o\        P                  P                  RR T3R lR7        Rp	?	K¢  Rp	?	ii ; i)zt
Grabs all the cache entries in the precompile context and
stitches them together into full PrecompileCacheEntries.
Únum_entriesÚ	artifactsrH   c                  ó   € R RRR/# )ÚnameÚdynamo_cache_entriesÚencodingÚjsonr   r   r   r   Ú<lambda>Ú8PrecompileContext.create_cache_entries.<locals>.<lambda>Ä   s   € ØÐ.Ø˜Fñ!r   c                  ó   <€ S # r9   r   )Ú	debug_strs   €r   r€   r�   È   s   ø€ ™yr   F)Úmetadata_fnÚ
payload_fnÚexpect_trace_idNzFailed to create cache entry %sT)Úexc_infor)   Úerrorc                  ó   € R RRR/# )r|   Údynamo_cache_exceptionr~   r   r   r   r   r   r€   r�   á   s   € ØÐ 8Ø" Fñ)r   c                  ó   <€ S # r9   r   )Údatas   €r   r€   r�   å   s   ø€ ¡tr   )r„   r…   )rD   rB   Úlenr>   rl   r   ÚdumpsÚtorchÚ_loggingÚtrace_structuredrg   r   Úfrom_cache_entryÚ	ExceptionÚloggerÚwarningr*   )rE   r`   ra   Únum_artifactsrh   rr   r)   rQ   ÚresultÚerˆ   rŒ   rƒ   s   &          @@r   rp   Ú&PrecompileContext.create_cache_entries¬   sN  ù€ ð ×2Ñ2ˆØ×9Ñ9Ðä˜NÓ+ˆä&×6Ñ6Øó
ˆ
ô —J’Jà˜}Ø˜Zðó
ˆ	ô 	�‰×'Ñ'Øñô )Ø!ð 	(ô 	
ð $&Ð à .× 4Ñ 4Ö 6ÑˆCðÜ-×>Ò>Øó�ð Ò%Ø4:¨SÓ1ñ &ñ !7ð4 (Ð3Ð3øô' ô Ü—‘Ð@À#ÐPT�ÔUà�Ü—z’zà˜sØ¤ U£ðó�ô —‘×/Ñ/Øñ!ô  ,ð 0ô õ ûð%ús   ÂB<Â<D6ÃA$D1Ä1D6c                ón   <€ V ^8„  d   Qh/ S[ S[S[S[,          3,          ;R&   S[ S[S[3,          ;R&   # )r   rB   rD   )rb   r
   r   r   r*   r   )r   r   s   "€r   r   r@   I   s:   ø‡ ‚ ñ&  $¡JÑ0DÁSÕ0IÐ$IÕJÑOñ' ñ.  ¡Ñ%6Ð 6Õ7Ñ<ò/ r   r   N)r+   r,   r-   r.   r/   rB   rD   ÚclassmethodrC   rN   rS   rX   r]   Ústaticmethodrl   rt   rp   r0   r1   r2   r3   s   @r   r>   r>   I   sÄ   ø‡ € ñð$ NPÐð ;=Ðà÷*ó ð*ð ÷ó ðð" ÷5ó ð5ð
 ÷(ó ð(ð ÷Hó ðHð ÷ó ðð( ÷ó ðð ÷;4ó ð;4÷I ƒ r   r>   )rL   r   ÚloggingÚabcr   Úcollectionsr   Úcollections.abcr   Údataclassesr   Útypingr   r   r	   r�   Útorch._dynamo.packager
   r   r   r   r   Ú	getLoggerr+   r”   r   r5   r“   r<   r>   r   r   r   Ú<module>r¥      s—   ðÛ Û Û Ý Ý #Ý $Ý !ß (Ñ (ã ÷ó ðñ ˆCƒL€Ø	×	Ò	˜8Ó	$€ð ô!-˜7 1�:ó !-ó ð!-ôHÐ-¨cÕ2ô ô
	˜Yô 	÷_4ó _4r   