+
    BåûjZ  ã                  óø   € R t ^ RIHt ^ RIt^ RIHt ^ RIHt ^ RIH	t	H
t
Ht ]'       d   ^ RIHt ]! R. RO4      t ! R R	]
4      t]! 4       t]]]	R
3,          ]]]]	3,          R
3,          3,          tR R ltR# )a  In-process specialization cache for FlyDSL native-op compile wrappers.

FlyDSL already owns the heavy compiler artifact cache, including its persistent
on-disk entries. PyTorch still benefits from a tiny native-op level cache: it
keeps the ``flyc.compile(...)`` result for a specialization such as
``(hidden_size, dtype, arch, backend)`` so repeated operator calls can skip
rebuilding the launcher and re-entering FlyDSL's compile path.

This mirrors the call shape of Quack/CuteDSL's ``@jit_cache`` -- a closure over
the cache, exposing the same ``cache`` / ``cache_clear`` / ``cache_info``
attributes -- while deliberately not copying its persistent ``.o`` cache
behavior.

Entries are never evicted: nothing here bounds the cache except the number of
distinct specializations the caller asks for, and each one holds a compiled
module plus its per-specialization lock alive for the life of the process,
both released only by ``cache_clear()``. That is the right trade for a model
with a fixed hidden size, which is the case these kernels are dispatched for;
a caller that sweeps a specialization parameter over an open range should
``cache_clear()`` rather than expect an eviction policy. Note the corollary for
a decorated method: ``self`` joins the key, so the instance stays alive too.
)ÚannotationsN)Ú
namedtuple)ÚLock)ÚAnyÚProtocolÚTYPE_CHECKING)ÚCallableÚ	CacheInfoc                  ó>   € ] tR t^'tRtR R ltR R ltR R ltRtR	# )
ÚCachedCompilezQCompile wrapper returned by ``flydsl_jit_cache`` / ``instrumented_flydsl_cache``.c               ó$   € V ^8„  d   QhRRRRRR/# ©é   Úargsr   ÚkwargsÚreturn© )Úformats   "ÚVC:\Ai_Coding\apps\studio\ComfyUI\.venv\Lib\site-packages\torch\_native\flydsl\cache.pyÚ__annotate__ÚCachedCompile.__annotate__*   s   € ×=Ñ=˜cÐ=¨SÐ=°SÑ=ó    c                	ó   € R # ©Nr   )Úselfr   r   s   &*,r   Ú__call__ÚCachedCompile.__call__*   s   € ¹#r   c               ó   € V ^8„  d   QhRR/# ©r   r   ÚNoner   )r   s   "r   r   r   ,   s   € ×&Ñ&˜TÑ&r   c                	ó   € R # r   r   ©r   s   &r   Úcache_clearÚCachedCompile.cache_clear,   s   € ¡3r   c               ó   € V ^8„  d   QhRR/# ©r   r   r	   r   )r   s   "r   r   r   .   s   € ×*Ñ*˜IÑ*r   c                	ó   € R # r   r   r!   s   &r   Ú
cache_infoÚCachedCompile.cache_info.   s   € ¡sr   r   N)	Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   r"   r'   Ú__static_attributes__r   r   r   r   r   '   s   † Ù[å=å&ç*Ñ*r   r   .c               ó    € V ^8„  d   QhRRRR/# )r   ÚfnzCallable[..., Any]r   r   )r   s   "r   r   r   5   s    € ÷ bñ bÐ+ð bÐ0Bñ br   c                óà   a aaaaa	€ / o/ o\        4       o^ o^ o	\        P                  ! S 4      R VV VVVV	3R ll4       pR VVVVV	3R llpR VVVV	3R llpTpSVn        W$n        W4n        V# )aU  Decorate a FlyDSL compile helper using its explicit args as the key.

The decorated function should take stable specialization parameters as its
normal arguments. Runtime sample objects can be passed by callers through the
reserved ``compile_args=...`` keyword; they are forwarded only on cache miss
and do not participate in keying. Declare it keyword-only: the name is
stripped from the cache key unconditionally, so a specialization parameter
that happened to be called ``compile_args`` would collapse every value of
itself onto one entry and hand back a kernel compiled for another.

Recursive calls back into a cached function are not expected.

Deliberately not named ``jit_cache``: the instrumentation coverage scan in
test_instrumentation.py attributes compile sites by decorator name, and that
name already belongs to CuTeDSL's vendored cache.
c               ó$   € V ^8„  d   QhRRRRRR/# r   r   )r   s   "r   r   Ú&flydsl_jit_cache.<locals>.__annotate__N   s!   € ÷ /ñ /�sð / cð /¨cñ /r   c            	     ó:  <€ VP                  R \        4      pV \        \        VP	                  4       4      4      3pSP                  V\        4      pV\        Jd   S	^,          o	V# S;_uu_ 4        S
P                  V4      pVf   \        4       pVS
V&   RRR4       X;_uu_ 4        SP                  V\        4      pV\        Jd   S	^,          o	VuuRRR4       # S;_uu_ 4        S^,          oRRR4       V\        J d
   S! V / VB pM
S! V R V/VB pS;_uu_ 4        S
P                  V4      VJ d   VSV&   RRR4       VuuRRR4       #   + '       g   i     LÂ; i  + '       g   i     Ly; i  + '       g   i     LB; i  + '       g   i     R# ; i)Úcompile_argsN)ÚpopÚ_MISSINGÚtupleÚsortedÚitemsÚgetr   )r   r   r5   Ú	cache_keyÚcachedÚkey_lockÚcompiledÚcacher0   ÚhitsÚ	key_locksÚlockÚmissess   *,     €€€€€€r   ÚwrapperÚ!flydsl_jit_cache.<locals>.wrapperM   sO  ø€ ð —z‘z .´(Ó;ˆØ#¤U¬6°&·,±,³.Ó+AÓ%BÐBˆ	ð —‘˜9¤hÓ/ˆØœÓ!Ø�A�IˆDØˆMçŠTØ —}‘} YÓ/ˆHØÒÜ›6�Ø'/�	˜)Ñ$÷	 ÷ ŠXØ—Y‘Y˜y¬(Ó3ˆFØœXÓ%Ø˜•	�Ø÷	 ŠX÷
 ’Ø˜!•�÷ ð œxÓ'Ù˜tÐ. vÑ.‘á˜tÐI°,ÐIÀ&ÑI�ç’ð —=‘= Ó+¨xÓ7Ø'/�E˜)Ñ$÷ ð ÷/ ŠX÷ �Tú÷ —ú÷ —ú÷ �XˆXúsN   Á1%EÂ(+F	Ã
F	Ã(
E#	Ã2/F	Ä!E6	Ä<	F	ÅE 	Å#E3Å.F	Å6FÆF	Æ	F	c               ó   € V ^8„  d   QhRR/# r   r   )r   s   "r   r   r3      s   € ÷ ñ ˜ñ r   c                 óž   <€ S;_uu_ 4        S P                  4        SP                  4        ^ o^ oRRR4       R#   + '       g   i     R# ; i)é    N)Úclear)r@   rA   rB   rC   rD   s   €€€€€r   r"   Ú%flydsl_jit_cache.<locals>.cache_clear   s1   ø€ çŠTØ�K‰KŒMØ�O‰OÔØˆDØˆF÷	 �T�TŠTús	   Œ%;»A	c               ó   € V ^8„  d   QhRR/# r%   r   )r   s   "r   r   r3   ‡   s   € ÷ 
7ñ 
7˜	ñ 
7r   c            	     ó‚   <€ S;_uu_ 4        \        SS\        S 4      4      uuRRR4       #   + '       g   i     R# ; i)a;  Return cache statistics.

``hits`` is best-effort under concurrent calls because hot cache hits
do not take the cache lock: an increment can be lost, and one racing a
``cache_clear()`` can survive it, leaving hits above zero right after a
clear. The lock taken here is what makes ``misses`` and ``currsize``
exact.
N)r	   Úlen)r@   rA   rC   rD   s   €€€€r   r'   Ú$flydsl_jit_cache.<locals>.cache_info‡   s&   ø€ ÷ ŠTÜ˜T 6¬3¨u«:Ó6÷ �T�T‹Tús   Œ-­>	)r   Ú	functoolsÚwrapsr@   r"   r'   )
r0   rE   r"   r'   r=   r@   rA   rB   rC   rD   s
   f    @@@@@r   Úflydsl_jit_cacherR   5   st   ý€ ð$ #%€EØ')€IÜ‹6€DØ€DØ€Fä‡_‚_�RÓ÷/ô /ó ð/÷bô ÷
7ó 
7ð €FØ€F„LØ$ÔØ"ÔØ€Mr   )rA   rD   Úcurrsize)r-   Ú
__future__r   rP   Úcollectionsr   Ú	threadingr   Útypingr   r   r   Úcollections.abcr   r	   r   Úobjectr7   r8   ÚstrÚ	_CacheKeyrR   r   r   r   Ú<module>r\      sy   ðñõ. #ã Ý "Ý ß /Ñ /÷ Ý(ñ �{Ò$BÓC€	ô+�Hô +ñ ‹8€Ø�%˜˜S˜•/ 5¨¨s°C¨x­¸#Ð)=Õ#>Ð>Õ?€	÷br   