§
    L�’jÄh  ã                   óÒ  — d dl Z d dlmZ d dlmZ d dlZg d¢Zd„ Z G d„ d¦  «        Z G d„ d	¦  «        Z	 G d
„ d¦  «        Z
 G d„ d¦  «        Zej        j        j        ej        j        j        ej        j        j        dœZd                     e                     ¦   «         ¦  «        Z	 d9ddez  ej        j        z  dej        j        fd„Zej        j        j        ej        j        j        ej        j        j        ej        j        j        ej        j        j        ej        j        j        dœZd                     e                     ¦   «         ¦  «        Z	 d9ddez  ej        j        z  dej        j        fd„Zd9ddez  defd„Zd9ddez  defd„Z 	 	 d:ddez  ddez  ej        j        z  defd„Z!ej        j"        j        ej        j"        j#        ej        j"        j        dœZ$d                     e$                     ¦   «         ¦  «        Z%d dl&m'Z(m)Z* 	 d9ddez  ej        j"        z  dej        j"        fd„Z+de(_,        de(_-        de.fd„Z/d„ Z0d e.fd!„Z1d"„ Z2d e.fd#„Z3d$„ Z4d e.fd%„Z5d e.fd&„Z6d'„ Z7de.fd(„Z8d;d*e(d+e.de.fd,„Z9d;d*e(d+e.de.fd-„Z:d;d*e(d+e.de.fd.„Z;d/„ Z<d e.fd0„Z=e j>         ed1e?¬2¦  «        	 	 	 	 d<d4e.d5e.d6e.d7e.fd8„¦   «         ¦   «         Z@ e
¦   «         ZA e¦   «         ZBdS )=é    N)ÚAny)Ú
deprecated)Úis_builtÚcuFFTPlanCacheAttrContextPropÚcuFFTPlanCacheÚcuFFTPlanCacheManagerÚcuBLASModuleÚpreferred_linalg_libraryÚpreferred_blas_libraryÚcublas_workspace_sizeÚcublaslt_workspace_sizeÚblas_workspace_sizeÚpreferred_rocm_fa_libraryÚis_ck_sdpa_availableÚcufft_plan_cacheÚmatmulÚ
SDPAParamsÚenable_cudnn_sdpÚcudnn_sdp_enabledÚenable_flash_sdpÚflash_sdp_enabledÚenable_mem_efficient_sdpÚmem_efficient_sdp_enabledÚmath_sdp_enabledÚenable_math_sdpÚ"allow_fp16_bf16_reduction_math_sdpÚ$fp16_bf16_reduction_math_sdp_allowedÚis_flash_attention_availableÚcan_use_flash_attentionÚcan_use_efficient_attentionÚcan_use_cudnn_attentionÚ
sdp_kernelc                  ó$   — t           j        j        S )zú
    Return whether PyTorch is built with CUDA support.

    Note that this doesn't necessarily mean CUDA is available; just that if this PyTorch
    binary were run on a machine with working CUDA drivers and devices, we would be able to use it.
    )ÚtorchÚ_CÚ	_has_cuda© ó    úJC:\Projects\DSCons\.venv\Lib\site-packages\torch\backends\cuda\__init__.pyr   r   +   s   € õ Œ8ÔÐr(   c                   ó    — e Zd Zd„ Zd„ Zd„ ZdS )r   c                 ó"   — || _         || _        d S ©N)ÚgetterÚsetter)Úselfr-   r.   s      r)   Ú__init__z&cuFFTPlanCacheAttrContextProp.__init__8   s   € ØˆŒØˆŒˆˆr(   c                 ó6   — |                       |j        ¦  «        S r,   )r-   Údevice_index)r/   ÚobjÚobjtypes      r)   Ú__get__z%cuFFTPlanCacheAttrContextProp.__get__<   s   € Ø�{Š{˜3Ô+Ñ,Ô,Ð,r(   c                 ó˜   — t          | j        t          ¦  «        rt          | j        ¦  «        ‚|                      |j        |¦  «         d S r,   )Ú
isinstancer.   ÚstrÚRuntimeErrorr2   )r/   r3   Úvals      r)   Ú__set__z%cuFFTPlanCacheAttrContextProp.__set__?   sC   € Ý�d”k¥3Ñ'Ô'ð 	,Ý˜tœ{Ñ+Ô+Ð+Ø�Š�CÔ$ cÑ*Ô*Ð*Ð*Ð*r(   N)Ú__name__Ú
__module__Ú__qualname__r0   r5   r;   r'   r(   r)   r   r   5   sA   € € € € € ðð ð ð-ð -ð -ð+ð +ð +ð +ð +r(   r   c                   ól   — e Zd ZdZd„ Z eej        d¦  «        Z eej	        ej
        ¦  «        Zd„ ZdS )r   zÌ
    Represent a specific plan cache for a specific `device_index`.

    The attributes `size` and `max_size`, and method `clear`, can fetch and/ or
    change properties of the C++ cuFFT plan cache.
    c                 ó   — || _         d S r,   )r2   )r/   r2   s     r)   r0   zcuFFTPlanCache.__init__M   s   € Ø(ˆÔÐÐr(   zŽ.size is a read-only property showing the number of plans currently in the cache. To change the cache capacity, set cufft_plan_cache.max_size.c                 ó4   — t          j        | j        ¦  «        S r,   )r$   Ú_cufft_clear_plan_cacher2   ©r/   s    r)   ÚclearzcuFFTPlanCache.clearZ   s   € ÝÔ,¨TÔ->Ñ?Ô?Ð?r(   N)r<   r=   r>   Ú__doc__r0   r   r$   Ú_cufft_get_plan_cache_sizeÚsizeÚ_cufft_get_plan_cache_max_sizeÚ_cufft_set_plan_cache_max_sizeÚmax_sizerD   r'   r(   r)   r   r   E   s€   € € € € € ðð ð)ð )ð )ð )Ð(ØÔ(ð	Nñô €Dð -Ð,ØÔ,¨eÔ.Rñô €Hð@ð @ð @ð @ð @r(   r   c                   ó8   ‡ — e Zd ZdZdZd„ Zd„ Zd„ Zˆ fd„Zˆ xZ	S )r   a  
    Represent all cuFFT plan caches, return the cuFFTPlanCache for a given device when indexed.

    Finally, this object, when used directly as a `cuFFTPlanCache` object (e.g.,
    setting the `.max_size`) attribute, the current device's cuFFT plan cache is
    used.
    Fc                 ó"   — g | _         d| _        d S )NT)ÚcachesÚ#_cuFFTPlanCacheManager__initializedrC   s    r)   r0   zcuFFTPlanCacheManager.__init__i   s   € ØˆŒØ!ˆÔÐÐr(   c                 óà  — t           j        j                             |¦  «        }|dk     s"|t           j                             ¦   «         k    r1t          dt           j                             ¦   «         › d|› �¦  «        ‚t          | j        ¦  «        dk    rM| j                             d„ t          t           j                             ¦   «         ¦  «        D ¦   «         ¦  «         | j        |         S )Nr   z/cufft_plan_cache: expected 0 <= device index < z, but got device with index c              3   ó4   K  — | ]}t          |¦  «        V — Œd S r,   )r   )Ú.0Úindexs     r)   ú	<genexpr>z4cuFFTPlanCacheManager.__getitem__.<locals>.<genexpr>u   s;   è è € ð ð Ø*/•˜uÑ%Ô%ðð ð ð ð ð r(   )
r$   ÚcudaÚ_utilsÚ_get_device_indexÚdevice_countr9   ÚlenrM   ÚextendÚrange)r/   ÚdevicerR   s      r)   Ú__getitem__z!cuFFTPlanCacheManager.__getitem__m   së   € Ý”
Ô!×3Ò3°FÑ;Ô;ˆØ�1Š9ˆ9˜¥¤×!8Ò!8Ñ!:Ô!:Ò:Ð:Ýð-Å%Ä*×BYÒBYÑB[ÔB[ð -ð -Ø%*ð-ð -ñô ð õ ˆtŒ{ÑÔ˜qÒ Ð ØŒK×Òð ð Ý38½¼×9PÒ9PÑ9RÔ9RÑ3SÔ3Sðñ ô ñ ô ð ð Œ{˜5Ô!Ð!r(   c                 óf   — t          | t          j                             ¦   «                  |¦  «        S r,   )Úgetattrr$   rT   Úcurrent_device)r/   Únames     r)   Ú__getattr__z!cuFFTPlanCacheManager.__getattr__z   s%   € Ý�t�EœJ×5Ò5Ñ7Ô7Ô8¸$Ñ?Ô?Ð?r(   c                 ó¼   •— | j         r3t          | t          j                             ¦   «                  ||¦  «        S t          ¦   «                              ||¦  «        S r,   )rN   Úsetattrr$   rT   r_   ÚsuperÚ__setattr__)r/   r`   ÚvalueÚ	__class__s      €r)   re   z!cuFFTPlanCacheManager.__setattr__}   sM   ø€ ØÔð 	4Ý˜4¥¤
× 9Ò 9Ñ ;Ô ;Ô<¸dÀEÑJÔJÐJå‘7”7×&Ò& t¨UÑ3Ô3Ð3r(   )
r<   r=   r>   rE   rN   r0   r\   ra   re   Ú__classcell__)rg   s   @r)   r   r   ^   sy   ø€ € € € € ðð ð €Mð"ð "ð "ð"ð "ð "ð@ð @ð @ð4ð 4ð 4ð 4ð 4ð 4ð 4ð 4ð 4r(   r   c            	       óN   — e Zd Zedededeeef         fd„¦   «         Zd„ Z	d„ Z
dS )r	   rf   Ú	attr_nameÚreturnc                 óÖ  ‡— dt           dt          dt          fˆfd„}t          | t          ¦  «        r| dfS t          | t          t
          f¦  «        rx| st          ‰› d�¦  «        ‚t          | ¦  «        dk    rt          ‰› d�¦  «        ‚ || d	         d
¦  «        }t          | ¦  «        dk    r|dfS  || d         d¦  «        }||fS t          ‰› dt          | ¦  «        ›�¦  «        ‚)Nr3   Úwhichrk   c           	      óz   •— t          | t          ¦  «        r| S t          ‰› d|› dt          | ¦  «        ›�¦  «        ‚)Nz expects a bool for z
, but got )r7   ÚboolÚ	TypeErrorÚtype)r3   rm   rj   s     €r)   Ú_ensure_boolz;cuBLASModule._parse_reduction_setting.<locals>._ensure_bool‡   sK   ø€ Ý˜#�tÑ$Ô$ð Ø�
ÝØÐPÐP°%ÐPÐPÅ4ÈÁ9Ä9ÐPÐPñô ð r(   Tz& expects at least one boolean argumenté   z& expects at most two boolean argumentsr   Úallow_reduced_precisioné   Úallow_splitkz2 expects a bool or a tuple/list of bools, but got )	r   r8   ro   r7   ÚlistÚtuplerp   rX   rq   )rf   rj   rr   rt   rv   s    `   r)   Ú_parse_reduction_settingz%cuBLASModule._parse_reduction_setting…   s+  ø€ ð	�cð 	­#ð 	µ$ð 	ð 	ð 	ð 	ð 	ð 	õ �e�TÑ"Ô"ð 	Ø˜$�;ÐÝ�e�d¥E˜]Ñ+Ô+ð 		9Øð VÝ 9Ð TÐ TÐ TÑUÔUÐUÝ�5‰zŒz˜AŠ~ˆ~Ý 9Ð TÐ TÐ TÑUÔUÐUØ&2 l°5¸´8Ð=VÑ&WÔ&WÐ#Ý�5‰zŒz˜QŠˆØ.°Ð4Ð4Ø'˜<¨¨a¬°.ÑAÔAˆLØ*¨LÐ8Ð8ÝØÐ[Ð[ÍDÐQVÉKÌKÐ[Ð[ñ
ô 
ð 	
r(   c                 óJ  — |dk    rt           j                             ¦   «         S |dk    r#t           j                             ¦   «         \  }}|S |dk    r#t           j                             ¦   «         \  }}|S |dk    r#t           j                             ¦   «         \  }}|S |dk    r#t           j                             ¦   «         \  }}|S |dk    rt           j                             ¦   «         S |dk    r t           j                             dd	¦  «        S t          d
|z   ¦  «        ‚)NÚ
allow_tf32Ú&allow_fp16_reduced_precision_reductionÚ.allow_fp16_reduced_precision_reduction_split_kÚ&allow_bf16_reduced_precision_reductionÚ.allow_bf16_reduced_precision_reduction_split_kÚallow_fp16_accumulationÚfp32_precisionrT   r   úUnknown attribute )r$   r%   Ú_get_cublas_allow_tf32Ú2_get_cublas_allow_fp16_reduced_precision_reductionÚ2_get_cublas_allow_bf16_reduced_precision_reductionÚ#_get_cublas_allow_fp16_accumulationÚ_get_fp32_precision_getterÚAttributeError)r/   r`   rt   Ú_rv   s        r)   ra   zcuBLASModule.__getattr__ž   s3  € Ø�<ÒÐÝ”8×2Ò2Ñ4Ô4Ð4ØÐ=Ò=Ð=å”×KÒKÑMÔMñ 'Ð# Qð +Ð*ØÐEÒEÐEå”×KÒKÑMÔMñ ˆAˆ|ð  ÐØÐ=Ò=Ð=å”×KÒKÑMÔMñ 'Ð# Qð +Ð*ØÐEÒEÐEå”×KÒKÑMÔMñ ˆAˆ|ð  ÐØÐ.Ò.Ð.Ý”8×?Ò?ÑAÔAÐAØÐ%Ò%Ð%Ý”8×6Ò6°v¸xÑHÔHÐHÝÐ1°DÑ8Ñ9Ô9Ð9r(   c                 ó  — |dk    rt           j                             |¦  «        S |dk    r9|                      |d¦  «        \  }}t           j                             ||¦  «        S |dk    r9|                      |d¦  «        \  }}t           j                             ||¦  «        S |dk    rt           j                             |¦  «        S |dk    r!t           j                             dd|¦  «        S t          d|z   ¦  «        ‚)	Nr{   r|   r~   r€   r�   rT   r   r‚   )	r$   r%   Ú_set_cublas_allow_tf32ry   Ú2_set_cublas_allow_fp16_reduced_precision_reductionÚ2_set_cublas_allow_bf16_reduced_precision_reductionÚ#_set_cublas_allow_fp16_accumulationÚ_set_fp32_precision_setterrˆ   )r/   r`   rf   rt   rv   s        r)   re   zcuBLASModule.__setattr__»   s!  € Ø�<ÒÐÝ”8×2Ò2°5Ñ9Ô9Ð9ØÐ=Ò=Ð=Ø48×4QÒ4QØÐ?ñ5ô 5Ñ1Ð# \õ ”8×NÒNØ'Øñô ð ð Ð=Ò=Ð=Ø48×4QÒ4QØÐ?ñ5ô 5Ñ1Ð# \õ ”8×NÒNØ'Øñô ð ð Ð.Ò.Ð.Ý”8×?Ò?ÀÑFÔFÐFØÐ%Ò%Ð%Ý”8×6Ò6°v¸xÈÑOÔOÐOÝÐ1°DÑ8Ñ9Ô9Ð9r(   N)r<   r=   r>   Ústaticmethodr   r8   rx   ro   ry   ra   re   r'   r(   r)   r	   r	   „   sn   € € € € € Øð
¨ð 
¸ð 
ÀÀdÈDÀjÔ@Qð 
ð 
ð 
ñ „\ð
ð0:ð :ð :ð::ð :ð :ð :ð :r(   r	   )ÚdefaultÚcusolverÚmagmaz, Úbackendrk   c                 ó¢  — | €n¯t          | t          ¦  «        rL| t          vrt          dt          › d�¦  «        ‚t
          j                             t          |          ¦  «         nNt          | t
          j        j        ¦  «        r t
          j                             | ¦  «         nt          d¦  «        ‚t
          j         	                    ¦   «         S )af  
    Override the heuristic PyTorch uses to choose between cuSOLVER and MAGMA for CUDA linear algebra operations.

    .. warning:: This flag is experimental and subject to change.

    When PyTorch runs a CUDA linear algebra operation it often uses the cuSOLVER or MAGMA libraries,
    and if both are available it decides which to use with a heuristic.
    This flag (a :class:`str`) allows overriding those heuristics.

    * If `"cusolver"` is set then cuSOLVER will be used wherever possible.
    * If `"magma"` is set then MAGMA will be used wherever possible.
    * If `"default"` (the default) is set then heuristics will be used to pick between
      cuSOLVER and MAGMA if both are available.
    * When no input is given, this function returns the currently preferred library.
    * User may use the environment variable TORCH_LINALG_PREFER_CUSOLVER=1 to set the preferred library to cuSOLVER
      globally.
      This flag only sets the initial value of the preferred library and the preferred library
      may still be overridden by this function call later in your script.

    Note: When a library is preferred other libraries may still be used if the preferred library
    doesn't implement the operation(s) called.
    This flag may achieve better performance if PyTorch's heuristic library selection is incorrect
    for your application's inputs.

    Currently supported linalg operators:

    * :func:`torch.linalg.inv`
    * :func:`torch.linalg.inv_ex`
    * :func:`torch.linalg.cholesky`
    * :func:`torch.linalg.cholesky_ex`
    * :func:`torch.cholesky_solve`
    * :func:`torch.cholesky_inverse`
    * :func:`torch.linalg.lu_factor`
    * :func:`torch.linalg.lu`
    * :func:`torch.linalg.lu_solve`
    * :func:`torch.linalg.qr`
    * :func:`torch.linalg.eigh`
    * :func:`torch.linalg.eighvals`
    * :func:`torch.linalg.svd`
    * :func:`torch.linalg.svdvals`
    Nú"Unknown input value. Choose from: ú.úUnknown input value type.)
r7   r8   Ú_LinalgBackendsr9   Ú_LinalgBackends_strr$   r%   Ú_set_linalg_preferred_backendÚ_LinalgBackendÚ_get_linalg_preferred_backend©r”   s    r)   r
   r
   Ý   s¾   € ðX €ØÝ	�G�SÑ	!Ô	!ð 	8Ø�/Ð)Ð)ÝØKÕ5HÐKÐKÐKñô ð õ 	Œ×.Ò.­¸wÔ/GÑHÔHÐHÐHÝ	�G�UœXÔ4Ñ	5Ô	5ð 8ÝŒ×.Ò.¨wÑ7Ô7Ð7Ð7åÐ6Ñ7Ô7Ð7åŒ8×1Ò1Ñ3Ô3Ð3r(   )r‘   ÚcublasÚhipblasÚcublasltÚ	hipblasltÚckc                 ó¢  — | €n¯t          | t          ¦  «        rL| t          vrt          dt          › d�¦  «        ‚t
          j                             t          |          ¦  «         nNt          | t
          j        j        ¦  «        r t
          j                             | ¦  «         nt          d¦  «        ‚t
          j         	                    ¦   «         S )a�  
    Override the library PyTorch uses for BLAS operations. Choose between cuBLAS, cuBLASLt, and CK [ROCm-only].

    .. warning:: This flag is experimental and subject to change.

    When PyTorch runs a CUDA BLAS operation it defaults to cuBLAS even if both cuBLAS and cuBLASLt are available.
    For PyTorch built for ROCm, hipBLAS, hipBLASLt, and CK may offer different performance.
    This flag (a :class:`str`) allows overriding which BLAS library to use.

    * If `"cublas"` is set then cuBLAS will be used wherever possible.
    * If `"cublaslt"` is set then cuBLASLt will be used wherever possible.
    * If `"ck"` is set then CK will be used wherever possible.
    * If `"default"` (the default) is set then heuristics will be used to pick between the other options.
    * When no input is given, this function returns the currently preferred library.
    * User may use the environment variable TORCH_BLAS_PREFER_CUBLASLT=1 to set the preferred library to cuBLASLt
      globally.
      This flag only sets the initial value of the preferred library and the preferred library
      may still be overridden by this function call later in your script.

    Note: When a library is preferred other libraries may still be used if the preferred library
    doesn't implement the operation(s) called.
    This flag may achieve better performance if PyTorch's library selection is incorrect
    for your application's inputs.

    Nr–   r—   r˜   )
r7   r8   Ú_BlasBackendsr9   Ú_BlasBackends_strr$   r%   Ú_set_blas_preferred_backendÚ_BlasBackendÚ_get_blas_preferred_backendrž   s    r)   r   r   $  s½   € ð8 €ØÝ	�G�SÑ	!Ô	!ð 	8Ø�-Ð'Ð'ÝØIÕ5FÐIÐIÐIñô ð õ 	Œ×,Ò,­]¸7Ô-CÑDÔDÐDÐDÝ	�G�UœXÔ2Ñ	3Ô	3ð 8ÝŒ×,Ò,¨WÑ5Ô5Ð5Ð5åÐ6Ñ7Ô7Ð7åŒ8×/Ò/Ñ1Ô1Ð1r(   rG   c                 ó€   — | �t           j                             | ¦  «         t           j                             ¦   «         S )a?  Query or set the cuBLAS workspace size in bytes.

    When called with no arguments, returns the current workspace size.
    When called with a size argument, sets the workspace size and returns the new value.
    Setting the workspace size will take precedence over the CUBLAS_WORKSPACE_CONFIG environment variable.
    Changes take effect lazily: only handles used after the change get new workspaces.

    Args:
        size (int, optional): workspace size in bytes. Must be non-negative.

    Returns:
        int: the current (or newly set) workspace size in bytes.
    )r$   r%   Ú_cuda_setCublasWorkspaceSizeÚ_cuda_getCublasWorkspaceSize©rG   s    r)   r   r   P  s4   € ð ÐÝŒ×-Ò-¨dÑ3Ô3Ð3ÝŒ8×0Ò0Ñ2Ô2Ð2r(   c                 ó€   — | �t           j                             | ¦  «         t           j                             ¦   «         S )aA  Query or set the cuBLASLt workspace size in bytes.

    When called with no arguments, returns the current workspace size.
    When called with a size argument, sets the workspace size and returns the new value.
    Setting the workspace size will take precedence over the CUBLASLT_WORKSPACE_SIZE environment variable.
    Changes take effect lazily: only handles used after the change get new workspaces.

    Args:
        size (int, optional): workspace size in bytes. Must be non-negative.

    Returns:
        int: the current (or newly set) workspace size in bytes.
    )r$   r%   Ú_cuda_setCublasLtWorkspaceSizeÚ_cuda_getCublasLtWorkspaceSizer­   s    r)   r   r   c  s4   € ð ÐÝŒ×/Ò/°Ñ5Ô5Ð5ÝŒ8×2Ò2Ñ4Ô4Ð4r(   c                 ó@  — |€t          ¦   «         }nut          |t          ¦  «        r/|t          vrt	          dt
          › d�¦  «        ‚t          |         }n1t          |t          j        j        ¦  «        r|}nt	          d¦  «        ‚|t          j        j        j	        k    rt          j         
                    ¦   «         }|t          j        j        j        k    rt	          d¦  «        ‚|t          j        j        j        k    rt          | ¦  «        S t          | ¦  «        S )a{  Query or set the BLAS workspace size for a given backend.

    Convenience wrapper that dispatches to :func:`cublas_workspace_size` or
    :func:`cublaslt_workspace_size` depending on the backend.

    When *backend* is ``None`` the current :func:`preferred_blas_library` is
    used.  ``Default`` is resolved to the platform's default backend (cuBLAS
    on NVIDIA, potentially hipBLASLt on supported ROCm architectures).

    .. note::

       When ``TORCH_CUBLASLT_UNIFIED_WORKSPACE`` is enabled (the default on
       open-source CUDA builds), the cuBLASLt workspace is capped at the
       cuBLAS workspace size and physically reuses the same allocation.
       Setting a large cuBLASLt workspace via this function will therefore
       *not* increase memory beyond the cuBLAS workspace size.

    .. note::

        Setting the workspace size for the cublas backend will take precedence
        over the CUBLAS_WORKSPACE_CONFIG environment variable, and setting the
        workspace size for the cublaslt backend will take precedence over the
        CUBLASLT_WORKSPACE_SIZE environment variable.

    Args:
        size (int, optional): workspace size in bytes.  Must be non-negative.
            When omitted the current size is returned without modification.
        backend (str | torch._C._BlasBackend, optional): which backend's
            workspace to query/set.  Accepts the same strings as
            :func:`preferred_blas_library` (e.g. ``"cublas"``, ``"cublaslt"``).

    Returns:
        int: the current (or newly set) workspace size in bytes.

    Raises:
        RuntimeError: if the resolved backend is CK (no workspace concept).
    Nz%Unknown backend string. Choose from: r—   zUnknown backend type.z$CK backend does not use a workspace.)r   r7   r8   r¥   r9   r¦   r$   r%   r¨   ÚDefaultÚ_get_blas_default_backendÚCkÚCublasltr   r   )rG   r”   Úresolveds      r)   r   r   v  s  € ðR €Ý)Ñ+Ô+ˆˆÝ	�G�SÑ	!Ô	!ð 	4Ø�-Ð'Ð'ÝØLÕ8IÐLÐLÐLñô ð õ ! Ô)ˆˆÝ	�G�UœXÔ2Ñ	3Ô	3ð 4ØˆˆåÐ2Ñ3Ô3Ð3à•5”8Ô(Ô0Ò0Ð0Ý”8×5Ò5Ñ7Ô7ˆà•5”8Ô(Ô+Ò+Ð+ÝÐAÑBÔBÐBà•5”8Ô(Ô1Ò1Ð1Ý& tÑ,Ô,Ð,Ý  Ñ&Ô&Ð&r(   )r‘   Úaotritonr£   )Ú_SDPAParamsÚ_SDPBackendc                 ó´  — | €n¸t          | t          ¦  «        rL| t          vrt          dt          › d�¦  «        ‚t
          j                             t          |          ¦  «         nWt          | t
          j        j        ¦  «        r t
          j                             | ¦  «         nt          dt          › d�¦  «        ‚t
          j         
                    ¦   «         S )aY  
    [ROCm-only]
    Override the backend PyTorch uses in ROCm environments for Flash Attention. Choose between AOTriton and CK

    .. warning:: This flag is experimental and subject to change.

    When Flash Attention is enabled and desired, PyTorch defaults to using AOTriton as the backend.
    This flag (a :class:`str`) allows users to override this backend to use composable_kernel

    * If `"default"` is set then the default backend will be used wherever possible. Currently AOTriton.
    * If `"aotriton"` is set then AOTriton will be used wherever possible.
    * If `"ck"` is set then CK will be used wherever possible.
    * When no input is given, this function returns the currently preferred library.
    * User may use the environment variable TORCH_ROCM_FA_PREFER_CK=1 to set the preferred library to CK
      globally.

    Note: When a library is preferred other libraries may still be used if the preferred library
    doesn't implement the operation(s) called.
    This flag may achieve better performance if PyTorch's library selection is incorrect
    for your application's inputs.
    Nr–   r—   )r7   r8   Ú_ROCmFABackendsr9   Ú_ROCmFABackends_strr$   r%   Ú_set_rocm_fa_preferred_backendÚ_ROCmFABackendÚ
ValueErrorÚ_get_rocm_fa_preferred_backendrž   s    r)   r   r   Â  sË   € ð0 €ØÝ	�G�SÑ	!Ô	!ð 	VØ�/Ð)Ð)ÝØKÕ5HÐKÐKÐKñô ð õ 	Œ×/Ò/µÀÔ0HÑIÔIÐIÐIÝ	�G�UœXÔ4Ñ	5Ô	5ð VÝŒ×/Ò/°Ñ8Ô8Ð8Ð8åÐTÕ>QÐTÐTÐTÑUÔUÐUåŒ8×2Ò2Ñ4Ô4Ð4r(   ztorch.backends.cudar   c                  ó>   — t           j                             ¦   «         S )z§
    .. warning:: This flag is beta and subject to change.

    Returns whether composable_kernel may be used as the backend for
    scaled-dot-product-attention.
    )r$   r%   Ú_is_ck_sdpa_availabler'   r(   r)   r   r   ï  s   € õ Œ8×)Ò)Ñ+Ô+Ð+r(   c                  ó>   — t           j                             ¦   «         S )zŠ
    .. warning:: This flag is beta and subject to change.

    Returns whether flash scaled dot product attention is enabled or not.
    )r$   r%   Ú_get_flash_sdp_enabledr'   r(   r)   r   r   ú  ó   € õ Œ8×*Ò*Ñ,Ô,Ð,r(   Úenabledc                 óD   — t           j                             | ¦  «         dS )z|
    .. warning:: This flag is beta and subject to change.

    Enables or disables flash scaled dot product attention.
    N)r$   r%   Ú_set_sdp_use_flash©rÆ   s    r)   r   r     ó    € õ 
„H×Ò Ñ(Ô(Ð(Ð(Ð(r(   c                  ó>   — t           j                             ¦   «         S )z•
    .. warning:: This flag is beta and subject to change.

    Returns whether memory efficient scaled dot product attention is enabled or not.
    )r$   r%   Ú_get_mem_efficient_sdp_enabledr'   r(   r)   r   r     s   € õ Œ8×2Ò2Ñ4Ô4Ð4r(   c                 óD   — t           j                             | ¦  «         dS )z‡
    .. warning:: This flag is beta and subject to change.

    Enables or disables memory efficient scaled dot product attention.
    N)r$   r%   Ú_set_sdp_use_mem_efficientrÉ   s    r)   r   r     s    € õ 
„H×'Ò'¨Ñ0Ô0Ð0Ð0Ð0r(   c                  ó>   — t           j                             ¦   «         S )z‰
    .. warning:: This flag is beta and subject to change.

    Returns whether math scaled dot product attention is enabled or not.
    )r$   r%   Ú_get_math_sdp_enabledr'   r(   r)   r   r     s   € õ Œ8×)Ò)Ñ+Ô+Ð+r(   c                 óD   — t           j                             | ¦  «         dS )z{
    .. warning:: This flag is beta and subject to change.

    Enables or disables math scaled dot product attention.
    N)r$   r%   Ú_set_sdp_use_mathrÉ   s    r)   r   r   '  s    € õ 
„H×Ò˜wÑ'Ô'Ð'Ð'Ð'r(   c                 óD   — t           j                             | ¦  «         dS )z’
    .. warning:: This flag is beta and subject to change.

    Enables or disables fp16/bf16 reduction in math scaled dot product attention.
    N)r$   r%   Ú'_set_math_sdp_allow_fp16_bf16_reductionrÉ   s    r)   r   r   0  s    € õ 
„H×4Ò4°WÑ=Ô=Ð=Ð=Ð=r(   c                  ó>   — t           j                             ¦   «         S )z 
    .. warning:: This flag is beta and subject to change.

    Returns whether fp16/bf16 reduction in math scaled dot product attention is enabled or not.
    )r$   r%   Ú'_get_math_sdp_allow_fp16_bf16_reductionr'   r(   r)   r   r   9  s   € õ Œ8×;Ò;Ñ=Ô=Ð=r(   c                  ó>   — t           j                             ¦   «         S )a5  Check if PyTorch was built with FlashAttention for scaled_dot_product_attention.

    Returns:
        True if FlashAttention is built and available; otherwise, False.

    Note:
        This function is dependent on a CUDA-enabled build of PyTorch. It will return False
        in non-CUDA environments.
    )r$   r%   Ú_is_flash_attention_availabler'   r(   r)   r   r   B  s   € õ Œ8×1Ò1Ñ3Ô3Ð3r(   FÚparamsÚdebugc                 óB   — t           j                             | |¦  «        S )až  Check if FlashAttention can be utilized in scaled_dot_product_attention.

    Args:
        params: An instance of SDPAParams containing the tensors for query,
                key, value, an optional attention mask, dropout rate, and
                a flag indicating if the attention is causal.
        debug: Whether to logging.warn debug information as to why FlashAttention could not be run.
            Defaults to False.

    Returns:
        True if FlashAttention can be used with the given parameters; otherwise, False.

    Note:
        This function is dependent on a CUDA-enabled build of PyTorch. It will return False
        in non-CUDA environments.
    )r$   r%   Ú_can_use_flash_attention©rÙ   rÚ   s     r)   r   r   O  ó   € õ" Œ8×,Ò,¨V°UÑ;Ô;Ð;r(   c                 óB   — t           j                             | |¦  «        S )a¬  Check if efficient_attention can be utilized in scaled_dot_product_attention.

    Args:
        params: An instance of SDPAParams containing the tensors for query,
                key, value, an optional attention mask, dropout rate, and
                a flag indicating if the attention is causal.
        debug: Whether to logging.warn with information as to why efficient_attention could not be run.
            Defaults to False.

    Returns:
        True if efficient_attention can be used with the given parameters; otherwise, False.

    Note:
        This function is dependent on a CUDA-enabled build of PyTorch. It will return False
        in non-CUDA environments.
    )r$   r%   Ú _can_use_mem_efficient_attentionrÝ   s     r)   r    r    c  s   € õ" Œ8×4Ò4°V¸UÑCÔCÐCr(   c                 óB   — t           j                             | |¦  «        S )a–  Check if cudnn_attention can be utilized in scaled_dot_product_attention.

    Args:
        params: An instance of SDPAParams containing the tensors for query,
                key, value, an optional attention mask, dropout rate, and
                a flag indicating if the attention is causal.
        debug: Whether to logging.warn with information as to why cuDNN attention could not be run.
            Defaults to False.

    Returns:
        True if cuDNN can be used with the given parameters; otherwise, False.

    Note:
        This function is dependent on a CUDA-enabled build of PyTorch. It will return False
        in non-CUDA environments.
    )r$   r%   Ú_can_use_cudnn_attentionrÝ   s     r)   r!   r!   w  rÞ   r(   c                  ó>   — t           j                             ¦   «         S )zŠ
    .. warning:: This flag is beta and subject to change.

    Returns whether cuDNN scaled dot product attention is enabled or not.
    )r$   r%   Ú_get_cudnn_sdp_enabledr'   r(   r)   r   r   ‹  rÅ   r(   c                 óD   — t           j                             | ¦  «         dS )z|
    .. warning:: This flag is beta and subject to change.

    Enables or disables cuDNN scaled dot product attention.
    N)r$   r%   Ú_set_sdp_use_cudnnrÉ   s    r)   r   r   ”  rÊ   r(   zÉ`torch.backends.cuda.sdp_kernel()` is deprecated. In the future, this context manager will be removed. Please see `torch.nn.attention.sdpa_kernel()` for the new context manager, with updated signature.)ÚcategoryTÚenable_flashÚenable_mathÚenable_mem_efficientÚenable_cudnnc              #   ó‚  K  — ddl m} g }| r|                     t          j        ¦  «         |r|                     t          j        ¦  «         |r|                     t          j        ¦  «         |r|                     t          j        ¦  «          ||¦  «        5 }	 |V — n# w xY w	 ddd¦  «         dS # 1 swxY w Y   dS )a  
    .. warning:: This flag is beta and subject to change.

    This context manager can be used to temporarily enable or disable any of the three backends for scaled dot product attention.
    Upon exiting the context manager, the previous state of the flags will be restored.
    r   )Úsdpa_kernelN)Útorch.nn.attentionrí   ÚappendÚ
SDPBackendÚFLASH_ATTENTIONÚEFFICIENT_ATTENTIONÚMATHÚCUDNN_ATTENTION)rè   ré   rê   rë   rí   Úbackend_listÚcontexts          r)   r"   r"   �  s'  è è € ð, /Ð.Ð.Ð.Ð.Ð.à€LØð 8Ø×Ò�JÔ6Ñ7Ô7Ð7Øð <Ø×Ò�JÔ:Ñ;Ô;Ð;Øð -Ø×Ò�JœOÑ,Ô,Ð,Øð 8Ø×Ò�JÔ6Ñ7Ô7Ð7à	ˆ�\Ñ	"Ô	"ð  gð	ØˆMˆMˆMàøˆDˆDˆDˆDˆDð	ð ð ñ ô ð ð ð ð ð ð ð øøøð ð ð ð ð ð s*   ÂB4ÂB!Â B4Â!B#Â#B4Â4B8Â;B8r,   )NN)F)TTTT)CÚ
contextlibÚtypingr   Útyping_extensionsr   r$   Ú__all__r   r   r   r   r	   r%   rœ   r²   ÚCusolverÚMagmar™   ÚjoinÚkeysrš   r8   r
   r¨   ÚCublasrµ   r´   r¥   r¦   r   Úintr   r   r   r¾   ÚAOTritonr»   r¼   Útorch._Cr¸   r   r¹   rð   r   r=   r<   ro   r   r   r   r   r   r   r   r   r   r   r   r    r!   r   r   ÚcontextmanagerÚFutureWarningr"   r   r   r'   r(   r)   ú<module>r     só  ðà Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø (Ð (Ð (Ð (Ð (Ð (à €€€ðð ð €ðDð ð ð+ð +ð +ð +ð +ñ +ô +ð +ð @ð @ð @ð @ð @ñ @ô @ð @ð2#4ð #4ð #4ð #4ð #4ñ #4ô #4ð #4ðLN:ð N:ð N:ð N:ð N:ñ N:ô N:ð N:ðd ŒxÔ&Ô.Ø”Ô'Ô0ØŒXÔ$Ô*ðð €ð
 —i’i × 4Ò 4Ñ 6Ô 6Ñ7Ô7Ð ð 59ð94ð 94Ø�C‰Z˜%œ(Ô1Ñ1ð94à
„XÔð94ð 94ð 94ð 94ðz ŒxÔ$Ô,ØŒhÔ#Ô*ØŒxÔ$Ô+Ø”Ô%Ô.Ø”Ô&Ô/Ø
Œ(Ô
Ô
"ðð €ð —I’I˜m×0Ò0Ñ2Ô2Ñ3Ô3Ð ð 37ð)2ð )2Ø�C‰Z˜%œ(Ô/Ñ/ð)2à
„XÔð)2ð )2ð )2ð )2ðX3ð 3  s¡
ð 3°cð 3ð 3ð 3ð 3ð&5ð 5 $¨¡*ð 5¸ð 5ð 5ð 5ð 5ð( Ø26ð>'ð >'Ø
�‰*ð>'à�C‰Z˜%œ(Ô/Ñ/ð>'ð 	ð>'ð >'ð >'ð >'ðD ŒxÔ&Ô.Ø”Ô'Ô0Ø
Œ(Ô
!Ô
$ðð €ð
 —i’i × 4Ò 4Ñ 6Ô 6Ñ7Ô7Ð ð JÐ IÐ IÐ IÐ IÐ IÐ IÐ Ið 59ð%5ð %5Ø�C‰Z˜%œ(Ô1Ñ1ð%5à
„XÔð%5ð %5ð %5ð %5ðR .€
Ô Ø"€
Ô ð,˜dð ,ð ,ð ,ð ,ð-ð -ð -ð)˜dð )ð )ð )ð )ð5ð 5ð 5ð1 dð 1ð 1ð 1ð 1ð,ð ,ð ,ð(˜Tð (ð (ð (ð (ð>°ð >ð >ð >ð >ð>ð >ð >ð
4 dð 
4ð 
4ð 
4ð 
4ð<ð < Jð <°tð <Èð <ð <ð <ð <ð(Dð D¨
ð D¸4ð DÈDð Dð Dð Dð Dð(<ð < Jð <°tð <Èð <ð <ð <ð <ð(-ð -ð -ð)˜dð )ð )ð )ð )ð ÔØ€ð	"ð
 ðñ ô ð ØØ!%Øð	ð Øðàðð ðð ð	ð ð ñô ñ Ôðð> )Ð(Ñ*Ô*Ð Ø	ˆ‰Œ€€€r(   