+
    –°³jÖ�  ã                   ó   a € R9 tG0 t ^ RIt^ RIt^ RIt^ RIt^ RIHtHt ^ RIHtH	t	 ^ RI
Ht ^ RIHt ^ RIHtHt ^ RIHtHtHt ^ RIt^ RIHu Ht ^ RIHu Ht ^ RIHt ^ R	I H!t! ^ R
I"H#t# ^ RI$H%t% ]PL                  PO                  ](R4      t)R:t*Rt+Rt,]! R4      t-]! R4      t.R R lt/R R lt0]. ]Pb                  R,          3,          t2Rs3] ^ k R R lt4]Pj                  R R l4       t6R R lt7/ t8] ^k RR/R R  llt9R! R" lt:R# R$ lt;R% R& lt< ! R' R(4      t=R) t>R* t?R+ t@]9! R,]>R-R.7       ]9! R]?R-R.7       ]9! R]@R-R.7       R/ R0 ltA ! R1 R2]=4      tB ! R3 R4]B4      tC ! R5 R6]C4      tDR7 R8 ltE]E! 4       tFR# );é    N)ÚCallableÚIterator)Úcached_propertyÚwraps)Úchain©Úmedian)ÚAnyÚConcatenate)Ú	ParamSpecÚSelfÚTypeVar)Úget_interface_for_device)Úcounters)Ú	DebugMode)Ú
OrderedSetÚbenchmarkingÚcudaÚxpuÚ	_CALLABLEiè  ÚPÚTc                ó$   € V ^8„  d   QhR\         /# ©é   Úreturn)Ústr)Úformats   "Úe/home/luca/screen-checking/.venv/lib/python3.14/site-packages/torch/_inductor/runtime/benchmarking.pyÚ__annotate__r        s   € ÷ 
@ñ 
@¤cñ 
@ó    c                  ó  € \          U u. uF+  p \        \        V 4      P                  4       '       g   K)  V NK-  	  pp \	        V4      ^8”  d   \        RV 24      h\	        V4      ^ 8X  d   R# VP                  4       # u up i )é   z-expected at most one available GPU type, got r   )ÚGPU_BENCHMARK_DEVICE_TYPESÚgetattrÚtorchÚis_availableÚlenÚAssertionErrorÚpop)Údevice_typeÚ
avail_gpuss     r   Ú_get_default_gpu_device_typer-       s‚   € õ 6óá5ˆKÜ”5˜+Ó&×3Ñ3×5÷ 	ˆÙ5ð ð ô
 ˆ:ƒ˜ÔÜØ;¸J¸<ÐHó
ð 	
ô ˜“_¨Ô)ˆ6Ð?¨z¯~©~Ó/?Ð?ùòs
   ‰&A<´A<c                óh   € V ^8„  d   QhR\         \        P                  ,          R,          R\         /# )r   r+   Nr   )r   r&   Údevice)r   s   "r   r    r    -   s(   € ÷ *ñ *¬C´%·,±,Õ,>ÀÕ,Eð *Ì#ñ *r!   c                 ó¶   € V f   \        4       # \        V \        P                  4      '       d   V P                  # \        P                  ! V 4      P                  # ©N)r-   Ú
isinstancer&   r/   Útype©r+   s   &r   Ú_normalize_gpu_device_typer5   -   sC   € ØÒÜ+Ó-Ð-Ü�+œuŸ|™|×,Ò,Ø×ÑÐÜ�<Š<˜Ó$×)Ñ)Ð)r!   c                óL   € V ^8„  d   QhR\         R,          R\         R,          /# )r   Úcontext_factoryNr   )Ú_GpuBenchmarkLockContext)r   s   "r   r    r    9   s&   € ÷ ñ Ü-°Õ4ðä Õ$ñr!   c                ó   € \         pV s V# )aS  Override the process-local GPU benchmark lock context.

This lets benchmark harnesses provide the context used by Inductor GPU
benchmark calls. Some benchmark helpers delegate to other benchmark
methods, so harness contexts should support nested entry from the same
thread. Returning the previous context lets callers restore it in tests.
©Ú_gpu_benchmark_lock_context)r7   Úpreviouss   & r   Úset_gpu_benchmark_lock_contextr=   9   s   € ô +€HØ"1ÐØ€Or!   c                ó2   € V ^8„  d   QhR\         R,          /# ©r   r   N)r   )r   s   "r   r    r    J   s   € ÷ ñ ¤(¨4¥.ñ r!   c               #  óŽ   "  € \         p V f   Rx € R# V ! 4       ;_uu_ 4        Rx € RRR4       R#   + '       g   i     R# ; i5i)z;Optionally enter the registered GPU benchmark lock context.Nr:   )r7   s    r   Úmaybe_gpu_benchmark_lockrA   I   s2   é € ô 2€OØÒÛÙÙ	×	Õ	Û÷ 
×	×	Ò	üs   ‚ A¢1§
A±A	¼	Ac                ót   € V ^8„  d   QhR\         \        \        3,          R\         \        \        3,          /# ©r   Úfnr   )r   r   r   )r   s   "r   r    r    T   s*   € ÷ ñ œ8¤A¤q D�>ð ¬h´q¼!°t­nñ r!   c                 ó6   a € \        S 4      R  V 3R ll4       pV# )c                ód   € V ^8„  d   QhR\         P                  R\         P                  R\        /# )r   ÚargsÚkwargsr   )r   rG   rH   r   )r   s   "r   r    Ú(gpu_benchmark_lock.<locals>.__annotate__V   s)   € ÷ 'ñ '”q—v‘vð '¬¯©ð '´añ 'r!   c                  óv   <€ \        4       ;_uu_ 4        S! V / VB uuR R R 4       #   + '       g   i     R # ; ir1   )rA   )rG   rH   rD   s   *,€r   ÚwrapperÚ#gpu_benchmark_lock.<locals>.wrapperU   s(   ø€ ä%×'Õ'Ù�tÐ&˜vÑ&÷ (×'×'Ó'ús   ”'§8	©r   ©rD   rK   s   f r   Úgpu_benchmark_lockrO   T   s    ø€ Ü
ˆ2ƒY÷'ó ð'ð €Nr!   ÚoverrideFc                óZ   € V ^8„  d   QhR\         R\        R\        3,          R\        RR/# )r   r+   rD   .rP   r   N)r   r   r
   Úbool)r   s   "r   r    r    d   s9   € ÷ *ñ *Üð*ä�”c�Õð*ô ð	*ð
 
ñ*r!   c               óæ   € \        V \        4      '       d	   V '       g   \        R4      h\        V4      '       g   \	        R4      hV'       g   V \
        9   d   \        RV  R24      hV\
        V &   R# )a   
Register a device-type specific benchmarker.

Args:
    device_type: torch.device.type string (e.g., "cuda", "cpu", "mps", "xpu").
    fn: callable(self, _callable, *, warmup, rep, **kwargs) -> Any
    override: allow overriding an existing registration.
zAdevice_type must be a non-empty string matching torch.device.typezfn must be callablezBenchmarker for device_type 'z' already registeredN)r2   r   Ú
ValueErrorÚcallableÚ	TypeErrorÚ_BENCHMARK_DISPATCH)r+   rD   rP   s   &&$r   Úregister_benchmarkerrX   d   sl   € ô �k¤3×'Ò'¯{ÜØOó
ð 	
ô �B�<Š<ÜÐ-Ó.Ð.ß˜Ô':Ô:ÜØ+¨K¨=Ð8LÐMó
ð 	
ð (*Ô˜Ó$r!   c                ód   € V ^8„  d   QhR\         R\        3,          R\         R\        3,          /# )r   rD   .r   )r   r
   )r   s   "r   r    r       s,   € ÷  ñ  ¬°´c°Õ(:ð  ¼xÈÌSÈÕ?Qñ  r!   c                 ó¬   a aa€ ^ RI Ho SP                  P                  R8X  d   S # R VV3R llo\        P
                  ! S 4      R VV 3R ll4       pV# )r   )ÚconfigÚ c                óè   € V ^8„  d   QhR\         \        ,          \        \        R3,          ,          \        ,          R\         \        ,          \        \        R3,          ,          \        ,          /# )r   Úms.r   )ÚlistÚfloatÚtuple)r   s   "r   r    Ú5may_distort_benchmarking_result.<locals>.__annotate__…   sN   € ÷ Pñ PÜ”�Kœ%¤ s 
Õ+Õ+¬eÕ3ðPä	Œe�”uœU C˜ZÕ(Õ	(¬5Õ	0ñPr!   c                 ó~  <€ \        V \        \        34      '       d   \        V 4      ! V3R  lV  4       4      # SP                  P
                  p\        V \        4      '       g   \        R\        V 4       24      hVR8X  d   V '       d
   RV ,          # R# VR8X  d   ^ RIpVP                  4       # \        RV 24      h)c              3   ó4   <"  € T F  pS! V4      x € K  	  R # 5ir1   © )Ú.0ÚvalÚdistorts   & €r   Ú	<genexpr>ÚCmay_distort_benchmarking_result.<locals>.distort.<locals>.<genexpr>‰   s   øé € Ð7±B¨S™G CŸL˜L³Bùs   ƒzExpected float, got Úinverseg      ð?ç        ÚrandomNzUnrecognized distort method )
r2   r_   ra   r3   Útest_configsÚdistort_benchmarking_resultr`   r)   rm   ÚRuntimeError)r^   Údistort_methodrm   r[   rh   s   &  €€r   rh   Ú0may_distort_benchmarking_result.<locals>.distort…   s¤   ø€ ô �bœ4¤˜-×(Ò(Ü˜”8Ô7±BÓ7Ó7Ð7à×,Ñ,×HÑHˆÜ˜"œe×$Ò$Ü Ð#7¼¸R»°zÐ!BÓCÐCØ˜YÔ&ß!�3˜•8Ð* sÐ*Ø˜xÔ'Ûà—=‘=“?Ð"äÐ!=¸nÐ=MÐNÓOÐOr!   c          	      óÐ   € V ^8„  d   QhR\         \        ,          R\        \        \        3,          R\         \        ,          \
        \        R3,          ,          \        ,          /# )r   rG   rH   r   .)r_   r
   Údictr   r`   ra   )r   s   "r   r    rb   ˜   sG   € ÷ ñ Ü”C�yðÜ$(¬¬c¨¥Nðä	Œe�”uœU C˜ZÕ(Õ	(¬5Õ	0ñr!   c                  ó$   <€ S! V / VB pS! V4      # r1   re   )rG   rH   r^   rh   rD   s   *, €€r   rK   Ú0may_distort_benchmarking_result.<locals>.wrapper—   s   ø€ ñ �Ð ˜Ñ ˆá�r‹{Ðr!   )Útorch._inductorr[   rn   ro   Ú	functoolsr   )rD   rK   r[   rh   s   f @@r   Úmay_distort_benchmarking_resultry      sT   ú€ Ý&à×Ñ×6Ñ6¸"Ô<Øˆ	÷Pñ Pô$ ‡_‚_�RÓ÷ð ó ðð €Nr!   c                ó   € V ^8„  d   QhRR/# r?   re   )r   s   "r   r    r    ¢   s   € ÷ ñ ˜dñ r!   c                  óp   € \         P                  P                  P                  '       d   \	        R 4      hR# )aî  In the deterministic mode of Inductor, we will avoid those
        benchmarkings that would cause non-deterministic results. Only benchmarkings in the vetted
        scenarios are allowed. Examples include autotuning for triton configs of pointwise kernels.

        When you see this exception, you can do one of the following two things:
        1. if the benchmarking you are doing does not introduce any non-determinism, you can just
        add is_vetted_benchmarking=True to your benchmark_gpu call. That would solve the issue.

        2. if the benchmarking you are doing indeed introduces non-determinism, you'll need to disable
        such feature in deterministic mode or find an alternative implementation that is deterministic.
        N)r&   Ú	_inductorr[   Údeterministicrp   re   r!   r   Úmay_ban_benchmarkingr~   ¢   s/   € Ü‡�×Ñ×+×+Ð+Üð 
ó 
ð 
	ñ ,r!   c                ó¸   € V ^8„  d   QhR\         \        \        \        3,          \        3,          R\         \        \        \        3,          \        3,          /# rC   )r   r   r
   r   r   )r   s   "r   r    r    ±   sB   € ÷ ñ Ü”œS¤!˜VÕ$¤aÐ'Õ(ðäŒkœ#œq˜&Õ!¤1Ð$Õ%ñr!   c                ó6   a € \        S 4      R V 3R ll4       pV# )aU  
Wraps `fn` to increment the appropriate dynamo counters. It is expected that `fn`
is a method of `Benchmarker` or one of its subclasses; typing limitations prevent
us from declaring this directly.

NOTE: If you're tempted to add a dynamo_timed call here, this function can be
called enough that the dynamo_timed overhead is not negligible.
c                óp   € V ^8„  d   QhR\         R\        P                  R\        P                  R\        /# ©r   ÚselfrG   rH   r   )r
   r   rG   rH   r   )r   s   "r   r    Ú$time_and_count.<locals>.__annotate__¾   s0   € ÷ )ñ )”cð )¤!§&¡&ð )´A·H±Hð )Äñ )r!   c                 ó¬   <€ V P                   P                   R SP                   2p\        R,          RV 2;;,          ^,          uu&   S! V .VO5/ VB # )Ú.Úinductorzbenchmarking.)Ú	__class__Ú__name__r   )rƒ   rG   rH   Úfn_qual_namerD   s   &*, €r   rK   Útime_and_count.<locals>.wrapper½   sS   ø€ àŸ.™.×1Ñ1Ð2°!°B·K±K°=ÐAˆÜ�Õ˜}¨\¨NÐ;×<ÀÕAÓ<Ù�$Ð(˜Ò( Ñ(Ð(r!   rM   rN   s   f r   Útime_and_countrŒ   ±   s"   ø€ ô ˆ2ƒY÷)ó ð)ð
 €Nr!   c                   ó¼   a € ] tR t^Æt o RtV 3R lR lt]RV 3R lR ll4       t]RV 3R lR ll4       t]V 3R	 lR
 l4       t	]]
RV 3R lR ll4       4       tRtV tR# )ÚBenchmarkerzc
A device-agnostic benchmarking utility for measuring the runtime of
inductor generated callables.
c                ó@   <€ V ^8„  d   QhRS[ RS[ RS[P                  /# )r   Úfn_argsÚ	fn_kwargsr   )r
   r&   r/   )r   Ú__classdict__s   "€r   r    ÚBenchmarker.__annotate__Ì   s&   ø€ ÷ ñ ¡Sð ±sð ¹u¿|¹|ñ r!   c                óB  € R p\        WP                  4       4       Fp  p\        P                  ! V4       FS  p\	        V\
        P                  4      '       g   K%  Vf   VP                  pK7  VP                  V8w  g   KJ  \        R4      h	  Kr  	  Vf   \        R4      hV# )NzcCan't safely infer the device type of `fn` with multiple device types in `fn_args` and `fn_kwargs`!zÆCan't safely infer the device type of `fn` with no device types in `fn_args` or `fn_kwargs`. Use a direct benchmarking method instead e.g. `Benchmarker.benchmark_cpu` or `Benchmarker.benchmark_gpu`.)	r   ÚvaluesÚpytreeÚtree_leavesr2   r&   ÚTensorr/   rT   )rƒ   r�   r‘   Úinferred_deviceÚarg_or_kwargÚarg_or_kwarg_leafs   &*,   r   Úinfer_deviceÚBenchmarker.infer_deviceÌ   sŸ   € Ø/3ˆÜ! '×+;Ñ+;Ó+=Ö>ˆLô &,×%7Ò%7¸Ö%EÐ!Ü!Ð"3´U·\±\×BÒBÙØ"Ò*Ø&7×&>Ñ&>’OØ&×-Ñ-°Ö@Ü$Ø}óð ó &Fñ ?ð Ò"ÜðNóð ð Ðr!   Nc                óÐ   <€ V ^8„  d   QhRS[ RS[RS[3,          RS[S[R3,          R,          RS[S[S[3,          R,          RS[S[P                  ,          R,          RS[R	S[/# )
r   rƒ   rD   .r�   Nr‘   r/   rH   r   )	r   r   r
   ra   rt   r   r&   r/   r`   )r   r’   s   "€r   r    r“   å   s’   ø€ ÷ VSñ VSÙðVSá�S™#�XÕðVSñ ‘s˜C�x• 4Õ'ðVSñ ™™S˜•> DÕ(ð	VSñ
 ‘e—l‘lÕ" TÕ)ðVSñ ðVSñ 
ñVSr!   c           	     ó.  aaa€ RpVe0   \        V\        4      '       d   \        P                  ! V4      MTpMEVf   Vf   \	        R4      hT;'       g    \        4       pT;'       g    / pV P                  ! V/ VB p\        V\        P                  4      '       g   \        R\        V4       24      hT;'       g    \        4       pT;'       g    / p\        V4      ^ 8X  d   \        V4      ^ 8X  d   R V3R llpMVoVoR VVV3R llpVP                  R\        P                  4      pVP                  R	\        P                  4      p	\        P                  ! 4       ;_uu_ 4        \         P#                  VP                  4      p
V
e   V
! W3RVR	V	/VB uuRRR4       # V\        P                  ! R
4      8X  d"   V P$                  ! V3RVR	V	/VB uuRRR4       # V P&                  ! V3RVR	V	/VB uuRRR4       #   + '       g   i     R# ; i)a  Benchmark `fn(*fn_args, *fn_kwargs)` and return the runtime, in milliseconds (the
actual runtime calculation is dictated by the benchmarking implementation, but may be
one of [mean, median, minimum, etc.]). Functions as a convenience wrapper around
device-specific implementations, like `benchmark_cpu` and `benchmark_gpu`. Raises
`ValueError(...)` if we can't safely infer the device type of `fn`; for example,
if multiple device types are found in `fn_args` and `fn_kwargs`, or if no device
types are found. To bypass device inference, provide the device to the `device`
parameter.

WARNING: if `fn` mutates `fn_args` or `fn_kwargs`, benchmarking may fail unexpectedly.
For example, if `fn` clears a mutable object, subsequent invocations of `fn` during
benchmarking will fail. In such cases, `fn` should handle cloning its arguments internally.
If device inference is required, `Benchmarker.infer_device` can be used prior to calling
this method without any arguments for `fn_args` and `fn_kwargs`.

Arguments:
- fn: The function to benchmark.
- fn_args: The function's arguments.
- fn_kwargs: The function's kwargs.

Keyword Arguments:
- device: Which device to use for benchmarking. If not provided the device will be attempted
to be inferred from `fn_args` and `fn_kwargs`.
- **kwargs: The benchmarking implementation's kwargs.

Returns:
- The runtime of `fn(*fn_args, **fn_kwargs)`, in milliseconds.
NzJ`fn_args` and `fn_kwargs` cannot both be None if `device` is not provided.zExpected torch.device, got c                ó$   € V ^8„  d   QhR\         /# r   ©r
   )r   s   "r   r    Ú+Benchmarker.benchmark.<locals>.__annotate__!  s   € ÷ ñ œsñ r!   c                  ó   <€ S ! 4       # r1   re   )rD   s   €r   Ú	_callableÚ(Benchmarker.benchmark.<locals>._callable!  s
   ø€ Ù“t�r!   c                ó$   € V ^8„  d   QhR\         /# r   r¡   )r   s   "r   r    r¢   '  s   € ÷ -ñ -œsñ -r!   c                  ó   <€ S! S / SB # r1   re   )Ú_argsÚ_kwargsrD   s   €€€r   r¤   r¥   '  s   ø€ Ù˜5Ð, GÑ,Ð,r!   ÚwarmupÚrepÚcpu)r2   r   r&   r/   rT   ra   rœ   r)   r3   r(   r*   Úinductor_configÚ inductor_default_autotune_warmupÚinductor_default_autotune_repr   Ú_benchmarking_inductorrW   ÚgetÚbenchmark_cpuÚbenchmark_gpu)rƒ   rD   r�   r‘   r/   rH   r™   r¤   rª   r«   Úbenchmark_fnr¨   r©   s   &f&&&,     @@r   Ú	benchmarkÚBenchmarker.benchmarkä   sß  ú€ ðJ 04ˆØÒä(2°6¼3×(?Ò(?”—’˜VÔ$ÀVñ ð Š 9Ò#4Ü Ø`óð ð ×(Ð(¤£ˆGØ!Ÿ˜ RˆIØ"×/Ò/°ÐF¸IÑFˆOä˜/¬5¯<©<×8Ò8Ü Ð#>¼tÀOÓ?TÐ>UÐ!VÓWÐWà×$Ð$œU›WˆØ—O�O ˆ	ô ˆw‹<˜1Ô¤ Y£°1Ô!4÷ñ ð ˆEØˆG÷-ò -ð —‘˜H¤o×&VÑ&VÓWˆØ�j‰j˜¤× MÑ MÓNˆô ×-Ò-×/Õ/ä6I×6MÑ6MØ×$Ñ$ó7ˆLð Ò'Ù# DÑV¸FÐVÈÐVÈvÑV÷ 0Ò/ð ¤%§,¢,¨uÓ"5Ô5Ø×)Ò)¨)ÑV¸FÐVÈÐVÈvÑV÷ 0Ò/ð ×%Ò% iÑR¸ÐRÀCÐRÈ6ÑR÷ 0×/×/Ó/ús   Å+0HÆ&1HÇ"HÈH	c          
      óL   <€ V ^8„  d   QhRS[ RS[. S[3,          RS[RS[RS[/# )r   rƒ   r¤   rª   r«   r   )r   r   r
   Úintr`   )r   r’   s   "€r   r    r“   >  s>   ø€ ÷  $ñ  $Ùð $Ù'¨©C¨Õ0ð $Ù:=ð $ÙILð $á	ñ $r!   c                óH   a€ R V3R llpV! V4       \        V! V4      4      # )a£  Benchmark the CPU callable, `_callable`, and return the median runtime,
in milliseconds.

Arguments:
- _callable: The CPU callable to benchmark.

Keyword Arguments:
- warmup: Optionally, the duration, in milliseconds, to run `_callable`
before benchmarking starts.
- rep: Optionally, the duration, in milliseconds, to run `_callable`
during benchmarking.

Returns:
- The median runtime of `_callable`, in milliseconds.
c                óF   € V ^8„  d   QhR\         R\        \        ,          /# )r   r^   r   )r¸   r_   r`   )r   s   "r   r    Ú/Benchmarker.benchmark_cpu.<locals>.__annotate__Q  s   € ÷ 
	ñ 
	œð 
	¤¤U¥ñ 
	r!   c                 ó  <€ . p\         P                  ! 4       p \         P                  ! 4       pS! 4        \         P                  ! 4       pVP                  WC,
          \        ,          4       WB,
          \        ,          V 8”  g   Kn   V# )T)ÚtimeÚperf_counterÚappendÚMILLISECONDS_PER_SECOND)r^   ÚtimingsÚrun_start_tÚstart_tÚend_tr¤   s   &    €r   Úrun_forÚ*Benchmarker.benchmark_cpu.<locals>.run_forQ  sg   ø€ ØˆGÜ×+Ò+Ó-ˆKØÜ×+Ò+Ó-�Ù”Ü×)Ò)Ó+�Ø—‘ ¥Ô3JÕJÔKØÕ(Ô,CÕCÀrÖIØØˆNr!   r   )rƒ   r¤   rª   r«   rÅ   s   &f&& r   r²   ÚBenchmarker.benchmark_cpu=  s%   ø€ ÷(
	ð 
	ñ 	�ŒÜ‘g˜c“lÓ#Ð#r!   c                ó2   <€ V ^8„  d   QhRS[ RS[RS[RS[/# r‚   )r   r
   r`   )r   r’   s   "€r   r    r“   a  s)   ø€ ÷ "ñ "™Dð "©ð "¹ð "Áñ "r!   c                ó   € \         hr1   )ÚNotImplementedError)rƒ   rG   rH   s   &*,r   r³   ÚBenchmarker.benchmark_gpu`  s   € ä!Ð!r!   c          
      ó~   <€ V ^8„  d   QhRS[ RS[. S[3,          RS[S[P
                  ,          R,          RS[RS[/# ©r   rƒ   r¤   Úgrad_to_noneNrH   r   ©r   r   r
   r_   r&   r˜   r`   )r   r’   s   "€r   r    r“   f  sR   ø€ ÷ (?ñ (?Ùð(?á˜B¡˜GÕ$ð(?ñ ™5Ÿ<™<Õ(¨4Õ/ð(?ñ ð	(?ñ
 
ñ(?r!   c                óÆ  € \         P                  P                  4        V! 4        \         P                  P                  4        \         P                  P                  4       pVP	                  \         P                  P                  4       4       \         P                  P                  V4      ;_uu_ 4        Ve   V F
  pRVn        K  	  V! 4        RRR4       VP                  4        \         P                  P                  4       p\         P                  P                  WdRR7      ;_uu_ 4        Ve   V F
  pRVn        K  	  V! 4        RRR4       \         P                  P                  4       P	                  V4       \         P                  P                  4        V P                  ! VP                  3/ VB #   + '       g   i     Ló; i  + '       g   i     L‹; i)zìBenchmark a GPU callable using CUDA graph capture and replay.

This captures the callable into a CUDA graph and benchmarks the graph replay,
which eliminates kernel launch overhead for fair comparison between different
implementations.
NÚthread_local)ÚstreamÚcapture_error_mode)r&   r   ÚsynchronizeÚStreamÚwait_streamÚcurrent_streamrÒ   ÚgradÚ	CUDAGraphÚgraphr³   Úreplay)rƒ   r¤   rÎ   rH   rÒ   ÚxÚ
cuda_graphs   &&&,   r   Úbenchmark_gpu_with_cuda_graphÚ)Benchmarker.benchmark_gpu_with_cuda_graphd  sQ  € ô 	�
‰
×ÑÔ ÙŒÜ�
‰
×ÑÔ ô —‘×"Ñ"Ó$ˆØ×Ñœ5Ÿ:™:×4Ñ4Ó6Ô7Ü�Z‰Z×Ñ˜v×&Õ&ØÒ'Û%�AØ!�A–Fñ &áŒK÷	 'ð
 	×ÑÔä—Z‘Z×)Ñ)Ó+ˆ
Ü�Z‰Z×ÑØ¸.ð ÷ 
õ 
ð Ò'Û%�AØ!�A–Fñ &áŒK÷
ô 	�
‰
×!Ñ!Ó#×/Ñ/°Ô7Ü�
‰
×ÑÔ ð ×!Ò! *×"3Ñ"3Ñ>°vÑ>Ð>÷) '×&ú÷
÷ 
ús   Â6F=Ä1GÆ=G	ÇG 	re   )NNN)é   éd   r1   )r‰   Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__rœ   rŒ   rµ   r²   r³   rO   rÞ   Ú__static_attributes__Ú__classdictcell__©r’   s   @r   rŽ   rŽ   Æ   sƒ   ø‡ € ñ÷
ð ð0 ÷VSñ VSó ðVSðp ÷ $ñ  $ó ð $ðD ÷"ó ð"ð Ø÷(?ñ (?ó ó ö(?r!   rŽ   c                ó0   € V P                   ! V3R VRV/VB # )rª   r«   )r²   ©rƒ   Úfrª   r«   Úkws   &&$$,r   Ú_default_cpu_benchrí   ’  s"   € Ø×Ò˜aÑ>¨Ð>°CÐ>¸2Ñ>Ð>r!   c                óT   € VP                  R R4       V P                  ! V3RVRV/VB # )r+   r   rª   r«   ©Ú
setdefaultr³   rê   s   &&$$,r   Ú_default_cuda_benchrñ   –  s0   € Ø‡M�M�- Ô(Ø×Ò˜aÑ>¨Ð>°CÐ>¸2Ñ>Ð>r!   c                óT   € VP                  R R4       V P                  ! V3RVRV/VB # )r+   r   rª   r«   rï   rê   s   &&$$,r   Ú_default_xpu_benchró   ›  s0   € Ø‡M�M�- Ô'Ø×Ò˜aÑ>¨Ð>°CÐ>¸2Ñ>Ð>r!   r¬   T)rP   c          
      óT   € V ^8„  d   QhR\         R\         R\        R\         R\        /# )r   Úkineto_eventsÚprofiler_eventsr«   Úprofiler_device_typer   )r
   r¸   r`   )r   s   "r   r    r    ¥  sA   € ÷ Kñ KÜðKäðKô 
ðKô ð	Kô
 ñKr!   c           
      óÜ  aaa€ ^ RI Ho \        4       oR VVV3R lloV Uu. uF9  pVP                  \        8X  g   K  VP
                  SP                  8X  g   K7  VNK;  	  pp\        V4      V8w  d#   \        RV R\         R\        V4       R24      hV F  pS! V4       K  	  . pV  Fn  pVP                  4       \        8X  g   K  VP                  4       SP                  8X  g   K?  VP                  VP                  4       VP                  4       34       Kp  	  V'       d†   V  F  pVP                  4       SP                  8w  d   K$  VP                  4       pVP                  4       p	V F5  w  r«WŠ8¼  g   K  W›8:  g   K  SP                  VP                  4       4        K}  	  K�  	  RpV  Fµ  pVP                  4       pVP                  4       pVP                  4       pVP                  4       V8X  g   KJ  VR	8w  g   KS  VS9   g   V^ 8X  g   Kc  VS9   g   Kl  VP                  4       R
8w  g   Kƒ  WÄP                  4       VP                  4       ,
          R,          ,          pK·  	  V# u upi )r   ©Ú
DeviceTypec                ó(   € V ^8„  d   QhR\         RR/# )r   Úeventr   Nr¡   )r   s   "r   r    Ú9_get_callable_device_kernel_time_us.<locals>.__annotate__¯  s   € ÷ )ñ )¤Sð )¨Tñ )r!   c                 ó®   <€ V P                   SP                  8w  d   R # SP                  V P                  4       V P                   F  pS! V4       K  	  R # r1   )r+   ÚCPUÚaddÚidÚcpu_children)rü   Úchildrú   Úbenchmark_event_idsÚcollect_cpu_event_idss   & €€€r   r  ÚB_get_callable_device_kernel_time_us.<locals>.collect_cpu_event_ids¯  sB   ø€ Ø×Ñ 
§¡Ô.Ùà×Ñ §¡Ô)Ø×'Ô'ˆEÙ! %Ö(ó (r!   z	Expected Ú z profiling events. Found z events.rl   Úgpu_user_annotationzContext Syncç     @�@)Útorch.autogradrú   r   ÚnameÚ_CALLABLE_PROFILE_EVENT_NAMEr+   rÿ   r(   rp   r¿   Ústart_nsÚend_nsr   Úcorrelation_idÚlinked_correlation_idÚactivity_type)rõ   rö   r«   r÷   rü   Úbenchmark_eventsÚcallable_kineto_windowsÚevÚev_startÚev_endÚ	win_startÚwin_endÚdevice_time_usr  r  r  rú   r  r  s   &&&&            @@@r   Ú#_get_callable_device_kernel_time_usr  ¥  s)  ú€ õ *ä+5«<Ð÷)ò )ñ %óá$ˆEØ�:‰:Ô5Ñ5ô 	ð ×Ñ §¡Ñ/÷ 	ˆÙ$ð ð ô ÐÓ Ô#ÜØ˜�u˜AÔ:Ð;ð <ÜÐ)Ó*Ð+¨8ð5ó
ð 	
ó
 "ˆÙ˜eÖ$ñ "ð 68ÐÛˆà�G‰G‹IÔ5Ö5Ø—‘Ó  J§N¡NÖ2à#×*Ñ*¨B¯K©K«M¸2¿9¹9»;Ð+GÖHñ ÷ ÛˆBØ�~‰~Ó :§>¡>Ô1ÙØ—{‘{“}ˆHØ—Y‘Y“[ˆFÛ&=Ñ"�	ØÖ(¨VÖ->Ø'×+Ñ+¨B×,=Ñ,=Ó,?Ô@Úó '>ñ  ð €NÛˆØ %× ;Ñ ;Ó =ÐØ×-Ñ-Ó/ˆØ×+Ñ+Ó-ˆà×ÑÓÐ#7Ö7ØÐ!6Ö6à%Ð)<Ô<à)¨QÖ.°>ÐEXÖ3Xð —
‘
“ Ö.àŸ|™|›~°·±Ó0@Õ@ÀFÕJÕJŠNñ ð" Ðùòss   £I)¿I)ÁI)c                   óp   a € ] tR tRt o ]V 3R lR l4       t]]]RV 3R lR ll4       4       4       t	Rt
V tR# )	ÚTritonBenchmarkerió  c                ó:   <€ V ^8„  d   QhRS[ RS[RS[3,          /# )r   rƒ   r   .)r   r   r
   )r   r’   s   "€r   r    ÚTritonBenchmarker.__annotate__õ  s$   ø€ ÷ ñ ™dð ¡x°±S°Õ'9ñ r!   c                óR   €  ^ RI Hp V#   \         d   p\        R4      ThRp?ii ; i)z"Lazily import Triton's `do_bench`.)Údo_benchzrequires TritonN)Útriton.testingr   ÚImportErrorrÊ   )rƒ   r   Úes   &  r   Útriton_do_benchÚ!TritonBenchmarker.triton_do_benchô  s4   € ð	@Ý/ð ˆøô ô 	@Ü%Ð&7Ó8¸aÐ?ûð	@ús   ‚
 Š&•!¡&c          
      óL   <€ V ^8„  d   QhRS[ RS[. S[3,          RS[RS[RS[/# )r   rƒ   r¤   Úis_vetted_benchmarkingrH   r   )r   r   r
   rR   r`   )r   r’   s   "€r   r    r    sD   ø€ ÷ -ñ -Ùð-á˜B¡˜GÕ$ð-ñ !%ð-ñ ð	-ñ
 
ñ-r!   c                ó(  € V'       g   \        4        \        P                  ! V P                  4      P                  p\        VP                  4       4       F  pWT9  g   K  W5 K  	   RV9   d   V P                  ! V3/ VB ^ ,          # RV9   d   V P                  ! V3/ VB # V P                  ! V3/ VBRR/B #   \         dM   p\        T4      P                  4       pRT9   d'   \        P                  RT4       \        R4      u Rp?# h Rp?ii ; i)a¥  Benchmark the GPU callable, `_callable`, and return the runtime, in milliseconds.

Arguments:
- _callable: The GPU callable to benchmark.

Keyword Arguments:
- quantiles: Optionally, a tuple of floats denoting the requested quantiles.
- return_mode: Optionally, the requested return mode. Currently, Triton's
`do_bench` supports min, max, mean, and median return modes.
- **kwargs: Additional kwargs passed to Triton's `do_bench`.

Returns:
- The runtime of `callable`, in milliseconds. If `kwargs["quantiles"]` is specified,
this is the first requested quantile. Else, if `kwargs["return_mode"]` is specified,
this is the requested return mode. Otherwise, this is the median.
Ú	quantilesÚreturn_moder	   zinvalid configurationz9Skipping benchmark due to invalid configuration error: %sÚinfN)r~   ÚinspectÚ	signaturer$  Ú
parametersr_   ÚkeysÚ	Exceptionr   ÚlowerÚloggerÚwarningr`   )rƒ   r¤   r'  rH   Údo_bench_paramsÚkwargr#  Ú	error_strs   &&&,    r   r³   ÚTritonBenchmarker.benchmark_gpuý  sô   € ÷4 &Ü Ô"ä!×+Ò+¨D×,@Ñ,@ÓA×LÑLˆÜ˜&Ÿ+™+›-Ö(ˆEØÖ+Ø’Mñ )ð	Ø˜fÔ$Ø×+Ò+¨IÑ@¸Ñ@ÀÕCÐCØ &Ô(Ø×+Ò+¨IÑ@¸Ñ@Ð@Ø×'Ò'¨	ÑR°VÑRÈÒRÐRøÜô 
	ô ˜A›Ÿ™›ˆIØ&¨)Ô3Ü—‘ØOØôô ˜U“|Õ#Øûð
	ús1   Á( B: Â	B: Â#B: Â:DÃA DÄDÄDÄDre   N)F)r‰   râ   rã   rä   r   r$  ry   rŒ   rO   r³   ræ   rç   rè   s   @r   r  r  ó  s@   ø‡ € Ø÷ó ðð %ØØ÷-ñ -ó ó ó %ö-r!   r  c                   óò   a a€ ] tR tRt oV3R lV 3R llt]V3R lR l4       tRV3R lR lltRV3R lR	 lltV3R
 lR lt	]
RV3R lV 3R lll4       t]]
]RV3R lR ll4       4       4       tRtVtV ;t# )ÚInductorBenchmarkeri1  c                ó$   <€ V ^8„  d   QhRS[ RR/# )r   rƒ   r   N)r   )r   r’   s   "€r   r    Ú InductorBenchmarker.__annotate__2  s   ø€ ÷ -ñ -‘tð - ñ -r!   c                ó2   <€ \         SV `  4        R V n        R# )FN)ÚsuperÚ__init__Ú_in_cudagraph_benchmark)rƒ   rˆ   s   &€r   r>  ÚInductorBenchmarker.__init__2  s   ø€ Ü‰ÑÔØ',ˆÖ$r!   c                ó&   <€ V ^8„  d   QhRS[ RS[/# )r   rƒ   r   )r   r¸   )r   r’   s   "€r   r    r;  7  s   ø€ ÷ ,ñ ,™Dð ,¡Sñ ,r!   c                ó"   € V P                  4       # )z7Get the L2 cache size, in bytes, of the current device.)Úget_device_cache_size)rƒ   s   &r   ÚL2_cache_sizeÚ!InductorBenchmarker.L2_cache_size6  s   € ð ×)Ñ)Ó+Ð+r!   c                ó^   <€ V ^8„  d   QhRS[ RS[S[P                  ,          R,          RS[/# )r   rƒ   r+   Nr   )r   r   r&   r/   r¸   )r   r’   s   "€r   r    r;  ;  s3   ø€ ÷ !ñ !Ùð!Ù!$¡u§|¡|Õ!3°dÕ!:ð!á	ñ!r!   c                óþ   € RV P                   9   d   V P                   R,          # \        V4      p\        V4      pVP                  4       pVP	                  V4      pR F  p\        WER4      pV'       g   K  Vu # 	  R# )z>Get the L2/global cache size, in bytes, of the current device.rD  N)rD  Úlast_level_cache_sizeé   )Ú__dict__r5   r   Úcurrent_deviceÚget_device_propertiesr%   )rƒ   r+   Údevice_interfacer/   ÚpropsÚattrÚ
cache_sizes   &&     r   rC  Ú)InductorBenchmarker.get_device_cache_size;  s{   € ð ˜dŸm™mÔ+Ø—=‘= Õ1Ð1ä0°Ó=ˆÜ3°KÓ@ÐØ!×0Ñ0Ó2ˆØ ×6Ñ6°vÓ>ˆÛ>ˆDÜ  ¨dÓ3ˆJß‰zØ!Ò!ñ ?ð !Ð r!   c                óŠ   <€ V ^8„  d   QhRS[ RS[RS[S[P                  ,          R,          RS[S[S[S[3,          ,          /# )r   rƒ   Úitersr+   Nr   )r   r¸   r   r&   r/   r_   ra   r
   )r   r’   s   "€r   r    r;  L  sH   ø€ ÷ 
ñ 
Ùð
Ùð
Ù-0±5·<±<Õ-?À$Õ-Fð
á	‰e‘C™�H�oÕ	ñ
r!   c                ó®   € \        \        V4      4      p\        V4       Uu. uF'  pVP                  RR7      VP                  RR7      3NK)  	  up# u upi )z#Get `iters` pairs of device events.T)Úenable_timing)r   r5   ÚrangeÚEvent)rƒ   rS  r+   rM  Ú_s   &&&  r   Úget_event_pairsÚ#InductorBenchmarker.get_event_pairsL  sj   € ô 4Ü& {Ó3ó
Ðô ˜5”\ó
ñ
 "�ð !×&Ñ&°TÐ&Ó:Ø ×&Ñ&°TÐ&Ó:óñ "ñ
ð 	
ùò 
s   ¢-Ac                óR   <€ V ^8„  d   QhRS[ RS[S[S[S[3,          ,          RS[/# )r   rƒ   Úevent_pairsr   )r   r_   ra   r
   r`   )r   r’   s   "€r   r    r;  [  s2   ø€ ÷ 	
ñ 	
Ùð	
Ù!%¡e©C±¨H¥oÕ!6ð	
á	ñ	
r!   c           	     ój   € \        V UUu. uF  w  r#VP                  V4      NK  	  upp4      # u uppi )zDGet the minimum timing, in milliseconds, for a group of event pairs.)ÚminÚelapsed_time)rƒ   r\  Ústart_eventÚ	end_events   &&  r   Úget_event_pairs_min_timingÚ.InductorBenchmarker.get_event_pairs_min_timing[  sA   € ô ñ /:ôá.9Ñ*�Kð ×(Ñ(¨Ö3Ù.9òó
ð 	
ùós   ‹/
c          
      ó~   <€ V ^8„  d   QhRS[ RS[. S[3,          RS[S[P
                  ,          R,          RS[RS[/# rÍ   rÏ   )r   r’   s   "€r   r    r;  g  sR   ø€ ÷ ñ Ùðá˜B¡˜GÕ$ðñ ™5Ÿ<™<Õ(¨4Õ/ðñ ð	ñ
 
ñr!   c                ód   <€ R V n          \        SV `  ! V3RV/VB pRV n         V#   RT n         i ; i)TrÎ   F)r?  r=  rÞ   )rƒ   r¤   rÎ   rH   Úresultrˆ   s   &&&, €r   rÞ   Ú1InductorBenchmarker.benchmark_gpu_with_cuda_graphf  sO   ø€ ð (,ˆÔ$ð	1Ü‘WÒ:ØñØ(4ðØ8>ñˆFð ,1ˆDÔ(Øˆøð ,1ˆDÕ(ús   Š& ¦	/c                óú   <€ V ^8„  d   QhRS[ RS[. S[3,          RS[RS[RS[RS[RS[RS[S[P                  ,          R	,          R
S[RS[S[P                  ,          R	,          RS[RS[
S[S[
,          ,          /# )r   rƒ   r¤   Úestimation_itersÚmemory_warmup_itersÚbenchmark_itersÚmax_benchmark_durationr*  rÎ   Nr'  r+   rH   r   )r   r   r
   r¸   r   r_   r&   r˜   rR   r/   r`   )r   r’   s   "€r   r    r;  {  s½   ø€ ÷ Qñ QÙðQá˜B¡˜GÕ$ðQñ ðQñ !ð	Qñ
 ðQñ !$ðQñ ðQñ ™5Ÿ<™<Õ(¨4Õ/ðQñ !%ðQñ ™5Ÿ<™<Õ'¨$Õ.ðQñ ðQñ 
‘‘e•Õ	ñQr!   c
                ó¸  € V'       g   \        4        \        V	4      p	\        V	4      pV	R8X  dY   \        P                  '       dC   \        P
                  '       d-   V P                  '       g    V P                  VVVVVVVV	R7      # VP                  4        V! 4        VP                  4        \        P                  ! V P                  V	4      ^,          \        P                  V	R7      pVP!                  4        V P#                  W)R7      pV FP  w  rïVe   V F
  pRVn        K  	  VP!                  4        VP'                  4        V! 4        VP'                  4        KR  	  VP                  4        V P)                  V4      pV^ 8”  d'   \+        \-        V\        VV,          4      4      ^4      p\/        V4       F  pVP!                  4        K  	  V P#                  WIR7      pV FP  w  rïVe   V F
  pRVn        K  	  VP!                  4        VP'                  4        V! 4        VP'                  4        KR  	  VP                  4        ?VR	8X  d'   V UUu. uF  w  rïVP1                  V4      NK  	  pppV# VR
8X  d   V P)                  V4      p\-        VV4      # \3        RV R24      h  \         d    \        P                  RRR7        ELJi ; iu uppi )aM  Benchmark a GPU callable using a custom benchmarking implementation.

Arguments:
- _callable: The callable to benchmark.

Keyword Arguments:
- estimation_iters: Optionally, the number of iterations to run `_callable`
during runtime estimation.
- memory_warmup_iters: Optionally, the number of iterations to flush the L2
cache before starting benchmarking.
- benchmark_iters: Optionally, the number of iterations to run `_callable`
during the benchmarking.
- max_benchmark_duration: Optionally, the maximum duration of the benchmarking,
in milliseconds. An estimated duration is calculated based on the values
of `memory_warmup_iters` and `benchmark_iters`, along with the estimated
runtime of `_callable` and various other factors, and we then shrink
`benchmark_iters` to fit in the allotted maximum duration.
- return_mode: Return mode for benchmark results. Options are "min" (default),
"all" (returns all measurements).
- grad_to_none: Optionally, a list of tensors whose gradients should be cleared
before each benchmark iteration.
- is_vetted_benchmarking: in deterministic mode, we only allow
benchmarking in vetted cases.
- **kwargs: Additional kwargs that may be passed to the fallback.

Returns:
- If return_mode="min": The minimum runtime of `_callable`, in milliseconds.
- If return_mode="all": List of all runtime measurements, in milliseconds.
r   )ri  rj  rk  rl  r*  rÎ   r+   zQCUDA graph capture failed during benchmarking, falling back to eager benchmarkingT)Úexc_info©Údtyper/   r4   NÚallr^  úUnsupported return_mode: z. Use 'min' or 'all'.)r~   r5   r   r­   Úautotune_cudagraph_benchmarkingÚmax_autotuner?  rÞ   rp   r2  r3  rÔ   r&   ÚemptyrC  r¸   Úzero_rY  rØ   Úrecordrb  Úmaxr^  rV  r_  rT   )rƒ   r¤   ri  rj  rk  rl  r*  rÎ   r'  r+   rH   rM  Úbufferr\  r`  ra  rÜ   Úestimated_timingrX  Úall_timingsÚbenchmarked_timings   &&&&&&&&&&,          r   r³   Ú!InductorBenchmarker.benchmark_gpux  sÎ  € ÷\ &Ü Ô"ä0°Ó=ˆÜ3°KÓ@Ðð ˜6Ô!Ü×?×?Ð?Ü×,×,Ð,Ø×0×0Ð0ðØ×9Ñ9ØØ%5Ø(;Ø$3Ø+AØ +Ø!-Ø +ð :ó 	ð 	ð$ 	×$Ñ$Ô&ñ 	ŒØ×$Ñ$Ô&ô —’Ø×&Ñ& {Ó3°qÕ8Ü—)‘)Øô
ˆð
 	�‰Œð ×*Ñ*Ð+;Ð*ÓUˆÛ&1Ñ"ˆKàÒ'Û%�AØ!�A–Fñ &à�L‰LŒNØ×ÑÔ ÙŒKØ×ÑÖñ '2ð 	×$Ñ$Ô&Ø×:Ñ:¸;ÓGÐð ˜aÔÜ!Ü�O¤SÐ)?ÐCSÕ)SÓ%TÓUÐWXóˆOô
 Ð*Ö+ˆAØ�L‰LŽNñ ,ð ×*Ñ*¨?Ð*ÓTˆÛ&1Ñ"ˆKàÒ'Û%�AØ!�A–Fñ &à�L‰LŒNØ×ÑÔ ÙŒKØ×ÑÖñ '2ð 	×$Ñ$Ô&ð ð ˜%Ôñ /:ôá.9Ñ*�Kð ×(Ñ(¨Ö3Ù.9ð ñ ð ÐØ˜EÔ!Ø!%×!@Ñ!@ÀÓ!MÐô Ð'Ð);Ó<Ð<äØ+¨K¨=Ð8MÐNóð øô[  ô Ü—‘ð9à!ð ÷ ðüóDs   Á/J- ÉKÊ-"KËK)r?  r1   )é   rá   rá   é   r^  NFN)r‰   râ   rã   rä   r>  r   rD  rC  rY  rb  rŒ   rÞ   ry   rO   r³   ræ   rç   Ú__classcell__)rˆ   r’   s   @@r   r9  r9  1  sŒ   ù‡ € ÷-ó -ð ÷,ó ð,÷!ò !÷"
ò 
÷	
ð 	
ð ÷ô ó ðð" %ØØ÷Qñ Qó ó ó %÷Qð Qr!   r9  c                   óN   a € ] tR tRt o Rt]]RV 3R lR ll4       4       tRtV t	R# )ÚTorchProfilerBenchmarkeri  zABenchmarker that uses torch.profiler for GPU kernel benchmarking.Nc                óÚ   <€ V ^8„  d   QhRS[ RS[. S[3,          RS[RS[RS[RS[RS[RS[R	S[S[P                  ,          R
,          RS[S[P                  ,          R
,          RS[RS[	/# )r   rƒ   r¤   rª   r«   ri  rj  rl  r*  rÎ   Nr+   rH   r   )
r   r   r
   r¸   r   r_   r&   r˜   r/   r`   )r   r’   s   "€r   r    Ú%TorchProfilerBenchmarker.__annotate__  s´   ø€ ÷ Zñ ZÙðZá˜B¡˜GÕ$ðZñ ðZñ ð	Zñ
 ðZñ !ðZñ !$ðZñ ðZñ ™5Ÿ<™<Õ(¨4Õ/ðZñ ™5Ÿ<™<Õ'¨$Õ.ðZñ ðZñ 
ñZr!   c
           
     óÆ  € \        V	4      p	\        V	4      pVP                  4        V! 4        VP                  4        \        P                  P
                  '       d   RpMV P                  V	4      p\        P                  ! V^,          \        P                  V	R7      pVP                  4        V P                  WIR7      pV FQ  w  ppVe   V F
  pRVn        K  	  VP                  4        VP                  4        V! 4        VP                  4        KS  	  VP                  4        V P                  V4      pV^ 8”  d'   \        \        V\        VV,          4      4      ^4      p\!        V4       F  pVP                  4        K  	  V	P#                  4       p\%        \        P&                  P(                  V4      p\        P&                  P+                  \        P&                  P(                  P,                  V.RR7      ;_uu_ 4       p\!        V4       F^  pVe   V F
  pRVn        K  	  VP                  4        \        P&                  P/                  R4      ;_uu_ 4        V! 4        RRR4       K`  	  RRR4       TP                  4        ^ RIHp \%        VV4      pRpXP&                  P4                  P7                  4        Fh  pVP9                  4       \:        8X  g   K  VP=                  4       V8X  g   K5  VVP?                  4       VPA                  4       ,
          R	,          ,          pKj  	  V^ 8:  d?   \C        VP&                  P4                  P7                  4       VP7                  4       VV4      pV^ 8:  d   \E        R
V R24      hTpVV,          R	,          p?VR9   d   V# \G        RV R24      h  + '       g   i     EK¶  ; i  + '       g   i     EL`; i)aÙ  Benchmark a GPU callable using torch.profiler.

Arguments:
- _callable: The callable to benchmark.

Keyword Arguments:
- warmup: Ignored (kept for API compat). Warmup is handled by the
estimation phase which runs estimation_iters with cache flushing.
- rep: Optionally, the maximum number of iterations to run during benchmarking.
- estimation_iters: Optionally, the number of iterations used to estimate
the runtime of `_callable` for dynamic rep adjustment. These iterations
also serve as warmup for the callable.
- memory_warmup_iters: Optionally, the number of buffer.zero_() iterations
to run after estimation to bring the cache into a steady state before
the profiled benchmark phase.
- max_benchmark_duration: Optionally, the maximum duration of the profiled
benchmark phase, in milliseconds. The rep count is reduced if the
estimated total would exceed this budget.
- return_mode: Return mode for benchmark results. Options are "min", "mean" (default),
or "max".
- grad_to_none: Optionally, a list of tensors whose gradients should be cleared
before each benchmark iteration.
- **kwargs: Additional kwargs that may be passed to the fallback.

Returns:
- The runtime of `_callable` in milliseconds, computed according to return_mode.
ro  r4   NF)Ú
activitiesÚrecord_shapesr   rù   rl   r	  z&TorchProfilerBenchmarker: '_CALLABLE' zS event not found in raw kineto results, and no correlated device events were found.rr  z. Use 'min', 'mean', or 'max'.rI  )r^  Úmeanrx  )$r5   r   rÔ   r&   ÚversionÚhiprC  ru  r¸   rv  rY  rØ   rw  rb  rx  r^  rV  Úupperr%   ÚprofilerÚProfilerActivityÚprofilerÿ   Úrecord_functionr
  rú   Úkineto_resultsÚeventsr  r  r+   r  r  r  r)   rT   )rƒ   r¤   rª   r«   ri  rj  rl  r*  rÎ   r+   rH   rM  Úbuffer_size_bytesry  r\  r`  ra  rÜ   Úestimated_msrX  Údevice_type_upperÚprofile_activityÚprofÚ_DeviceTyper÷   Úcallable_gpu_time_usÚkineto_eventÚtotal_time_usÚavg_time_mss   &&&&&&&&&&,                  r   r³   Ú&TorchProfilerBenchmarker.benchmark_gpu  so  € ôT 1°Ó=ˆÜ3°KÓ@Ðð 	×$Ñ$Ô&ñ 	ŒØ×$Ñ$Ô&ô
 �=‰=××ÐØ 1Ñà $× :Ñ :¸;Ó GÐÜ—’Ø Õ"¬%¯)©)¸Kô
ˆð 	�‰Œð
 ×*Ñ*Ð+;Ð*ÓUˆÛ&1Ñ"ˆK˜ØÒ'Û%�AØ!�A–Fñ &à�L‰LŒNØ×ÑÔ ÙŒKØ×ÑÖñ '2ð 	×$Ñ$Ô&Ø×6Ñ6°{ÓCˆØ˜!ÔÜ”c˜#œsÐ#9¸LÕ#HÓIÓJÈAÓNˆCô Ð*Ö+ˆAØ�L‰LŽNñ ,ð (×-Ñ-Ó/ÐÜ"¤5§>¡>×#BÑ#BÐDUÓVÐÜ�^‰^×#Ñ#ä—‘×/Ñ/×3Ñ3Ø ðð  ð $÷ 
ô 
ð Ü˜3–Z�ØÒ+Û)˜Ø!%˜žñ *à—‘”ä—^‘^×3Ñ3°K×@Õ@Ù”K÷ AÑ@ñ  ÷
ð  	×$Ñ$Ô&õ 	=ä& {Ð4EÓFÐØ"ÐØ ŸM™M×8Ñ8×?Ñ?ÖAˆLà×!Ñ!Ó#Ô'CÖCØ ×,Ñ,Ó.Ð2FÖFà$Ø ×'Ñ'Ó)¨L×,AÑ,AÓ,CÕCØõ)õ Ò$ñ Bð   1Ô$Ü#FØ—‘×,Ñ,×3Ñ3Ó5Ø—‘“ØØ$ó	$Ð ð   1Ô$Ü Ø8Ð9JÐ8Kð LRð Róð ð -ˆØ$ sÕ*¨fÕ4ˆð ð
 Ð0Ô0ØÐäØ+¨K¨=Ð8VÐWóð ÷e A×@Ñ@ú÷
÷ 
ð 
ús%   È
AOÉ$N:É,OÎ:OÏ
OÏO 	re   )r  rá   r~  é
   r  rˆ  NN)
r‰   râ   rã   rä   rå   rŒ   rO   r³   ræ   rç   rè   s   @r   r‚  r‚    s*   ø‡ € ÙKàØ÷Zñ Zó ó öZr!   r‚  c                ó$   € V ^8„  d   QhR\         /# r   )rŽ   )r   s   "r   r    r    ±  s   € ÷ ñ ¤;ñ r!   c                  ó–   € \         P                  '       d   \        4       # \         P                  '       d   \	        4       # \        4       # r1   )r­   Úuse_torch_profiler_benchmarkerr‚  Úuse_experimental_benchmarkerr9  r  re   r!   r   Ú_make_default_benchmarkerr¢  ±  s5   € Ü×5×5Ð5Ü'Ó)Ð)Ü×3×3Ð3Ü"Ó$Ð$ÜÓÐr!   c                ó²   € V ^8„  d   Qh/ ^ \         9   d   \        R,          ;R&   ^\         9   d(   \        \        \        R\
        3,          3,          ;R&   # )r   Nr;   .rW   )Ú__conditional_annotations__r8   rt   r   r   r
   )r   s   "r   r    r       sJ   € × Ñ ÷j DÒ CÔ5¸Õ<Ñ Cñk ÷@ 8Ò 7”Tœ#œx¨¬S¨Õ1Ð1Õ2Ñ 7òA r!   )r   r   Úmtia)Hr¤  Ú
contextlibrx   r,  r½   Úcollections.abcr   r   r   r   Ú	itertoolsr   Ú
statisticsr	   Útypingr
   r   Útyping_extensionsr   r   r   r&   Útorch._inductor.configr|   r[   r­   Útorch.utils._pytreeÚutilsÚ_pytreer–   Útorch._dynamo.device_interfacer   Útorch._dynamo.utilsr   Útorch.utils._debug_moder   Útorch.utils._ordered_setr   Ú_loggingÚgetArtifactLoggerr‰   r2  r$   r  rÀ   r   r   r-   r5   ÚAbstractContextManagerr8   r;   r=   ÚcontextmanagerrA   rO   rW   rX   ry   r~   rŒ   rŽ   rí   rñ   ró   r  r  r9  r‚  r¢  Úbenchmarkerr    )r¤  s   @r   Ú<module>r¹     sŠ  øðß Ð Û Û Û ß .ß ,Ý Ý ß #ß 6Ñ 6ã ß 0Ð 0ß $Ð $Ý CÝ (Ý -Ý /ð 
�‰×	)Ñ	)¨(°NÓ	C€Ø4Ð Ø*Ð ð Ð áˆcƒN€ÙˆCƒL€õ
@õ*ð $ B¨
×(IÑ(IÈ$Õ(OÐ$OÕPÐ Ø?CÐ Ó Cõð  ×Ñôó ðõð 68Ð Ó 7ð*ð ÷	*õ6 õFõ÷*H?ñ H?òX?ò?ò
?ñ
 �UÐ.¸Õ >Ù �VÐ0¸4Õ @Ù �UÐ.¸Õ >õKô\;˜ô ;ô|[Ð+ô [ô|_Ð2ô _õDñ (Ó)‚r!   