+
    –°³jZN  ã                  óò  € R t ^ RIHt ^ RIt^ RIt^ RIHtHt ^ RIH	t	H
t
Ht ^ RIt]
'       d   ^ RIHt . R/OtR	t]P$                  P'                  ]]4      t]! R
4      t]! RR7       ! R R4      4       tR R ltR R ltR R ltR R ltR R ltR R ltRR/R R lltR R lt ! R R4      t RR/R  R! llt!R" R# lt" ! R$ R4      t#RR/R% R& llt$RR/R' R( llt%RR/R) R* llt&R+R,RR/R- R. llt'R# )0aø  Structured compile/cache instrumentation for ``torch._native`` ops.

Native DSL ops compile device kernels lazily on first call. Those compiles
are the dominant first-call latency, and a silent cache miss is a common
"why is this slow again?" question. This module surfaces both, with no
runtime cost unless ``TORCH_LOGS=+native_dsl_compile`` is set. That artifact
is off by default to avoid log spew: these wrappers sit on the compile
*cache*, so they run on every op call, cache hits included.

Two sinks, both gated on that artifact and fed by a single
:class:`CompileEvent`:

* The ``native_dsl_compile`` artifact logger: a one-line human-readable
  summary per compile -- outcome, wall time, and running hit/miss totals.
* ``trace_structured`` artifacts (tlparse): a JSON record per compile, for
  production jobs where only the structured trace is retrievable.

The DSLs compile through different machinery, so each has an entry point.
All reduce to the same shared core (:func:`_make_wrapper`): snapshot the
cache, time the call, snapshot again, and flag ``compiled`` when the miss
counter advanced. They differ only in how a snapshot is sampled:

* :func:`instrument_cutedsl_compile` -- for CuTeDSL, stacked *above* the
  vendored ``quack`` ``@jit_cache`` decorator. It reads the cache wrapper's
  ``cache_info()`` and times the wrapped ``cute.compile`` call::

      @instrument_cutedsl_compile("aten::topk")
      @jit_cache
      def _compile_topk_radix(N, K, deterministic): ...

  A ``cache_info().misses`` delta means the cache ran a real
  ``cute.compile``, so the measured wall time *is* the compile time;
  otherwise the key was served from the in-memory or on-disk ``.o`` cache.

* :func:`instrument_triton_kernel` -- for Triton ``@triton.jit`` kernels,
  which compile *and* launch in one ``kernel[grid](...)`` call and keep
  their own per-kernel cache (``JITFunction.device_caches``). Stacked above
  ``@triton.jit``, it wraps the kernel in a transparent proxy that watches
  *that one kernel's* variant count; a launch that grows it means a fresh
  compile. Scoping to the single kernel gives clean per-kernel attribution --
  two kernels in one module never collide. Because compile and launch are
  fused, ``wall_ms`` on a miss is compile + host-launch latency (compile
  dominates); on a hit it is just host-launch latency.

* :func:`instrument_helion_kernel` -- for regular and AOT Helion kernels. It
  tracks compiled configurations across the kernel's bound specialization
  cache; a growing count means the call compiled a new configuration.

The DSLs only expose miss-side signal directly (CuTeDSL's vendored cache
reports aggregate counters; Triton's cache only grows), so finer reasons
(disk-hit vs lock-timeout, Triton's on-disk cache) are not distinguished
here -- the boolean ``compiled`` flag plus wall time covers the common case.

Neither entry point touches the underlying DSL/vendored code, and neither
hijacks Triton's process-global ``knobs.runtime`` hooks (those would also
capture Inductor's unrelated Triton compiles).
)ÚannotationsN)ÚasdictÚ	dataclass)ÚAnyÚTYPE_CHECKINGÚTypeVar)ÚCallableÚCompileEventÚInstrumentedHelionKernelÚInstrumentedTritonKernelÚnative_dsl_compileÚRT)Úfrozenc                  óx   € ] tR t^_t$ RtR]R&   R]R&   R]R&   R]R&   R]R	&   R]R
&   R]R&   R]R&   R R ltRtR# )r	   a�  One compile-function invocation, as recorded to logs and tlparse.

``compiled`` is the ground truth (did the cache run a real compile);
``outcome`` is its human-readable form. ``hits`` / ``misses`` are the
cache's running totals *after* this call, useful for spotting churn
(e.g. misses climbing across calls of the same shape => keys not
stable, or the persistent cache is disabled).
ÚstrÚopÚdslÚoutcomeÚboolÚcompiledÚfloatÚwall_msÚkeyÚintÚhitsÚmissesc               ó   € V ^8„  d   QhRR/# )é   Úreturnzdict[str, Any]© )Úformats   "Ú^/home/luca/screen-checking/.venv/lib/python3.14/site-packages/torch/_native/instrumentation.pyÚ__annotate__ÚCompileEvent.__annotate__s   s   € ÷ ñ ˜ñ ó    c                	ó   € \        V 4      # ©N)r   ©Úselfs   &r!   Úas_dictÚCompileEvent.as_dicts   s   € Ü�d‹|Ðr$   r   N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú__annotations__r)   Ú__static_attributes__r   r$   r!   r	   r	   _   s;   ‡ ñð 	ƒGØ	ƒHØƒLØƒNØƒNØ	ƒHØ
ƒIØƒK÷ñ r$   c               ó   € V ^8„  d   QhRR/# )r   r   r   r   )r    s   "r!   r"   r"   w   s   € ÷ Cñ C�Dñ Cr$   c                 óL   € ^ RI Hp  V P                  P                  \        4      # )aR  True if the ``native_dsl_compile`` artifact is enabled.

Lets the wrapper skip all instrumentation work (cache sampling, timing,
key formatting, event construction) on the hot path when nothing is
listening -- important because the CuTeDSL wrapper sits on the compile
*cache* and so runs on every op call, cache hits included.

Both sinks share this one gate; tlparse emission cannot be left to
``trace_structured``'s internal ``trace_log.handlers`` check, which is
true in any job collecting a structured trace.

``log_state`` is read off the module because ``TORCH_LOGS`` parsing
rebinds it.
©Ú	_internal)Útorch._loggingr5   Ú	log_stateÚis_artifact_enabledÚ_ARTIFACT_NAMEr4   s    r!   Ú
_listeningr:   w   s   € õ )à×Ñ×2Ñ2´>ÓBÐBr$   c               ó    € V ^8„  d   QhRRRR/# )r   Úeventr	   r   ÚNoner   )r    s   "r!   r"   r"   ‹   s   € ÷ ñ �ð  $ñ r$   c           
     óú   a € \         P                  RS P                  S P                  S P                  S P
                  S P                  S P                  S P                  4       ^ RI	H
p V! RR RV 3R lR7       R# )	z5Fan the event out to the artifact logger and tlparse.z6%s [%s] %s in %.1fms (key=%s, cache hits=%d misses=%d))Útrace_structuredÚartifactc                 ó   € R \         RR/# )ÚnameÚencodingÚjson)r9   r   r$   r!   Ú<lambda>Ú_emit.<locals>.<lambda>¤   s   € ˜V¤^°ZÀÑHr$   Fc                 ó   <€ \        S 4      # r&   )Ú_json_payload)r<   s   €r!   rE   rF   ¦   s
   ø€ œ=¨Ô/r$   )Úmetadata_fnÚexpect_trace_idÚ
payload_fnN)ÚlogÚinfor   r   r   r   r   r   r   Útorch._logging._internalr?   )r<   r?   s   f r!   Ú_emitrO   ‹   s^   ø€ ä‡H�HØ@Ø�‰Ø�	‰	Ø�‰Ø�‰Ø�	‰	Ø�
‰
Ø�‰ô	õ :ñ ØÙHØÜ/÷	r$   c               ó    € V ^8„  d   QhRRRR/# )r   r<   r	   r   r   r   )r    s   "r!   r"   r"   ª   s   € ÷ 7ñ 7˜ð 7¨#ñ 7r$   c                óL   € ^ RI pVP                  V P                  4       RR7      # )é    NT)Ú	sort_keys)rD   Údumpsr)   )r<   rD   s   & r!   rH   rH   ª   s   € Ûà�:‰:�e—m‘m“o°ˆ:Ó6Ð6r$   c               ó(   € V ^8„  d   QhRRRRRRRR/# )	r   ÚargsÚtupleÚkwargsÚdictÚkey_fnzCallable | Noner   r   r   )r    s   "r!   r"   r"   °   s(   € ÷ (ñ (�eð ( Tð (°?ð (Àsñ (r$   c                ó:  € Ve
    V! V / VB # V  Uu. uF  p\        V4      NK  	  ppT\        VP                  4       4       UUu. uF  w  rVV RV: 2NK  	  upp,          pRRP	                  V4      ,           R,           #   \          d     L€i ; iu upi u uppi )NÚ=Ú(z, Ú))Ú	ExceptionÚreprÚsortedÚitemsÚjoin)rV   rX   rZ   ÚaÚpartsÚkÚvs   &&&    r!   Ú_format_keyrh   °   s›   € ØÒð	Ù˜4Ð* 6Ñ*Ð*ñ #Ó#™d˜ŒT�!ŽW™d€EÐ#Ø	¤v¨f¯l©l«nÔ'=Ô>Ñ'=™t˜q���1�Q‘E‹lÑ'=Ò>Õ>€EØ�—‘˜5Ó!Õ! CÕ'Ð'øô	 ô 	Ùð	üâ#ùÛ>s   †B ’BÁBÂBÂBc               ó0   € V ^8„  d   QhRRRRRRRRRR	R
R/# )r   ÚfnúCallable[..., R]r   r   r   rZ   úCallable[..., str] | NoneÚsampleú+Callable[[], tuple[int | None, int | None]]r   r   )r    s   "r!   r"   r"   »   sD   € ÷ :ñ :Øð:àð:ð 
ð:ð &ð	:ð
 8ð:ð ñ:r$   c                ó\   a aaaa€ \         P                  ! S 4      R VV VVV3R ll4       pV# )aI  Shared instrumentation core for both DSL entry points.

``sample()`` returns a ``(hits, misses)`` snapshot of the relevant cache;
a ``misses`` increase across the call means a real compile fired. Timing,
error handling, classification, and emission are identical across DSLs --
only ``sample`` (and the reported ``dsl``) differ.
c               ó$   € V ^8„  d   QhRRRRRR/# )r   rV   r   rX   r   r   r   )r    s   "r!   r"   Ú#_make_wrapper.<locals>.__annotate__Ë   s!   € ÷ (ñ (�sð ( cð (¨añ (r$   c                 óZ  <€ \        4       '       g	   S! V / VB # S! 4       w  r#\        P                  ! 4       p S! V / VB pR p \        P                  ! 4       T,
          R,          pS! 4       w  r‰T'       * ;'       d    TRJ;'       d    T	RJ;'       d    Y“8„  p
T'       d   RpMT
'       d   RMRp\	        \        SSTT
T\        YS4      T;'       g    ^ T	;'       g    ^ R7      4       T#   \         d    Rph i ; i  \        P                  ! 4       T,
          R,          pS! 4       w  r‰X'       * ;'       d    TRJ;'       d    T	RJ;'       d    Y“8„  p
T'       d   RpMT
'       d   RMRp\	        \        SSTT
T\        YS4      T;'       g    ^ T	;'       g    ^ R7      4       i ; i)FTg     @�@NÚerrorr   Ú	cache_hit)r   r   r   r   r   r   r   r   )r:   ÚtimeÚperf_counterr_   rO   r	   rh   )rV   rX   Ú_Úmisses_beforeÚstartÚresultÚoutcome_is_errorr   Ú
hits_afterÚmisses_afterr   r   r   rj   rZ   r   rm   s   *,          €€€€€r!   ÚwrapperÚ_make_wrapper.<locals>.wrapperÊ   sÚ  ø€ ô
 �|Š|Ù�tÐ&˜vÑ&Ð&á!›8ÑˆÜ×!Ò!Ó#ˆð	Ù˜Ð( Ñ(ˆFØ$Ñô
 ×(Ò(Ó*¨UÕ2°cÕ9ˆGÙ'-£xÑ$ˆJà$Ô$÷ 1ð 1Ø!¨Ð-÷1ð 1à ¨Ð,÷1ð 1ð !Ñ0ð	 ÷  Ø!‘ç(0™*°k�ÜÜØØØ#Ø%Ø#Ü# D°&Ó9Ø#Ÿ˜ qØ'×,Ð,¨1ô	ôð ˆøô9 ô 	Ø#ÐØð	ûô ×(Ò(Ó*¨UÕ2°cÕ9ˆGÙ'-£xÑ$ˆJà$Ô$÷ 1ð 1Ø!¨Ð-÷1ð 1à ¨Ð,÷1ð 1ð !Ñ0ð	 ÷  Ø!‘ç(0™*°k�ÜÜØØØ#Ø%Ø#Ü# D°&Ó9Ø#Ÿ˜ qØ'×,Ð,¨1ô	õús6   ¹
C. Ã.C=Ã=D  Ä AF*ÅF*ÅF*Å 
F*Å+1F*ÆF*)Ú	functoolsÚwraps)rj   r   r   rZ   rm   r~   s   fffff r!   Ú_make_wrapperr‚   »   s-   ü€ ô ‡_‚_�RÓ÷(ó (ó ð(ðT €Nr$   c               ó    € V ^8„  d   QhRRRR/# )r   rj   r   r   rn   r   )r    s   "r!   r"   r"   ø   s   € ÷ ñ ˜Cð Ð$Oñ r$   c                ó   a € R V 3R llpV# )a  Sampler reading ``(hits, misses)`` from a ``jit_cache`` wrapper.

Defensive: the wrapped callable may not be ``jit_cache``-decorated (e.g.
a plain function in tests). Then we report ``(None, None)`` and the core
still times the call, just without compile/hit classification.
c               ó   € V ^8„  d   QhRR/# ©r   r   ztuple[int | None, int | None]r   )r    s   "r!   r"   Ú)_cache_info_sampler.<locals>.__annotate__   s   € ÷ ñ Ð1ñ r$   c                 ó�   <€ \        SR R4      p V f   R#  V ! 4       pVP                  VP                  3#   \         d    Ru # i ; i)Ú
cache_infoN)NN)Úgetattrr   r   r_   )rM   Úcirj   s     €r!   rm   Ú#_cache_info_sampler.<locals>.sample   sP   ø€ Ü�r˜<¨Ó.ˆØŠ<ØÐð	Ù“ˆBØ—7‘7˜BŸI™IÐ%Ð%øÜô 	ØÒð	ús   –5 µAÁAr   )rj   rm   s   f r!   Ú_cache_info_samplerr�   ø   s   ø€ ÷ð ð €Mr$   rZ   c               ó$   € V ^8„  d   QhRRRRRR/# ©r   r   r   rZ   rl   r   z.Callable[[Callable[..., R]], Callable[..., R]]r   )r    s   "r!   r"   r"     s(   € ÷ ñ Øðð &ðð 4ñ	r$   c               ó   a a€ R VV 3R llpV# )a^  Instrument a CuTeDSL (``@jit_cache``-decorated) compile function.

Args:
    op: Operator symbol being compiled for, e.g. ``"aten::topk"``.
    key_fn: Optional callable with the wrapped function's signature
        returning a short string describing the compile key for logs.
        Defaults to a repr of the args/kwargs.

Returns a decorator. The decorated function behaves identically to the
original (same return value, same caching); it only adds a log line and
a tlparse artifact per call. Errors raised by the wrapped compile are
timed, reported with ``outcome="error"``, and re-raised unchanged.
c               ó    € V ^8„  d   QhRRRR/# ©r   rj   rk   r   r   )r    s   "r!   r"   Ú0instrument_cutedsl_compile.<locals>.__annotate__   s   € ÷ ñ Ð&ð Ð+;ñ r$   c           	     óš   <€ \        V SR S\        V 4      4      pR F+  p\        W4      '       g   K  \        W\	        W4      4       K-  	  V# )Úcutedsl)ÚcacheÚcache_clearr‰   )r‚   r�   ÚhasattrÚsetattrrŠ   )rj   r~   ÚattrrZ   r   s   &  €€r!   Ú	decoratorÚ-instrument_cutedsl_compile.<locals>.decorator   sH   ø€ Ü  B¨	°6Ô;NÈrÓ;RÓSˆó ;ˆDÜ�r× Ô Ü˜¤w¨rÓ'8Ö9ñ ;ð ˆr$   r   ©r   rZ   r›   s   fd r!   Úinstrument_cutedsl_compilerž     s   ù€ ÷&ñ ð Ðr$   c               ó    € V ^8„  d   QhRRRR/# ©r   Úkernelr   r   z
int | Noner   )r    s   "r!   r"   r"   -  s   € ÷ ñ ˜sð  zñ r$   c                óŽ   € \        V RR4      pVf   R#  \        R VP                  4        4       4      #   \         d     R# i ; i)a  Compiled-variant count across one JITFunction's per-device caches.

Triton stores one entry per specialized variant in
``JITFunction.device_caches[device]``, a ``(kernel_cache, ...)`` tuple
whose first element is the dict of compiled kernels. The count grows by
one each time a new (signature, constexpr, options) variant compiles, so
a delta across a launch tells us whether *this* kernel compiled. Returns
None if the object doesn't expose ``device_caches`` (a future Triton that
renames this, or a non-kernel in tests).
Údevice_cachesNc              3  óF   "  € T F  p\        V^ ,          4      x € K  	  R# 5i)rR   N)Úlen)Ú.0Ú
per_devices   & r!   Ú	<genexpr>Ú%_triton_cache_size.<locals>.<genexpr><  s   é € ÐH¹¨*”3�z !•}×%Ð%»ùs   ‚!©rŠ   ÚsumÚvaluesr_   )r¡   Úcachess   & r!   Ú_triton_cache_sizer®   -  sH   € ô �V˜_¨dÓ3€FØ‚~ÙðÜÑH¸¿¹¼ÓHÓHÐHøÜô Úðúó   •5 µAÁAc                  ó`   € ] tR tRtRtR R lt]R R l4       tR R ltR	 R
 lt	R R lt
RtR# )r   iA  a&  Transparent proxy over a single ``@triton.jit`` kernel.

Watches only this kernel's ``device_caches``, so a launch that grows the
variant count is unambiguously *this* kernel compiling -- two kernels in
one module never collide. All attribute access except the ``kernel[grid]``
launch path is delegated to the wrapped kernel, so the proxy is a drop-in
for the original ``JITFunction`` for attribute/method use (``.warmup``,
``.cache_key``).

Composition with ``torch.library.wrap_triton``: that API does a strict
``isinstance(JITFunction)`` check and would reject this proxy, but it
targets a different path (export/tracing, where the compile does not run
through our eager launch). When a native op needs ``wrap_triton``, pass the
raw kernel via :attr:`jit_kernel`: ``wrap_triton(my_kernel.jit_kernel)``.
c               ó(   € V ^8„  d   QhRRRRRRRR/# ©	r   r¡   r   r   r   rZ   rl   r   r=   r   )r    s   "r!   r"   Ú%InstrumentedTritonKernel.__annotate__R  s2   € ÷ ñ àðð ðð *ð	ð
 
ñr$   c                	ó*   € Wn         W n        W0n        R # r&   )Ú_kernelÚ_opÚ_key_fn©r(   r¡   r   rZ   s   &&&&r!   Ú__init__Ú!InstrumentedTritonKernel.__init__R  s   € ð ŒØŒØŽr$   c               ó   € V ^8„  d   QhRR/# ©r   r   r   r   )r    s   "r!   r"   r³   ]  s   € ÷ ñ ˜Cñ r$   c                ó   € V P                   # )z;The wrapped raw ``JITFunction`` (e.g. for ``wrap_triton``).©rµ   r'   s   &r!   Ú
jit_kernelÚ#InstrumentedTritonKernel.jit_kernel\  s   € ð �|‰|Ðr$   c               ó   € V ^8„  d   QhRR/# r†   r   )r    s   "r!   r"   r³   a  s   € ÷ 6ñ 6Ð6ñ 6r$   c                	ó0   € R \        V P                  4      3# r&   )r®   rµ   r'   s   &r!   Ú_sampleÚ InstrumentedTritonKernel._samplea  s   € ð Ô'¨¯©Ó5Ð5Ð5r$   c               ó    € V ^8„  d   QhRRRR/# )r   Úgridr   r   zCallable[..., Any]r   )r    s   "r!   r"   r³   f  s   € ÷ Wñ W ð WÐ(:ñ Wr$   c                	ó€   € V P                   V,          p\        W P                  R V P                  V P                  4      # ©Útriton)rµ   r‚   r¶   r·   rÃ   )r(   rÆ   Úlaunchers   && r!   Ú__getitem__Ú$InstrumentedTritonKernel.__getitem__f  s/   € ð —<‘< Õ%ˆÜ˜X§x¡x°¸4¿<¹<ÈÏÉÓVÐVr$   c               ó    € V ^8„  d   QhRRRR/# ©r   rB   r   r   r   r   )r    s   "r!   r"   r³   l  s   € ÷ +ñ + ð +¨ñ +r$   c                	ó.   € \        V P                  V4      # r&   ©rŠ   rµ   ©r(   rB   s   &&r!   Ú__getattr__Ú$InstrumentedTritonKernel.__getattr__l  s   € ô �t—|‘| TÓ*Ð*r$   )rµ   r·   r¶   N)r+   r,   r-   r.   r/   r¹   Úpropertyr¿   rÃ   rË   rÒ   r1   r   r$   r!   r   r   A  s5   † ñõ ð ôó ðõ6õ
W÷+ñ +r$   c               ó$   € V ^8„  d   QhRRRRRR/# )r   r   r   rZ   rl   r   z)Callable[[Any], InstrumentedTritonKernel]r   )r    s   "r!   r"   r"   r  s(   € ÷ ñ Øðð &ðð /ñ	r$   c               ó   a a€ R VV 3R llpV# )a}  Instrument a single ``@triton.jit`` kernel, stacked above the jit::

    @instrument_triton_kernel("aten::bmm")
    @triton.jit
    def _bmm_kernel(...): ...

Unlike CuTeDSL, a Triton kernel compiles lazily *inside* its
``kernel[grid](...)`` launch and caches variants on the kernel object. So
rather than wrap a separate compile fn, wrap the kernel itself: the proxy
watches that one kernel's variant count and records a compile when the
launch grows it. Because compile and launch are fused, ``wall_ms`` on a
miss is compile + host-launch latency (compile dominates); on a hit it is
just host-launch latency.

Args:
    op: Operator symbol being compiled for, e.g. ``"aten::bmm"``.
    key_fn: Optional callable with the kernel's launch-arg signature
        returning a short string for logs (the constexprs it sees, e.g.
        ``BLOCK``, are the actual compile key). Defaults to a repr.
c               ó    € V ^8„  d   QhRRRR/# )r   r¡   r   r   r   r   )r    s   "r!   r"   Ú.instrument_triton_kernel.<locals>.__annotate__Œ  ó   € ÷ <ñ <˜#ð <Ð":ñ <r$   c                ó   <€ \        V SS4      # r&   )r   ©r¡   rZ   r   s   &€€r!   r›   Ú+instrument_triton_kernel.<locals>.decoratorŒ  ó   ø€ Ü'¨°°FÓ;Ð;r$   r   r�   s   fd r!   Úinstrument_triton_kernelrÞ   r  s   ù€ ÷4<ñ <ð Ðr$   c               ó    € V ^8„  d   QhRRRR/# r    r   )r    s   "r!   r"   r"   ’  s   € ÷ ñ ˜sð  zñ r$   c                óŽ   € \        V RR4      pVf   R#  \        R VP                  4        4       4      #   \         d     R# i ; i)a™  Compiled-config count across a Helion Kernel's bound specializations.

Helion stores compiled configs in ``Kernel._bound_kernels[*]._compile_cache``;
the total grows by one each time a new configuration compiles, so a delta
across a call tells us whether *this* kernel compiled. Returns None if the
object doesn't expose these private attributes (a future Helion that renames
them, or a non-kernel in tests).
Ú_bound_kernelsNc              3  óN   "  € T F  p\        \        VR R4      4      x € K  	  R# 5i)Ú_compile_cacheNr   )r¥   rŠ   )r¦   Úbounds   & r!   r¨   Ú%_helion_cache_size.<locals>.<genexpr>Ÿ  s)   é € ð 
á/�ô ”˜Ð/°Ó4×5Ð5Û/ùs   ‚#%rª   )r¡   Úbound_kernelss   & r!   Ú_helion_cache_sizerç   ’  sX   € ô ˜FÐ$4°dÓ;€MØÒÙðÜñ 
à&×-Ñ-Ô/ó
ó 
ð 	
øô ô Úðúr¯   c                  ó`   € ] tR tRtRtR R lt]R R l4       tR R ltR	 R
 lt	R R lt
RtR# )r
   i§  z9Transparent proxy over a Helion ``Kernel`` compile cache.c               ó(   € V ^8„  d   QhRRRRRRRR/# r²   r   )r    s   "r!   r"   Ú%InstrumentedHelionKernel.__annotate__ª  s8   € ÷ Rñ RàðRð ðRð *ð	Rð
 
ñRr$   c                	óJ   € Wn         \        WR W0P                  4      V n        R# )ÚhelionN)rµ   r‚   rÃ   Ú_wrappedr¸   s   &&&&r!   r¹   Ú!InstrumentedHelionKernel.__init__ª  s   € ð ŒÜ% f°(¸FÇLÁLÓQˆŽr$   c               ó   € V ^8„  d   QhRR/# r¼   r   )r    s   "r!   r"   rê   ´  s   € ÷ ñ ˜sñ r$   c                	ó   € V P                   # r&   r¾   r'   s   &r!   Úhelion_kernelÚ&InstrumentedHelionKernel.helion_kernel³  s   € à�|‰|Ðr$   c               ó   € V ^8„  d   QhRR/# r†   r   )r    s   "r!   r"   rê   ·  s   € ÷ 6ñ 6Ð6ñ 6r$   c                	ó0   € R \        V P                  4      3# r&   )rç   rµ   r'   s   &r!   rÃ   Ú InstrumentedHelionKernel._sample·  s   € ØÔ'¨¯©Ó5Ð5Ð5r$   c               ó$   € V ^8„  d   QhRRRRRR/# )r   rV   r   rX   r   r   )r    s   "r!   r"   rê   º  s!   € ÷ .ñ .˜cð .¨Sð .°Sñ .r$   c                	ó&   € V P                   ! V/ VB # r&   )rí   )r(   rV   rX   s   &*,r!   Ú__call__Ú!InstrumentedHelionKernel.__call__º  s   € Ø�}Š}˜dÐ- fÑ-Ð-r$   c               ó    € V ^8„  d   QhRRRR/# rÎ   r   )r    s   "r!   r"   rê   ½  s   € ÷ +ñ + ð +¨ñ +r$   c                	ó.   € \        V P                  V4      # r&   rÐ   rÑ   s   &&r!   rÒ   Ú$InstrumentedHelionKernel.__getattr__½  s   € Ü�t—|‘| TÓ*Ð*r$   )rµ   rí   N)r+   r,   r-   r.   r/   r¹   rÔ   rñ   rÃ   rø   rÒ   r1   r   r$   r!   r
   r
   §  s3   † ÙCõRð ôó ðõ6õ.÷+ñ +r$   c               ó$   € V ^8„  d   QhRRRRRR/# )r   r   r   rZ   rl   r   z)Callable[[Any], InstrumentedHelionKernel]r   )r    s   "r!   r"   r"   Á  s(   € ÷ 
ñ 
Øð
ð &ð
ð /ñ	
r$   c               ó   a a€ R VV 3R llpV# )z@Instrument a Helion ``Kernel`` without importing Helion eagerly.c               ó    € V ^8„  d   QhRRRR/# )r   r¡   r   r   r
   r   )r    s   "r!   r"   Ú.instrument_helion_kernel.<locals>.__annotate__È  rÙ   r$   c                ó   <€ \        V SS4      # r&   )r
   rÛ   s   &€€r!   r›   Ú+instrument_helion_kernel.<locals>.decoratorÈ  rÝ   r$   r   r�   s   fd r!   Úinstrument_helion_kernelr  Á  s   ù€ ÷<ñ <ð Ðr$   c               ó$   € V ^8„  d   QhRRRRRR/# r�   r   )r    s   "r!   r"   r"   ×  s(   € ÷ ñ Øðð &ðð 4ñ	r$   c               ó.   a aa€ ^ RI Ho R VVV 3R llpV# )a‰  Cache + instrument a CuTeDSL compile function in one decorator::

    @instrumented_cutedsl_cache("aten::topk")
    def _compile_topk_radix(N, K, deterministic):
        return cute.compile(...)

Equivalent to ``instrument_cutedsl_compile(op) `` stacked above the
vendored ``@jit_cache``. ``jit_cache`` is imported lazily so plain
``import torch._native`` doesn't pull in the CuTeDSL runtime.
)Ú	jit_cachec               ó    € V ^8„  d   QhRRRR/# r’   r   )r    s   "r!   r"   Ú0instrumented_cutedsl_cache.<locals>.__annotate__é  s    € ÷ Lñ LÐ&ð LÐ+;ñ Lr$   c                ó6   <€ \        SSR 7      ! S! V 4      4      # ©©rZ   )rž   )rj   r  rZ   r   s   &€€€r!   r›   Ú-instrumented_cutedsl_cache.<locals>.decoratoré  s   ø€ Ü)¨"°VÕ<¹YÀr»]ÓKÐKr$   )Útorch._vendor.quack.cacher  )r   rZ   r›   r  s   fd @r!   Úinstrumented_cutedsl_cacher  ×  s   ú€ õ  4÷Lò Lð Ðr$   c               ó$   € V ^8„  d   QhRRRRRR/# )r   r   r   rZ   rl   r   z6Callable[[Callable[..., R]], InstrumentedTritonKernel]r   )r    s   "r!   r"   r"   ï  s(   € ÷ ñ Øðð &ðð <ñ	r$   c               ó*   a aa€ ^ RI oR VV V3R llpV# )a^  JIT + instrument a Triton kernel in one decorator::

    @instrumented_triton_cache("aten::bmm")
    def _bmm_kernel(...):  # bare kernel body, no @triton.jit
        ...

Equivalent to ``instrument_triton_kernel(op)`` stacked above
``@triton.jit``. ``triton`` is imported lazily so plain
``import torch._native`` doesn't pull in the Triton runtime.
Nc               ó    € V ^8„  d   QhRRRR/# )r   rj   rk   r   r   r   )r    s   "r!   r"   Ú/instrumented_triton_cache.<locals>.__annotate__  s    € ÷ Kñ KÐ&ð KÐ+Cñ Kr$   c                óH   <€ \        SSR 7      ! SP                  V 4      4      # r
  )rÞ   Újit)rj   rZ   r   rÉ   s   &€€€r!   r›   Ú,instrumented_triton_cache.<locals>.decorator  s   ø€ Ü'¨°6Õ:¸6¿:¹:Àb»>ÓJÐJr$   rÈ   )r   rZ   r›   rÉ   s   fd @r!   Úinstrumented_triton_cacher  ï  s   ú€ ó  ÷Kò Kð Ðr$   ÚaotFc          
     ó,   € V ^8„  d   QhRRRRRRRRR	R
/# )r   r   r   r  r   rZ   rl   ÚsettingsÚobjectr   z6Callable[[Callable[..., R]], InstrumentedHelionKernel]r   )r    s   "r!   r"   r"     s<   € ÷ ñ Øðð 
ðð &ð	ð
 ðð <ñr$   c               óŠ   a aaa€ ^ RI p^ RIpV'       d   VP                  P                  MVP                  oR VVV V3R llpV# )z5Create and instrument a regular or AOT Helion kernel.Nc               ó    € V ^8„  d   QhRRRR/# )r   rj   rk   r   r
   r   )r    s   "r!   r"   Ú0instrumented_helion_kernel.<locals>.__annotate__  s   € ÷ 
ñ 
Ð&ð 
Ð+Cñ 
r$   c                óB   <€ \        SSR 7      ! S! R/ SB ! V 4      4      # )r  r   )r  )rj   Úkernel_decoratorrZ   r   r  s   &€€€€r!   r›   Ú-instrumented_helion_kernel.<locals>.decorator  s'   ø€ Ü'¨°6Õ:ÙÑ(˜xÒ(¨Ó,ó
ð 	
r$   )rì   Úhelion.experimentalÚexperimentalÚ
aot_kernelr¡   )r   r  rZ   r  rì   r›   r  s   f$dl  @r!   Úinstrumented_helion_kernelr$    s7   û€ ó Ûç9<�v×*Ñ*×5Ò5À&Ç-Á-Ð÷
ó 
ð
 Ðr$   )	r	   r
   r   rž   r  rÞ   r  r$  r  )(r/   Ú
__future__r   r€   ru   Údataclassesr   r   Útypingr   r   r   r6   ÚtorchÚcollections.abcr   Ú__all__r9   Ú_loggingÚgetArtifactLoggerr+   rL   r   r	   r:   rO   rH   rh   r‚   r�   rž   r®   r   rÞ   rç   r
   r  r  r  r$  r   r$   r!   Ú<module>r-     s  ðñ8õt #ã Û ß )ß .Ñ .ã ÷ Ý(ò
€ð &€à‡n�n×&Ñ& x°Ó@€áˆCƒL€ñ �$Ô÷ð ó ðõ.Cõ(õ>7õ(õ:õzð*ð )-÷õ@÷(.+ñ .+ðbð )-÷õ@÷*+ñ +ð4
ð )-÷
ð,ð )-÷ð0ð )-÷ð0ð ðð )-÷	ñ r$   