+
    œ°³jª4  ã                   ó>   € ^RI Ht R tRR ltR t ! R R]4      tR# )	é   )ÚPushToHubMixinc                ó  € Rp \        V P                  4       4      pTP                  P
                  pTR8X  d2   ^RIHp T! 4       '       d   ^ RIp\        TR4      P                  e   R# T#   \         d    \        RT 24      hi ; i)zw
Infers the device type from the model parameters.
Args:
    model: The model instance.

Returns:
    The device type.
zž
    {
        "RMSNorm": {
            "cuda":
                "kernels-community/layer_norm:LlamaRMSNorm",
            ...
        },
        ...
    }
    zPCannot determine model device, please provide a device to the mapping. Example: Úcuda)Úis_torch_availableNÚversionÚrocm)ÚnextÚ
parametersÚStopIterationÚ
ValueErrorÚdeviceÚtypeÚutilsr   ÚtorchÚgetattrÚhip)ÚmodelÚEXAMPLE_MAPPINGÚparamÚdev_typer   r   s   &     Úa/home/luca/screen-checking/.venv/lib/python3.14/site-packages/transformers/utils/kernel_config.pyÚinfer_devicer      sŽ   € ð	€Oð
Ü�U×%Ñ%Ó'Ó(ˆð �|‰|× Ñ €HØ�6Ôå.á×ÒÛä�u˜iÓ(×,Ñ,Ò8Ùà€Oøô! ô 
ÜØ^Ð_nÐ^oÐpó
ð 	
ð
ús   „A- Á-BNc           
      óÀ   € ^ RI Hp VR9  d   \        RV 24      hVP                  R4      ^,          p	VP                  R4      ^ ,          p
VW8! V
V	VVVR7      //W@&   R# )é    ©ÚLayerRepositoryúBOnly cuda, rocm, xpu, npu, neuron and tpu devices supported, got: Ú:)Úrepo_idÚ
layer_namer   ÚrevisionÚtrust_remote_codeN©r   r   ÚxpuÚnpuÚneuronÚtpu)Úkernelsr   r   Úsplit)r    r   Ú	repo_nameÚmodeÚcompatible_mappingr   r!   r"   r   Úrepo_layer_namer   s   &&&&&&&&   r   Úadd_to_mappingr.   :   sw   € õ (àÐDÔDÜÐ]Ð^dÐ]eÐfÓgÐgØ—o‘o cÓ*¨1Õ-€OØ�o‰o˜cÓ" 1Õ%€GàØ�/ØØ*ØØ!Ø"3ôð
ð
&ÐÓ"ó    c                 óÒ   € ^ RI Hp ^ RIHp VR9  d   \	        RV 24      hVP                  R4      ^,          pVP                  R4      ^ ,          pVW6! V! V4      VR7      //W@&   R# )r   )ÚPath)ÚLocalLayerRepositoryr   r   )Ú	repo_pathr    Nr#   )Úpathlibr1   r(   r2   r   r)   )	r    r   r*   r+   r,   r1   r2   r-   r3   s	   &&&&&    r   Úadd_to_mapping_localr5   P   st   € Ýå,àÐDÔDÜÐ]Ð^dÐ]eÐfÓgÐgØ—o‘o cÓ*¨1Õ-€OØ—‘ Ó$ QÕ'€IàØÐ&Ù˜y›/Ø*ôð
ð&ÐÓ"r/   c                   óN   a € ] tR t^ct o RtR	R ltR
R ltR tR tRR lt	Rt
V tR# )ÚKernelConfigz]
Kernel configuration class. This class is used to configure the kernel mapping for a model.
Nc                óF   € Ve   TM/ V n         / V n        W n        W0n        R # )N)Úkernel_mappingÚregistered_layer_namesÚuse_local_kernelÚinherit_mapping)Úselfr9   r;   r<   s   &&&&r   Ú__init__ÚKernelConfig.__init__h   s&   € Ø0>Ò0J™nÐPRˆÔØ&(ˆÔ#Ø 0ÔØ.Ör/   c	           
     óL   € ^ RI Hp	 VWY! VVVVVR7      //V P                  V&   R# )r   r   )r   r    r!   r   r"   N)r(   r   r9   )
r=   r   Úregistered_namer    r   r+   r!   r   r"   r   s
   &&&&&&&&& r   Úupdate_kernelÚKernelConfig.update_kerneln   s<   € õ 	,ð Ø�oØ#Ø)Ø%Ø#Ø&7ôðð
0
ˆ×Ñ˜OÓ,r/   c                ó"  € VP                  4        Fz  w  r#\        VR R4      e:   VP                  P                  4        F  pW@P                  VRV 2,           &   K  	  \        VR4      '       g   Ka  VP                  V P                  V&   K|  	  R# )Ú_kernel_funcsNÚ.Úkernel_layer_name)Únamed_modulesr   rE   Úkeysr:   ÚhasattrrG   )r=   r   ÚnameÚmodulerG   s   &&   r   Ústore_registered_layer_namesÚ)KernelConfig.store_registered_layer_names   sƒ   € Ø!×/Ñ/Ö1‰LˆDä�v˜°Ó5ÒAØ)/×)=Ñ)=×)BÑ)BÖ)DÐ%ØRc×/Ñ/°¸Ð;LÐ:MÐ7NÕ0NÓOñ *Eô �vÐ2×3Ô3Ø4:×4LÑ4L�×+Ñ+¨DÓ1ó 2r/   c           	     óZ  € RpV P                  V4       \        V P                  \        4      '       g%   \	        RV R\        V P                  4       24      hV P                  P                  4        EF´  w  r4W0P                  P                  4       9  d   \	        RV R24      hRp\        V\        \        34      '       d   RV/pRp\        V\        4      '       Ed9   VP                  4        EF   w  rgTpV'       g   VR9  d   \	        R	V 24      h\        V\        4      '       d±   Vw  r‰\        V	\        4      '       g   \	        R
\        V	4      : RV	 R24      hV	P                  RR4      ;p
e%   \        V
\        4      '       g   \	        RV
 24      hV	P                  RR4      ;pf+   V	P                  RR4      ;p f   \	        RV: RV: 24      h\        V\        4      '       d   RV9  g   RV9  g   EK  \	        RV RV 24      h	  EK¦  \	        RV RV 24      h	  R# )aò  
Validates the kernel_mapping to ensure that:
1. Each layer_name in the mapping is registered in the model (i.e., the model contains a module with a matching kernel_layer_name).
2. Each kernel value is
    - either a string of the form 'org/repo:layer_name' or a tuple with the same as string and a dict of {"revision"/"version/trust_remote_code": ...},
    - or a dict mapping device types ("cuda", "rocm", "xpu", "npu") to such values as above.
3. Each device key in a dict is one of "cuda", "rocm", "xpu", or "npu".
5. Each trust remote code key must be a bool.
6. Each revision or version key must exist mutually exclusive if it has been passed explicitly.
7. Each repo_name is a valid repository and layer name in the format 'org/repo:layer_name' (i.e., a string containing both a slash and a colon).
8. If a local path is detected, it should be in the format '/abs/path:layer_name', where the absolute path points to the kernel repository, like "/home/user/layer_norm".

Args:
    model: The model instance whose modules are checked for registered kernel_layer_name attributes.

Raises:
    ValueError: If a layer_name is not registered in the model, if a device is not supported,
                or if a repo_name is not a valid 'org/repo:layer_name' string.
a}  
        For single device form remote
        {
            "RMSNorm":
                "kernels-community/layer_norm:LlamaRMSNorm",
            ...
        },
        For multiple devices form remote
        {
            "RMSNorm": {
                "cuda":
                    "kernels-community/layer_norm:LlamaRMSNorm",
                "rocm":
                    "kernels-community/layer_norm:LlamaRMSNorm",
                ...
            },
            ...
        }
        You can also pass metadata along to inform about specific kernel information
        {
            "RMSNorm":
                ("kernels-community/layer_norm:LlamaRMSNorm", {"version": 1, "trust_remote_code": True}),
            ...
        },
        For single device form local
        {
            "RMSNorm":
                "/abs/path:LlamaRMSNorm",
            ...
        },
        For multiple devices form local
        {
            "RMSNorm": {
                "cuda":
                    "/abs/path:LlamaRMSNorm",
                "rocm":
                    "/abs/path:LlamaRMSNorm",
                ...
            },
            ...
        }
        z7Kernel mapping must be a dict of the following format: z, got: zLayer z[ is not registered in the model, please register it first using use_kernel_forward_from_hubFNTr   z^The passed metadata as second entry in a tuple needs to be a dict but found: type(metadata) = z for rF   r"   z6Expected a bool value for `trust_remote_code` but got r!   r   zŠExpected valid combination for version/revision (mutually exclusive but one of them) to be passed when passed as tuple, but got revision= z and version= Ú/r   zKernel mapping for 'zl' must be a valid repo name with a layer name (e.g., 'org/repo:layer_name' or '/abs/path:layer_name'), got: z'Kernel mapping must follow the format: r#   )rM   Ú
isinstancer9   Údictr   r   Úitemsr:   ÚvaluesÚstrÚtupleÚgetÚbool)r=   r   ÚMAPPING_FORMATr    ÚkernelÚskip_device_checkr   Úrepor*   Úmetadatar"   r!   r   s   &&           r   Úsanitize_kernel_mappingÚ$KernelConfig.sanitize_kernel_mappingŠ   st  € ð()ˆðT 	×)Ñ)¨%Ô0ä˜$×-Ñ-¬t×4Ò4ÜØIÈ.ÐIYÐY`ÔaeÐfj×fyÑfyÓazÐ`{Ð|óð ð #'×"5Ñ"5×";Ñ";×"=ÑˆJØ×!<Ñ!<×!CÑ!CÓ!EÔEÜ Ø˜Z˜Lð  )Dð  Eóð ð !&ÐÜ˜&¤3¬ ,×/Ò/Ø ˜�Ø$(Ð!ä˜&¤$×'Ó'Ø$*§L¡L§N‘L�FØ $�Iß,°Ð?nÔ1nÜ(Ð+mÐntÐmuÐ)vÓwÐwô " $¬×.Ò.Ø.2Ñ+˜	ä)¨(´D×9Ò9Ü",ð!5Ü#'¨£>Ñ"5°U¸8¸*ÀAð!Gó#ð ð
 2:·±Ð>QÐSWÓ1XÐXÐ-ÒeÜ#-Ð.?Ä×#FÒ#FÜ&0Ø&\Ð]nÐ\oÐ$pó'"ð !"ð )1¯©°ZÀÓ(FÐF˜HÒOØ'/§|¡|°I¸tÓ'DÐD˜GØ!òU"ô #-ð!YØNVÉ\ÐYhÐ_fÑ^ið!kó#ð ô
 & i´×5Ò5¸ÀIÔ9MÐQTÐ\e×QeÜ(Ø2°:°,ð  ?kð  luð  kvð  wóð ô= %3ôD !Ð#JÈ>ÐJZÐZaÐbhÐaiÐ!jÓkÐkó] #>r/   c                ó¤  € ^ RI Hp / p\        V4      pV P                  P	                  4        EF  w  rgVP
                  '       d   VP                  MVP                  pV'       d   WƒP                  ,          p\        V\        \        34      '       d   WW/pVP	                  4        Fš  w  ršW•8w  d   K  V P                  '       d   \        WiW¨V4       K.  \        V
\        4      '       d<   V
w  r¼VP                  RR4      pVP                  RR4      pVP                  RR4      pMT
pRp^pRp\        VV	VVVVVVR7       Kœ  	  EK  	  W@n        R# )ae  
Transforms a simple kernel_mapping of the form:
    {
        "RMSNorm":
            ("kernels-community/layer_norm:LlamaRMSNorm", {"version": 1, "trust_remote_code": True}),
        ...
    },

    or for local path:

    {
        "RMSNorm":
            "/home/user/liger_kernels:LigerRMSNorm",
        ...
    },

into a nested mapping:

    {
        "RMSNorm": {
            "cuda": {
                Mode.INFERENCE: LayerRepository(
                    repo_id="kernels-community/layer_norm",
                    layer_name="LlamaRMSNorm",
                    version=1,
                    trust_remote_code=True,
                )
            }
        }
    }

    or for local path:

    {
        "RMSNorm": {
            "cuda": {
                Mode.INFERENCE: LocalLayerRepository(
                    repo_path=Path("/home/user/liger_kernels"),
                    layer_name="LigerRMSNorm",
                )
            }
        }
    }

that's compatible with the kernels library.

The device is inferred from the model's parameters if not provided.
The Mode is inferred from the model's training state.
)ÚModer!   Nr   r"   F)r   r*   r+   r,   r   r!   r"   )r(   ra   r   r9   rS   ÚtrainingÚTRAININGÚ	INFERENCEÚTORCH_COMPILErQ   rU   rV   r;   r5   rW   r.   )r=   r   Úcompilera   r,   Úcurrent_devicer    rZ   r+   r   r\   r*   r]   r!   r   r"   s   &&&             r   Úcreate_compatible_mappingÚ&KernelConfig.create_compatible_mappingÿ   s3  € õd 	!àÐÜ% eÓ,ˆØ"&×"5Ñ"5×";Ñ";×"=ÑˆJà$)§N§N N�4—=’=¸¿¹ˆDßØ×0Ñ0Õ0�ä˜&¤3¬ ,×/Ò/Ø(Ð1�à &§¡¦‘�ØÔ+Ùà×(×(Ð(Ü(¨¸TÐI[Ô\Ùô ˜d¤E×*Ò*Ø*.Ñ'�IØ'Ÿ|™|¨J¸Ó=�HØ&Ÿl™l¨9°dÓ;�GØ(0¯©Ð5HÈ%Ó(PÑ%à $�IØ#�HØ�GØ(-Ð%äØØ!Ø'ØØ'9Ø#Ø%Ø&7÷	ô) !/ñ #>ðP 1Ör/   )r<   r9   r:   r;   )NFT)Né   F)F)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r>   rB   rM   r^   rh   Ú__static_attributes__Ú__classdictcell__)Ú__classdict__s   @r   r7   r7   c   s.   ø‡ € ñô/ô
ò"	Mòsl÷j^1ò ^1r/   r7   )rj   NF)r   r   r   r.   r5   r7   © r/   r   Ú<module>rt      s(   ðõ #ò%ôPò,ô&z1�>ö z1r/   