+
    QV-jì(  ã                   ó:   € ^RI Ht R tR 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   &     Úq/Volumes/fast/ai/experiments/ui-tars-smoke/.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c                 óº   € ^ RI Hp VR9  d   \        RV 24      hVP                  R4      ^,          pVP                  R4      ^ ,          pVW5! VVR7      //W@&   R# )é    ©ÚLayerRepositoryúBOnly cuda, rocm, xpu, npu, neuron and tpu devices supported, got: Ú:)Úrepo_idÚ
layer_nameN©r   r   ÚxpuÚnpuÚneuronÚtpu)Úkernelsr   r   Úsplit)r    r   Ú	repo_nameÚmodeÚcompatible_mappingr   Úrepo_layer_namer   s   &&&&&   r   Úadd_to_mappingr,   :   sl   € Ý'àÐDÔDÜÐ]Ð^dÐ]eÐfÓgÐgØ—o‘o cÓ*¨1Õ-€OØ�o‰o˜cÓ" 1Õ%€GàØ�/ØØ*ôð
ð&ÐÓ"ó    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P                  R4      R	,          p	VW6! V! V4      V	VR7      //W@&   R# )
r   )ÚPath)ÚLocalLayerRepositoryr   r   Ú/)Ú	repo_pathÚpackage_namer    Nr!   éÿÿÿÿ)Úpathlibr/   r&   r0   r   r'   )
r    r   r(   r)   r*   r/   r0   r+   r2   Úrepo_package_names
   &&&&&     r   Úadd_to_mapping_localr7   K   s‹   € Ýå,àÐDÔDÜÐ]Ð^dÐ]eÐfÓgÐgØ—o‘o cÓ*¨1Õ-€OØ—‘ Ó$ QÕ'€IØ!Ÿ™¨Ó,¨RÕ0ÐàØÐ&Ù˜y›/Ø.Ø*ôð
ð&ÐÓ"r-   c                   óN   a € ] tR t^`t 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                ó:   € Ve   TM/ V n         / V n        W n        R # ©N©Úkernel_mappingÚregistered_layer_namesÚuse_local_kernel)Úselfr=   r?   s   &&&r   Ú__init__ÚKernelConfig.__init__e   s    € Ø0>Ò0J™nÐPRˆÔØ&(ˆÔ#Ø 0Ör-   c                óH   € ^ RI Hp VWW! VVVR7      //V P                  V&   R# )r   r   )r   r    ÚrevisionN)r&   r   r=   )r@   r   Úregistered_namer    r   r)   rD   r   s   &&&&&&& r   Úupdate_kernelÚKernelConfig.update_kernelj   s4   € Ý+ð Ø�oØ#Ø)Ø%ôðð0
ˆ×Ñ˜OÓ,r-   c                ó’   € VP                  4        F2  w  r#\        VR 4      '       g   K  VP                  V P                  V&   K4  	  R# )Úkernel_layer_nameN)Únamed_modulesÚhasattrrI   r>   )r@   r   ÚnameÚmodules   &&  r   Ústore_registered_layer_namesÚ)KernelConfig.store_registered_layer_namesw   s;   € Ø!×/Ñ/Ö1‰LˆDÜ�vÐ2×3Ô3Ø4:×4LÑ4L�×+Ñ+¨DÓ1ó 2r-   c                óÖ  € RpV P                  V4       \        V P                  \        4      '       g%   \	        RV R\        V P                  4       24      hV P                  P                  4        Fó  w  r4W0P                  P                  4       9  d   \	        RV R24      h\        V\        4      '       d"   RV9  g   RV9  d   \	        RV R	V 24      hKi  \        V\        4      '       df   VP                  4        FO  w  rVVR9  d   \	        R
V 24      h\        V\        4      '       d   RV9  g
   RV9  g   K@  \	        RV R	V 24      h	  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 dict mapping device types ("cuda", "rocm", "xpu", "npu") to such strings.
3. Each device key in a dict is one of "cuda", "rocm", "xpu", or "npu".
4. 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).
5. If a local path is detected, it should be in the format '/abs/path:layer_name'. The absolute path must include the `package_name`, 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",
                ...
            },
            ...
        }
        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_hubr1   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: r   z'Kernel mapping must follow the format: Nr!   )
rN   Ú
isinstancer=   Údictr   r   Úitemsr>   ÚvaluesÚstr)r@   r   ÚMAPPING_FORMATr    Úkernelr   r(   s   &&     r   Úsanitize_kernel_mappingÚ$KernelConfig.sanitize_kernel_mapping|   s¨  € ð #ˆðH 	×)Ñ)¨%Ô0ä˜$×-Ñ-¬t×4Ò4ÜØIÈ.ÐIYÐY`ÔaeÐfj×fyÑfyÓazÐ`{Ð|óð ð #'×"5Ñ"5×";Ñ";Ö"=ÑˆJØ×!<Ñ!<×!CÑ!CÓ!EÔEÜ Ø˜Z˜Lð  )Dð  Eóð ô ˜&¤#×&Ò&Ø˜fÔ$¨°6Ô(9Ü$Ø.¨z¨lð  ;gð  hnð  goð  póð ñ ):ô
 ˜F¤D×)Ò)Ø)/¯©®Ñ%�FØÐ%TÔTÜ(Ð+mÐntÐmuÐ)vÓwÐwä% i´×5Ò5¸ÀIÔ9MÐQTÐ\eÖQeÜ(Ø2°:°,ð  ?kð  luð  kvð  wóð ó *8ô !Ð#JÈ>ÐJZÐZaÐbhÐaiÐ!jÓkÐkó- #>r-   c           	     ód  € ^ RI Hp / p\        V4      pV P                  P	                  4        Fø  w  rgVP
                  '       d   VP                  MVP                  pV'       d   WƒP                  ,          p\        V\        4      '       d3   Tp	V P                  '       g   \        WeW˜V4       K‚  \        WeW˜V4       K‘  \        V\        4      '       g   K©  VP	                  4        F;  w  r©W¥8w  d   K  V P                  '       g   \        WjW˜V4       K.  \        WjW˜V4       K=  	  Kú  	  W@n        R# )a  
Transforms a simple kernel_mapping of the form:
    {
        "RMSNorm":
            "kernels-community/layer_norm:LlamaRMSNorm",
        ...
    },

    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",
                )
            }
        }
    }

    or for local path:

    {
        "RMSNorm": {
            "cuda": {
                Mode.INFERENCE: LocalLayerRepository(
                    repo_path=Path("/home/user/liger_kernels"),
                    package_name="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.
)ÚModeN)r&   r[   r   r=   rS   ÚtrainingÚTRAININGÚ	INFERENCEÚTORCH_COMPILErQ   rU   r?   r,   r7   rR   )r@   r   Úcompiler[   r*   Úcurrent_devicer    rW   r)   r(   r   s   &&&        r   Úcreate_compatible_mappingÚ&KernelConfig.create_compatible_mappingÏ   së   € õb 	!àÐÜ% eÓ,ˆØ"&×"5Ñ"5×";Ñ";Ö"=ÑˆJà$)§N§N N�4—=’=¸¿¹ˆDßØ×0Ñ0Õ0�ä˜&¤#×&Ò&Ø"�	Ø×,×,Ð,Ü" :¸yÐPbÖcä(¨ÀYÐVhÖiÜ˜F¤D×)Ô)Ø)/¯©®Ñ%�FØÔ/Ù Ø×0×0Ð0Ü& z¸9ÐL^Ö_ä,¨ZÀÐRdÖeó *8ñ #>ð* 1Ör-   r<   )NFr;   )F)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__rA   rF   rN   rX   rb   Ú__static_attributes__Ú__classdictcell__)Ú__classdict__s   @r   r9   r9   `   s.   ø‡ € ñô1ô

òMò
Ql÷fJ1ò J1r-   r9   N)r   r   r   r,   r7   r9   © r-   r   Ú<module>rm      s(   ðõ #ò%òPò"ô*y1�>ö y1r-   