+
    ˜°³j“ ã                  óH  € ^ RI Ht ^ RIt^ RIt^ RIt^ RIt^ RI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 ^ RIHt ^ RIt^ RIHu Ht ^ R	IHt ^ R
IHtHtH t H!t!H"t" ^ RI#H$t$ ^ RI%H&t& ^ RI'H(t(H)t) ^ RI*H+t+H,t, ]'       d	   ^ RI-H.t.H/t/ . R.Ot0Rt1]2! 4       t3]4^3R lt5R R lt6 ! R R]Pn                  4      t8R t9 ! R R]4      t:R R lt; ! R R4      t< ! R  R]4      t=R! R" lt>R#^ R$^ R%^ /R& R' llt?R( R) lt@R/R* R+ lltA ! R, R]<4      tB ! R- R]:4      tCR# )0é    )ÚannotationsN)ÚABCÚabstractmethod)ÚEnum)Úpartial)ÚAnyÚTYPE_CHECKING)Ú
deprecatedÚSelf)Úwarn)Ú_get_privateuse1_backend_name)Ú_add_execution_trace_observerÚ!_disable_execution_trace_observerÚ _enable_execution_trace_observerÚ_ExperimentalConfigÚ _remove_execution_trace_observer)Ú	is_fbcode)Ú1profiler_allow_cudagraph_cupti_lazy_reinit_cuda12)Úkineto_availableÚProfilerActivity)ÚMemoryProfileÚMemoryProfileTimeline)ÚCallableÚIterableÚProfilerActionÚprofileÚExecutionTraceObserverÚProfilerStepc                ód   € V \         9  d%   \         P                  V 4       \        WVR 7       R# R# ))ÚcategoryÚ
stacklevelN)Ú_WARNINGS_SHOWNÚaddr   )Úmsgr    r!   s   &&&ÚX/home/luca/screen-checking/.venv/lib/python3.14/site-packages/torch/profiler/profiler.pyÚ
_warn_oncer&   1   s'   € Ø
”/Ô!Ü×Ñ˜CÔ ÜˆS°
×;ñ "ó    c               ó    € V ^8„  d   QhRRRR/# )é   Úexperimental_configú_ExperimentalConfig | NoneÚreturnzdict[str, Any]© )Úformats   "r%   Ú__annotate__r/   7   s   € ÷ 6ñ 6Ø3ð6àñ6r'   c                óÜ   € V f   / # \        V RR 4      pV'       g   / #  \        P                  ! V4      p\	        T\
        4      '       d   T# / #   \        P                   d    RT/u # i ; i)NÚcustom_profiler_configÚbackend)ÚgetattrÚjsonÚloadsÚJSONDecodeErrorÚ
isinstanceÚdict)r*   ÚrawÚparseds   &  r%   Ú_parse_custom_profiler_configr;   7   st   € ð Ò"Øˆ	Ü
Ð%Ð'?ÀÓ
F€CßØˆ	ð Ü—’˜C“ˆô   ¬×-Ò-ˆ6Ð5°2Ð5øô ×Ñô  Ø˜3ÐÒð ús   ŸA ÁA+Á*A+c                  ó    € ] tR t^FtRtR tRtR# )Ú_NumpyEncoderzr
Json encoder for numpy types (np.int, np.float, np.array etc.)
Returns default encoder if numpy is not available
c                ó˜  €  ^ RI p\        YP                  4      '       d   \        T4      # \        YP                  4      '       d   \        T4      # \        YP                  4      '       d   TP                  4       # \        P                  P	                  Y4      #   \         d#    \        P                  P	                  Y4      u # i ; i)zEncode NumPy types to JSONN)ÚnumpyÚImportErrorr4   ÚJSONEncoderÚdefaultr7   ÚintegerÚintÚfloatingÚfloatÚndarrayÚtolist)ÚselfÚobjÚnps   && r%   rB   Ú_NumpyEncoder.defaultL   s—   € ð	7Ûô �cŸ:™:×&Ò&Ü�s“8ˆOÜ˜Ÿ[™[×)Ò)Ü˜“:ÐÜ˜ŸZ™Z×(Ò(Ø—:‘:“<Ðä×#Ñ#×+Ñ+¨DÓ6Ð6øô ô 	7Ü×#Ñ#×+Ñ+¨DÓ6Ò6ð	7ús   ‚B Â*C	ÃC	r-   N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__rB   Ú__static_attributes__r-   r'   r%   r=   r=   F   s   † ñö
7r'   r=   c                 ó>   € \         P                  P                  4       # )a°  
Returns a set of supported profiler tracing activities.

Note: profiler uses CUPTI library to trace on-device CUDA kernels.
In case when CUDA is enabled but CUPTI is not available, passing
``ProfilerActivity.CUDA`` to profiler results in using the legacy CUDA
profiling code (same as in the legacy ``torch.autograd.profiler``).
This, in turn, results in including CUDA time in the profiler table output,
but not in the JSON trace.
)ÚtorchÚautogradÚ_supported_activitiesr-   r'   r%   Úsupported_activitiesrW   \   s   € ô �>‰>×/Ñ/Ó1Ð1r'   c                  óJ   € ] tR t^jtRt]R 4       t]R 4       t]R 4       tRt	R# )Ú_ITraceObserverzZAbstract interface for a Trace observer.
This satisfies 3 methods: start, stop and cleanupc                	ó   € R # ©Nr-   ©rI   s   &r%   ÚstartÚ_ITraceObserver.startn   ó   € ár'   c                	ó   € R # r[   r-   r\   s   &r%   ÚstopÚ_ITraceObserver.stopr   r_   r'   c                	ó   € R # r[   r-   r\   s   &r%   ÚcleanupÚ_ITraceObserver.cleanupv   r_   r'   r-   N)
rM   rN   rO   rP   rQ   r   r]   ra   rd   rR   r-   r'   r%   rY   rY   j   sC   † ñ9ð ñó ðð ñó ðð ñó ôr'   rY   c               ó    € V ^8„  d   QhRRRR/# )r)   Ú
activitiesz>Iterable[ProfilerActivity | dict[ProfilerActivity, list[str]]]r,   z>tuple[set[ProfilerActivity], dict[ProfilerActivity, set[str]]]r-   )r.   s   "r%   r/   r/   {   s   € ÷ /ñ /ØNð/àCñ/r'   c                ó   € \        4       p/ pV  Fº  p\        V\        4      '       d)   W19   d   \        RV R24      hVP	                  V4       KA  \        V\
        4      '       dO   VP                  4        F8  w  rEWA9   d   \        RV R24      hVP	                  V4       \        V4      W$&   K:  	  K¥  \        R\        V4       24      h	  W3# )a.  Parse a mixed activities list into a set of activities and a filter dict.

Each item is either a bare ``ProfilerActivity`` (collect all defaults) or a
``dict[ProfilerActivity, list[str]]`` (collect only the named subset).
An empty list value (e.g. ``{CUDA: []}``) means collect nothing for that group.
z	Activity z specified more than oncez'Expected ProfilerActivity or dict, got )	Úsetr7   r   Ú
ValueErrorr#   r8   ÚitemsÚ	TypeErrorÚtype)rg   Úparsed_activitiesÚactivity_filtersÚitemÚkeyÚvals   &     r%   Ú_parse_activitiesrs   {   sÌ   € ô 03«uÐØ9;ÐÛˆÜ�dÔ,×-Ò-ØÔ(Ü  9¨T¨FÐ2KÐ!LÓMÐMØ×!Ñ! $Ö'Ü˜œd×#Ò#Ø ŸJ™JžL‘�ØÔ+Ü$ y°°Ð5NÐ%OÓPÐPØ!×%Ñ% cÔ*Ü(+¨C«Ð Ó%ó	 )ô ÐEÄdÈ4ÃjÀ\ÐRÓSÐSñ ð Ð.Ð.r'   c                  óL  € ] tR t^–tRtRRRRRRRRRRR	RR
RRRRRRRRR/R R lltR R ltR R ltR R ltR R lt	R R lt
R6R R lltR R ltR R  ltR7R! R" lltR# R$ ltR8R% R& lltR' tR( R) ltR* R+ ltR, R- ltR. tR/ R0 lt]! R1]R27      R9R3 R4 ll4       tR5tR# ):Ú_KinetoProfilea¤  Low-level profiler wrap the autograd profile

Args:
    activities (iterable): list of activity groups (CPU, CUDA) to use in profiling, supported values:
        ``torch.profiler.ProfilerActivity.CPU``, ``torch.profiler.ProfilerActivity.CUDA``,
        ``torch.profiler.ProfilerActivity.XPU``.
        Default value: ProfilerActivity.CPU and (when available) ProfilerActivity.CUDA
        or (when available) ProfilerActivity.XPU.

        Each item can be a ``ProfilerActivity`` enum (collects all default
        activity types for that group) or a ``dict`` mapping a ``ProfilerActivity``
        to a list of individual activity type names to collect, e.g.
        ``{ProfilerActivity.CUDA: ["GPU_MEMCPY", "CUDA_RUNTIME"]}``.
        An empty list (e.g. ``{ProfilerActivity.CUDA: []}``) means collect
        nothing for that group.
        The same activity group must not appear more than once.
        See :class:`~torch.profiler.ProfilerActivity` for the valid
        activity type names and device-specific behavior.
    record_shapes (bool): save information about operator's input shapes.
    profile_memory (bool): track tensor memory allocation/deallocation (see ``export_memory_timeline``
        for more details).
    with_stack (bool): record source information (file and line number) for the ops.
    with_flops (bool): use formula to estimate the FLOPS of specific operators
        (matrix multiplication and 2D convolution).
    with_modules (bool): record module hierarchy (including function names)
        corresponding to the callstack of the op. e.g. If module A's forward call's
        module B's forward which contains an aten::add op,
        then aten::add's module hierarchy is A.B

        .. deprecated::
            ``with_modules`` is deprecated and will be removed in a future version.
            It only collects data for TorchScript models, which are themselves
            deprecated, and does nothing in eager mode. Use ``with_stack=True``,
            which records ``nn.Module`` events for eager models.
    experimental_config (_ExperimentalConfig) : A set of experimental options
        used by profiler libraries like Kineto. Note, backward compatibility is not guaranteed.
    execution_trace_observer (ExecutionTraceObserver) : A PyTorch Execution Trace Observer object.
        `PyTorch Execution Traces <https://arxiv.org/pdf/2305.14516.pdf>`__ offer a graph based
        representation of AI/ML workloads and enable replay benchmarks, simulators, and emulators.
        When this argument is included the observer start() and stop() will be called for the
        same time window as PyTorch profiler.
    acc_events (bool): Enable the accumulation of FunctionEvents across multiple profiling cycles
    post_processing_timeout_s (float): Optional timeout in seconds for post-processing profiler
        results. In this context, post-processing happens after the profiling itself has finished.
        If specified, event parsing will stop after this duration and return partial results. Useful
        for handling large traces that may take too long to process.


.. note::
    This API is experimental and subject to change in the future.

    Enabling shape and stack tracing results in additional overhead.
    When record_shapes=True is specified, profiler will temporarily hold references to the tensors;
    that may further prevent certain optimizations that depend on the reference count and introduce
    extra tensor copies.
rg   NÚrecord_shapesFÚprofile_memoryÚ
with_stackÚ
with_flopsÚwith_modulesr*   Úexecution_trace_observerÚ
acc_eventsÚcustom_trace_id_callbackÚpost_processing_timeout_sc               óH   € V ^8„  d   QhRRRRRRRRRRRRR	R
RRRRRRRRRR/# )r)   rg   úEIterable[ProfilerActivity | dict[ProfilerActivity, list[str]]] | Nonerv   Úboolrw   rx   ry   rz   r*   r+   r{   ú_ITraceObserver | Noner|   r}   úCallable[[], str] | Noner~   úfloat | Noner,   ÚNoner-   )r.   s   "r%   r/   Ú_KinetoProfile.__annotate__Ð   s’   € ÷ oñ oððoð
 ðoð ðoð ðoð ðoð ðoð 8ðoð #9ðoð ðoð #;ðoð $0ðoð 
ñor'   c               	óR  € Ve   \        V4      w  V n        V n        M\        4       V n        / V n        W n        WPn        W0n        W@n        W`n        VeD   VP                  '       d2   V'       d*   ^ R I
p\        R4       VP                  V4      pRVn	        TpWpn        W€n        W�n        W n        W°n        R V n        RV n        R V n        R V n        \*        P,                  V P                  9   d	   RV n        M£\*        P.                  V P                  9   d	   RV n        M|\*        P0                  V P                  9   d	   RV n        MU\*        P2                  V P                  9   d	   RV n        M.\*        P4                  V P                  9   d   \7        4       V n        / V n        / V n        \=        V P                  4      V n        V P>                  PA                  R4      R8H  ;'       g%    \C        V P>                  PA                  R4      4      V n"        R V n#        R V n$        RV n%        V PD                  '       dÑ   \*        PL                  V P                  9  d   \O        R	4      h\C        V P>                  PA                  R
R4      4      V n%        V P>                  PA                  R4      '       d   ^ RI(H)p V! 4       PU                  4        V P>                  PA                  R4      '       d   ^ RI+H,p V! 4       PU                  4        R # R # R
V P>                  9   d   \O        R4      hR # )Nzxtrace_only=True is incompatible with with_stack=True (stack traces require event post-processing). Disabling trace_only.FÚcudaÚxpuÚmtiaÚhpur2   Úcupti_monitorz>cupti_monitor profiler backend currently requires CPU activityÚcupti_monitor_async_exportÚenable_graph_dependencies)Ú_GraphDependencyRecorderÚenable_event_node_ids)Ú_EventNodeRecorderzKcupti_monitor_async_export is only supported with the cupti_monitor backend)-rs   rg   ro   rW   rv   ry   rw   rx   rz   Ú
trace_onlyÚcopyr   r*   r{   r|   r}   r~   ÚprofilerÚhas_cudagraphsÚmem_tlÚ
use_devicer   ÚCUDAÚXPUÚMTIAÚHPUÚPrivateUse1r   Úpreset_metadataÚ_trace_metadatar;   Ú_custom_profiler_configÚgetr�   Ú_use_cupti_monitorÚ_cupti_profiler_observerÚ_monitor_window_idÚ_cupti_async_exportÚCPUrj   Ú!torch.profiler._cupti._graph_depsr�   ÚarmÚ"torch.profiler._cupti._event_nodesr‘   )rI   rg   rv   rw   rx   ry   rz   r*   r{   r|   r}   r~   r“   Úexperimental_config_copyr�   r‘   s   &$$$$$$$$$$$    r%   Ú__init__Ú_KinetoProfile.__init__Ð   s½  € ð  Ò!Ü5FÀzÓ5RÑ2ˆDŒO˜TÕ2ä2Ó4ˆDŒOØFHˆDÔ!Ø*ÔØ$ŒØ,ÔØ$ŒØ(ÔàÒ+Ø#×.×.Ð.ßãäð(ôð
 =A¿I¹IØ#ó=Ð$ð 38Ð$Ô/Ø":ÐØ#6Ô Ø(@Ô%Ø$ŒØ(@Ô%Ø)BÔ&Ø-1ˆŒØ#ˆÔØ48ˆŒØˆŒÜ× Ñ  D§O¡OÔ3à$ˆD�OÜ×!Ñ! T§_¡_Ô4à#ˆD�OÜ×"Ñ" d§o¡oÔ5à$ˆD�OÜ×!Ñ! T§_¡_Ô4à#ˆD�OÜ×)Ñ)¨T¯_©_Ô<ä;Ó=ˆDŒOð 02ˆÔØ/1ˆÔÜ'DØ×$Ñ$ó(
ˆÔ$ð #'×">Ñ">×"BÑ"BØó#
àñ#÷ #Xð #Xä $ T×%AÑ%A×%EÑ%EÀoÓ%VÓ Wð 	Ôð
 .2ˆÔ%Ø.2ˆÔð $)ˆÔ Ø×"×"Ð"Ü×#Ñ#¨4¯?©?Ô:Ü ØTóð ô (,Ø×,Ñ,×0Ñ0Ð1MÈuÓUó(ˆDÔ$ð ×+Ñ+×/Ñ/Ð0K×LÒLÝVá(Ó*×.Ñ.Ô0ð ×+Ñ+×/Ñ/Ð0G×HÒHÝQá"Ó$×(Ñ(Ö*ñ Ið *¨T×-IÑ-IÔIÜðóð ñ Jr'   c               ó   € V ^8„  d   QhRR/# ©r)   r,   r…   r-   )r.   s   "r%   r/   r†   A  s   € ÷ ñ �tñ r'   c                	óF   € V P                  4        V P                  4        R # r[   )Úprepare_traceÚstart_tracer\   s   &r%   r]   Ú_KinetoProfile.startA  s   € Ø×ÑÔØ×ÑÖr'   c               ó   € V ^8„  d   QhRR/# r­   r-   )r.   s   "r%   r/   r†   E  s   € ÷ ñ �dñ r'   c                	ó&   € V P                  4        R # r[   )Ú
stop_tracer\   s   &r%   ra   Ú_KinetoProfile.stopE  s   € Ø�‰Ör'   c               ó   € V ^8„  d   QhRR/# r­   r-   )r.   s   "r%   r/   r†   H  s   € ÷ J'ñ J'˜tñ J'r'   c                	ó„  € \        \        R 4      '       d%   ^ RIHu Hp VP
                  P                  V n        V P                  e   V P                  '       g   \        R4       V P                  e   V P                  '       gÜ   V P                  '       d   RMV P                  p\        P                  ! \        P                   V P"                  9   TV P$                  V P&                  V P(                  V P*                  V P,                  RV P.                  V P                  V P0                  V P2                  V P4                  '       d   V P4                  MRR7      V n        V P                  '       Ed3   ^ RIHp RV n        V! \=        V P>                  PA                  R4      4      \=        V P>                  PA                  R4      4      \=        V P>                  PA                  R4      4      V P>                  PA                  R	4      \=        V P>                  PA                  R
4      4      \=        V P>                  PA                  R4      4      \C        V P>                  PA                  R^4      4      V PD                  R7      V n#        \        PH                  ! V PF                  4       V P                  PK                  4        R# )Ú	_inductorNz¡Warning: Profiler clears events at the end of each cycle. Only events from the current cycle will be reported. To keep events across cycles, set acc_events=True.T)Úuse_cpur—   rv   ry   rw   rx   rz   Ú
use_kinetor*   r|   r}   r~   ro   )ÚProfilerObserverÚenable_cuda_sync_eventsÚenable_environment_countersÚenable_pm_samplingÚ
pm_metricsrŽ   r�   Úpftrace_compression_level)Úenable_cuda_syncr½   r¾   r¿   rŽ   r�   rÀ   Údefer_export)&ÚhasattrrT   Útorch._inductor.configr¸   ÚconfigÚtritonÚ
cudagraphsr•   r”   r|   r&   r¡   r—   Úprofr   r   r¥   rg   rv   ry   rw   rx   rz   r*   r}   r~   ro   Ú(torch.profiler._cupti.observers.profilerr»   Ú_monitor_trace_windowr�   rŸ   r    rD   r¤   r¢   Ú#_set_active_cupti_profiler_observerÚ_prepare_trace)rI   Úinductor_configr—   r»   s   &   r%   r¯   Ú_KinetoProfile.prepare_traceH  s,  € Ü”5˜+×&Ò&ß<Ð<à"1×"8Ñ"8×"CÑ"CˆDÔØ�M‰MÒ%°··°ÜðEôð
 �M‰MÒ!¨4¯?¯?¨?Ø!%×!8×!8Ð!8™¸d¿o¹oˆJÜ ŸLšLÜ)×-Ñ-°·±Ñ@Ø%Ø"×0Ñ0ØŸ?™?Ø#×2Ñ2ØŸ?™?Ø!×.Ñ.ØØ$(×$<Ñ$<ØŸ?™?Ø)-×)FÑ)FØ*.×*HÑ*Hà×(×(Ð(ð "&×!6Ò!6àôˆDŒMð" ×"×"Ñ"ÝQà)-ˆDÔ&ñ -=Ü!%Ø×0Ñ0×4Ñ4Ð5NÓOó"ô
 -1Ø×0Ñ0×4Ñ4Ð5RÓSó-ô $(Ø×0Ñ0×4Ñ4Ð5IÓJó$ð  ×7Ñ7×;Ñ;¸LÓIô +/Ø×0Ñ0×4Ñ4Ð5PÓQó+ô '+Ø×0Ñ0×4Ñ4Ð5LÓMó'ô +.Ø×0Ñ0×4Ñ4Ð5PÐRSÓTó+ð "×5Ñ5ôA!-ˆDÔ)ôJ ×4Ò4°T×5RÑ5RÔSØ�‰×$Ñ$Ö&r'   c               ó   € V ^8„  d   QhRR/# r­   r-   )r.   s   "r%   r/   r†   ”  s   € ÷ 1-ñ 1-˜Tñ 1-r'   c                	ó  € V P                   '       d   V P                   P                  4        V P                  f   \        R4      hV P                  P	                  4        V P
                  '       d)   V P                  e   V P                  P                  4        V P                  '       d   V P                  RR4       V P                  '       d   V P                  RR4       V P                  '       d   V P                  RR4       V P                  '       d   V P                  RR4       V P                  '       d   V P                  RR4       \        4       '       Ed#   V P                  4       pV'       d-   V P                  R\         P"                  ! V\$        R	7      4       R p\'        \(        R
4      '       d(   ^ RIHp V! \/        \(        P0                  RR4      4      pV P2                  '       dX   V'       d   VR8  g   \5        4       '       g9   R\6        P8                  R&   V P                  RR4       R\6        P8                  R&   V P:                  P=                  4        F  w  rEV P                  WE4       K  	  R # R # )Nz2Profiler must be initialized before starting tracerw   Ú1rx   rv   rz   ry   ÚdistributedInfo©ÚclsÚversion)ÚTorchVersionrˆ   z0.0z12.6ÚDISABLE_CUPTI_LAZY_REINITÚ0ÚTEARDOWN_CUPTI)r{   r]   r”   ÚAssertionErrorÚ_start_tracer¡   r¢   Úopen_windowrw   Úadd_metadata_jsonrx   rv   rz   ry   r   Ú_get_distributed_infor4   Údumpsr=   rÃ   rT   Útorch.torch_versionrÖ   r3   rÕ   r•   r   ÚosÚenvironr�   rk   )rI   Ú	dist_infoÚcuda_versionrÖ   ÚkÚvs   &     r%   r°   Ú_KinetoProfile.start_trace”  sÞ  € Ø×(×(Ð(Ø×)Ñ)×/Ñ/Ô1Ø�=‰=Ò Ü Ð!UÓVÐVØ�‰×"Ñ"Ô$Ø×"×"Ð" t×'DÑ'DÒ'Pð ×)Ñ)×5Ñ5Ô7à××ÐØ×"Ñ"Ð#3°SÔ9Ø�?�?ˆ?Ø×"Ñ" <°Ô5Ø××ÐØ×"Ñ" ?°CÔ8Ø××ÐØ×"Ñ" >°3Ô7Ø�?�?ˆ?Ø×"Ñ" <°Ô5ä×ÓØ×2Ñ2Ó4ˆIßØ×&Ñ&Ø%¤t§z¢z°)ÄÔ'Oôð  ˆLÜ”u˜i×(Ò(Ý<á+¬G´E·M±MÀ6È5Ó,QÓR�à×"×"Ð"ß ,°Ô"7ÜH×JÒJà:=”—
‘
Ð6Ñ7Ø×&Ñ&Ð'BÀCÔHð
 03”—
‘
Ð+Ñ,ð ×,Ñ,×2Ñ2Ö4‘�Ø×&Ñ& qÖ,ó 5ñ5 r'   c               ó   € V ^8„  d   QhRR/# r­   r-   )r.   s   "r%   r/   r†   Ç  s   € ÷ 1ñ 1˜Dñ 1r'   c                	ót  € V P                   '       d   V P                   P                  4        V P                  f   \        R4      hV P                  '       dD   \
        P                  ! R 4       V P                  e    V P                  P                  4       V n	        V P                  P                  R R R 4       R # )Nz2Profiler must be initialized before stopping trace)r{   ra   r”   rÚ   r¡   rÈ   rË   r¢   Úclose_windowr£   Ú__exit__r\   s   &r%   r´   Ú_KinetoProfile.stop_traceÇ  s‹   € Ø×(×(Ð(Ø×)Ñ)×.Ñ.Ô0Ø�=‰=Ò Ü Ð!UÓVÐVØ×"×"Ð"ô ×4Ò4°TÔ:Ø×,Ñ,Ò8Ø*.×*GÑ*G×*TÑ*TÓ*V�Ô'Ø�‰×Ñ˜t T¨4Ö0r'   c               ó    € V ^8„  d   QhRRRR/# )r)   ÚpathÚstrÚuse_python_exportr�   r-   )r.   s   "r%   r/   r†   Õ  s   € ÷ 6Jñ 6J¨ð 6JÀñ 6Jr'   c                ó�  € V P                   f   \        R4      hV P                  '       Ed8   V P                  pVe!   VP                  '       d   V P
                  fB   \        R4       Ve#   VP                  '       d   VP                  4        RV n        RV n        R# \        P                  ! RRRR7      pVP                  4        V P                   P                  VP                  V P                  4       V P                  P                  V P
                  VP                  V4       V P                  '       g)   V P                  P                  4        RV n        RV n        R# V'       d*   V P                   P                  WP                  RR	7       R# VP!                  R
4      '       d¼   \        P                  ! RRR7      ;_uu_ 4       pV P                   P                  VP                  V P                  4       \#        VP                  R4      ;_uu_ 4       p\$        P"                  ! VR4      ;_uu_ 4       pVP'                  V4       RRR4       RRR4       RRR4       R# V P                   P                  WP                  4       R#   + '       g   i     LI; i  + '       g   i     LT; i  + '       g   i     R# ; i)zs
Exports the collected trace in Chrome JSON format. If kineto is enabled, only
last cycle in schedule is exported.
Nz:Profiler must be initialized before exporting chrome tracez@CUPTI monitor observer unavailable; skipping chrome trace exportúw+tú.jsonF©ÚsuffixÚdeleteT©rð   ú.gzúw+b©rõ   ÚrbÚwb)r”   rÚ   r¡   r¢   Ú	availabler£   r&   ÚjoinÚtempfileÚNamedTemporaryFileÚcloseÚexport_chrome_traceÚnamerž   Ú
set_exportr¤   ÚendswithÚopenÚgzipÚ
writelines)rI   rî   rð   ÚobsÚfpÚfinÚfouts   &&&    r%   r  Ú"_KinetoProfile.export_chrome_traceÕ  s  € ð
 �=‰=Ò Ü ØLóð ð ×"×"Ñ"Ø×/Ñ/ˆCØŠ{ #§-§- -°4×3JÑ3JÒ3Rô
 ØVôð ’? s§}§} }Ø—H‘H”JØ04�Ô-Ø*.�Ô'Ùô ×,Ò,Ø˜g¨eôˆBð �H‰HŒJØ�M‰M×-Ñ-¨b¯g©g°t×7KÑ7KÔLØ×)Ñ)×4Ñ4Ø×'Ñ'¨¯©°$ôð ×+×+Ð+à×-Ñ-×2Ñ2Ô4Ø04�Ô-Ø*.�Ô'ÙßØ�M‰M×-Ñ-Ø×*Ñ*¸dð .ö ð �]‰]˜5×!Ò!Ü×,Ò,¨U¸7×CÕCÀrØ—‘×1Ñ1°"·'±'¸4×;OÑ;OÔPÜ˜"Ÿ'™' 4×(Ô(¨C´·²¸4À×1FÔ1FÈ$Ø—O‘O CÔ(÷ 2G×(÷ DÑCð
 �M‰M×-Ñ-¨d×4HÑ4HÖI÷ 2G×1Fú×(×(ú÷ D×CÐCús=   ÇAJ4È J!	È;JÉJ!	ÉJ4ÊJÊJ!	Ê!J1Ê,J4Ê4K	c               ó   € V ^8„  d   QhRR/# r­   r-   )r.   s   "r%   r/   r†     s   € ÷ +ñ + $ñ +r'   c                óž   € V P                   '       d;   V P                  e+   V P                  P                  4        RV n        RV n        R# R# R# )zëBlock until every deferred cupti_monitor export is written, then unregister.
No-op unless the cupti_monitor backend is active. Call on the training thread when
you need the file(s) on disk; the finalize force-flushes CUPTI (safe here).N)r¡   r¢   rþ   r£   r\   s   &r%   Úwait_for_exportsÚ_KinetoProfile.wait_for_exports  sF   € ð ×"×"Ð" t×'DÑ'DÒ'PØ×)Ñ)×.Ñ.Ô0Ø,0ˆDÔ)Ø&*ˆDÖ#ñ (QÑ"r'   c               ó   € V ^8„  d   QhRR/# )r)   r,   r   r-   )r.   s   "r%   r/   r†     s   € ÷ 	ñ 	¨3ñ 	r'   c                ób   € V P                   '       g   R# V P                  pRV n        RV n        V# )zÙDetach this cycle's cupti_monitor ProfilerObserver (with its unwritten window) so
the deferred export can be finalized OFF the training thread (call
``obs.join(force=False)`` on a worker). None for non-cupti backends.N)r¡   r¢   r£   )rI   r	  s   & r%   Útake_pending_cupti_exportÚ(_KinetoProfile.take_pending_cupti_export  s3   € ð ×&×&Ð&ÙØ×+Ñ+ˆØ(,ˆÔ%Ø"&ˆÔØˆ
r'   c               ó    € V ^8„  d   QhRRRR/# )r)   rî   rï   Úmetricr-   )r.   s   "r%   r/   r†   !  s   € ÷ 	9ñ 	9 #ð 	9¨sñ 	9r'   c                ój   € V P                   f   \        R4      hV P                   P                  W4      # )z§Save stack traces to a file

Args:
    path (str): save stacks file to this location;
    metric (str): metric to use: "self_cpu_time_total" or "self_cuda_time_total"
z4Profiler must be initialized before exporting stacks)r”   rÚ   Úexport_stacks)rI   rî   r  s   &&&r%   r  Ú_KinetoProfile.export_stacks!  s/   € ð �=‰=Ò Ü Ð!WÓXÐXØ�}‰}×*Ñ*¨4Ó8Ð8r'   c               ó$   € V ^8„  d   QhRRRRRR/# )r)   Úenabler�   rg   zIterable[ProfilerActivity]r,   r…   r-   )r.   s   "r%   r/   r†   ,  s)   € ÷ Dñ DØðDØ(BðDà	ñDr'   c                ó\   € V P                   f   R# V P                   P                  W4       R# )aÛ  Toggle collection of activities on/off at any point of collection. Currently supports toggling Torch Ops
(CPU) and CUDA activity supported in Kineto

Args:
    activities (iterable): list of activity groups to use in profiling, supported values:
        ``torch.profiler.ProfilerActivity.CPU``, ``torch.profiler.ProfilerActivity.CUDA``
Examples:

.. code-block:: python

    with torch.profiler.profile(
        activities=[
            torch.profiler.ProfilerActivity.CPU,
            torch.profiler.ProfilerActivity.CUDA,
        ]
    ) as p:
        code_to_profile_0()
        // turn off collection of all CUDA activity
        p.toggle_collection_dynamic(False, [torch.profiler.ProfilerActivity.CUDA])
        code_to_profile_1()
        // turn on collection of all CUDA activity
        p.toggle_collection_dynamic(True, [torch.profiler.ProfilerActivity.CUDA])
        code_to_profile_2()
    print(p.key_averages().table(
        sort_by="self_cuda_time_total", row_limit=-1))
N)r”   Útoggle_collection_dynamic)rI   r  rg   s   &&&r%   r  Ú(_KinetoProfile.toggle_collection_dynamic,  s#   € ð: �=‰=Ò ÙØ�‰×/Ñ/°ÖCr'   c               ó(   € V ^8„  d   QhRRRRRRRR/# )r)   Úgroup_by_input_shaper�   Úgroup_by_stack_nrD   Úgroup_by_overload_nameÚinclude_python_functionsr-   )r.   s   "r%   r/   r†   M  s2   € ÷ 
ñ 
à"ð
ð ð
ð !%ð	
ð
 #'ñ
r'   c                óp   € V P                   f   \        R4      hV P                   P                  VVVV4      # )aE  Averages events, grouping them by operator name and (optionally) input shapes, stack
and overload name.

Returns an :class:`~torch.autograd.profiler_util.EventList` of the aggregated events.

.. note::
    To use shape/stack functionality make sure to set record_shapes/with_stack
    when creating profiler context manager.
z8Profiler must be initialized before getting key averages)r”   rÚ   Úkey_averages)rI   r!  r"  r#  r$  s   &&&&&r%   r&  Ú_KinetoProfile.key_averagesM  sC   € ð  �=‰=Ò Ü ØJóð ð �}‰}×)Ñ)Ø ØØ"Ø$ó	
ð 	
r'   c                óÊ   € V P                   f   \        R4      hV P                  e(   V P                  P                  '       d   \	        R4      hV P                   P
                  # )zž
Return the list of unaggregated :class:`~torch.autograd.profiler_util.FunctionEvent`
objects, for use in the trace callback or after profiling has finished.
z4Profiler must be initialized before accessing eventszhevents() is not available when trace_only=True in ExperimentalConfig. Use export_chrome_trace() instead.)r”   rÚ   r*   r’   ÚRuntimeErrorÚfunction_eventsr\   s   &r%   ÚeventsÚ_KinetoProfile.eventsh  s\   € ð
 �=‰=Ò Ü Ð!WÓXÐXØ×#Ñ#Ò/°D×4LÑ4L×4W×4WÐ4WÜðIóð ð �}‰}×,Ñ,Ð,r'   c               ó$   € V ^8„  d   QhRRRRRR/# ©r)   rq   rï   Úvaluer,   r…   r-   )r.   s   "r%   r/   r†   v  s!   € ÷ >ñ > ð >¨Cð >°Dñ >r'   c                ó    € RVP                  RR4      ,           R,           pW0P                  V&   \        P                  P	                  W4       R# )zW
Adds a user defined metadata with a string key and a string value
into the trace file
Ú"z\"N)Úreplacerž   rT   rU   Ú_add_metadata_json)rI   rq   r/  Úwrapped_values   &&& r%   Úadd_metadataÚ_KinetoProfile.add_metadatav  s>   € ð
 ˜eŸm™m¨C°Ó7Õ7¸#Õ=ˆØ$1×Ñ˜SÑ!Ü�‰×)Ñ)¨#Ö=r'   c               ó$   € V ^8„  d   QhRRRRRR/# r.  r-   )r.   s   "r%   r/   r†     s!   € ÷ 6ñ 6 Sð 6°ð 6¸ñ 6r'   c                ó`   € W P                   V&   \        P                  P                  W4       R# )z[
Adds a user defined metadata with a string key and a valid json value
into the trace file
N)rž   rT   rU   r3  ©rI   rq   r/  s   &&&r%   rÝ   Ú _KinetoProfile.add_metadata_json  s$   € ð
 %*×Ñ˜SÑ!Ü�‰×)Ñ)¨#Ö5r'   c               ó$   € V ^8„  d   QhRRRRRR/# r.  r-   )r.   s   "r%   r/   r†   ‡  s!   € ÷ *ñ *¨ð *°Cð *¸Dñ *r'   c                ó"   € W P                   V&   R# )z§
Preset a user defined metadata when the profiler is not started
and added into the trace file later.
Metadata is in the format of a string key and a valid json value
N)r�   r9  s   &&&r%   Úpreset_metadata_jsonÚ#_KinetoProfile.preset_metadata_json‡  s   € ð %*×Ñ˜SÓ!r'   c                	ó¾  € ^ RI Hp VP                  4       '       d   VP                  4       '       g   R# VP	                  4       pRVRVP                  4       RVP                  4       RVP                  4       RVP                  P                  4       /pVR8X  dD   \        P                  P                  P                  4       pRP                  R	 V 4       4      VR
&   V# )r   Nr2   ÚrankÚ
world_sizeÚpg_countÚ	pg_configÚncclÚ.c              3  ó8   "  € T F  p\        V4      x € K  	  R # 5ir[   )rï   )Ú.0ræ   s   & r%   Ú	<genexpr>Ú7_KinetoProfile._get_distributed_info.<locals>.<genexpr>   s   é € Ð0NÁ¸A´°Q·°Ãùs   ‚Únccl_version)Útorch.distributedÚdistributedÚis_availableÚis_initializedÚget_backendÚget_rankÚget_world_sizeÚget_pg_countÚdistributed_c10dÚ_get_all_pg_configsrT   rˆ   rD  rÕ   rþ   )rI   Údistr2   rã   rJ  s   &    r%   rÞ   Ú$_KinetoProfile._get_distributed_info�  s¹   € Ý(à× Ñ ×"Ò"¨$×*=Ñ*=×*?Ò*?Ùà×"Ñ"Ó$ˆà�wØ�D—M‘M“OØ˜$×-Ñ-Ó/Ø˜×)Ñ)Ó+Ø˜×.Ñ.×BÑBÓDð
ˆ	ð �fÔÜ Ÿ:™:Ÿ?™?×2Ñ2Ó4ˆLà(+¯©Ñ0NÁÓ0NÓ(NˆI�nÑ%ØÐr'   c               ó   € V ^8„  d   QhRR/# )r)   r,   r   r-   )r.   s   "r%   r/   r†   £  s   € ÷ 
;ñ 
; ñ 
;r'   c                	óH  € RpV Uu. uF  p\        W4      '       d   K  V R2NK  	  ppV'       d   \        RP                  V4       R24      hV P                  e   V P                  P                  f   \        R4      h\        V P                  P                  4      # u upi )rv   z=Truez, z required for memory profiling.zDProfiler and kineto_results must be initialized for memory profiling)rv   rw   rx   )r3   rj   rþ   r”   Úkineto_resultsrÚ   r   )rI   ÚrequiredÚiÚmissings   &   r%   Ú_memory_profileÚ_KinetoProfile._memory_profile£  s�   € ØDˆÙ(0ÓI© 1¼À×8H”;�a�S˜“;©ˆÐIßÜ §	¡	¨'Ó 2Ð3Ð3RÐSÓTÐTà�=‰=Ò  D§M¡M×$@Ñ$@Ò$HÜ ØVóð ô ˜TŸ]™]×9Ñ9Ó:Ð:ùò Js
   ‡BŸ	Bz¾`export_memory_timeline` is deprecated and will be removed in a future version. Please use `torch.cuda.memory._record_memory_history` and `torch.cuda.memory._export_memory_snapshot` instead.)r    c               ó$   € V ^8„  d   QhRRRRRR/# )r)   rî   rï   Údeviceú
str | Noner,   r…   r-   )r.   s   "r%   r/   r†   ´  s!   € ÷ 2=ñ 2=¨3ð 2=¸
ð 2=Èdñ 2=r'   c                ó$  € Vf`   V P                   '       d&   V P                   R8w  d   V P                   R,           pM(\        P                  P                  4       '       d   RMRp\	        V P                  4       4      V n        VP                  R4      '       d   V P                  P                  W4       R# VP                  R4      '       dï   \        P                  ! RR	R
7      ;_uu_ 4       pVP                  R4      '       d(   V P                  P                  VP                  V4       M&V P                  P                  VP                  V4       \        VP                  4      ;_uu_ 4       p\        P                  ! VR4      ;_uu_ 4       pVP!                  V4       RRR4       RRR4       RRR4       R# V P                  P                  W4       R#   + '       g   i     L?; i  + '       g   i     LJ; i  + '       g   i     R# ; i)aÑ  Export memory event information from the profiler collected
tree for a given device, and export a timeline plot. There are 3
exportable files using ``export_memory_timeline``, each controlled by the
``path``'s suffix.

- For an HTML compatible plot, use the suffix ``.html``, and a memory timeline
  plot will be embedded as a PNG file in the HTML file.

- For plot points consisting of ``[times, [sizes by category]]``, where
  ``times`` are timestamps and ``sizes`` are memory usage for each category.
  The memory timeline plot will be saved a JSON (``.json``) or gzipped JSON
  (``.json.gz``) depending on the suffix.

- For raw memory points, use the suffix ``.raw.json.gz``. Each raw memory
  event will consist of ``(timestamp, action, numbytes, category)``, where
  ``action`` is one of ``[PREEXISTING, CREATE, INCREMENT_VERSION, DESTROY]``,
  and ``category`` is one of the enums from
  ``torch.profiler._memory_profiler.Category``.

Output: Memory timeline written as gzipped JSON, JSON, or HTML.

.. deprecated::
    ``export_memory_timeline`` is deprecated and will be removed in a future version.
    Please use ``torch.cuda.memory._record_memory_history`` and
    ``torch.cuda.memory._export_memory_snapshot`` instead.
Nrˆ   z:0zcuda:0Úcpuz.htmlrø   rò   ró   rú   zraw.json.gzÚwt)r—   rT   rˆ   rM  r   r]  r–   r  Úexport_memory_timeline_htmlrÿ   r   Úexport_memory_timeline_rawr  Úexport_memory_timeliner  r  r  )rI   rî   r`  r
  r  r  s   &&&   r%   rg  Ú%_KinetoProfile.export_memory_timeline¯  sP  € ðB Š>Ø��ˆ 4§?¡?°fÔ#<ØŸ™¨4Õ/‘ä%*§Z¡Z×%<Ñ%<×%>Ò%>™ÀE�ô ,¨D×,@Ñ,@Ó,BÓCˆŒð �=‰=˜×!Ò!Ø�K‰K×3Ñ3°DÖAØ�]‰]˜5×!Ò!Ü×,Ò,¨U¸7×CÕCÀrØ—=‘= ×/Ò/Ø—K‘K×:Ñ:¸2¿7¹7ÀFÕKà—K‘K×6Ñ6°r·w±wÀÔGÜ˜"Ÿ'™'—]”] c¬4¯9ª9°T¸4×+@Ô+@ÀDØ—O‘O CÔ(÷ ,A—]÷ DÑCð �K‰K×.Ñ.¨tÖ<÷ ,A×+@ú—]—]ú÷ D×CÐCús=   Ã-BG>Å/ G+	ÆGÆ!G+	Æ)G>ÇG(Ç#G+	Ç+G;Ç6G>Ç>H	)r¤   r¢   rŸ   rÊ   r£   rž   r¡   r|   rg   ro   r}   r{   r*   r•   r–   r~   r�   rw   r”   rv   r—   ry   rz   rx   ©F)Úself_cpu_time_total)Fr   FFr[   )rM   rN   rO   rP   rQ   rª   r]   ra   r¯   r°   r´   r  r  r  r  r  r&  r+  r5  rÝ   r=  rÞ   r]  r
   ÚFutureWarningrg  rR   r-   r'   r%   ru   ru   –   s  † ñ7ðroð ð	oð
 $ðoð  %ðoð !ðoð !ðoð #ðoð ;?ðoð <@ðoð !ðoð >Bðoð 37÷oõbõõJ'õX1-õf1÷6Jõp+õ	÷	9õD÷B
ò6-õ>õ6õ*òõ(
;ñ ð	yàôö
2=óô
2=r'   ru   c                  ó.   € ] tR tRtRt^ t^t^t^t^t	Rt
R# )r   ié  aP  
Profiler actions that can be taken at the specified intervals.

NONE, WARMUP, RECORD, and RECORD_AND_SAVE are user-facing values that may
be returned from a user-provided schedule. DEVICE_STOPPED is set
internally by the profiler when device collection stops early due to
errors; it must not be returned from a user-provided schedule.
r-   N)rM   rN   rO   rP   rQ   ÚNONEÚWARMUPÚRECORDÚRECORD_AND_SAVEÚDEVICE_STOPPEDrR   r-   r'   r%   r   r   é  s"   † ñð €DØ€FØ€FØ€OØ„Nr'   c               ó$   € V ^8„  d   QhRRRRRR/# )r)   Úprevrï   Úcurrentr,   r…   r-   )r.   s   "r%   r/   r/   ú  s!   € ÷ ñ  #ð °ð ¸ñ r'   c                ó&   € \        R V  RV R24      h)zProfiler internal error: z -> z should be unreachable)r)  )rs  rt  s   &&r%   Ú_unreachable_transitionrv  ú  s"   € Ü
Ø
# D 6¨¨g¨YÐ6LÐMóð r'   ÚrepeatÚ
skip_firstÚskip_first_waitc               ó4   € V ^8„  d   QhRRRRRRRRRRRRRR	/# )
r)   ÚwaitrD   ÚwarmupÚactiverw  rx  ry  r,   r   r-   )r.   s   "r%   r/   r/      sP   € ÷ ;ñ ;à
ð;ð ð;ð ð	;ð
 ð;ð ð;ð ð;ð ñ;r'   c                óÒ   a aaaaa€ R VVVVV V3R llpS ^ 8  g   S^ 8  g   S^ 8:  g   S^ 8  g   S^ 8  d   \        RS  RS RS RS RS R24      hS^ 8X  d   \        R	^R
7       V# )aÛ  
Returns a callable that can be used as profiler ``schedule`` argument. The profiler will skip
the first ``skip_first`` steps, then wait for ``wait`` steps, then do the warmup for the next ``warmup`` steps,
then do the active recording for the next ``active`` steps and then repeat the cycle starting with ``wait`` steps.
The optional number of cycles is specified with the ``repeat`` parameter, the zero value means that
the cycles will continue until the profiling is finished.

The ``skip_first_wait`` parameter controls whether the first ``wait`` stage should be skipped.
This can be useful if a user wants to wait longer than ``skip_first`` between cycles, but not
for the first profile. For example, if ``skip_first`` is 10 and ``wait`` is 20, the first cycle will
wait 10 + 20 = 30 steps before warmup if ``skip_first_wait`` is zero, but will wait only 10
steps if ``skip_first_wait`` is non-zero. All subsequent cycles will then wait 20 steps between the
last active and warmup.
c               ó    € V ^8„  d   QhRRRR/# )r)   ÚsteprD   r,   r   r-   )r.   s   "r%   r/   Úschedule.<locals>.__annotate__  s   € ÷ ñ ˜#ð  .ñ r'   c                óÌ  <€ V ^ 8  d   \        RV  R24      hV S8  d   \        P                  # V S,          p S^ 8w  d
   V S,          p SS,           S,           pS^ 8”  d   W,          S8¼  d   \        P                  # W,          pVS8  d   \        P                  # VSS,           8  d   \        P                  # W!^,
          8  d   \        P                  # \        P
                  # )r   zStep must be non-negative. Got rE  )rÚ   r   rm  rn  ro  rp  )	r€  Ú	num_stepsÚmod_stepr}  rw  rx  ry  r{  r|  s	   &  €€€€€€r%   Úschedule_fnÚschedule.<locals>.schedule_fn  sØ   ø€ Ø�!Œ8Ü Ð#BÀ4À&ÈÐ!JÓKÐKØ�*ÔÜ!×&Ñ&Ð&à�JÕˆDà˜aÔØ�D�LˆDØ˜6•M FÕ*ˆ	Ø�AŒ:˜$Õ*¨fÔ4Ü!×&Ñ&Ð&ØÕ#ˆØ�dŒ?Ü!×&Ñ&Ð&Ø˜˜v�Ô%Ü!×(Ñ(Ð(ð ¨!�mÔ+ô ×%Ñ%ðô $×3Ñ3ðr'   z.Invalid profiler schedule arguments. Got wait=z (need >= 0), warmup=z (need >= 0), active=z (need > 0), repeat=z (need >= 0), skip_first=z (need >= 0).z>Profiler won't be using warmup, this can skew profiler results©r!   )rÚ   r   )r{  r|  r}  rw  rx  ry  r…  s   dddddd r%   Úschedulerˆ     sŽ   ý€ ÷0õ ð2 ˆa„x�6˜A”: ¨1¤°¸´
¸jÈ1¼nÜØ<¸T¸FÐBWÐX^ÐW_ð `Ø�XÐ1°&°Ð9RÐS]ÐR^Ð^kðmó
ð 	
ð �„{ÜØLØõ	
ð Ðr'   c               ó    € V ^8„  d   QhRRRR/# )r)   Ú_rD   r,   r   r-   )r.   s   "r%   r/   r/   >  s   € ÷ !ñ !˜Cð ! Nñ !r'   c                ó"   € \         P                  # )zm
Default profiler behavior - immediately starts recording the events,
keeps doing it on every profiler step.
)r   ro  )rŠ  s   &r%   Ú_default_schedule_fnrŒ  >  s   € ô
 × Ñ Ð r'   c               ó(   € V ^8„  d   QhRRRRRRRR/# )r)   Údir_namerï   Úworker_namera  Úuse_gzipr�   rð   r-   )r.   s   "r%   r/   r/   F  s0   € ÷ !ñ !Øð!àð!ð ð!ð ñ	!r'   c                ó>   a aaaaa€ ^ RI o^ RIoR V VVVVV3R llpV# )zø
Outputs tracing files to directory of ``dir_name``, then that directory can be
directly delivered to tensorboard as logdir.
``worker_name`` should be unique for each worker in distributed scenario,
it will be set to '[hostname]_[pid]' by default.
Nc               ó   € V ^8„  d   QhRR/# r­   r-   )r.   s   "r%   r/   Ú/tensorboard_trace_handler.<locals>.__annotate__U  s   € ÷ 
ñ 
˜Dñ 
r'   c                óâ  <€ \         P                  P                  S4      '       g    \         P                  ! SR R7       S'       g)   SP                  4        R\         P                  ! 4        2oS RSP                  4        R2pS'       d
   VR,           pV P                  ! \         P                  P                  SV4      SR7       R#   \         d   p\        RS,           4      ThRp?ii ; i)	T)Úexist_okzCan't create directory: NrŠ  rE  z.pt.trace.jsonrø   r÷   )rá   rî   ÚisdirÚmakedirsÚ	Exceptionr)  ÚgethostnameÚgetpidÚtime_nsr  rþ   )	rÈ   ÚeÚ	file_namerŽ  ÚsocketÚtimer�  rð   r�  s	   &  €€€€€€r%   Ú
handler_fnÚ-tensorboard_trace_handler.<locals>.handler_fnU  s¿   ø€ ä�w‰w�}‰}˜X×&Ò&ðQÜ—’˜H¨tÕ4÷ Ø#×/Ñ/Ó1Ð2°!´B·I²I³K°=ÐAˆKà"�m 1 T§\¡\£^Ð$4°NÐCˆ	ßØ! EÕ)ˆIØ× Ò Ü�G‰G�L‰L˜ 9Ó-Ø/÷	
øô ô QÜ"Ð#=ÀÕ#HÓIÈqÐPûðQús   ¨C ÃC.ÃC)Ã)C.)rž  rŸ  )rŽ  r�  r�  rð   r   rž  rŸ  s   ffff @@r%   Útensorboard_trace_handlerr¢  F  s   ý€ ó Û÷
õ 
ð$ Ðr'   c                  óÐ   a € ] tR tRtRtRRRRRRRRR	RR
RRRRRRRRRRRRRRR/R V 3R llltR tR tR R ltR R lt	R R lt
R R ltR tR R  ltR! R" ltR# R$ ltR%tV ;t# )&r   ij  aŠ  Profiler context manager.

Args:
    activities (iterable): list of activity groups (CPU, CUDA) to use in profiling, supported values:
        ``torch.profiler.ProfilerActivity.CPU``, ``torch.profiler.ProfilerActivity.CUDA``,
        ``torch.profiler.ProfilerActivity.XPU``.
        Default value: ProfilerActivity.CPU and (when available) ProfilerActivity.CUDA
        or (when available) ProfilerActivity.XPU.

        Each item can be a ``ProfilerActivity`` enum (collects all default
        activity types for that group) or a ``dict`` mapping a ``ProfilerActivity``
        to a list of individual activity type names to collect, e.g.
        ``{ProfilerActivity.CUDA: ["GPU_MEMCPY", "CUDA_RUNTIME"]}``.
        An empty list (e.g. ``{ProfilerActivity.CUDA: []}``) means collect
        nothing for that group.
        The same activity group must not appear more than once.
        See :class:`~torch.profiler.ProfilerActivity` for the valid
        activity type names and device-specific behavior.
    schedule (Callable): callable that takes step (int) as a single parameter and returns
        ``ProfilerAction`` value that specifies the profiler action to perform at each step.
    on_trace_ready (Callable): callable invoked at the end of each profiling cycle
        (when ``schedule`` returns ``ProfilerAction.RECORD_AND_SAVE``). Receives the
        :class:`profile` instance as its only argument, typically used to export the
        trace (e.g. via :meth:`export_chrome_trace`) or print a summary.
    record_shapes (bool): save information about operator's input shapes.
    profile_memory (bool): track tensor memory allocation/deallocation.
    with_stack (bool): record source information (file and line number) for the ops.
    with_flops (bool): use formula to estimate the FLOPs (floating point operations) of specific operators
        (matrix multiplication and 2D convolution).
    with_modules (bool): record module hierarchy (including function names)
        corresponding to the callstack of the op. e.g. If module A's forward call's
        module B's forward which contains an aten::add op,
        then aten::add's module hierarchy is A.B

        .. deprecated::
            ``with_modules`` is deprecated and will be removed in a future version.
            It only collects data for TorchScript models, which are themselves
            deprecated, and does nothing in eager mode. Use ``with_stack=True``,
            which records ``nn.Module`` events for eager models.
    experimental_config (_ExperimentalConfig) : A set of experimental options
        used for Kineto library features. Note, backward compatibility is not guaranteed.
    execution_trace_observer (ExecutionTraceObserver) : A PyTorch Execution Trace Observer object.
        `PyTorch Execution Traces <https://arxiv.org/pdf/2305.14516.pdf>`__ offer a graph based
        representation of AI/ML workloads and enable replay benchmarks, simulators, and emulators.
        When this argument is included the observer start() and stop() will be called for the
        same time window as PyTorch profiler. See the examples section below for a code sample.
    acc_events (bool): Enable the accumulation of FunctionEvents across multiple profiling cycles
    post_processing_timeout_s (float): Optional timeout in seconds for post-processing profiler
        results. If specified, event parsing will stop after this duration and return partial
        results. Useful for handling large traces that may take too long to process.
    custom_trace_id_callback (Callable[[], str], optional): User-supplied trace ID generator,
        invoked once per profiling cycle. Defaults to a random UUID; retrieve via
        :meth:`get_trace_id`.

.. note::
    Use :func:`~torch.profiler.schedule` to generate the callable schedule.
    Non-default schedules are useful when profiling long training jobs
    and allow the user to obtain multiple traces at the different iterations
    of the training process.
    The default schedule simply records all the events continuously for the
    duration of the context manager.

.. note::
    Use :func:`~torch.profiler.tensorboard_trace_handler` to generate result files for TensorBoard:

    ``on_trace_ready=torch.profiler.tensorboard_trace_handler(dir_name)``

    After profiling, result files can be found in the specified directory. Use the command:

    ``tensorboard --logdir dir_name``

    to see the results in TensorBoard.
    For more information, see
    `PyTorch Profiler TensorBoard Plugin <https://github.com/pytorch/kineto/tree/master/tb_plugin>`__

.. note::
    Enabling shape and stack tracing results in additional overhead.
    When record_shapes=True is specified, profiler will temporarily hold references to the tensors;
    that may further prevent certain optimizations that depend on the reference count and introduce
    extra tensor copies.


Examples:

.. code-block:: python

    with torch.profiler.profile(
        activities=[
            torch.profiler.ProfilerActivity.CPU,
            torch.profiler.ProfilerActivity.CUDA,
        ]
    ) as p:
        code_to_profile()
    print(p.key_averages().table(sort_by="self_cuda_time_total", row_limit=-1))

Using the profiler's ``schedule``, ``on_trace_ready`` and ``step`` functions:

.. code-block:: python

    # Non-default profiler schedule allows user to turn profiler on and off
    # on different iterations of the training loop;
    # trace_handler is called every time a new trace becomes available
    def trace_handler(prof):
        print(
            prof.key_averages().table(sort_by="self_cuda_time_total", row_limit=-1)
        )
        # prof.export_chrome_trace("/tmp/test_trace_" + str(prof.step_num) + ".json")


    with torch.profiler.profile(
        activities=[
            torch.profiler.ProfilerActivity.CPU,
            torch.profiler.ProfilerActivity.CUDA,
        ],
        # In this example with wait=1, warmup=1, active=2, repeat=1,
        # profiler will skip the first step/iteration,
        # start warming up on the second, record
        # the third and the fourth iterations,
        # after which the trace will become available
        # and on_trace_ready (when set) is called;
        # the cycle repeats starting with the next step
        schedule=torch.profiler.schedule(wait=1, warmup=1, active=2, repeat=1),
        on_trace_ready=trace_handler,
        # on_trace_ready=torch.profiler.tensorboard_trace_handler('./log')
        # used when outputting for tensorboard
    ) as p:
        for iter in range(N):
            code_iteration_to_profile(iter)
            # send a signal to the profiler that the next iteration has started
            p.step()

The following sample shows how to setup up an Execution Trace Observer (`execution_trace_observer`)

.. code-block:: python

    with torch.profiler.profile(
        ...
        execution_trace_observer=(
            ExecutionTraceObserver().register_callback("./execution_trace.json")
        ),
    ) as p:
        for iter in range(N):
            code_iteration_to_profile(iter)
            p.step()

You can also refer to test_execution_trace_with_kineto() in tests/profiler/test_profiler.py.
Note: One can also pass any object satisfying the _ITraceObserver interface.
rg   Nrˆ  Úon_trace_readyrv   Frw   rx   ry   rz   r*   r{   r|   r}   r~   c               óP   € V ^8„  d   QhRRRRRRRRR	RR
RRRRRRRRRRRRRRRRR/# )r)   rg   r€   rˆ  z&Callable[[int], ProfilerAction] | Noner¤  zCallable[..., Any] | Nonerv   r�   rw   rx   ry   rz   r*   r+   r{   r‚   r|   r}   rƒ   r~   r„   r,   r…   r-   )r.   s   "r%   r/   Úprofile.__annotate__   s¸   € ÷ qCñ qCððqCð
 9ðqCð 2ðqCð ðqCð ðqCð ðqCð ðqCð ðqCð 8ðqCð #9ðqCð ðqCð #;ðqCð  $0ð!qCð" 
ñ#qCr'   c               	ó@  <€ Ve   \        V4      w  rïM
\        4       p\        V4      ^ 8X  d   \        R4      h\        ST `  TTTTTTT	T
;'       g    \        P                  4       VVVR7       V'       d   W n        RV n	        M\        V n        RV n	        W0n        ^ V n        R V n        V P                  V P                  4      pV\        P                  8X  d   \!        R4      hVV n        VV n        / \        P&                  \        P&                  3. b\        P&                  \        P(                  3V P*                  .b\        P&                  \        P,                  3V P*                  V P.                  .b\        P&                  \        P0                  3V P*                  V P.                  .b\        P(                  \        P&                  3\3        \4        R4      V P.                  V P6                  .b\        P(                  \        P(                  3. b\        P(                  \        P,                  3V P.                  .b\        P(                  \        P0                  3V P.                  .b\        P,                  \        P&                  3\3        \4        R4      V P6                  .b\        P,                  \        P(                  3\3        \4        R4      V P6                  .b\        P,                  \        P,                  3. b\        P,                  \        P0                  3. b\        P0                  \        P&                  3V P6                  V P8                  .b\        P0                  \        P(                  3V P6                  V P8                  V P*                  .b\        P0                  \        P,                  3V P6                  V P8                  V P*                  V P.                  .b\        P0                  \        P0                  3V P6                  V P8                  V P*                  V P.                  .b\        P(                  \        P                  3V P.                  V P6                  V P8                  .b\        P,                  \        P                  3V P6                  V P8                  .\        P                  \        P                  3. \        P                  \        P(                  3V P*                  .\        P                  \        P&                  3. \        P                  \        P,                  3V P*                  V P.                  .\        P                  \        P0                  3V P*                  V P.                  .\        P&                  \        P                  3\3        \:        R	R
4      .\        P0                  \        P                  3\3        \:        RR
4      .\        P(                  R 3V P.                  V P6                  .\        P,                  R 3V P6                  V P8                  .\        P0                  R 3V P6                  V P8                  .\        P                  R 3. /CV n        \>        P@                  PC                  \D        4       R # )Nz"No valid profiler activities found)rg   rv   rw   rx   ry   rz   r*   r{   r|   r}   r~   TFútProfilerAction.DEVICE_STOPPED is set internally by the profiler and must not be returned by a user-provided schedulez+Incorrect schedule: WARMUP followed by NONEz+Incorrect schedule: RECORD followed by NONEz-Incorrect schedule: RECORD followed by WARMUPrm  rq  rp  )#rs   rW   ÚlenrÚ   Úsuperrª   r   Ú"build_execution_trace_obs_from_envrˆ  Úrecord_stepsrŒ  r¤  Ústep_numÚstep_rec_fnr   rq  rj   Úcurrent_actionÚ_prev_schedule_actionrm  rn  r¯   ro  r°   rp  r   r   r´   Ú_trace_readyrv  Ú
action_maprÈ   ÚKinetoStepTrackerÚinit_step_countÚPROFILER_STEP_NAME)rI   rg   rˆ  r¤  rv   rw   rx   ry   rz   r*   r{   r|   r}   r~   Úactivities_setrŠ  Úschedule_actionÚ	__class__s   &$$$$$$$$$$$$$   €r%   rª   Úprofile.__init__   s  ø€ ð$ Ò!Ü 1°*Ó =ÑˆN˜Aä1Ó3ˆNÜˆ~Ó !Ô#Ü Ð!EÓFÐFä‰ÑØ!Ø'Ø)Ø!Ø!Ø%Ø 3Ø%=÷ &Kð &KÜ%×HÑHÓJØ!Ø%=Ø&?ð 	ô 	
÷ Ø$ŒMà $ˆDÕä0ˆDŒMØ %ˆDÔØ,ÔØˆŒØ8<ˆÔàŸ-™-¨¯©Ó6ˆØœn×;Ñ;Ô;ÜðPóð ð .ˆÔð
 &5ˆÔ"ðl
ä× Ñ ¤.×"5Ñ"5Ð6¸ðl
ô × Ñ ¤.×"7Ñ"7Ð8¸4×;MÑ;MÐ:Nðl
ô × Ñ ¤.×"7Ñ"7Ð8Ø×"Ñ"Ø× Ñ ð;ð	l
ô × Ñ ¤.×"@Ñ"@ÐAØ×"Ñ"Ø× Ñ ðDðl
ô ×"Ñ"¤N×$7Ñ$7Ð8ÜœÐKÓLØ× Ñ Ø—‘ð;ðl
ô" ×"Ñ"¤N×$9Ñ$9Ð:¸Bð#l
ô$ ×"Ñ"¤N×$9Ñ$9Ð:¸T×=MÑ=MÐ<Nð%l
ô& ×"Ñ"¤N×$BÑ$BÐCÀd×FVÑFVÐEWð'l
ô( ×"Ñ"¤N×$7Ñ$7Ð8ÜœÐKÓLØ—‘ð;ð)l
ô0 ×"Ñ"¤N×$9Ñ$9Ð:ÜœÐMÓNØ—‘ð=ð1l
ô8 ×"Ñ"¤N×$9Ñ$9Ð:¸Bð9l
ô: ×"Ñ"¤N×$BÑ$BÐCÀRð;l
ô< ×+Ñ+¬^×-@Ñ-@ÐAØ—‘Ø×!Ñ!ðDð=l
ôD ×+Ñ+¬^×-BÑ-BÐCØ—‘Ø×!Ñ!Ø×"Ñ"ðFðEl
ôN ×+Ñ+¬^×-BÑ-BÐCØ—‘Ø×!Ñ!Ø×"Ñ"Ø× Ñ ð	FðOl
ôZ ×+Ñ+¬^×-KÑ-KÐLØ—‘Ø×!Ñ!Ø×"Ñ"Ø× Ñ ð	Oð[l
ô~ ×"Ñ"¤N×$AÑ$AÐBØ× Ñ Ø—‘Ø×!Ñ!ðEðl
ôH ×"Ñ"¤N×$AÑ$AÐBØ—‘Ø×!Ñ!ðEô ×*Ñ*¬N×,IÑ,IÐJÈBÜ×*Ñ*¬N×,AÑ,AÐBØ×"Ñ"ðEô ×*Ñ*¬N×,?Ñ,?Ð@À"ô ×*Ñ*¬N×,AÑ,AÐBØ×"Ñ"Ø× Ñ ðEô ×*Ñ*¬N×,JÑ,JÐKØ×"Ñ"Ø× Ñ ðNô × Ñ ¤.×"?Ñ"?Ð@ÜÔ/°Ð9IÓJðCô ×+Ñ+¬^×-JÑ-JÐKÜÔ/Ð1BÐDTÓUðNô ×"Ñ" DÐ)¨D×,<Ñ,<¸d¿o¹oÐ+NÜ×"Ñ" DÐ)¨D¯O©O¸T×=NÑ=NÐ+OÜ×+Ñ+¨TÐ2Ø—‘Ø×!Ñ!ð5ô ×*Ñ*¨DÐ1°2ñWl
ð 	Œôb 	×Ñ×.Ñ.Ô/AÖBr'   c                	ó&   € V P                  4        V # r[   )r]   r\   s   &r%   Ú	__enter__Úprofile.__enter__³  s   € Ø�
‰
ŒØˆr'   c                	óÈ   € V P                  4        \        P                  P                  \        4       V P
                  '       d   V P
                  P                  4        R # R # r[   )ra   rÈ   r³  Úerase_step_countrµ  r{   rd   )rI   Úexc_typeÚexc_valÚexc_tbs   &&&&r%   rë   Úprofile.__exit__·  sC   € Ø�	‰	ŒÜ×Ñ×/Ñ/Ô0BÔCØ×(×(Ð(Ø×)Ñ)×1Ñ1Ö3ñ )r'   c               ó   € V ^8„  d   QhRR/# r­   r-   )r.   s   "r%   r/   r¦  ½  s   € ÷ )ñ )�tñ )r'   c                	ó   € V P                  \        P                  V P                  4       V P                  '       dR   \
        P                  ! R \        V P                  4      ,           4      V n	        V P                  P                  4        R# R# )úProfilerStep#N)Ú_transit_actionr   rm  r¯  r¬  rÈ   Úrecord_functionrï   r­  r®  r»  r\   s   &r%   r]   Úprofile.start½  sg   € Ø×Ñœ^×0Ñ0°$×2EÑ2EÔFØ××ÐÜ#×3Ò3Ø¤# d§m¡mÓ"4Õ4ó ˆDÔð ×Ñ×&Ñ&Ö(ñ	 r'   c               ó   € V ^8„  d   QhRR/# r­   r-   )r.   s   "r%   r/   r¦  Å  s   € ÷ 9ñ 9�dñ 9r'   c                	óD  € V P                   '       d7   V P                  '       d%   V P                  P                  R R R 4       R V n        V P                  V P                  R 4       V P
                  \        P                  8X  d   \        R4      hV P
                  V n        R # )Nz7_prev_schedule_action must never be DEVICE_STOPPED here)	r¬  r®  rë   rÆ  r¯  r°  r   rq  rÚ   r\   s   &r%   ra   Úprofile.stopÅ  s…   € Ø××Ð ×!1×!1Ð!1Ø×Ñ×%Ñ% d¨D°$Ô7Ø#ˆDÔØ×Ñ˜T×0Ñ0°$Ô7ð
 ×%Ñ%¬×)FÑ)FÔFÜ ØIóð ð #×8Ñ8ˆÖr'   c               ó   € V ^8„  d   QhRR/# r­   r-   )r.   s   "r%   r/   r¦  Ô  s   € ÷ W)ñ W)�dñ W)r'   c                óŠ  € V P                   '       d7   V P                  '       d%   V P                  P                  RRR4       RV n        V P                  pV P                  pV P
                  ^,           pV P                  V4      pV\        P                  8X  d   \        R4      hW0n        W@n        W@n        V\        P                  8X  dW   V\        P                  8H  ;'       g    V P                  \        P                  8H  pV'       g   \        P                  V n        M¤\        P                  P                  4       '       d�   V P                  es   V\        P                   \        P"                  39   dN   V P                  \        P                  8w  d/   \%        RV P
                   R24       \        P                  V n        V P'                  WP                  4       \(        P*                  P-                  RR4      '       g7   \/        4       '       dJ   \(        P*                  P-                  RR4      '       d$   \0        P2                  P5                  \6        4       V P                   '       dR   \0        P8                  ! R\;        V P
                  4      ,           4      V n        V P                  P=                  4        R# R# )	z@
Signals the profiler that the next profiling step has started.
Nr¨  z?Device profiling activity collection was stopped early at step z_. Profiler schedule is proceeding until next cycle without actual profiler activity collection.ÚKINETO_USE_DAEMONÚ ÚKINETO_FORCE_STEP_HOOKrÅ  )r¬  r®  rë   r¯  r°  r­  rˆ  r   rq  rj   rp  rm  rT   rU   Ú_is_kineto_stoppedr—   rn  ro  r   rÆ  rá   râ   r    r   rÈ   r³  Úincrement_steprµ  rÇ  rï   r»  )rI   Úprev_actionÚprev_schedule_actionÚ	next_stepr·  Úat_cycle_boundarys   &     r%   r€  Úprofile.stepÔ  s  € ð ××Ð ×!1×!1Ð!1Ø×Ñ×%Ñ% d¨D°$Ô7ð  $ˆDÔØ×)Ñ)ˆØ#×9Ñ9ÐØ—M‘M AÕ%ˆ	ØŸ-™-¨	Ó2ˆð
 œn×;Ñ;Ô;ÜðPóð ð
 "ŒØ-ÔØ%4Ô"ð@ œ.×7Ñ7Ô7à$¬×(FÑ(FÑF÷ >ð >Ø×&Ñ&¬.×*=Ñ*=Ñ=ð ÷ %Ü&4×&CÑ&C�Ô#øä�N‰N×-Ñ-×/Ò/Ø—‘Ò+Ø¤× 5Ñ 5´~×7LÑ7LÐMÔMØ×#Ñ#¤~×':Ñ':Ô:äðØŸ=™=˜/ð *PðPôô
 #1×"?Ñ"?ˆDÔà×Ñ˜[×*=Ñ*=Ô>Ü�:‰:�>‰>Ð-¨r×2Ò2Ü�KŠKœBŸJ™JŸN™NÐ+CÀR×HÒHä×"Ñ"×1Ñ1Ô2DÔEà××ÐÜ#×3Ò3Ø¤# d§m¡mÓ"4Õ4ó ˆDÔð ×Ñ×&Ñ&Ö(ñ	 r'   c               ó   € V ^8„  d   QhRR/# r­   r-   )r.   s   "r%   r/   r¦  -  s   € ÷ 1ñ 1¸ñ 1r'   c                ó   € Wn         R# )z}
Set the trace ID generator. Called at the start of each cycle, so updating
it between cycles yields distinct IDs per cycle.
N)r}   )rI   Úcallbacks   &&r%   Úset_custom_trace_id_callbackÚ$profile.set_custom_trace_id_callback-  s
   € ð
 )1Ö%r'   c                óN   € V P                   f   R# V P                   P                  # )z
Returns the current trace ID.
N)r”   Útrace_idr\   s   &r%   Úget_trace_idÚprofile.get_trace_id4  s!   € ð �=‰=Ò ÙØ�}‰}×%Ñ%Ð%r'   c               ó   € V ^8„  d   QhRR/# r­   r-   )r.   s   "r%   r/   r¦  <  s   € ÷ &ñ &˜dñ &r'   c                	óP   € V P                   '       d   V P                  V 4       R # R # r[   )r¤  r\   s   &r%   r±  Úprofile._trace_ready<  s!   € Ø××ÐØ×Ñ Ö%ñ r'   c               ó   € V ^8„  d   QhRR/# r­   r-   )r.   s   "r%   r/   r¦  @  s   € ÷ ñ ¸dñ r'   c                	ór   € V P                   P                  W34      pV'       d   V F
  pV! 4        K  	  R # R # r[   )r²  r    )rI   rÓ  r¯  Úaction_listÚactions   &&&  r%   rÆ  Úprofile._transit_action@  s0   € Ø—o‘o×)Ñ)¨;Ð*GÓHˆßÛ%�Ù–ó &ñ r'   c               ó   € V ^8„  d   QhRR/# )r)   r,   zprof._ProfilerStats | Noner-   )r.   s   "r%   r/   r¦  F  s   € ÷ $ñ $Ð2ñ $r'   c                	óN   € V P                   f   R # V P                   P                  # r[   )r”   Ú_statsr\   s   &r%   rë  Úprofile._statsF  s   € Ø�=‰=Ò ÙØ�}‰}×#Ñ#Ð#r'   )	r°  r²  r¯  r}   r¤  r¬  rˆ  r­  r®  )rM   rN   rO   rP   rQ   rª   r»  rë   r]   ra   r€  rÛ  rß  r±  rÆ  rë  rR   Ú__classcell__)r¸  s   @r%   r   r   j  sñ   ø† ñSðjqCð ð	qCð
 <@ðqCð 59ðqCð $ðqCð  %ðqCð !ðqCð !ðqCð #ðqCð ;?ðqCð <@ðqCð !ðqCð >BðqCð  37÷!qCò qCòfò4õ)õ9õW)õr1ò&õ&õ÷$ó $r'   c                  óè   € ] tR tRtRtR R ltR R lt]R R l4       tR	 R
 lt	R R lt
R!R R llt]R!R R ll4       tR R lt]R 4       tR tR R ltR R ltR R ltR R ltR R ltRtR # )"r   iL  af  Execution Trace Observer

Each process can have a single ExecutionTraceObserver instance. The observer
can be added to record function callbacks via calling register_callback()
explicitly. Without calling unregister_callback(), repeated calls to
register_callback() will not add additional observers to record function
callbacks. Once an ExecutionTraceObserver is created, the start() and stop()
methods control when the event data is recorded.

Deleting or calling unregister_callback() will remove the observer from the
record function callbacks, finalize the output file, and will stop
incurring any overheads.
c               ó   € V ^8„  d   QhRR/# r­   r-   )r.   s   "r%   r/   Ú#ExecutionTraceObserver.__annotate__[  s   € ÷ 	1ñ 	1˜$ñ 	1r'   c                óZ   € RV n         RV n        RV n        RV n        RV n        RV n        R# )z!
Initializes the default states.
FrÏ  N)Ú_registeredÚ_execution_trace_runningÚextra_resources_collectionÚresources_dirÚoutput_file_pathÚoutput_file_path_observerr\   s   &r%   rª   ÚExecutionTraceObserver.__init__[  s4   € ð !ˆÔØ(-ˆÔ%Ø*/ˆÔ'Ø"$ˆÔØ%'ˆÔØ.0ˆÖ&r'   c               ó   € V ^8„  d   QhRR/# r­   r-   )r.   s   "r%   r/   rð  f  ó   € ÷ #ñ #˜ñ #r'   c                ó&   € V P                  4        R# ©z?
Calls unregister_callback() to make sure to finalize outputs.
N©Úunregister_callbackr\   s   &r%   Ú__del__ÚExecutionTraceObserver.__del__f  ó   € ð 	× Ñ Ö"r'   c               ó   € V ^8„  d   QhRR/# )r)   r,   zExecutionTraceObserver | Noner-   )r.   s   "r%   r/   rð  m  s   € ÷ ñ Ð0Mñ r'   c                 ó  € \         P                  P                  RR4      R8X  dž    \        P                  ! RRRR7      ;_uu_ 4       p V P
                  pRRR4       \        4       pTP                  X4       \         P                  P                  RR4      R8X  d   TP                  R4       T# TP                  R4       T# R#   + '       g   i     Lx; i  \         d   p\        R	T 2^R
7        Rp?R# Rp?ii ; i)aŽ  
Returns an ExecutionTraceObserver instance if the environment variable
ENABLE_PYTORCH_EXECUTION_TRACE is set to 1, otherwise returns None.

Configures the observer to also collect extra resources if the environment variable
``ENABLE_PYTORCH_EXECUTION_TRACE_EXTRAS=1``. These are resources such as generated kernels,
index tensor data etc. that are required to make the Execution Trace replayable.
ÚENABLE_PYTORCH_EXECUTION_TRACErØ   rÑ   rò   z.et.jsonFrô   NzTExecution trace will not be recorded. Exception on creating default temporary file: r‡  Ú%ENABLE_PYTORCH_EXECUTION_TRACE_EXTRAST)rá   râ   r    rÿ   r   r  r˜  r   r   Úregister_callbackÚset_extra_resource_collection)r
  Úfilenamerœ  Úets       r%   r«  Ú9ExecutionTraceObserver.build_execution_trace_obs_from_envl  sá   € ô �:‰:�>‰>Ð:¸CÓ@ÀCÔGð
Ü×0Ò0Ø *°U÷õ àØ!Ÿw™w�H÷ô (Ó)ˆBØ× Ñ  Ô*ä�z‰z�~‰~ÐEÀsÓKÈsÔRØ×0Ñ0°Ô6ð ˆIð ×0Ñ0°Ô7ØˆIÙ÷%÷ ûô ô ÜØjÐklÐjmÐnØ õõ ûðús5   §!C ÁCÁC ÃC	ÃC ÃC ÃC>Ã#C9Ã9C>c               ó   € V ^8„  d   QhRR/# r­   r-   )r.   s   "r%   r/   rð  Œ  s   € ÷ ñ °Dñ r'   c                óZ   € Wn         V P                   '       d   V P                  RR7       R# )a  
Collects extra resources such as generated kernels, index tensor data, and any other
metadata that is required to complete the Execution Trace content.

The caller should call this method with val=True after calling register_callback() if they want
to collect the extra resources.
T)Ú
can_createN)rô  Úget_resources_dir)rI   rr   s   &&r%   r  Ú4ExecutionTraceObserver.set_extra_resource_collectionŒ  s*   € ð +.Ô'Ø×*×*Ð*Ø×"Ñ"¨dÐ"Ô3Ùr'   c               ó    € V ^8„  d   QhRRRR/# )r)   rö  rï   r,   r   r-   )r.   s   "r%   r/   rð  ™  s   € ÷ ñ °#ð ¸$ñ r'   c                óª   € R R lpV P                   '       g;   Wn        VP                  R4      '       d   V! 4       pWn        \	        V4      V n         V # )z^
Adds ET observer to record function callbacks. The data will be
written to output_file_path.
c               ó   € V ^8„  d   QhRR/# )r)   r,   rï   r-   )r.   s   "r%   r/   Ú>ExecutionTraceObserver.register_callback.<locals>.__annotate__Ÿ  s   € ÷ 	ñ 	¨Cñ 	r'   c                 óš   € \         P                  ! R RRR7      ;_uu_ 4       p V P                  uuRRR4       #   + '       g   i     R# ; i)rù   ró   Frô   N)rÿ   r   r  )r
  s    r%   Úget_temp_uncompressed_fileÚLExecutionTraceObserver.register_callback.<locals>.get_temp_uncompressed_fileŸ  s1   € Ü×,Ò,¨U¸7È5×QÕQÐUWØ—w‘w÷ R×Q×QÓQús	   ¢9¹A
	rø   )rò  rö  r  r÷  r   )rI   rö  r  s   && r%   r  Ú(ExecutionTraceObserver.register_callback™  sN   € õ	ð ××ÐØ$4Ô!Ø×(Ñ(¨×/Ò/Ù#=Ó#?Ð Ø-=Ô*Ü<Ð=MÓNˆDÔØˆr'   c               ó   € V ^8„  d   QhRR/# ©r)   r,   ra  r-   )r.   s   "r%   r/   rð  «  s   € ÷ "ñ "°Zñ "r'   c                óà   € V P                   '       g   R# V P                  '       d   V P                  # \        P                  V P                  VR7      pV'       g   R# W n        V P                  # )a†  
Generates the resources directory for the generated kernels,
or index tensor data or any other metadata that is required
to complete the Execution Trace content.

The directory is created right where the ET file is being output.

Only works if the observer has called set_extra_resource_collection(val=True).

Returns None if the observer is not configured with extra resource collection.
N)Ú
create_dir)rô  rõ  r   Úget_resources_dir_for_et_pathrö  )rI   r  Úgenerated_paths   && r%   r  Ú(ExecutionTraceObserver.get_resources_dir«  sf   € ð ×.×.Ð.ÙØ××Ðà×%Ñ%Ð%Ü/×MÑMØ×!Ñ!¨jð Nó 
ˆ÷ áØ+ÔØ×!Ñ!Ð!r'   c               ó    € V ^8„  d   QhRRRR/# )r)   r  r�   r,   ra  r-   )r.   s   "r%   r/   rð  Æ  s   € ÷ ñ Ø $ðà	ñr'   c                	ó²  € \         P                  P                  V 4      w  r#\         P                  P                  V\         P                  P	                  V4      ^ ,          R,           4      p\         P                  P                  V4      '       g$   V'       d    \         P                  ! V4       V# R# V#   \         d    \        RT 2^R7        R# i ; i)r   Ú
_resourcesz(Execution trace exception when creating r‡  N)	rá   rî   Úsplitrþ   ÚsplitextÚexistsÚmkdirr˜  r   )Ú
trace_pathr  Úwork_dirr�  Úresource_dirs   &&   r%   r  Ú4ExecutionTraceObserver.get_resources_dir_for_et_pathÅ  s°   € ô !Ÿg™gŸm™m¨JÓ7ÑˆÜ—w‘w—|‘|Ø”b—g‘g×&Ñ& yÓ1°!Õ4°|ÕCó
ˆô �w‰w�~‰~˜l×+Ò+ßð Ü—H’H˜\Ô*ð Ðñ ØÐøô !ô  ÜØBÀ<À.ÐQØ#$õò  ð ús   ÂB7 Â7CÃCc               ó   € V ^8„  d   QhRR/# r­   r-   )r.   s   "r%   r/   rð  Û  s   € ÷ 4%ñ 4% Tñ 4%r'   c                ól  a € R V 3R llpR R lpS P                   '       dj   S P                  4         V! 4        \	        4        S P
                  P                  R4      '       d   V! S P                  S P
                  4       R	S n         R# R#   \         d   p\        RT 2^R7        Rp?LsRp?ii ; i)
z5
Removes ET observer from record function callbacks.
c               ó   € V ^8„  d   QhRR/# r­   r-   )r.   s   "r%   r/   Ú@ExecutionTraceObserver.unregister_callback.<locals>.__annotate__à  s   € ÷ 	2ñ 	2 dñ 	2r'   c                 óØ  <€  SP                  4       p T '       g   R# ^ RIHp TP
                   Uu. uF   p\        TRR4      f   K  TP                  NK"  	  ppT F]  pTf   K	  \        P                  P                  T4      p\        P                  P                  Y4      p\        P                  ! YW4       K_  	  R#   \         d   p\        R T 2^R7        Rp?R# Rp?ii ; iu upi )z>Execution trace exception when generating resource directory: r‡  N)ÚPyCodeCacheÚ__file__)r  r˜  r   Útorch._inductor.codecacher/  Úmodulesr3   r0  rá   rî   Úbasenamerþ   ÚshutilÚcopyfile)	r(  rœ  r/  ræ   Úkernel_filesÚkernel_filer  ÚdstrI   s	           €r%   Ú_save_triton_kernelsÚHExecutionTraceObserver.unregister_callback.<locals>._save_triton_kernelsà  sÖ   ø€ ðØ#×5Ñ5Ó7�÷  Ùõ >ð %×,Ò,óá,�AÜ˜1˜j¨$Ó/ô �—
”
Ù,ð ð ó  ,�ØÒ&ÙÜ—w‘w×'Ñ'¨Ó4�Ü—g‘g—l‘l <Ó6�Ü—’ Ö1ó  ,øô% ô ÜØTÐUVÐTWÐXØ õõ ûðüòs"   ƒB> ±C'ÁC'Â>C$Ã	CÃC$c               ó$   € V ^8„  d   QhRRRRRR/# )r)   Úuncompressed_filerï   Úoutput_filer,   r…   r-   )r.   s   "r%   r/   r-  ü  s!   € ÷ 	)ñ 	)¨Sð 	)¸sð 	)Àtñ 	)r'   c           	     óL  € \        R V  RV 24       \        V R4      ;_uu_ 4       p\        P                  ! VR4      ;_uu_ 4       pVP                  V4       RRR4       RRR4       \        P
                  ! V 4       R#   + '       g   i     L0; i  + '       g   i     L;; i)zExecution Trace: compressing z to rû   rü   N)Úprintr  r  r  rá   Úremove)r<  r=  r  r  s   &&  r%   Ú_save_gz_fileÚAExecutionTraceObserver.unregister_callback.<locals>._save_gz_fileü  st   € ÜÐ1Ð2CÐ1DÀDÈÈÐVÔWÜÐ'¨×.Ô.°#Ü—Y’Y˜{¨D×1Ô1°TØ—O‘O CÔ(÷ 2÷ /ô �IŠIÐ'Ö(÷ 2×1ú÷ /×.ús#   ¦ BÁB 	ÁBÂ BÂBÂB#	z(Execution trace failed to save kernels: r‡  NÚgzF)rò  ra   r˜  r   r   rö  r  r÷  )rI   r9  rA  rœ  s   f   r%   rþ  Ú*ExecutionTraceObserver.unregister_callbackÛ  s¡   ø€ ÷
	2ð 	2õ8	)ð ××ÐØ�I‰IŒKðSÙ$Ô&ô -Ô.Ø×$Ñ$×-Ñ-¨d×3Ò3Ù˜d×<Ñ<¸d×>SÑ>SÔTà$ˆDÖñ øô
 ô SÜÐ?À¸sÐCÐPQ×RÒRûðSús   ´B ÂB3ÂB.Â.B3c                ó   € V P                   # )zN
Returns True if the execution trace observer is registered, otherwise False.
)rò  r\   s   &r%   Úis_registeredÚ$ExecutionTraceObserver.is_registered  s   € ð
 ×ÑÐr'   c                ó   € V P                   # )z;
Returns True if the observer is running, otherwise False.
)ró  r\   s   &r%   Ú
is_runningÚ!ExecutionTraceObserver.is_running  s   € ð ×,Ñ,Ð,r'   c               ó   € V ^8„  d   QhRR/# r­   r-   )r.   s   "r%   r/   rð    s   € ÷ %ñ %�tñ %r'   c                ó˜   € V P                   '       d8   V P                  '       g$   \        4        RV n        V P                  4        R# R# R# )z
Starts to capture.
TN)rò  ró  r   Ú_record_pg_configr\   s   &r%   r]   ÚExecutionTraceObserver.start  s>   € ð ××Ð D×$A×$AÐ$AÜ,Ô.Ø,0ˆDÔ)Ø×"Ñ"Ö$ñ %BÑr'   c               ó   € V ^8„  d   QhRR/# r­   r-   )r.   s   "r%   r/   rð  '  s   € ÷ 2ñ 2�dñ 2r'   c                óP   € V P                   '       d   \        4        RV n         R# R# )z
Stops to capture.
FN)ró  r   r\   s   &r%   ra   ÚExecutionTraceObserver.stop'  s#   € ð ×(×(Ð(Ü-Ô/Ø,1ˆDÖ)ñ )r'   c               ó   € V ^8„  d   QhRR/# r­   r-   )r.   s   "r%   r/   rð  /  rú  r'   c                ó&   € V P                  4        R# rü  rý  r\   s   &r%   rd   ÚExecutionTraceObserver.cleanup/  r  r'   c               ó   € V ^8„  d   QhRR/# r  r-   )r.   s   "r%   r/   rð  5  s   € ÷ ñ  jñ r'   c                óB   € V P                   '       d   V P                   # R# )z'
Returns the output file name or None.
N)rö  r\   s   &r%   Úget_output_file_pathÚ+ExecutionTraceObserver.get_output_file_path5  s   € ð × × Ð Ø×(Ñ(Ð(ár'   c               ó   € V ^8„  d   QhRR/# r­   r-   )r.   s   "r%   r/   rð  >  s   € ÷ ñ  4ñ r'   c                	ó–  € V P                   '       d·   \        P                  P                  4       '       d‘   \        P                  P	                  4       '       dk   \        P                  P
                  P                  P                  p\        P                  P                  R \        P                  ! V\        R7      4       R# R# R# R# )z## process_group:init ##rÓ   N)rF  rT   rL  rM  rN  rS  Ú_worldÚpg_config_inforU   Ú _record_function_with_args_enterr4   rß   r=   )rI   r\  s   & r%   rM  Ú(ExecutionTraceObserver._record_pg_config>  s‰   € ð ××ÐÜ×!Ñ!×.Ñ.×0Ò0Ü×!Ñ!×0Ñ0×2Ò2ä"×.Ñ.×?Ñ?×FÑF×UÑUˆNÜ�N‰N×;Ñ;Ø*Ü—
’
˜>¬}Ô=öñ 3ñ 1ñ r'   )ró  rò  rô  rö  r÷  rõ  Nri  )rM   rN   rO   rP   rQ   rª   rÿ  Ústaticmethodr«  r  r  r  r  rþ  ÚpropertyrF  rI  r]   ra   rd   rW  rM  rR   r-   r'   r%   r   r   L  s…   † ñõ	1õ#ð ôó ðõ>õ÷$"ð4 öó ðõ*4%ðl ñ ó ð ò-õ%õ2õ#õ÷ñ r'   )rW   r   rˆ  r¢  r   r   )NFF)DÚ
__future__r   r  r4   rá   r4  rÿ   Úabcr   r   Úenumr   Ú	functoolsr   Útypingr   r	   Útyping_extensionsr
   r   Úwarningsr   rT   Útorch.autograd.profilerrU   r”   rÈ   Útorch._Cr   Útorch._C._profilerr   r   r   r   r   Útorch._environmentr   Útorch._utils_internalr   Útorch.autogradr   r   Útorch.profiler._memory_profilerr   r   Úcollections.abcr   r   Ú__all__rµ  ri   r"   ÚUserWarningr&   r;   rA   r=   rW   rY   rs   ru   r   rv  rˆ  rŒ  r¢  r   r   r-   r'   r%   Ú<module>rr     s  ðå "ã Û Û 	Û Û ß #Ý Ý ß %ß .Ý ã ß &Ð &Ý 2÷õ õ )Ý Sß =ß P÷ ß2ò€ð $Ð á“%€ð )°Qô <õ6ô7�D×$Ñ$ô 7ò,2ô�cô õ"/÷6P	=ñ P	=ôf�Tô õ"ð;ð
 ð;ð ð;ð ÷;õ|!÷!ôH_$ˆnô _$ôD~˜_ö ~r'   