+
    Ðåûjø  ã                   ó  a € R t0 t R t^ RIt^ RIHt ^ RIHtHt ]P                  ! ]	4      t
 ! R R]4      t]R]R,          3,          t]R,          t/ s] ^ k Rs] ^k R R ltR	 R
 ltR R ltR R ltRR R lltR# )zÏRegistry for flash attention implementations.

This module contains the registration system for flash attention implementations.
It has no torch dependencies to avoid circular imports during initialization.
N)ÚCallable)ÚLiteralÚProtocolc                   ó2   a € ] tR t^t o V 3R lR ltRtV tR# )ÚFlashAttentionHandlec                ó   <€ V ^8„  d   QhRR/# ©é   ÚreturnN© )ÚformatÚ__classdict__s   "€ÚXC:\Ai_Coding\apps\studio\ComfyUI\.venv\Lib\site-packages\torch\nn\attention\_registry.pyÚ__annotate__Ú!FlashAttentionHandle.__annotate__   s   ø€ ×!Ñ!˜Ñ!ó    c                ó   € R # )Nr   )Úselfs   &r   ÚremoveÚFlashAttentionHandle.remove   s   € ™cr   r   N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__r   Ú__static_attributes__Ú__classdictcell__)r   s   @r   r   r      s   ø‡ € ß!Ö!r   r   .c                óJ   € V ^8„  d   QhR\         \        ,          R\        RR/# )r	   ÚimplÚregister_fnr
   N)ÚstrÚ_FlashAttentionImplÚ_RegisterFn)r   s   "r   r   r      s.   € ÷ /ñ /Ü
Ô#Õ
#ð/ô ð/ð 
ñ	/r   c               ó   € V\         V &   R# )aÓ  
Register the callable that activates a flash attention impl.

.. note::
    This function is intended for SDPA backend providers to register their
    implementations. End users should use :func:`activate_flash_attention_impl`
    to activate a registered implementation.

Args:
    impl: Implementation identifier (e.g., ``"FA4"``).
    register_fn: Callable that performs the actual dispatcher registration.
        This function will be invoked by :func:`activate_flash_attention_impl`
        and should register custom kernels with the PyTorch dispatcher.
        It may optionally return a handle implementing
        :class:`FlashAttentionHandle` to keep any necessary state alive.

Example:
    >>> def my_impl_register(module_path: str = "my_flash_impl"):
    ...     # Register custom kernels with torch dispatcher
    ...     pass  # doctest: +SKIP
    >>> register_flash_attention_impl(
    ...     "MyImpl", register_fn=my_impl_register
    ... )  # doctest: +SKIP
N)Ú_FLASH_ATTENTION_IMPLS)r   r   s   &$r   Úregister_flash_attention_implr$      s   € ð< $/Ô˜4Ó r   c                ó>   € V ^8„  d   QhR\         \        ,          RR/# )r	   r   r
   N)r   r    )r   s   "r   r   r   =   s"   € ÷ &1ñ &1Ü
Ô#Õ
#ð&1à	ñ&1r   c                ó¢   € \        RR7       \        P                  V 4      pVf   \        RV  R\	        4        24      hV! 4       pVe   W3sR# R# )a#  
Activate into the dispatcher a previously registered flash attention impl.

.. note::
    Backend providers should NOT automatically activate their implementation
    on import. Users should explicitly opt-in by calling this function or via
    environment variables to ensure multiple provider libraries can coexist.

Args:
    impl: Implementation identifier to activate. See
        :func:`~torch.nn.attention.list_flash_attention_impls` for available
        implementations.
        If the backend's :func:`register_flash_attention_impl` callable
        returns a :class:`FlashAttentionHandle`, the registry keeps that
        handle alive for the lifetime of the process (until explicit
        uninstall support exists).

Example:
    >>> activate_flash_attention_impl("FA4")  # doctest: +SKIP
F)Ú_raise_warnNzUnknown flash attention impl 'z'. Available implementations: )Úrestore_flash_attention_implr#   ÚgetÚ
ValueErrorÚlist_flash_attention_implsÚ_FLASH_ATTENTION_ACTIVE)r   r   Úhandles   &  r   Úactivate_flash_attention_implr.   =   sk   € ô2 !Øõô )×,Ñ,¨TÓ2€KØÒÜØ,¨T¨Fð 3*Ü*DÓ*FÐ)GðIó
ð 	
ñ
 ‹]€FØÒØ#' .Òñ r   c                ó:   € V ^8„  d   QhR\         \        ,          /# )r	   r
   )Úlistr   )r   s   "r   r   r   f   s   € ÷ 1ñ 1¤D¬¥Iñ 1r   c                 ó<   € \        \        P                  4       4      # )zBReturn the names of all available flash attention implementations.)Úsortedr#   Úkeysr   r   r   r+   r+   f   s   € äÔ(×-Ñ-Ó/Ó0Ð0r   c                ó2   € V ^8„  d   QhR\         R,          /# r   )r   )r   s   "r   r   r   k   s   € ÷ 
ñ 
¤c¨D¥jñ 
r   c                 ó8   € \         e   \         ^ ,          # \         # )z
Return the currently activated flash attention impl name, if any.

``None`` indicates that no custom impl has been activated.
)r,   r   r   r   Úcurrent_flash_attention_implr6   k   s#   € ô #Ò.ô 	  Õ"ðô %ðr   c                ó(   € V ^8„  d   QhR\         RR/# )r	   r'   r
   N)Úbool)r   s   "r   r   r   x   s   € ÷ #ñ #¬dð #¸dñ #r   c                ó¢   € Rp\         e   \         ^,          pVe   VP                  4        Rs R# V '       d   \        P                  R4       Rs R# )z(
Restore the default FA2 implementation
NzDTrying to restore default FA2 impl when no custom impl was activated)r,   r   ÚloggerÚwarning)r'   r-   s   & r   r(   r(   x   sL   € ð €FÜÒ*Ü(¨Õ+ˆàÒØ�‰Œð #Ò÷ 
Ü�‰ØRô	
ð #Òr   c                óº   € V ^8„  d   Qh/ ^ \         9   d   \        \        \        3,          ;R&   ^\         9   d"   \        \        \
        3,          R,          ;R&   # )r	   r#   Nr,   )Ú__conditional_annotations__Údictr   r!   Útupler   )r   s   "r   r   r      sK   € ÷ ñ ÷* 4Ò 3œœS¤+Ð-Õ.Ñ 3ñ+÷. HÒ GœœsÔ$8Ð8Õ9¸DÕ@Ñ Gò/r   )ÚFA3ÚFA4)T)r=   Ú__doc__ÚloggingÚcollections.abcr   Útypingr   r   Ú	getLoggerr   r:   r   r!   r    r#   r,   r$   r.   r+   r6   r(   r   )r=   s   @r   Ú<module>rG      sˆ   øðöó Ý $ß $ð 
×	Ò	˜8Ó	$€ô"˜8ô "ð �sÐ0°4Õ7Ð7Õ8€Ø˜lÕ+Ð à13Ð Ó 3àCGÐ Ó Gõ/õB&1õR1õ

÷#ñ #r   