
    Uh`                     8   U d dl mZmZ ddlmZ 	 d dlmZmZmZm	Z	 d dlm
Z dZd edd	
      id edd
      id eddd      id edd
      idZeeeeeef   ef   f   ed<    ee       d Z
d Zg dZy# e$ r d Z
 G d d      Zd Z	d ZdZY $w xY w)    )DictUnion   )is_torchdynamo_compiling)DeviceLayerRepositoryregister_kernel_mappingreplace_kernel_forward_from_hub)use_kernel_forward_from_hubTcudaz!kernels-community/deformable-detrMultiScaleDeformableAttention)repo_id
layer_namezkernels-community/moeLlama4TextMoez#kernels-community/triton-layer-normLlamaRMSNormzpure-layer-test)r   r   revisionzmedmekk/triton-llama-mlpTritonLlamaMLP)r   r   RMSNormMLP_KERNEL_MAPPINGc                        fd}|S )a5  
        Expands `kernels`' `use_kernel_forward_from_hub` to NOT use a kernel at compile time. This should be removed
        when `kernels` supports `torch.compile`.

        If the layer has a `config` attribute, we can also set `config.disable_custom_kernels = True` to disable the
        kernel.
        c                       j                   t        i } |         j                    fd}| _          S )Nc                      t        d      xr t        j                  dd       }t               s|r | i |S  | i |S )Nconfigdisable_custom_kernels)hasattrgetattrr   r   )forward_argsforward_kwargsr   clskernel_forwardoriginal_forwards      w/var/www/catia.catastroantioquia-mas.com/valormas/lib/python3.12/site-packages/transformers/integrations/hub_kernels.pyforward_with_compile_pathzcuse_kernel_forward_from_hub.<locals>.decorator_with_compile_path.<locals>.forward_with_compile_pathS   sM    )0h)?)wGCJJXprvDw&+-1G+\L^LL)<J>JJ    )forward$original_use_kernel_forward_from_hub)r    	decoratorr$   r!   r"   argskwargss   `  @@r#   decorator_with_compile_pathz@use_kernel_forward_from_hub.<locals>.decorator_with_compile_pathH   sF    "{{ =dMfMIC.C ![[NK 4CKJr%    )r)   r*   r+   s   `` r#   r   r   ?   s    	, +*r%   c                      d }|S )Nc                     | S Nr,   )r    s    r#   r(   z.use_kernel_forward_from_hub.<locals>.decoratore   s    Jr%   r,   )r)   r*   r(   s      r#   r   r   d   s    	 r%   c                       e Zd Zd Zy)r   c                     t        d      )NzNLayerRepository requires `kernels` to be installed. Run `pip install kernels`.RuntimeError)selfr)   r*   s      r#   __init__zLayerRepository.__init__k   s    oppr%   N)__name__
__module____qualname__r5   r,   r%   r#   r   r   j   s    	qr%   r   c                      t        d      )Nz^replace_kernel_forward_from_hub requires `kernels` to be installed. Run `pip install kernels`.r2   r)   r*   s     r#   r
   r
   n   s    l
 	
r%   c                      t        d      )NzVregister_kernel_mapping requires `kernels` to be installed. Run `pip install kernels`.r2   r:   s     r#   r	   r	   s   s    sttr%   Fc                      t         S r/   )_hub_kernels_availabler,   r%   r#   is_hub_kernels_availabler>   y   s    !!r%   )r   r>   r   r	   r
   N)typingr   r   utilsr   kernelsr   r   r	   r
   r   r'   r=   r   str__annotations__ImportErrorr>   __all__r,   r%   r#   <module>rF      s	     ,c#  " O;:*
 O/*
 O=)*
 O2+
+MOT#tE&#+$6$GHHI : O,+t"9  #q q

u #+#s   A#A< <BB