ó
    Eñi°u ã                   óž  • S SK r S SKrS SKrS SKrS SKrS SKrS SKrS SKrS SKrS SK	r	S SK
JrJr  S SKJrJr  S SKrS SKJr  S SKJr  SSKJr  SS	KJrJr  SS
KJrJrJr  SSKJrJrJ r J!r!J"r"J#r#J$r$J%r%J&r&  SSK'J(r(  SSK)J*r*J+r+J,r,  SSK-J.r.J-r-  SSK/J0r0  \"" SS9(       a  S SK1r1\" SS9(       a  S SK2r2\$" SS9(       a  S SK3r3\!" SS9(       a  S SK4r4S SK5J6r6  S SK7J8r9  Sr:\Rv                  " \<5      r=S r>S r?S\\@\A4   4S jrBS\R†                  4S jrDS\RŠ                  S\F\RŽ                  \@\@4   4S jrH      SgS\R’                  S\AS \\@\A\RŽ                  4   S!\\RŠ                     S\\\A\R†                  4      S"\\R”                     S#\\K\@\K\RŽ                  \RŠ                  4   4      S$\LS%\L4S& jjrM ShS\R’                  S'\LS(\LS)\L4S* jjrNSiS\R’                  S(\LS+\L4S, jjrOS-\R’                  4S. jrPS/ rQS0 rRS-\R&                  R’                  S\S\S\A      4S1 jrTS2 rUS\\A\RŽ                  4   S\R†                  4S3 jrV   SjS-\R’                  S\\\A\RŽ                  4      S4\\K\A\\A\RŽ                  4   4      S5\L4S6 jjrW  SkS-\R’                  S\\\A\RŽ                  4      S4\\K\A\\A\RŽ                  4   4      4S7 jjrXS8\S\F\A\R&                  R’                  4      S9\K\A\@4   S:\S\A   4S; jrYSlS<\\K\\@\A4   \\@\A4   4      4S= jjrZSmS>\K\A\\@\A\RŽ                  4   4   S?\A4S@ jjr[SA r\SB r]     SnS-\R’                  S<\\K\\@\A4   \\@\A4   4      S:\\S\A      S\\\A\R†                  4      S4\\K\A\\A\RŽ                  4   4      SC\L4SD jjr^S-\R&                  R’                  4SE jr_    SoS-\R’                  S<\\K\\@\A4   \\@\A4   4      S:\\S\A      S\\\A\R†                  4      S4\\K\A\\A\RŽ                  4   4      S\F\S\\@\A4      \K\\@\A4   \\@\A4   4   \S\\@\A4      \S\@   \K\A\@4   \S\S\A      \S\A   \S\F\A\R’                  4      4   4SF jjr`S\F\@\S\A   \S\R’                     4   4SG jra  SkS8\S\F\A\R’                  4      S9\K\A\@4   SH\\@\A4   S:\\S\A      SI\\S\S\A         S\F\\A   \\R’                     \S\F\A\R’                  4      4   4SJ jjrb        SpS-\R’                  S<\\K\\@\A4   \\@\A4   4      S:\\S\A      S\\\A\R†                  4      S4\\K\A\\A\R†                  4   4      SK\LSL\LSM\LSN\L4SO jjrcS-\R’                  S>\K\A\\@\A\RŽ                  4   4   4SP jrdSlSQ jreS-\R’                  4SR jrf SqS\R’                  S?\ASS\K\A\\A\RÎ                  4   4   ST\\@\A\RŽ                  4   4SU jjrh          SrS-\R’                  SV\\A\RÒ                  4   S>\\K\A\\@\A\RŽ                  4   4      SW\\\A\RÒ                  4      S\\\A\R†                  4      SX\LSM\LSY\\S\A      SZ\LS[\LS\\LS]\L4S^ jjrjSsS_\LS`\4Sa jjrkSlSb\4Sc jjrlS\R&                  R’                  S\L4Sd jrm\ RÜ                  SlS\R&                  R’                  Se\\RŽ                     4Sf jj5       rog)té    N)ÚOrderedDictÚdefaultdict)ÚOptionalÚUnion)Údistributed)Únné   )ÚAcceleratorStateé   )ÚSAFE_WEIGHTS_NAMEÚWEIGHTS_NAME)ÚAutocastKwargsÚCustomDtypeÚDistributedType)	Úis_hpu_availableÚis_mlu_availableÚis_mps_availableÚis_musa_availableÚis_npu_availableÚis_peft_availableÚis_sdaa_availableÚis_torch_xla_availableÚis_xpu_available)Úclear_device_cache)Úload_offloaded_weightÚoffload_weightÚsave_offload_index)Úis_tqdm_availableÚtqdm)Úis_torch_versionF)Úcheck_device)Ú	safe_open)Ú	load_filezpytorch_model.bin.index.jsonc                 ó~   • SSK Jn  [        5       (       a  SSKJn  [        5       =(       a    [        U" U 5      W5      $ )Nr   )Úextract_model_from_parallelr   )Ú	PeftModel)Úotherr%   r   Úpeftr&   Ú
isinstance)Úmodelr%   r&   s      ÚV/home/mande/repo/quber/.venv/lib/python3.13/site-packages/accelerate/utils/modeling.pyÚis_peft_modelr,   I   s-   € Ý2ä×ÑÝ"äÓ×\¤:Ñ.IÈ%Ó.PÐR[Ó#\Ð\ó    c                 ó0  • U R                   UR                   :w  a  gU R                   S:w  a,  U R                  c  [        R                  " U R                   SS9n UR                   S:w  a,  UR                  c  [        R                  " UR                   SS9nX:H  $ )aj  
Utility method to check if two `torch` devices are similar. When dealing torch accelerator devices(e.g. cuda, xpu),
torch throws `False` for `torch.device("cuda") == torch.device("cuda:0")` whereas they should be the same

Args:
    first_device (`torch.device`):
        First device to check
    second_device (`torch.device`):
        Second device to check
FÚcpur   ©Úindex)Útyper1   ÚtorchÚdevice)Úfirst_deviceÚsecond_devices     r+   Úcheck_device_samer7   R   s†   € ð ×Ñ˜M×.Ñ.Ó.Øà×Ñ˜EÓ! l×&8Ñ&8Ñ&@ô —|’| L×$5Ñ$5¸QÑ?ˆà×Ñ˜UÓ" }×':Ñ':Ñ'Bô Ÿš ]×%7Ñ%7¸qÑAˆàÑ(Ð(r-   Úsizec                 óD  • SnSU  S3n [        U [        5      (       a  U nGOÓU R                  5       R                  S5      (       a  [        [	        U SS 5      S-  5      nGO“U R                  5       R                  S5      (       a  [        [	        U SS 5      S	-  5      nGOSU R                  5       R                  S
5      (       a  [        [	        U SS 5      S-  5      nGOU R                  5       R                  S5      (       a8  [        [	        U SS 5      S-  5      nU R                  S5      (       a  US-  OUnO·U R                  5       R                  S5      (       a8  [        [	        U SS 5      S-  5      nU R                  S5      (       a  US-  OUnO[U R                  5       R                  S5      (       a7  [        [	        U SS 5      S-  5      nU R                  S5      (       a  US-  OUnUS:  a  [        U5      eU$ ! [
         a    [        U5      ef = f)a  
Converts a size expressed as a string with digits an unit (like `"5MB"`) to an integer (in bytes).

Args:
    size (`int` or `str`): The size to convert. Will be directly returned if an `int`.

Example:

```py
>>> convert_file_size_to_int("1MiB")
1048576
```
éÿÿÿÿz`size` z] is not in a valid format. Use an integer for bytes, or a string with an unit (like '5.0GB').ÚGIBNéýÿÿÿi   @ÚMIBi   ÚKIBi   ÚGBéþÿÿÿi Êš;Úbé   ÚMBi@B ÚKBiè  r   )r)   ÚintÚupperÚendswithÚfloatÚ
ValueError)r8   Úmem_sizeÚerr_msgÚint_sizes       r+   Úconvert_file_size_to_intrM   m   sØ  € ð €Hà
�$�ÐtÐuð ð"Ü�dœC× Ñ ØŠHØ�Z‰Z‹\×"Ñ" 5×)Ñ)Üœ5  c r Ó+¨uÑ5Ó6ŠHØ�Z‰Z‹\×"Ñ" 5×)Ñ)Üœ5  c r Ó+¨uÑ5Ó6ŠHØ�Z‰Z‹\×"Ñ" 5×)Ñ)Üœ5  c r Ó+¨uÑ5Ó6ŠHØ�Z‰Z‹\×"Ñ" 4×(Ñ(Üœ5  c r Ó+¨uÑ5Ó6ˆHØ(,¯©°c×(:Ñ(:�x 1’}À‰HØ�Z‰Z‹\×"Ñ" 4×(Ñ(Üœ5  c r Ó+¨uÑ5Ó6ˆHØ(,¯©°c×(:Ñ(:�x 1’}À‰HØ�Z‰Z‹\×"Ñ" 4×(Ñ(Üœ5  c r Ó+¨uÑ5Ó6ˆHØ(,¯©°c×(:Ñ(:�x 1’}ÀˆHð �!ƒ|Ü˜Ó!Ð!Ø€Oøô ó "Ü˜Ó!Ð!ð"ús1   ŠH	 £>H	 Á#>H	 Â#>H	 Ã#AH	 Ä?AH	 ÆAH	 È	HÚdtypec                 ó¼  • U [         R                  :X  a  gU [        R                  :X  a  gU [        R                  :X  a  gU [        R
                  :X  a  g[        SS5      (       a%  U [         R                  [         R                  4;   a  g[        R                  " S[        U 5      5      nUc  [        SU  S	35      e[        UR                  5       S
   5      nUS-  $ )z‚
Returns the size (in bytes) occupied by one parameter of type `dtype`.

Example:

```py
>>> dtype_byte_size(torch.float32)
4
```
g      À?g      Ð?g      à?r   ú>=z2.1.0z[^\d](\d+)$z`dtype` is not a valid dtype: Ú.r   rB   )r3   Úboolr   ÚINT2ÚINT4ÚFP8r    Úfloat8_e4m3fnÚfloat8_e5m2ÚreÚsearchÚstrrI   rE   Úgroups)rN   Ú
bit_searchÚbit_sizes      r+   Údtype_byte_sizer^   ™   s½   € ð ”—
‘
ÓØØ	”+×"Ñ"Ó	"ØØ	”+×"Ñ"Ó	"ØØ	”+—/‘/Ó	!ØÜ	˜$ ×	(Ñ	(¨U´u×7JÑ7JÌE×L]ÑL]Ð6^Ó-^ØÜ—’˜>¬3¨u«:Ó6€JØÑÜÐ9¸%¸ÀÐBÓCÐCÜ�:×$Ñ$Ó& qÑ)Ó*€HØ�q‰=Ðr-   ÚtensorÚreturnc                 óø  • [         R                  S[         R                  S[         R                  S[         R                  S[         R
                  S[         R                  S[         R                  S[         R                  S[         R                  S[         R                  S0
n U R                  5       R                  5       nU R                  5       R                  5       nU R(                  X#4$ ! [         a�     U R                  5       R                  5       nU R                  5       R!                  5       XR"                     -  n Nf! [$         a%    SnU R'                  5       XR"                     -  n  N”f = ff = f)a  
Unique identifier to a tensor storage. Multiple different tensors can share the same underlying storage. For
example, "meta" tensors all share the same storage, and thus their identifier will all be equal. This identifier is
guaranteed to be unique and constant for this tensor's storage during its lifetime. Two tensor storages with
non-overlapping lifetimes may have the same id.
rB   é   r	   r   r   )r3   Úint64Úfloat32Úint32Úbfloat16Úfloat16Úint16Úuint8Úint8rR   Úfloat64Úuntyped_storageÚdata_ptrÚnbytesÚ	ExceptionÚstorager8   rN   ÚNotImplementedErrorÚnelementr4   )r_   Ú_SIZEÚstorage_ptrÚstorage_sizes       r+   Úid_tensor_storagerv   µ   s'  € ô 	�‰�QÜ�‰�qÜ�‰�QÜ�‰˜Ü�‰�qÜ�‰�QÜ�‰�QÜ�
‰
�AÜ�
‰
�AÜ�‰�qð€EðCØ×,Ñ,Ó.×7Ñ7Ó9ˆØ×-Ñ-Ó/×6Ñ6Ó8ˆð �=‰=˜+Ð3Ð3øô ó 	Cð	Cà Ÿ.™.Ó*×3Ñ3Ó5ˆKØ!Ÿ>™>Ó+×0Ñ0Ó2°U¿<¹<Ñ5HÑHŠLøÜ"ó 	CàˆKà!Ÿ?™?Ó,¨u·\±\Ñ/BÑB‹Lð		Cúð	Cús+   Â$<C. Ã.
E9Ã9AEÅ+E5Å1E9Å4E5Å5E9ÚmoduleÚtensor_namer4   ÚvalueÚfp16_statisticsÚtied_params_mapÚnon_blockingÚclear_cachec	           	      ó�  • SU;   aC  UR                  S5      n	U	SS  H$  n
[        X
5      nUc  [        U  SU
 S35      eUn M&     U	S   nXR                  ;  a   XR                  ;  a  [        U  SU S35      eXR                  ;   n[        X5      nUbP  UbM  UR                  5       U;   a9  X&UR                  5          ;   a#  XcR                  5          U   U R                  U'   gUbM  UR                  5       U;   a9  X&UR                  5          ;   a#  XmR                  5          U   U R                  U'   gUR                  [        R                  " S5      :X  a0  US[        R                  " S5      4;  a  Uc  [        U SU S35      eXR                  ;   a  U R                  U   OSn[        U5      nUb©  UR                  UR                  :w  a9  UR                  S:w  a)  [        S	UR                   S
U SUR                   S35      eUc  UR                  UR                  US9nO8[        UR                  5      R                  S5      (       d  UR                  XGS9nSn[        R                  " 5          UbR  UR                  R                  S;  a8  [        R                  " U5      R                  S;   a  UR                  S;   a  UnSn[!        U["        5      (       ae  [%        5       (       a  SU 3nOP['        5       (       a  SU 3nO;[)        5       (       a  SU 3nO&[+        5       (       a  SU 3nO[-        5       (       a  SnS[        U5      ;   a  [/        5       (       d  [        U S35      eUcŒ  UR                  X'S9nUby  US[        R                  " S5      4;   a]  [        UR                  5      R                  S5      (       d  UR                  XGS9nU(       d  U" UUR0                  S9U R                  U'   OC[!        U[        R2                  5      (       a  UR                  X'S9nO[        R4                  " X2S9nUb  UnU(       a  UU R                  U'   GO)Uc=  [7        [        R                  " U5      U R                  U   R                  5      (       Gdé  [        U R                  U   5      nU R                  U   R8                  nUR                  S;   aù  UR                  S:X  a<  UR                  [        R:                  :X  a  UR                  [        R<                  US9nUS:X  a„  UR                  S:X  at  U" U4SUR0                  0UD6R                  S5      R                  S5      nUR>                  R                  S5      Ul        UR@                  R                  S5      Ul         O§U" U4SUR0                  0UD6R                  X'S9nO„UR                  S;   a6  [        RB                  RE                  UUR0                  S9R                  X'S9nO>UR                  S;   a  UR                  X'S9nOU" UUR0                  S9R                  X'S9nUU R                  U'   Ub"  UR                  X'S9U R                  U   l         AU RF                  R                  S :X  Ga  [        U RH                  S!S5      cê  [        U RH                  R                  5      S:w  aÇ  [        R                  " U5      R                  S;   a   [        R                  " U5      RJ                  OSn[        U RH                  S!S5      (       dd  Uba  U RL                  b6  U RL                  R                  R                  S:w  a  U R                  U5      n OùU RL                  c  U R                  U5      n OÚU RF                  R                  S":X  aÀ  [        U RH                  S#S5      c¨  [        U RH                  R                  5      S:w  a…  [        R                  " U5      R                  S;   a   [        R                  " U5      RJ                  OSn[        U RH                  S#S5      (       d#  Ub   U RH                  R                  U5      U l$        SSS5        U(       a  US$;  a
  [O        5         Ub@  UR                  5       U;   a,  X&UR                  5          ;  a  WXmR                  5          U'   gUbF  UbB  UR                  5       U;   a-  X&UR                  5          ;  a  WXcR                  5          U'   ggggg! , (       d  f       N²= f)%aŠ  
A helper function to set a given tensor (parameter of buffer) of a module on a specific device (note that doing
`param.to(device)` creates a new tensor not linked to the parameter, which is why we need this function).

Args:
    module (`torch.nn.Module`):
        The module in which the tensor we want to move lives.
    tensor_name (`str`):
        The full name of the parameter/buffer.
    device (`int`, `str` or `torch.device`):
        The device on which to set the tensor.
    value (`torch.Tensor`, *optional*):
        The value of the tensor (useful when going from the meta device to any other device).
    dtype (`torch.dtype`, *optional*):
        If passed along the value of the parameter will be cast to this `dtype`. Otherwise, `value` will be cast to
        the dtype of the existing parameter in the model.
    fp16_statistics (`torch.HalfTensor`, *optional*):
        The list of fp16 statistics to set on the module, used for 8 bit model serialization.
    tied_params_map (Dict[int, Dict[torch.device, torch.Tensor]], *optional*, defaults to `None`):
        A map of current data pointers to dictionaries of devices to already dispatched tied weights. For a given
        execution device, this parameter is useful to reuse the first available pointer of a shared weight on the
        device for all others, instead of duplicating memory.
    non_blocking (`bool`, *optional*, defaults to `False`):
        If `True`, the device transfer will be asynchronous with respect to the host, if possible.
    clear_cache (`bool`, *optional*, defaults to `True`):
        Whether or not to clear the device cache after setting the tensor on the device.
rQ   Nr:   z has no attribute z- does not have a parameter or a buffer named Úmetaz7 is on the meta device, we need a `value` to put in on Ú
Params4bitz Trying to set a tensor of shape z in "z" (which has shape z), this looks incorrect.)r|   ©z
torch.uintz	torch.intz
torch.bool)ÚcudaÚxpu)Ú
Int8ParamsÚ	FP4Paramsr€   r/   únpu:zmlu:zsdaa:zmusa:Úhpurƒ   z6 is not available, you should use device="cpu" instead)Úrequires_grad©r4   r„   rˆ   r   )ÚQTensorÚQBitsTensor)ÚAffineQuantizedTensorÚLinear8bitLtÚSCBÚ
Linear4bitÚquant_state)r/   r   )(ÚsplitÚgetattrrI   Ú_parametersÚ_buffersrm   r4   r3   r2   ÚshapeÚ__name__ÚtorN   rZ   Ú
startswithÚno_gradr)   rE   r   r   r   r   r   r   rˆ   ÚTensorr_   r7   Ú__dict__rd   rg   ÚCBrŽ   r   Ú	ParameterÚ	__class__Úweightr1   Úbiasr   )rw   rx   r4   ry   rN   rz   r{   r|   r}   Úsplitsr‘   Ú
new_moduleÚ	is_bufferÚ	old_valueÚparamÚ	param_clsÚdevice_quantizationÚ	new_valueÚkwargsÚdevice_indexs                       r+   Úset_module_tensor_to_devicer«   Ù   sL  € ðN ˆkÓØ×"Ñ" 3Ó'ˆØ˜C˜R“[ˆEÜ  Ó/ˆJØÑ!Ü  F 8Ð+=¸e¸WÀAÐ!FÓGÐGØŠFñ	 !ð
 ˜R‘jˆà×,Ñ,Ó,°ÇOÁOÓ1SÜ˜F˜8Ð#PÐQ\ÐP]Ð]^Ð_Ó`Ð`ØŸ™Ñ.€IÜ˜Ó,€Ið
 	ÑØÑ'Ø�N‰NÓ Ó/Ø e§n¡nÓ&6Ñ7Ó7à*9¿.¹.Ó:JÑ*KÈFÑ*Sˆ×Ñ˜;Ñ'ØàÑ#Ø×ÑÓ  OÓ3Ø i×&8Ñ&8Ó&:Ñ;Ó;à*9×:LÑ:LÓ:NÑ*OÐPVÑ*Wˆ×Ñ˜;Ñ'Øà×Ñœ5Ÿ<š<¨Ó/Ó/°FÀ6Ì5Ï<Ê<ÐX^ÓK_ÐB`Ó4`ÐejÑerÜ˜K˜=Ð(_Ð`fÐ_gÐghÐiÓjÐjà/:×>PÑ>PÓ/PˆF×Ñ˜{Ò+ÐVZ€EÜ�U“€IàÑð �?‰?˜eŸk™kÓ)¨i×.@Ñ.@ÀLÓ.PÜØ2°5·;±;°-¸uÀ[ÀMÐQdÐen×etÑetÐduð  vNð  Oóð ð ‰=à—H‘H˜YŸ_™_¸<�HÐH‰EÜ�U—[‘[Ó!×,Ñ,Ð-V×WÑWØ—H‘H˜U�HÐ>ˆEàÐÜ	�Š�ð ÑØ—‘×!Ñ!¨Ó8Ü—’˜VÓ$×)Ñ)¨_Ó<Ø×"Ñ"Ð&OÓOà"(ÐØˆFä�fœc×"Ñ"Ü×!Ñ!Ø ˜x˜‘Ü!×#Ñ#Ø ˜x˜‘Ü"×$Ñ$Ø   Ð)‘Ü"×$Ñ$Ø   Ð)‘Ü!×#Ñ#Ø�Ø”C˜“KÓÔ(8×(:Ñ(:Ü ˜xÐ']Ð^Ó_Ð_Ø‰=Ø!Ÿ™ V˜ÐGˆIØÑ  V°¼¿ºÀVÓ8LÐ/MÓ%MÜ˜9Ÿ?™?Ó+×6Ñ6Ð7`×aÑaØ )§¡¨U Ð N�Iæ Ù6?À	ÐYb×YpÑYpÑ6q�F×&Ñ& {Ñ3øÜ˜œuŸ|™|×,Ñ,ØŸ™ ˜ÐC‰IäŸš UÑ:ˆIØÑ*Ø(ˆFÞØ+4ˆF�O‰O˜KÓ(ØÑÔ&7¼¿ºÀVÓ8LÈf×N`ÑN`ÐalÑNm×NtÑNt×&uÒ&uÜ˜V×/Ñ/°Ñ<Ó=ˆIØ×'Ñ'¨Ñ4×=Ñ=ˆFØ×!Ñ!Ð%NÓNØ×%Ñ%¨Ó5¸)¿/¹/ÌUÏ]É]Ó:Zà )§¡¬U¯]©]È Ð V�Ià˜U“? y×'9Ñ'9¸\Ó'IÙ )¨)Ñ eÀ9×CZÑCZÐ eÐ^dÑ e× hÑ hÐijÓ k× nÑ nÐotÓ u�IØ#,§<¡<§?¡?°5Ó#9�I”LØ$-§M¡M×$4Ñ$4°UÓ$;�I•Má )¨)Ñ eÀ9×CZÑCZÐ eÐ^dÑ e× hÑ hØð !ið !‘Ið ×#Ñ#Ð'AÓAÜ!ŸH™H×.Ñ.¨yÈ	×H_ÑH_Ð.Ð`×cÑcØð dð ‘	ð ×#Ñ#Ð'@Ó@Ø%ŸL™L¨˜LÐK‘	á% i¸y×?VÑ?VÑW×ZÑZØð [ð �	ð /8ˆF×Ñ˜{Ñ+ØÑ*Ø6E×6HÑ6HÈÐ6HÐ6k�×"Ñ" ;Ñ/Ô3Ø#ð × Ñ ×)Ñ)¨^Ô;Ü˜FŸM™M¨5°$Ó7Ñ?Ü˜Ÿ™×,Ñ,Ó-°Ó7ô >C¿\º\È&Ó=Q×=VÑ=VÐZiÓ=iœuŸ|š|¨FÓ3×9Ò9Ðos�Ü˜vŸ}™}¨e°T×:Ñ:¸|Ñ?WØ—{‘{Ñ.°6·;±;×3EÑ3E×3JÑ3JÈfÓ3Tà!'§¡¨<Ó!8™ØŸ™Ñ,à!'§¡¨<Ó!8˜øà× Ñ ×)Ñ)¨\Ó9Ü˜FŸM™M¨=¸$Ó?ÑGÜ˜Ÿ™×,Ñ,Ó-°Ó7ô >C¿\º\È&Ó=Q×=VÑ=VÐZiÓ=iœuŸ|š|¨FÓ3×9Ò9Ðos�Ü˜vŸ}™}¨m¸T×BÑBÀ|ÑG_Ø$*§M¡M×$4Ñ$4°\Ó$B�F”M÷ 
öD �v _Ó4ÜÔð
 	Ñ#Ø×ÑÓ  OÓ3Ø¨)×*<Ñ*<Ó*>Ñ?Ó?à8Aˆ×*Ñ*Ó,Ñ-¨fÒ5àÑØÑ'Ø�N‰NÓ Ó/Ø¨%¯.©.Ó*:Ñ;Ó;à4=ˆŸ™Ó(Ñ)¨&Ò1ð <ð 0ð (ð 	÷] 
�ús   É7Xd7ä7
eÚinclude_buffersÚrecurseÚremove_non_persistentc              #   óÌ   #   • U R                  US9 Sh  v•N   U(       a@  [        5       nU(       a	  [        XS9nU R                  US9 H  nUu  pgXd;  d  M  Uv •  M     gg NL7f)a  
A helper function that gathers all the tensors (parameters + buffers) of a given module. If `include_buffers=True`
it's the same as doing `module.named_parameters(recurse=recurse) + module.named_buffers(recurse=recurse)`.

Args:
    module (`torch.nn.Module`):
        The module we want the tensors on.
    include_buffer (`bool`, *optional*, defaults to `True`):
        Whether or not to include the buffers in the result.
    recurse (`bool`, *optional`, defaults to `False`):
        Whether or not to go look in every submodule or just return the direct parameters and buffers.
    remove_non_persistent (`bool`, *optional*, defaults to `False`):
        Whether or not to remove the non persistent buffer from the buffers. Useful only when include_buffers =
        True
©r­   N)Únamed_parametersÚsetÚget_non_persistent_buffersÚnamed_buffers)rw   r¬   r­   r®   Únon_persistent_buffersÚnamed_bufferÚnameÚ_s           r+   Únamed_module_tensorsr¹   «  sm   é € ð$ ×&Ñ&¨wÐ&Ð7×7Ð7æÜ!$£ÐÞ Ü%?ÀÑ%XÐ"Ø"×0Ñ0¸Ð0ÓAˆLØ"‰GˆDØÕ1Ø"Ô"ò Bð	 ñ 8ùs   ‚A$•A"–>A$ÁA$Úfqnsc                 óÞ   • U R                   nU(       aT  U R                  5        H@  u  pEU(       a&  X5R                    Vs1 s H
  odS-   U-   iM     sn-  nM2  X5R                   -  nMB     U$ s  snf )aÈ  
Gather all non persistent buffers of a given modules into a set

Args:
    module (`nn.Module`):
        The module we want the non persistent buffers on.
    recurse (`bool`, *optional*, defaults to `False`):
        Whether or not to go look in every submodule or just return the direct non persistent buffers.
    fqns (`bool`, *optional*, defaults to `False`):
        Whether or not to return the fully-qualified names of the non persistent buffers.
rQ   )Ú_non_persistent_buffers_setÚnamed_modules)rw   r­   rº   Únon_persistent_buffers_setÚnÚmrA   s          r+   r³   r³   É  sn   € ð "(×!CÑ!CÐÞØ×(Ñ(Ö*‰DˆAÞØ*×DaÒDaÓ.bÒDa¸q°3©w¸¬{ÑDaÑ.bÑbÒ*à*×.KÑ.KÑKÒ*ñ	 +ð &Ð%ùò	 /cs   ¾A*r*   c                 ó†  • SnSnSnS[         R                  " U R                  5       Vs/ s H  oDR                  PM     sn;   aì  SnSn[	        U S5      (       a@  [	        U R
                  S5      (       a  U R
                  R                  SS9OU R
                  nUSL=(       a$    [        USS5      =(       a    U R                  5       n[	        U S5      =(       a5    [        U R
                  S	S5      =(       a    [        U R
                  S
S5      n[        S U R                  5        5       5      n[        XU/5      $ s  snf )zÓ
Check if there is any indication in the given model that some weights should be tied.

Args:
    model (`torch.nn.Module`): The model to inspect

Returns:
    bool: True if the model needs to have tied weights
FÚPreTrainedModelNÚconfigÚget_text_configT)ÚdecoderÚtie_word_embeddingsÚis_encoder_decoderÚtie_encoder_decoderc              3   ó:   #   • U  H  n[        US 5      v •  M     g7f)Ú_tie_weightsN)Úhasattr)Ú.0rw   s     r+   Ú	<genexpr>Ú2check_tied_parameters_in_config.<locals>.<genexpr>  s   é € Ð\ÊOÀ&œg f¨n×=Ð=ÊOùs   ‚)ÚinspectÚgetmrorž   r–   rË   rÃ   rÄ   r’   Úget_output_embeddingsÚanyÚmodules)r*   Úhas_tied_word_embeddingÚhas_tied_encoder_decoderÚhas_tied_moduleÚcÚmodel_decoder_configs         r+   Úcheck_tied_parameters_in_configrÙ   á  s.  € ð $ÐØ$ÐØ€Oà´·²ÀÇÁÔ1PÓQÒ1P¨AŸZœZÑ1PÑQÓQØ"'ÐØ#ÐÜ�5˜(×#Ñ#ô ˜5Ÿ<™<Ð):×;Ñ;ð —‘×,Ñ,°TÐ,Ñ:à—\‘\ð !ð !¨Ð,÷ .ÜÐ,Ð.CÀUÓK÷.à×+Ñ+Ó-ð 	 ô �E˜8Ó$÷ DÜ˜Ÿ™Ð&:¸EÓB÷Dä˜Ÿ™Ð&;¸UÓCð 	!ô
 Ñ\ÈEÏMÉMÌOÓ\Ó\ˆÜÐ'À?ÐSÓTÐTùò+ Rs   ªD>c                 ó˜   • X;   a  X   $ SR                  U R                  S5      S S 5      nX :X  a  [        SU  S35      e[        X!5      $ )NrQ   r:   z-The `device_map` does not contain the module )Újoinr‘   rI   Ú_get_param_device)r¥   Ú
device_mapÚparent_params      r+   rÜ   rÜ   	  sU   € ØÓØÑ Ð Ø—8‘8˜EŸK™K¨Ó,¨S¨bÐ1Ó2€LØÓÜÐHÈÈÈqÐQÓRÐRä  Ó:Ð:r-   c                 óÈ   • U  H\  n0 nU H  n[        XA5      X4'   M     [        [        UR                  5       5      5      S:”  d  MC  [        R                  SU S35        M^     g)a  
Check if tied parameters are on the same device

Args:
    tied_params (`List[List[str]]`):
        A list of lists of parameter names being all tied together.

    device_map (`Dict[str, Union[int, str, torch.device]]`):
        A map that specifies where each submodule should go.

r   z*Tied parameters are on different devices: zC. Please modify your custom device map or set `device_map='auto'`. N)rÜ   Úlenr²   ÚvaluesÚloggerÚwarning)Útied_paramsrÝ   Ú	tie_paramÚtie_param_devicesr¥   s        r+   Ú$check_tied_parameters_on_same_devicerç     sj   € ó !ˆ	ØÐÛˆEÜ'8¸Ó'KÐÓ$ñ äŒsÐ$×+Ñ+Ó-Ó.Ó/°!Õ3Ü�N‰NØ<Ð=NÐ<Oð PTð Töò !r-   c                 ó4  • U R                  SS9 VVs0 s H  u  p#X#_M	     nnnU R                  SS9 VVs0 s H  u  p#X#_M	     nnn[        UR                  5       5      [        UR                  5       5      -
  n0 nU HB  nXH   n	UR                  5        H'  u  p£X9L d  M  X§;  a  / Xz'   Xz   R	                  U5        M)     MD     UR                  5        VVs/ s H&  u  p¼[        U/[        [        U5      5      -   5      PM(     snn$ s  snnf s  snnf s  snnf )a�  
Find the tied parameters in a given model.

<Tip warning={true}>

The signature accepts keyword arguments, but they are for the recursive part of this function and you should ignore
them.

</Tip>

Args:
    model (`torch.nn.Module`): The model to inspect.

Returns:
    List[List[str]]: A list of lists of parameter names being all tied together.

Example:

```py
>>> from collections import OrderedDict
>>> import torch.nn as nn

>>> model = nn.Sequential(OrderedDict([("linear1", nn.Linear(4, 4)), ("linear2", nn.Linear(4, 4))]))
>>> model.linear2.weight = model.linear1.weight
>>> find_tied_parameters(model)
[['linear1.weight', 'linear2.weight']]
```
F)Úremove_duplicateT)r±   r²   ÚkeysÚitemsÚappendÚsortedÚlist)r*   r©   r·   r¥   Úall_named_parametersÚno_duplicate_named_parametersÚtied_param_namesÚtied_param_groupsÚtied_param_nameÚ
tied_paramÚ
param_namerŸ   Útieds                r+   Úfind_tied_parametersr÷   *  s+  € ð> <A×;QÑ;QÐchÐ;QÑ;iÔjÒ;i©K¨D˜DšKÑ;iÐÑjð EJ×DZÑDZÐlpÐDZÑDqÔ$rÒDq±[°T T¢[ÑDqÐ!Ñ$rô Ð/×4Ñ4Ó6Ó7¼#Ð>[×>`Ñ>`Ó>bÓ:cÑcÐð ÐÛ+ˆØ)Ñ:ˆ
Ø!>×!DÑ!DÖ!FÑˆJàÔ"ØÓ6Ø46Ð%Ñ1Ø!Ñ-×4Ñ4°_ÖEó "Gñ ,ð DU×CZÑCZÔC\Ô]ÒC\±<°6ŒF�F�8œd¤3 t£9›oÑ-Ö.ÑC\Ò]Ð]ùó+ kùó %sùó" ^s   “D¶DÃ-Dc                 ó„  • U Hº  nSnU Hh  nU nUR                  S5      nUSS  H  n[        XW5      nM     [        XVS   5      nUb  M@  UR                  [        R                  " S5      :w  d  Mf  Un  O   Uc  Mx  U H<  nU nUR                  S5      nUSS  H  n[        XW5      nM     [	        XVS   U5        M>     M¼     g)a<  
Reties tied parameters in a given model if the link was broken (for instance when adding hooks).

Args:
    model (`torch.nn.Module`):
        The model in which to retie parameters.
    tied_params (`List[List[str]]`):
        A mapping parameter name to tied parameter name as obtained by `find_tied_parameters`.
NrQ   r:   r   )r‘   r’   r4   r3   Úsetattr)	r*   rä   Ú
tied_groupÚparam_to_tierõ   rw   r¡   r‘   r¥   s	            r+   Úretie_parametersrü   a  sË   € ó "ˆ
Øˆã$ˆJØˆFØ×%Ñ% cÓ*ˆFØ  ›�Ü  Ó/’ñ %ä˜F¨2¡JÓ/ˆEØÓ#¨¯©¼¿ºÀVÓ8LÕ(LØ$�Ùñ %ð Ó#Û(�
Ø�Ø#×)Ñ)¨#Ó.�Ø# C R›[�EÜ$ VÓ3’Fñ )ä˜ r¡
¨LÖ9ó )ò "r-   c                 ót   • [        U [        5      (       a"  U R                  SS5      n [        [        U 5      n U $ )z,
Just does torch.dtype(dtype) if necessary.
útorch.Ú )r)   rZ   Úreplacer’   r3   ©rN   s    r+   Ú_get_proper_dtyper  €  s2   € ô �%œ×Ñà—‘˜h¨Ó+ˆÜœ˜uÓ%ˆØ€Lr-   Úspecial_dtypesÚbuffers_onlyc                 óº  • Ub  [        U5      n[        U5      nUb\  UR                  5        VVs0 s H  u  pVU[        U5      _M     nnnUR                  5        VVs0 s H  u  pVU[        U5      _M     nnn[        [        5      n/ n	U(       d  [        U SS9n	OU R                  SS9n	U	 GH  u  p«Ub  X¢;   a  UR                  5       WU
   -  nOªUc'  UR                  5       [        UR                  5      -  nO€[        UR                  5      R                  S5      (       a'  UR                  5       [        UR                  5      -  nO0UR                  5       [        W[        UR                  5      5      -  nU
R                  S5      n[        [        U5      S-   5       H"  nUSR                  USU 5      ==   U-  ss'   M$     GM      U$ s  snnf s  snnf )z6
Compute the size of each submodule of a given model.
NTr°   r�   rQ   r   )r  r^   rë   r   rE   r¹   r´   ÚnumelrN   rZ   r˜   Úminr‘   Úrangerà   rÛ   )r*   rN   r  r  Ú
dtype_sizeÚkeyÚdtypÚspecial_dtypes_sizeÚmodule_sizesÚmodule_listr·   r_   r8   Ú
name_partsÚidxs                  r+   Úcompute_module_sizesr  ‹  s¤  € ð ÑÜ! %Ó(ˆÜ$ UÓ+ˆ
ØÑ!ØHV×H\ÑH\ÔH^Ô_ÒH^¹9¸3˜#Ô0°Ó6Ò6ÑH^ˆÑ_ØKY×K_ÑK_ÔKaÔbÒKa¹i¸c˜s¤O°DÓ$9Ò9ÑKaÐÑbÜœsÓ#€Là€KæÜ*¨5¸$Ñ?‰à×)Ñ)°$Ð)Ð7ˆä#‰ˆØÑ%¨$Ó*@Ø—<‘<“>Ð$7¸Ñ$=Ñ=‰DØ‰]Ø—<‘<“>¤O°F·L±LÓ$AÑA‰DÜ�—‘Ó×)Ñ)Ð*S×TÑTð —<‘<“>¤O°F·L±LÓ$AÑA‰Dà—<‘<“>¤C¨
´OÀFÇLÁLÓ4QÓ$RÑRˆDØ—Z‘Z “_ˆ
Üœ˜Z›¨1Ñ,Ö-ˆCØ˜Ÿ™ *¨T¨cÐ"2Ó3Ó4¸Ñ<Õ4ô .ñ $ð Ðùó5 `ùÛbs   °GÁGc                 ó<   • [        XUSS9nUR                  SS5      $ )zG
Compute the total size of buffers in each submodule of a given model.
T)rN   r  r  rÿ   r   )r  Úget)r*   rN   r  r  s       r+   Ú compute_module_total_buffer_sizer  µ  s&   € ô (¨È>ÐhlÑm€LØ×Ñ˜B Ó"Ð"r-   rÓ   r  Úno_split_module_classesc                 ó
  • Sn/ nU R                  5       n[        U5      S:”  aØ  UR                  S5      u  pg[        U[        R
                  R                  5      (       a  [        UR                  5       5      O/ n[        U5      S:X  d  UR                  R                  U;   a&  X   n	X“:”  a  U	nU/nO8X“:X  a  UR                  U5        O!U V
Vs/ s H  u  p«U SU
 3U4PM     snn
U-   n[        U5      S:”  a  MØ  X44$ s  snn
f )a  
Utility function that will scan a list of named modules and return the maximum size used by one full layer. The
definition of a layer being:
- a module with no direct children (just parameters and buffers)
- a module whose class name is in the list `no_split_module_classes`

Args:
    modules (`List[Tuple[str, torch.nn.Module]]`):
        The list of named modules where we want to determine the maximum layer size.
    module_sizes (`Dict[str, int]`):
        A dictionary mapping each layer name to its size (as generated by `compute_module_sizes`).
    no_split_module_classes (`List[str]`):
        A list of class names for layers we don't want to be split.

Returns:
    `Tuple[int, List[str]]`: The maximum size of a layer with the list of layer names realizing that maximum size.
r   rQ   )Úcopyrà   Úpopr)   r3   r   ÚModulerî   Únamed_childrenrž   r–   rì   )rÓ   r  r  Úmax_sizeÚlayer_namesÚmodules_to_treatÚmodule_namerw   Úmodules_childrenr8   r¿   Úvs               r+   Úget_max_layer_sizer!  Á  s  € ð( €HØ€KØ—|‘|“~ÐÜ
ÐÓ
 !Ó
#Ø.×2Ñ2°1Ó5ÑˆÜ<FÀvÌuÏxÉxÏÉ×<_Ñ<_œ4 × 5Ñ 5Ó 7Ô8ÐegÐÜÐÓ  AÓ%¨×)9Ñ)9×)BÑ)BÐF]Ó)]àÑ,ˆDØ‹Ø�Ø*˜m‘ØÓ!Ø×"Ñ" ;Ô/øáFVÔWÒFV¹d¸a K =°°!°Ð!5°qÓ 9ÑFVÒWÐZjÑjÐô ÐÓ
 !Õ
#ð Ð Ð ùó  Xs   ÃC?Ú
max_memoryc                 óR  • SSK nU Gc
  0 n [        5       (       a  [        [        R                  R                  5       5       HR  n [        R                  " S[        R                  " SU5      S9n[        R                  R                  U5      S   X'   MT     GO-[        5       (       a  [        [        R                  R                  5       5       HR  n [        R                  " S[        R                  " SU5      S9n[        R                  R                  U5      S   X'   MT     GOŸ[        5       (       a  [        [        R                  R                  5       5       HR  n [        R                  " S[        R                  " SU5      S9n[        R                  R                  U5      S   X'   MT     GO[!        5       (       a  [        [        R"                  R                  5       5       HR  n [        R                  " S[        R                  " S	U5      S9n[        R"                  R                  U5      S   X'   MT     GOƒ[%        5       (       a~  [        [        R&                  R                  5       5       HR  n [        R                  " S[        R                  " S
U5      S9n[        R&                  R                  U5      S   X'   MT     Oö[)        5       (       a~  [        [        R*                  R                  5       5       HR  n [        R                  " S[        R                  " SU5      S9n[        R*                  R                  U5      S   X'   MT     Oi[        [        R,                  R                  5       5       H>  n [        R                  " S/US9n[        R,                  R                  U5      S   X'   M@     [/        5       (       a  UR1                  5       R2                  U S'   U $ UR1                  5       R2                  U S'   U $ U  H+  n[5        X   [6        5      (       d  M  [9        X   5      X'   M-     U R;                  5        Vs/ s H  n[5        U[<        5      (       d  M  UPM     nnUR?                  5         [        5       (       a   [        R                  R                  5       nGO[        5       (       a  [        R                  R                  5       nOÖ[        5       (       a  [        R                  R                  5       nO¨[!        5       (       a  [        R"                  R                  5       nOz[%        5       (       a  [        R&                  R                  5       nOL[)        5       (       a  [        R*                  R                  5       nO[        R,                  R                  5       nU H=  nX‡:¼  d  US:  d  M  [        RA                  SU S[C        [        U5      5       35        M?     US Vs/ s H  oUU R;                  5       ;   d  M  UPM     sn-   n	U R;                  5        H  nXY;  d  M
  [E        SU S35      e   U	 Vs0 s H  oUX   _M	     n nU $ ! [         a    [        R                  SU S35         GMS  f = f! [         a    [        R                  SU S35         GMð  f = f! [         a    [        R                  SU S35         GM�  f = f! [         a    [        R                  SU S35         GM*  f = f! [         a    [        R                  SU S35         GMÇ  f = f! [         a    [        R                  SU S35         GMe  f = f! [         a    [        R                  SU S35         GM  f = fs  snf s  snf s  snf )zZ
Get the maximum memory available if nothing is passed, converts string to int otherwise.
r   NÚnpur‰   zDevice z; seems unavailable, Proceeding to check subsequent devices.ÚmluÚsdaaÚmusarƒ   r‡   Úmpsr/   z) is not available, available devices are )r(  r/   ÚdiskzX is not recognized, available devices are integers(for GPU/XPU), 'mps', 'cpu' and 'disk')#Úpsutilr   r  r3   r$  Údevice_countr_   r4   Úmem_get_inforo   râ   Úinfor   r%  r   r&  r   r'  r   rƒ   r   r‡   r‚   r   Úvirtual_memoryÚ	availabler)   rZ   rM   rê   rE   Úsortrã   rî   rI   )
r"  r*  Úir¸   r
  ÚkÚgpu_devicesÚnum_devicesr4   Úall_devicess
             r+   Úget_max_memoryr6  è  só  € ó àÒØˆ
ä×ÑÜœ5Ÿ9™9×1Ñ1Ó3Ö4�ðÜŸš Q¬u¯|ª|¸EÀ1Ó/EÑF�AÜ$)§I¡I×$:Ñ$:¸1Ó$=¸aÑ$@�J“Mó 5ô ×ÑÜœ5Ÿ9™9×1Ñ1Ó3Ö4�ðÜŸš Q¬u¯|ª|¸EÀ1Ó/EÑF�AÜ$)§I¡I×$:Ñ$:¸1Ó$=¸aÑ$@�J“Mó 5ô × Ñ Üœ5Ÿ:™:×2Ñ2Ó4Ö5�ðÜŸš Q¬u¯|ª|¸FÀAÓ/FÑG�AÜ$)§J¡J×$;Ñ$;¸AÓ$>¸qÑ$A�J“Mó 6ô × Ñ Üœ5Ÿ:™:×2Ñ2Ó4Ö5�ðÜŸš Q¬u¯|ª|¸FÀAÓ/FÑG�AÜ$)§J¡J×$;Ñ$;¸AÓ$>¸qÑ$A�J“Mó 6ô ×ÑÜœ5Ÿ9™9×1Ñ1Ó3Ö4�ðÜŸš Q¬u¯|ª|¸EÀ1Ó/EÑF�AÜ$)§I¡I×$:Ñ$:¸1Ó$=¸aÑ$@�J“Mò 5ô ×ÑÜœ5Ÿ9™9×1Ñ1Ó3Ö4�ðÜŸš Q¬u¯|ª|¸EÀ1Ó/EÑF�AÜ$)§I¡I×$:Ñ$:¸1Ó$=¸aÑ$@�J“Mò 5ô œ5Ÿ:™:×2Ñ2Ó4Ö5�ðÜŸš a S°Ñ3�AÜ$)§J¡J×$;Ñ$;¸AÓ$>¸qÑ$A�J“Mñ 6ô ×ÑØ &× 5Ñ 5Ó 7× AÑ AˆJ�uÑð Ðð !'× 5Ñ 5Ó 7× AÑ AˆJ�uÑØÐãˆÜ�j‘o¤s×+Ó+Ü6°z±ÓGˆJ‹Oñ ð )Ÿo™oÔ/ÓFÒ/˜´:¸aÄ×3E—1Ñ/€KÐFØ×ÑÔä×ÑÜ—i‘i×,Ñ,Ó.ŠÜ	×	Ñ	Ü—i‘i×,Ñ,Ó.‰Ü	×	Ñ	Ü—j‘j×-Ñ-Ó/‰Ü	×	Ñ	Ü—j‘j×-Ñ-Ó/‰Ü	×	Ñ	Ü—i‘i×,Ñ,Ó.‰Ü	×	Ñ	Ü—i‘i×,Ñ,Ó.‰ä—j‘j×-Ñ-Ó/ˆÛˆØÓ  F¨Q¥JÜ�N‰N˜W V HÐ,UÔVZÔ[`ÐalÓ[mÓVnÐUoÐpÖqñ ð Ñ,BÓ ]Ò,B qÈ:Ï?É?ÓK\ÑF\§Ñ,BÑ ]Ñ]€Kà�_‰_ÖˆØÕÜØ˜!˜ÐtÐuóð ñ ñ
 -8Ó8ªK q�Z‘]Ò"©K€JÐ8àÐøô} !ó Ü—K‘K '¨!¨Ð,gÐ hÔiÛðûô !ó Ü—K‘K '¨!¨Ð,gÐ hÔiÛðûô !ó Ü—K‘K '¨!¨Ð,gÐ hÔiÛðûô !ó Ü—K‘K '¨!¨Ð,gÐ hÔiÛðûô !ó Ü—K‘K '¨!¨Ð,gÐ hÔiÛðûô !ó Ü—K‘K '¨!¨Ð,gÐ hÔiÛðûô !ó Ü—K‘K '¨!¨Ð,gÐ hÔiÛðüò  Gùò* !^ùò 9s¢   ÁAY-ÃAZÅ!A[Ç/A[.É=A\Ì
A]Î:]/Ñ^Ñ3^Ø^Ø!^Ù^$Ù-#ZÚZÚ#[ Ú?[ Û#[+Û*[+Û.#\Ü\Ü#]Ý ]Ý#],Ý+],Ý/#^Þ^rÝ   r  c                 óÈ  ^• US:X  a  SOU S3nU R                  5        VVs/ s H  u  p4UR                  U5      (       d  M  UPM!     nnn[        [        U5      5      S:X  aI  [        U5      S:”  a:  U  Vs/ s H  o3R                  U5      (       d  M  UPM     sn H  nX	 M     US   X'   U R	                  5        Vs/ s H6  o3R                  U5      (       d  M  [        U5      [        U5      :”  d  M4  UPM8     nn[        U5      S:”  a  [        UR                  S5      5      S-   OSm[        U4S jU 5       5      nU H  n[        XS9  M     U $ s  snnf s  snf s  snf )zU
Cleans a device_map by grouping all submodules that go on the same device together.
rÿ   rQ   r   r   c              3   ój   >#   • U  H(  nS R                  UR                  S 5      ST 5      v •  M*     g7f©rQ   N)rÛ   r‘   )rÌ   r2  r  s     €r+   rÍ   Ú#clean_device_map.<locals>.<genexpr>f  s.   øé € ÐRÒAQ¸A˜3Ÿ8™8 A§G¡G¨C£L°°#Ð$6×7Ð7ÒAQùs   ƒ03)r  )rë   r˜   rà   r²   rê   r‘   Úclean_device_map)	rÝ   r  Úprefixr2  r   rá   Úchildren_modulesÚchildr  s	           @r+   r;  r;  W  s8  ø€ ð
  "Ó$‰R¨[¨M¸Ð*;€FØ&×,Ñ,Ô.ÔGÒ.‘D�A°!·,±,¸v×2F�aÑ.€FÑGÜ
Œ3ˆv‹;Ó˜1Ó¤ V£¨q£Ù'Ó@šZ˜¯<©<¸×+?—!™ZÔ@ˆAØ’ñ Aà"(¨¡)ˆ
Ñð $.§?¡?Ô#4ÓkÒ#4˜a¿¹ÀV×8L›ÔQTÐUVÓQWÔZ]Ð^iÓZjÑQjŸÑ#4ÐÐkÜ-0°Ó-=ÀÓ-AŒ#ˆk×Ñ Ó$Ó
%¨Ò
)Àq€CÜÔRÑAQÓRÓRÐÛ!ˆÜ˜Ô7ñ "ð Ðùó Hùâ@ùò
 ls)   ¢EÁEÁ6EÂEÂ>EÃEÃ5Ec           	      ó´  • Ub  [        U5      S:X  a  gUR                  5        H±  u  p4SU;   a  M  SnSU;   ad  UR                  SS5      UR                  5       ;   a@  UR                  SS5      n[	        [
        R                  R                  X& S35      X   5      n[
        R                  R                  X# S35      n[	        Xt5      n[        XSX…S9  M³     g)az  
Loads the weights from the offload folder into the model.

Args:
    model (`torch.nn.Module`):
        The model to load the weights into.
    index (`dict`):
        A dictionary containing the parameter name and its metadata for each parameter that was offloaded from the
        model.
    offload_folder (`str`):
        The folder where the offloaded weights are stored.
Nr   rŽ   rŸ   z.datr/   )ry   rz   )	rà   rë   r   rê   r   ÚosÚpathrÛ   r«   )	r*   r1   Úoffload_folderrõ   Úmetadatarz   Úweight_nameÚtensor_filerŸ   s	            r+   Úload_offloaded_weightsrF  m  sÄ   € ð �}œ˜E›
 a›àØ %§¡¦Ñˆ
Ø�JÓÙØˆØ�zÓ! j×&8Ñ&8¸À5Ó&IÈUÏZÉZË\Ó&YØ$×,Ñ,¨X°uÓ=ˆKÜ3Ü—‘—‘˜^¨}¸DÐ-AÓBÀEÑDVóˆOô —g‘g—l‘l >°\ÀÐ3FÓGˆÜ& {Ó=ˆÜ# E°uÀFÔlò !.r-   c                 óü   • 0 nU  H=  nUS:X  d  SU;  a  M  UR                  SS5      S   nUR                  US5      S-   X'   M?     U  Vs/ s H$  o!R                  US5      S:X  d  M  US:w  d  M"  UPM&     nnU$ s  snf )Nrÿ   rQ   r   r   )Úrsplitr  )r  Úmodule_childrenrw   ÚparentÚleavess        r+   Úget_module_leavesrL  ‹  s�   € Ø€OÛˆØ�R‹<˜3 fÓ,ÙØ—‘˜s AÓ& qÑ)ˆØ"1×"5Ñ"5°f¸aÓ"@À1Ñ"DˆÓñ	 ñ
 $0Óh¢<˜×3FÑ3FÀvÈqÓ3QÐUVÑ3V‹fÐ[aÐegÑ[g�f¡<€FÐhØ€Mùò is   Á
A9Á'A9Á/A9Úlow_zeroc                 óŽ  • USL n[        U5      n[        5       (       a  SnOn[        5       (       a  SnO\[        5       (       a  SnOJ[	        5       (       a  SnO8[        5       (       a  SnO&[        5       (       a  SnO[        5       (       a  SnOS	n[        U Vs/ s H5  n[        R                  " U5      R                  U:X  d  M)  X   S
:”  d  M3  UPM7     sn5      n	U	S
:X  a  U$ U	S:X  a\  SnU(       aS  UR                  5        H?  n
[        U
[        5      (       d  M  X==   S-  ss'   [        R!                  SU
 S35          O   [#        XUS9nUS   U(       a  U	S-
  OU	-  nUc  / nO[        U[$        [&        45      (       d  U/n[        U5      S
:”  aÂ  0 nUR)                  5        H�  u  pïUS:X  a  M  U nUR+                  S5       H  n[-        UU5      nM     UR.                  R0                  nUU;   a
  UU;  a  XýU'   [3        UR                  5       5      [3        U5      :X  d  M�    O   [        U5      S
:”  a  [5        UR7                  5       5      OS
nOS
n[9        U5      n[3        U5      nUR)                  5        VVs0 s H  u  nnUU;  d  M  UU_M     nnn[9        U5      n[        [;        U Vs/ s H  nUU   PM
     sn5      [5        [        U5      S5      -  5      n[        S[5        UU5      -  5      nUU-  n[%        [=        S UR)                  5        5       5      5      nUSS  H'  n[?        U(       a  US
:X  a  US
   OUUU   5      UU'   M)     U(       aK  [5        S
US   [;        [A        SU	5       Vs/ s H  nUU   PM
     sn5      -
  5      n[?        UUS
   5      US
'   U$ s  snf s  snnf s  snf s  snf )a$  
Compute a `max_memory` dictionary for [`infer_auto_device_map`] that will balance the use of each available GPU.

<Tip>

All computation is done analyzing sizes and dtypes of the model parameters. As a result, the model can be on the
meta device (as it would if initialized within the `init_empty_weights` context manager).

</Tip>

Args:
    model (`torch.nn.Module`):
        The model to analyze.
    max_memory (`Dict`, *optional*):
        A dictionary device identifier to maximum memory. Will default to the maximum memory available if unset.
        Example: `max_memory={0: "1GB"}`.
    no_split_module_classes (`List[str]`, *optional*):
        A list of layer class names that should never be split across device (for instance any layer that has a
        residual connection).
    dtype (`str` or `torch.dtype`, *optional*):
        If provided, the weights will be converted to that type when loaded.
    special_dtypes (`Dict[str, Union[str, torch.device]]`, *optional*):
        If provided, special dtypes to consider for some specific weights (will override dtype used as default for
        all weights).
    low_zero (`bool`, *optional*):
        Minimizes the number of weights on GPU 0, which is convenient when it's used for other operations (like the
        Transformers generate function).
Nr$  r%  r&  r'  rƒ   r‡   r(  r‚   r   r   FgÍÌÌÌÌÌì?z(We will use 90% of the memory on device z‘ for storing the model, and 10% for the buffer to avoid OOM. You can set `max_memory` in to a higher value to use more memory (at your own risk).©rN   r  rÿ   rQ   g      ô?c              3   óh   #   • U  H(  u  p[        U[        5      (       d  M  US :”  d  M$  Uv •  M*     g7f)r   N)r)   rE   )rÌ   Ú	device_idÚ
device_mems      r+   rÍ   Ú&get_balanced_memory.<locals>.<genexpr>  s/   é € ð 
Ú3EÑ/˜)ÌÐT]Ô_b×Ic‹IÐhrÐuvÑhv�I‰IÒ3Eùs   ‚2¡2©	2r:   )!r6  r   r   r   r   r   r   r   rà   r3   r4   r2   rê   r)   rE   râ   r-  r  rî   Útuplerë   r‘   r’   rž   r–   r²   Úmaxrá   rL  Úsumrí   r  r  )r*   r"  r  rN   r  rM  Úuser_not_set_max_memoryÚexpected_device_typeÚdr4  r
  r  Úper_gpuÚno_split_childrenr·   r8   Ú	submoduleÚsubmodule_nameÚ
class_nameÚbufferrK  Ú
leaves_setr¿   r   Úmean_leavesÚgpus_idx_listr  r1  Úmin_zeros                                r+   Úget_balanced_memoryrd  –  sÂ  € ðJ )¨DÐ0ÐÜ 
Ó+€Jä×ÑØ$ÑÜ	×	Ñ	Ø$ÑÜ	×	Ñ	Ø%ÑÜ	×	Ñ	Ø%ÑÜ	×	Ñ	Ø$ÑÜ	×	Ñ	Ø$ÑÜ	×	Ñ	Ø$Ñà%ÐÜ¡*Ós¢*˜Q´·²¸Q³×0DÑ0DÐH\Ñ0\“qÐakÑanÐqrÑar—q¡*ÑsÓt€Kà�aÓØÐà�aÓàˆæ"Ø!—‘Ö(�Ü˜c¤3×'Ó'Ø“O sÑ*“OÜ—K‘KØBÀ3À%ð Hoð oôñ ñ )ô (¨È>ÑZ€LØ˜2Ñ¶h ;°¢?ÀKÑP€Gð Ñ&Ø"$ÑÜÐ/´$¼°×?Ñ?Ø#:Ð";Ðô Ð"Ó# aÓ'ØÐØ&×,Ñ,Ö.‰JˆDØ�r‹zÙØˆIØ"&§*¡*¨S¦/�Ü# I¨~Ó>’	ñ #2à"×,Ñ,×5Ñ5ˆJØÐ4Ó4¸ÐK\Ó9\Ø04 *Ñ-äÐ$×)Ñ)Ó+Ó,´Ð4KÓ0LÕLÙñ /ô 58Ð8IÓ4JÈQÓ4N”Ð&×-Ñ-Ó/Ô0ÐTU‰àˆô ˜|Ó,€FÜ�V“€JØ%1×%7Ñ%7Ô%9ÔQÒ%9™T˜Q ¸QÀjÑ=P“D�A�q’DÑ%9€LÑQä˜|Ó,€FÜ”c±FÓ;²F¨q˜<¨œ?±FÑ;Ó<¼sÄ3ÀvÃ;ÐPQÓ?RÑRÓS€KÜ�œ˜F KÓ0Ñ0Ó1€FØˆvÑ€Gô Üñ 
Ø3=×3CÑ3CÔ3Eó
ó 	
ó€Mð ˜S˜bÓ!ˆÜ®x¸CÀ1»H˜j¨šmÈ'ÐS]Ð^aÑSbÓcˆ
�3‹ñ "ö Ü�q˜, rÑ*¬SÌÈqÐR]ÔI^Ó1_ÒI^ÀA°*¸Q´-ÑI^Ñ1_Ó-`Ñ`ÓaˆÜ˜H j°¡mÓ4ˆ
�1‰àÐùòW tùól Rùò <ùò 2`s*   Â(N2ÃN2ÃN2ÊN7ÊN7Ê8N=ÎOc                 óú   • [        U 5      n[        U SS5      nUc  / n[        U R                  SS95      [        U R	                  5       5      -   [        U R                  SS95      -   n[        X1U5      nUS   nXT4$ )z:Computes the total size of the model and its largest layerÚ_no_split_modulesNFr°   rÿ   )r  r’   rî   r±   r  r´   r!  )r*   ÚsizesÚno_split_modulesr  Úlargest_layerÚ
total_sizes         r+   Úcalculate_maximum_sizesrk    s˜   € ä  Ó'€Eä˜uÐ&9¸4Ó@ÐØÑØÐô 	ˆU×#Ñ#¨EÐ#Ð2Ó3Ü
ˆu×#Ñ#Ó%Ó
&ñ	'ä
ˆu×"Ñ"¨5Ð"Ð1Ó
2ñ	3ð ô
 'Ð'7Ð@PÓQ€MØ�r‘€JØÐ$Ð$r-   c                 ó€  • [        U5      nUc  / nO[        U[        [        45      (       d  U/n[        UR	                  5       5      nSU;  a  UR                  S5        U Vs/ s H  ofS;  d  M
  UPM     nnSU;   a  S/nO[        U5      S:”  a  US   S/nOS/n[        XUS9n	[        U 5      n
[        U 5      (       a$  [        U
5      S:X  a  [        R                  S5        [        U R                  SS	95      [        U R                  5       5      -   [        U R                  SS	95      -   nUUUUU	U
UU4$ s  snf )
zR
Initialize variables required for computing the device map for model allocation.
r)  )r/   r)  r(  r   r/   rO  úrThe model weights are not tied. Please use the `tie_weights` method before using the `infer_auto_device` function.Fr°   )r6  r)   rî   rT  rê   rì   rà   r  r÷   rÙ   râ   rã   r±   r  r´   )r*   r"  r  rN   r  Údevicesr4   ÚgpusÚmain_devicesr  Útied_parametersr  s               r+   Ú_init_infer_auto_device_maprr  .  sZ  € ô&   
Ó+€JØÑ&Ø"$ÑÜÐ/´$¼°×?Ñ?Ø#:Ð";Ðä�:—?‘?Ó$Ó%€GØ�WÓØ�‰�vÔÙ!(ÓJ¢�v¸/Ñ,I�F¡€DÐJð �ƒ}Ø�w‰Ü	ˆT‹�Q‹Ø˜Q™ Ð'‰à�wˆä'¨È>ÑZ€LÜ*¨5Ó1€OÜ& u×-Ñ-´#°oÓ2FÈ!Ó2KÜ�‰ð Aô	
ô 	ˆU×#Ñ#¨EÐ#Ð2Ó3Ü
ˆu×#Ñ#Ó%Ó
&ñ	'ä
ˆu×"Ñ"¨5Ð"Ð1Ó
2ñ	3ð ð 	ØØØØØØØð	ð 	ùò1 Ks   Á$	D;Á1D;c           
      ó|  • [        U 5      S:  a  U/ / 4$ / n/ nU  Hr  n[        U5       VVV	s/ s H%  u  nu  p‰UR                  US-   5      (       d  M#  UPM'     sn	nnS   n
UR                  X:   S   5        UR                  X:   S   5        Mt     Un[	        X5       H  u  plX²U   X&   -
  -  nM     X´U4$ s  sn	nnf )a  
Calculate the total size of a module, including its tied parameters.

Args:
    tied_params (`List[str]`): The list of tied parameters.
    module_size (`int`): The size of the module without tied parameters.
    module_sizes (`Dict[str, int]`): A dictionary mapping each layer name to its size.
    modules_to_treat (`List[Tuple[str, nn.Module]]`): The list of named modules to treat.

Returns:
    `Tuple[int, List[str], List[nn.Module]]`: The total size of the module, the names of the tied modules, and the
    tied modules.
r   rQ   r   )rà   Ú	enumerater˜   rì   Úzip)rä   Úmodule_sizer  r  Útied_module_namesÚtied_modulesrô   r1  r¿   r¸   Útied_module_indexÚmodule_size_with_tiesÚtied_module_names                r+   Úget_module_size_with_tiesr|  n  sã   € ô& ˆ;Ó˜!ÓØ˜B Ð"Ð"ØÐØ€Lã!ˆ
Ü09Ð:JÔ0KÕnÒ0K¡9 1¡f qÈz×OdÑOdÐefÐilÑel×OmŸQÑ0KÓnÐopÑqÐØ× Ñ Ð!1Ñ!DÀQÑ!GÔHØ×ÑÐ,Ñ?ÀÑBÖCñ "ð
 (ÐÜ(+¨KÖ(KÑ$ˆ
ØÐ.>Ñ!?À,ÑBZÑ!ZÑZÒñ )Lð !°\ÐAÐAùô os   ­"B7
ÁB7
Ú
size_limitrq  c                 ó  ^•  [        U5      nUc  / nUc  / nU R                  5       nSnU(       Ga‚  UR                  S5      u  mnU Vs/ s H=  n[	        U4S jU 5       5      (       d  M  [        U4S jU 5       5      (       a  M;  UPM?     n	n[        U	 VV
s/ s H#  oˆ V
s/ s H  n
TS-   U
S-   ;  d  M  U
PM     sn
PM%     sn
n/ 5      n[        X±T   X5      u  n  nXÂ::  a  SnOÌ[        U[        R                  5      (       d  [        U[        R                  5      (       a  / O[        UR                  5       5      n[        U5      S:X  d  UR                   R"                  U;   a  GMC  [        UR%                  SS95      U-   nU VVs/ s H  u  nnT SU 3U4PM     snnU-   nU(       a  GM‚  U(       d  SSU 4$ U  VVs/ s H  u  pýUPM	     nnn['        T5       VVs/ s H  u  nnUS:X  d  M  UPM     nnnU HŸ  nTSU nUU;   d  M  UR)                  U5      nU U   u  nn[        UR%                  SS95      [        UR                  5       5      -   nU SU U VVs/ s H  u  nnU SU 3U4PM     snn-   U US	-   S -   n U  VVs/ s H  u  pýUPM	     nnnM¡     UR)                  T5      nU R                  U5      u  mnTXp4$ ! [         a    SSU 4s $ f = fs  snf s  sn
f s  sn
nf s  snnf s  snnf s  snnf s  snnf s  snnf )
a¹  
Find a module that fits in the size limit using BFS and return it with its name and the remaining modules.

Args:
    modules (`List[Tuple[str, nn.Module]]`):
        The list of named modules to search in.
    module_sizes (`Dict[str, int]`):
        A dictionary mapping each layer name to its size (as generated by `compute_module_sizes`).
    size_limit (`Union[int, str]`):
        The maximum size a module can have.
    no_split_module_classes (`Optional[List[str]]`, *optional*):
        A list of class names for layers we don't want to be split.
    tied_parameters (`Optional[List[List[str]]`, *optional*):
        A list of lists of parameter names being all tied together.

Returns:
    `Tuple[Optional[str], Optional[nn.Module], List[Tuple[str, nn.Module]]]`: A tuple containing:
    - The name of the module that fits within the size limit.
    - The module itself.
    - The list of remaining modules after the found module is removed.
NFr   c              3   ó:   >#   • U  H  nTS -   US -   ;   v •  M     g7fr9  © ©rÌ   r2  r·   s     €r+   rÍ   Ú$fallback_allocate.<locals>.<genexpr>Â  ó   øé € Ð=²*¨Q�4˜#‘:  S¡Ö(²*ùó   ƒc              3   ó:   >#   • U  H  nTS -   US -   ;   v •  M     g7fr9  r€  r�  s     €r+   rÍ   r‚  Â  ó%   øé € ÐItÒisÐdeÈ$ÐQTÉ*ÐXYÐ\_ÑX_ÖJ_Òisùr„  rQ   Tr°   r   )rM   rI   r  r  rÒ   ÚallrV  r|  r)   r   r�   r3   rš   rî   r  rà   rž   r–   r±   rt  r1   )rÓ   r  r}  r  rq  Úmodules_to_searchÚmodule_foundrw   rú   rò   Úprä   rz  r¸   r  r¿   r   Úcurrent_namesr1  r×   Údot_idxÚ	dot_indexÚparent_nameÚparent_module_idxÚparent_modulerI  Ú
target_idxr·   s                              @r+   Úfallback_allocater’  ’  sg  ø€ ð8#Ü-¨jÓ9ˆ
ð Ñ&Ø"$ÐàÑØˆàŸ™›ÐØ€Lç
Ø(×,Ñ,¨QÓ/‰ˆˆfñ .ó
â-�
ÜÔ=±*Ó=×=ó äFIÔItÑisÓIt×Ft÷ Ù-ð 	ð 
ô ÙTeÔfÒTeÀj˜ÓAš�A t¨c¡z¸¸S¹Ñ'@�a™ÔAÑTeÒfÐhjó
ˆô '@Ø dÑ+¨\ó'
Ñ#Ð˜q !ð
 !Ó.ØˆLØô
 ˜&¤"§,¡,×/Ñ/´:¸fÄeÇlÁl×3SÑ3Sñ ä�f×+Ñ+Ó-Ó.ð 	ô ÐÓ  AÓ%¨×)9Ñ)9×)BÑ)BÐF]Ó)]Úô   × 7Ñ 7ÀÐ 7Ð FÓGÐJZÑZÐÙ<LÔMÒ<L±D°A°q   a¨ s˜m¨QÓ/Ñ<LÒMÐPaÑaÐ÷G Ñ
öJ Ø�T˜7Ð"Ð"ñ $+Ô+¢7™4˜1“Q¡7€MÑ+Ü& tœ_Ô9š_‘T�Q˜°°S±�q™_€GÑ9ãˆ	Ø˜:˜IÐ&ˆØ˜-Õ'Ø -× 3Ñ 3°KÓ @ÐØ&Ð'8Ñ9ÑˆAˆ}Ü" =×#AÑ#AÈ%Ð#AÐ#PÓQÔTXØ×,Ñ,Ó.óUñ ˆOð Ð*Ð*Ð+Ù9HÔIº±°°A�{�m 1 Q CÐ(¨!Ó,¹ÒIñJàÐ+¨aÑ/Ð1Ð2ñ3ð ñ
 ,3Ô3ª7¡4 1›Q©7ˆMÑ3‰Mñ ð  ×$Ñ$ TÓ*€JØ—;‘;˜zÓ*�L€Dˆ&à�Ð Ð øôW ó #Ø�T˜7Ð"Ò"ð#üò
ùò BùÓfùó2 Nùó ,ùÛ9ùó Jùó 4se   ƒK Á
K!Á,K!ÂK!Â	K+
Â#K&Â7K&Â=K+
ÆK1ÇK7Ç$K=Ç5K=É$L
ÊL	ËKËKË&K+
ÚverboseÚclean_resultÚoffload_buffersÚfallback_allocationc	                 óÔ  ^8^9• [        XX#U5      u  n	nn
nnnnn[        5       nSnU	 Vs0 s H  nUS_M     nn0 n0 n[        XìU5      u  nn[        U5      S:”  Ga‰  UR	                  S5      u  m8nU(       a  [        ST8 S35        U Vs/ s H(  nUT8:w  d  M  UR                  T8S-   5      (       a  M&  UPM*     nn[        U5      S:X  aS  [        U VVs/ s H5  u  nn[        U[        R                  R                  5      (       d  M1  UU4PM7     snnUU5      u  nnUT8   nU Vs/ s H=  n[        U84S jU 5       5      (       d  M  [        U84S jU 5       5      (       a  M;  UPM?     nnU(       a  [        U5      S:”  a  [        SU 35        [        U VVs/ s H$  nU Vs/ s H  nT8S-   US-   ;  d  M  UPM     snPM&     snn/ 5      nU(       a  [        U5      S:”  a  [        SU 35        U	U   nUS:w  a  UU   OS	nSn U	U   U
;   a  UU-
  nUn [        UUXÎ5      u  n!n"n#Ub  UU   U!-   U::  aÿ  U(       aD  S
T8 3n$U"(       a	  U$SU" 3-  n$O	U$SU S3-  n$Ub  U$SUUU   -
   S3-  n$U$SU S3-  n$[        U$5        UU==   U!-  ss'   UUT8'   U" HQ  m9T9U Vs/ s H  nUS   PM
     sn;   a/  [        U94S j[!        U5       5       5      n%UR	                  U%5        UUT9'   MS     U(       dA  [        U[        R                  5      (       a"  [#        UX4S9n&UR%                  US5      U&-   UU'   GMé  [        U5      S:”  Ga�  UU   U-   U::  Ga�  U(       a$  [        SU	U    ST8 SU" SUUU   -
   SU! S35        Sn'['        U"U#5       GH6  u  m9n([)        U(R+                  5       5      n)[        U)5      S:X  d  U(R,                  R.                  U;   a  MK  U(       a  [        ST9 S35        [)        U(R1                  SS95      U)-   n)U) VV*s/ s H  u  nn*T9 SU 3U*4PM     n)nn*[!        U5       V+VV,s/ s H  u  n+u  nn,UT9:X  d  M  U+PM     sn,nn+S   n%T8U4/US	U% -   U)-   UU%S-   S	 -   n[        U VVs/ s H5  u  nn[        U[        R                  R                  5      (       d  M1  UU4PM7     snnUU5      u  nnSn'  O   U'(       a  GM„  U(       a  [        S5        UU   U-   U:¼  Gaf  [        U[        R2                  5      (       d  [        U[        R4                  5      (       a  / O[)        UR+                  5       5      n-U(       a!  [        SU	U    ST8 SUUU   -
   SU S3	5        [        U-5      S:X  d  UR,                  R.                  U;   a  U(       a  [        S5        O©U(       a  [        ST8 S35        [)        UR1                  SS95      U--   n-U- VV*s/ s H  u  nn*T8 SU 3U*4PM     sn*nU-   n[        U VVs/ s H5  u  nn[        U[        R                  R                  5      (       d  M1  UU4PM7     snnUU5      u  nnGM	  UU   S:X  aL  U(       aE  US:w  a?  UU   [7        UU!5      -
  n[9        UUUUU   -
  UU5      u  n.n/n0U/b  U.U/4/T8U4/-   U0-   nGM^  UU   S:X  a  U!U -   UU'   UU   U -   UU'   US-  nT8U4/U-   n[        U5      S:”  a  GM‰  UR;                  5        VV1s0 s H  u  nn1U1S:”  d  M  UU1_M     nnn1U(       a  [=        U5      nUR%                  SS5      UR%                  SS5      -   n2U2S:”  a‰  U(       d‚  Sn3UR;                  5        H<  u  n4n5U4S:X  d  U4S:X  a  M  U3(       a  M  UR%                  U4S5      n6U5U2U6-   :¼  d  M:  Sn3M>     [        U5      S:”  a!  U3(       d  [>        R@                  " S U2 S!35        U(       a?  S"RC                  S# UR;                  5        5       5      n7[D        RG                  S$U7 S%35        U$ s  snf s  snf s  snnf s  snf s  snf s  snnf s  snf s  sn*nf s  sn,nn+f s  snnf s  sn*nf s  snnf s  sn1nf )&aÁ  
Compute a device map for a given model giving priority to GPUs, then offload on CPU and finally offload to disk,
such that:
- we don't exceed the memory available of any of the GPU.
- if offload to the CPU is needed, there is always room left on GPU 0 to put back the layer offloaded on CPU that
  has the largest size.
- if offload to the CPU is needed,we don't exceed the RAM available on the CPU.
- if offload to the disk is needed, there is always room left on the CPU to put back the layer offloaded on disk
  that has the largest size.

<Tip>

All computation is done analyzing sizes and dtypes of the model parameters. As a result, the model can be on the
meta device (as it would if initialized within the `init_empty_weights` context manager).

</Tip>

Args:
    model (`torch.nn.Module`):
        The model to analyze.
    max_memory (`Dict`, *optional*):
        A dictionary device identifier to maximum memory. Will default to the maximum memory available if unset.
        Example: `max_memory={0: "1GB"}`.
    no_split_module_classes (`List[str]`, *optional*):
        A list of layer class names that should never be split across device (for instance any layer that has a
        residual connection).
    dtype (`str` or `torch.dtype`, *optional*):
        If provided, the weights will be converted to that type when loaded.
    special_dtypes (`Dict[str, Union[str, torch.device]]`, *optional*):
        If provided, special dtypes to consider for some specific weights (will override dtype used as default for
        all weights).
    verbose (`bool`, *optional*, defaults to `False`):
        Whether or not to provide debugging statements as the function builds the device_map.
    clean_result (`bool`, *optional*, defaults to `True`):
        Clean the resulting device_map by grouping all submodules that go on the same device together.
    offload_buffers (`bool`, *optional*, defaults to `False`):
        In the layers that are offloaded on the CPU or the hard drive, whether or not to offload the buffers as
        well as the parameters.
    fallback_allocation (`bool`, *optional*, defaults to `False`):
        When regular allocation fails, try to allocate a module that fits in the size limit using BFS.
r   z
Treating module rQ   c              3   ó:   >#   • U  H  nTS -   US -   ;   v •  M     g7fr9  r€  r�  s     €r+   rÍ   Ú(infer_auto_device_map.<locals>.<genexpr>`  rƒ  r„  c              3   ó:   >#   • U  H  nTS -   US -   ;   v •  M     g7fr9  r€  r�  s     €r+   rÍ   r™  `  r†  r„  z'  Found the relevant tied param groups z4  So those parameters need to be taken into account r)  NzPutting z and z (size=Ú)z (available=z on c              3   óB   >#   • U  H  u  nu  p#UT:X  d  M  Uv •  M     g 7f©Nr€  )rÌ   r1  r¿   r¸   r{  s       €r+   rÍ   r™  “  s$   øé € Ð,uÒ@[±9°1±f°qÐ_`ÐdtÑ_t¯Q©QÒ@[ùs   ƒ–	rO  zNot enough space on z to put z (space available z, needed size z).Fz
Splitting r°   r   Tz?None of the tied module can be split, going to the next device.z, module size z6This module cannot be split, going to the next device.r/   zCurrent model requires z¬ bytes of buffer for offloaded layers, which seems does not fit any GPU's remaining memory. If you are experiencing a OOM later, please consider using offload_buffers=True.Ú
c              3   ó8   #   • U  H  u  pS U SU S3v •  M     g7f)z  - ú: z bytes requiredNr€  )rÌ   r4   Úmems      r+   rÍ   r™  %  s%   é € ð !
ÚEm±k°fˆd�6�(˜"˜S˜E Õ1ÒEmùs   ‚z{Based on the current allocation process, no modules could be assigned to the following devices due to insufficient memory:
zÎ
These minimum requirements are specific to this allocation attempt and may vary. Consider increasing the available memory for these devices to at least the specified minimum, or adjusting the model config.)$rr  r   r!  rà   r  Úprintr˜   r)   r3   r   r  rÒ   r‡  rV  r|  Únextrt  r  r  ru  rî   r  rž   r–   r±   r�   rš   rU  r’  rë   r;  ÚwarningsÚwarnrÛ   râ   r-  ):r*   r"  r  rN   r  r“  r”  r•  r–  rn  rp  ro  r  rq  r  rÝ   Úcurrent_devicer4   Údevice_memory_usedÚdevice_buffer_sizesÚ device_minimum_assignment_memoryÚmax_layer_sizeÚmax_layer_namesrw   r¿   rÀ   rv  rú   rò   rŠ  rä   Úcurrent_max_sizeÚcurrent_memory_reservedrz  rw  rx  Úoutputry  Úcurrent_buffer_sizeÚsplit_happenedÚtied_moduleÚtied_module_childrenr   r1  r¸   r  Úfallback_module_nameÚfallback_moduleÚremaining_modulesr¡  Únon_gpu_buffer_sizeÚis_buffer_fit_any_gpuÚ
gpu_deviceÚgpu_max_memoryÚgpu_memory_usedÚdevices_infor·   r{  s:                                                           @@r+   Úinfer_auto_device_mapr¼  þ  sÕ	  ù€ ô~ 	$ EÐ7NÐWeÓfñ	ØØØØØØØØô “€JØ€NÙ29Ó:²'¨˜& !š)±'ÐÐ:ØÐØ')Ð$ô '9Ð9IÐYpÓ&qÑ#€N�Oô ÐÓ
 !Ô
#Ø'×+Ñ+¨AÓ.‰ˆˆfÞÜÐ& t f¨AÐ.Ô/á&5Ód¢o ¸¸d¹›1È1Ï<É<ÐX\Ð_bÑXb×KcŸ1¡oˆÐdÜˆÓ 1Ó$Ü.@Ù$4ÔWÒ$4™D˜A˜q¼
À1ÄeÇhÁhÇoÁo×8V“�!�Q“Ñ$4ÒWØØ'ó/Ñ+ˆN˜Oð # 4Ñ(ˆñ .ó
â-�
ÜÔ=±*Ó=×=ó äFIÔItÑisÓIt×Ft÷ Ù-ð 	ð 
ö ”sÐ,Ó-°Ó1ÜÐ;Ð<MÐ;NÐOÔPô ÙTeÔfÒTeÀj™ÓAš�A t¨c¡z¸¸S¹Ñ'@�a™ÔAÑTeÒfÐhjó
ˆö ”s˜;Ó'¨!Ó+ÜÐHÈÈÐVÔWà˜Ñ(ˆØ17¸6Ó1A˜: fÒ-ÀtÐØ"#Ðà�>Ñ" lÓ2Ø/°.Ñ@ÐØ&4Ð#äAZØ˜ lóB
Ñ>ÐÐ0°,ð
 Ñ#Ð'9¸&Ñ'AÐDYÑ'YÐ]mÓ'mÞØ# D 6Ð*�æ$Ø Ð&7Ð%8Ð9Ñ9‘Fà ¨ }°AÐ6Ñ6�Fà#Ñ/Ø Ð-=Ð@RÐSYÑ@ZÑ-ZÐ,[Ð[\Ð]Ñ]�Fà˜D  ¨Ð*Ñ*�Ü�f”à˜vÓ&Ð*?Ñ?Ó&ð  &ˆJ�tÑó %6Ð Ø#Ñ6FÓ'GÒ6F°¨¨!¬Ñ6FÑ'GÓGä(,Ô,uÄ	ÐJZÔ@[Ó,uÓ(uÐ%à$×(Ñ(Ð):Ô;ð 06�
Ð+Ó,ñ %6ö #¤z°&¼"¿)¹)×'DÑ'Dä&FØ %ñ'Ð#ð /B×.EÑ.EÀfÈaÓ.PÐSfÑ.fÐ# FÑ+âô ˆ{Ó˜aÔÐ$6°vÑ$>ÀÑ$LÐP`Ô$`æÜØ*¨7°>Ñ+BÐ*CÀ8ÈDÈ6ÐQVÐWhÐVið j!Ø!1Ð4FÀvÑ4NÑ!NÐ OÈ~Ð^sÐ]tÐtvðxôð #ˆNÜ14Ð5FÈ×1UÑ-Ð  +Ü'+¨K×,FÑ,FÓ,HÓ'IÐ$ÜÐ+Ó,°Ó1°[×5JÑ5J×5SÑ5SÐWnÓ5náæÜ˜JÐ'7Ð&8¸Ð:Ô;Ü'+¨K×,HÑ,HÐQVÐ,HÐ,WÓ'XÐ[oÑ'oÐ$ÙSgÔ'hÒSgÉ4È1ÈaÐ,<Ð+=¸Q¸q¸cÐ)BÀAÓ(FÑSgÐ$Ñ'hÜ8AÐBRÔ8SÕ$mÒ8S©9¨1©f¨q°!ÐWXÐ\lÑWl§QÑ8SÓ$mÐnoÑ$pÐ!ð ˜F�^Ð$Ø&Ð'9Ð(9Ð:ñ;à*ñ+ð 'Ð'8¸1Ñ'<Ð'>Ð?ñ@ð !ô 3EÙ(8Ô[Ò(8¡  1¼JÀqÌ%Ï(É(Ï/É/×<Z“V�a˜“VÑ(8Ò[Ø Ø+ó3Ñ/� ð
 "&�Ùñ3 2Vö6 Úö ÜÐWÔXð ˜fÑ%¨Ñ3Ð7GÔGô ˜f¤b§l¡l×3Ñ3´zÀ&Ì%Ï,É,×7WÑ7Wñ ä˜&×/Ñ/Ó1Ó2ð ö
 ÜØ*¨7°>Ñ+BÐ*CÀ8ÈDÈ6ÐQcØ'Ð*<¸VÑ*DÑDÐEÀ^ÐT_ÐS`Ð`bðdôô Ð#Ó$¨Ó)¨V×-=Ñ-=×-FÑ-FÐJaÓ-aæÜÐRÔSøö Ü˜J t f¨AÐ.Ô/Ü#'¨×(?Ñ(?ÈÐ(?Ð(NÓ#OÐRbÑ#bÐ ÙCSÔ#TÒCS¹4¸1¸a¨ v¨Q¨q¨c ]°AÓ$6ÑCSÒ#TÐWgÑ#gÐ ä2DÙ(8Ô[Ò(8¡  1¼JÀqÌ%Ï(É(Ï/É/×<Z“V�a˜“VÑ(8Ò[Ø Ø+ó3Ñ/� ò
 ð ˜fÑ%¨Ó*Ö/BÀvÐQWÓGWð  *¨&Ñ1´C¸ÐH]Ó4^Ñ^ÐäGXØ ØØ Ð#5°fÑ#=Ñ=Ø'ØóHÑDÐ  /Ð3Dð Ñ*Ø%9¸?Ð$KÐ#LÐQUÐW]ÐP^ÐO_Ñ#_ÐbsÑ#sÐ Úà˜fÑ%¨Ó*Ø7LÐOfÑ7fÐ,¨VÑ4ð &8¸Ñ%?ÐBYÑ%YÐ˜6Ñ"Ø˜!ÑˆØ! 6˜NÐ+Ð.>Ñ>ÐôA ÐÓ
 !Ö
#ðD :L×9QÑ9QÔ9SÔ_Ò9S©+¨&°#ÐWZÐ]^ÑW^›+˜& #š+Ñ9SÐÑ_æÜ% jÓ1ˆ
à-×1Ñ1°%¸Ó;Ð>Q×>UÑ>UÐV\Ð^_Ó>`Ñ`ÐØ˜QÓ¦Ø %ÐØ*4×*:Ñ*:Ö*<Ñ&ˆJ˜Ø˜UÓ" j°FÓ&:Ùç(Ð(Ø"4×"8Ñ"8¸ÀQÓ"G�à!Ð%8¸?Ñ%JÕJØ,0Ò)ñ +=ô ˆt‹9�q‹=Ö!6Ü�MŠMØ)Ð*=Ð)>ð ?(ð )ôö (Ø—y‘yñ !
ØEe×EkÑEkÔEmó!
ó 
ˆô 	�‰ð%àˆnð wðxô	
ð Ðùò] ;ùò eùó Xùò
ùò BùÓfùòR (HùóL (iùÜ$mùó \ùóJ $Uùó \ùóB `s•   ©` Â	
`%Â`%Â2`%Ã0`*
Ä`*
Ä%`0Å`0Å#`0Æ
`:
Æ#`5Æ7`5Æ=`:
Êa ÐaÐ3a
Ña
Ñ60aÒ*a×!aØ0a
Ø<a
Û7a$Üa$à5`:
c                 óf  • [        U R                  5       5      nU Vs/ s H  o3S:w  d  M
  X2;  d  M  UPM     nnU(       a  [        R                  " SU 3[        5        U R                  5       R                  5        VVs/ s H  u  pVUPM	     nnnUR                  5        HO  nUS:X  a  UR                  5           O8U Vs/ s H'  nXX:X  a  M
  UR                  US-   5      (       a  M%  UPM)     nnMQ     [        U5      S:”  a  SR                  U5      n	[        SU	 35      egs  snf s  snnf s  snf )zà
Checks a device map covers everything in a given model.

Args:
    model (`torch.nn.Module`): The model to check the device map against.
    device_map (`Dict[str, Union[int, str, torch.device]]`): The device map to check.
rÿ   zHThe following device_map keys do not match any submodules in the model: rQ   r   z, zOThe device_map provided does not give any device for the following parameters: N)Údictr½   r¤  r¥  ÚUserWarningÚ
state_dictrë   rê   Úclearr˜   rà   rÛ   rI   )
r*   rÝ   Úall_module_namesr2  Úinvalid_keysr·   r¸   Úall_model_tensorsr  Únon_covered_paramss
             r+   Úcheck_device_maprÆ  2  s;  € ô ˜E×/Ñ/Ó1Ó2ÐÙ)ÓSšz˜!°"©W“A¸Ñ9R—A™z€LÐSæÜ�ŠØVÐWcÐVdÐeÔgrô	
ð .3×-=Ñ-=Ó-?×-EÑ-EÔ-GÔHÒ-G¡' $›Ñ-GÐÑHØ!—‘Ö(ˆØ˜"ÓØ×#Ñ#Ô%Ùñ .ó!â-�DØÑ*ó à37·?±?À;ÐQTÑCT×3U÷ Ù-ð ð !Ññ )ô ÐÓ Ó!Ø!ŸY™YÐ'8Ó9ÐÜØ]Ð^pÐ]qÐró
ð 	
ð "ùò% Tùó Iùò!s'   ž	D#«D#²D#Â D(Ã 	D.ÃD.Ã(D.c                 óL  • U R                  S5      (       Ga+  [        U SS9 nUR                  5       nUR                  5       nSSS5        Wc  [        R                  SU  S35        SS0nUR                  S5      S;  a  [        SU  S	35      eUS   S:w  a  [        S
US    S35      eUc  [        U 5      $ [        [        UR                  5       5      5      S:X  ab  [        UR                  5       5      S   nUn[        U[        5      (       a&  [!        5       (       a  SU 3nO[#        5       (       a  Sn[        XS9$ [        [        UR                  5       5      S1-
  5      nSU;  a  UR%                  S5        U Vs0 s H  oU/ _M     nnUR'                  5        HP  u  p•XW;   d  M  X…   R)                  W V
s/ s H%  oªU	:X  d  U
R+                  U	S-   5      (       d  M#  U
PM'     sn
5        MR     US   R)                  W V
s/ s H$  oª[-        UR                  5       / 5      ;  d  M"  U
PM&     sn
5        0 n[/        5       (       a3  [1        S[-        U Vs/ s H  n[        X…   5      PM     sn5      SSSS9nOSnU H«  nUn[        U[        5      (       a&  [!        5       (       a  SU 3nO[#        5       (       a  Sn[        U SUS9 nX…    HO  nUb!  UR3                  USS9  UR5                  U5        UR7                  U5      X½'   Uc  M?  UR9                  5         MQ     SSS5        M­     Ub  UR;                  5         U$ [<        R>                  " U [<        R@                  " S5      SS9$ ! , (       d  f       GN1= fs  snf s  sn
f s  sn
f s  snf ! , (       d  f       GM$  = f)a  
Load a checkpoint from a given file. If the checkpoint is in the safetensors format and a device map is passed, the
weights can be fast-loaded directly on the GPU.

Args:
    checkpoint_file (`str`): The path to the checkpoint to load.
    device_map (`Dict[str, Union[int, str, torch.device]]`, *optional*):
        A map that specifies where each submodule should go. It doesn't need to be refined to each parameter/buffer
        name, once a given module name is inside, every submodule of it will be sent to the same device.
z.safetensorsÚpt)Ú	frameworkNz"The safetensors archive passed at zx does not contain metadata. Make sure to save your model with the `save_pretrained` method. Defaulting to 'pt' metadata.Úformat)rÈ  ÚtfÚflaxzf does not contain the valid metadata. Make sure you save your model with the `save_pretrained` method.z%The checkpoint passed was saved with z, we need a the pt format.r   r   r†   r‡   r‰   r)  r/   rQ   FÚw)Úmain_process_onlyÚtotalÚunitÚ	smoothingÚleave)rÉ  r4   )ÚdevÚrefreshT)Úmap_locationÚweights_only)!rG   r"   rC  rê   râ   rã   r  ÚOSErrorrI   Úsafe_load_filerà   r²   rá   rî   r)   rE   r   r   rì   rë   Úextendr˜   rV  r   r   Úset_postfixÚset_descriptionÚ
get_tensorÚupdateÚcloser3   Úloadr4   )Úcheckpoint_filerÝ   ÚfrC  Úweight_namesr4   Útarget_devicern  Údevice_weightsr  r2  ÚtensorsÚprogress_barr
  s                 r+   Úload_state_dictrç  T  s‰  € ð ×Ñ ×/Ò/Ü�°$Ò7¸1Ø—z‘z“|ˆHØŸ6™6›8ˆL÷ 8ð ÑÜ�N‰NØ4°_Ð4Eð Foð oôð ! $Ð'ˆHà�<‰<˜Ó!Ð)=Ó=ÜØ4°_Ð4Eð FIð Ióð ð �hÑ 4Ó'ÜÐDÀXÈhÑEWÐDXÐXrÐsÓtÐtØÑÜ! /Ó2Ð2ô ”3�z×(Ñ(Ó*Ó+Ó,°Ó1Ü˜j×/Ñ/Ó1Ó2°1Ñ5�Ø &�Ü˜f¤c×*Ñ*Ü'×)Ñ)Ø*.¨v¨h¨™Ü)×+Ñ+Ø(-˜ä% oÑLÐLäœ3˜z×0Ñ0Ó2Ó3°v°hÑ>Ó?ˆGà˜GÓ#Ø—‘˜uÔ%ñ 8?Ó?²w¨V bšj±wˆNÐ?Ø'1×'7Ñ'7Ö'9Ñ#�ØÕ$Ø"Ñ*×1Ñ1Ù$0Óh¢L˜q¸Ó4DÈÏÉÐU`ÐcfÑUf×HgŸ¡LÑhöñ (:ð ˜5Ñ!×(Ñ(±\Ó)o²\°ÌcÐR`×RgÑRgÓRiÐkmÓNnÑEn¯!±\Ñ)oÔpØˆGÜ ×"Ñ"Ü#Ø&+ÜÉÓQÊ¸vœs >Ñ#9Ö:ÉÑQÓRØØØñ ‘ð  $�Û!�Ø &�Ü˜f¤c×*Ñ*Ü'×)Ñ)Ø*.¨v¨h¨™Ü)×+Ñ+Ø(-˜ä˜¸$À}ÒUÐYZØ-Ô5˜Ø'Ñ3Ø(×4Ñ4¸ÈÐ4ÑOØ(×8Ñ8¸Ô=Ø'(§|¡|°CÓ'8˜™Ø'Ó3Ø(×/Ñ/Ö1ñ  6÷ VÑUñ "ð  Ñ'Ø×"Ñ"Ô$àˆNä�zŠz˜/¼¿ºÀUÓ8KÐZ^Ñ_Ð_÷a 8Ö7üòN @ùò iùò *pùò
 R÷ V×UúsB   ¢!M-ÆM?Æ<"N
Ç"N
È!N	È*N	ÉNË
A NÌNÍ-
M<Î
N#	c                 óh  • 0 n[        5       nU R                  5        H˜  u  p4US:X  a  M   [        US5         UR                  5       nSSS5        W H_  nXV   R
                  [        R
                  " S5      :X  a  UR                  USU 3-   5        MB  XV   nUR                  S5      XSU 3-   '   Ma     Mš     UR                  5        H  nXa;   d  M
  UR                  U5        M     U(       a  [        R                  SU 35        U$ ! , (       d  f       NÇ= f! [         a    [	        S5      Sef = f)zŸ
Returns the state dictionary for an offloaded model via iterative onloading

Args:
    model (`torch.nn.Module`):
        The offloaded model we want to save
rÿ   r/   Nz;Offloaded module must fit in CPU memory to call save_model!r   rQ   zMThe following tensors were not saved because they were still on meta device: )r²   r½   Úalign_module_devicerÀ  ÚMemoryErrorr4   r3   Úaddr—   r  Úremoverâ   rã   )r*   rÀ  Úplaceholdersr·   rw   Úmodule_state_dictr
  Úparamss           r+   Úget_state_dict_offloaded_modelrð  ³  s+  € ð €JÜ“5€LØ×+Ñ+Ö-‰ˆØ�2‹:Ùð	gÜ$ V¨UÕ3Ø$*×$5Ñ$5Ó$7Ð!÷ 4ó
 %ˆCà Ñ%×,Ñ,´·²¸VÓ0DÓDØ× Ñ  ¨!¨C¨5¨	Ñ!1Ô2ÙØ&Ñ+ˆFØ+1¯9©9°UÓ+;ˆJ  # ˜iÑ'Ó(ó %ñ .ð" × Ñ Ö"ˆØÕØ×Ñ Ö$ñ #ö Ü�‰ÐfÐgsÐftÐuÔvàÐ÷% 4Õ3ûäó 	gÜÐ[Ó\ÐbfÐfð	gús(   «D·D	ÁDÄ	
D	ÄDÄDÄD1rÀ  Údevice_to_put_offloadc                 ó  • USUR                  S5       n[        U 5      (       d  Sn[        X5         U R                  5       R	                  5        H  u  pVUSU 3-   U;   d  M  XbUSU 3-   '   M     SSS5        U$ ! , (       d  f       U$ = f)a  
Retrieve the state dictionary (with parameters) from an offloaded module and load into a specified device (defaults
to cpu).

Args:
    module: (`torch.nn.Module`):
        The module we want to retrieve a state dictionary from
    module_name: (`str`):
        The name of the module of interest
    state_dict (`Dict[str, Union[int, str, torch.device]]`):
        Dictionary of {module names: parameters}
    device_to_put_offload (`Union[int, str, torch.device]`):
        Device to load offloaded parameters into, defaults to the cpu.
NrQ   )ÚrfindÚhas_offloaded_paramsré  rÀ  rë   )rw   r  rÀ  rñ  ÚrootÚm_keyrï  s          r+   Úget_state_dict_from_offloadr÷  Ø  s›   € ð* Ð/˜×*Ñ*¨3Ó/Ð0€Dô   ×'Ñ'Ø $Ðô 
˜VÕ	;Ø#×.Ñ.Ó0×6Ñ6Ö8‰MˆEØ˜˜5˜'�{Ñ" zÕ1Ø17˜4 A e W +Ñ-Ó.ñ 9÷ 
<ð
 Ð÷ 
<Ô	;ð
 Ðús   ².A<Á$A<Á<
BÚ
checkpointrB  Úoffload_state_dictÚkeep_in_fp32_modulesÚoffload_8bit_bnbÚstrictÚfull_state_dictÚbroadcast_from_rank0c                 óD  • U(       a  SSK Jn  [        U 5      n[        U 5      (       a$  [	        U5      S:X  a  [
        R                  S5        Ub  [        XÒ5        Uc"  Ub  SUR                  5       ;   a  [        S5      eUb,  Ub)  SUR                  5       ;   a  [        R                  " USS	9  [        U[        5      (       a"  UR                  S
S5      n[        [         U5      nSnSn[        R"                  R%                  U5      (       a(  [        U5      R'                  S5      (       a  UnGO¯U/nGOª[        R"                  R)                  U5      (       Gav  [        R*                  " U5       Vs/ s H  nU[,        :X  d  M  UPM     nn[        R*                  " U5       Vs/ s H  nU[.        :X  d  M  UPM     nn[	        U5      S:X  a%  [        R"                  R1                  UUS   5      /nOí[	        U5      S:X  a%  [        R"                  R1                  UUS   5      /nO¹[        R*                  " U5       Vs/ s H  nUR'                  S5      (       d  M  UPM     nn[	        U5      S:X  a  [        U S[,         S[.         S35      e[	        U5      S:X  a$  [        R"                  R1                  UUS   5      nO[        U S35      e[        SU S35      eUbÀ  [        R"                  R3                  U5      S   n[5        U5       n[6        R8                  " UR;                  5       5      nSSS5        SW;   a  US   n[=        [?        [A        UR                  5       5      5      5      nU Vs/ s H#  n[        R"                  R1                  UU5      PM%     nn0 nU(       a  [B        RD                  " 5       n0 n[A        5       n[A        U RG                  5       RI                  5       5      nU RK                  5        VVs/ s H  u  nnUPM
     nnnU RG                  5       R                  5        Vs1 s H0  n[        U[         RL                  5      (       d  M$  URN                  iM2     nnU[         RN                  " S5      1-
  n U GHS  n!Ucñ  [Q        SS5      (       a™  [Q        SS5      (       a  [	        U 5      S::  d  [	        U5      S::  aj  SSK)J*n"J+n#  U[Q        SS5      -  nU(       a  [X        RZ                  " 5       S:X  a
  []        U!US9O0 n$U#" U U$U"" S-U
U	S.[Q        SS5      (       a  SU0O0 D6S9  O[]        U!US9n$U R]                  U$U	S9  UR_                  [A        U$RI                  5       5      U-
  5        GOE[]        U!US9n$U$Ra                  5        GH&  u  n%n&S U%;   a  M  U%U;  a  URc                  U%5        U	(       d  M/  U%n'[	        U'5      S:”  a@  U'U;  a:  SR1                  U'R3                  S5      SS! 5      n'[	        U'5      S:”  a  U'U;  a  M:  U'S:X  a  SU;  a  [        U% S"35      eUU'   n(Un)Ubm  [         Rd                  " U&5      (       aR  UbO  U[         Rf                  :X  a;  S#n*U H  n+U+U%;   a	  U+S-   U%;   d  U+U%:X  d  M  Sn*  O   U*(       a  [         Rh                  n)S$U%;   aX  U%R                  S$S 5      U$RI                  5       ;   a4  U&Rj                  [         Rl                  :X  a  U$U%R                  S$S 5         n,OSn,U(S:X  aR  U(       d  U%U;  aB  U)c  U&Rj                  n)U(       a  W" U U&U%U)UUW,5        GM«  [o        U U%SU)S%9  [q        U&U%UUS&9  GMÆ  GMÉ  U(S':X  aI  U(       aB  U)c  U&Rj                  n)U(       a  W" U U&U%U)WWW,5        GMý  [o        U U%SU)S%9  [q        U&U%WWS&9  GM  [o        U U%U(U&U)W,S(9  GM)     A$[r        Rt                  " 5         GMV     U	(       dB  [	        U5      S:”  a3  [
        R                  S)U S*U Rv                  Rx                   S+U S,35        [{        UU5        U(       a#  [}        U WW5        [~        R€                  " U5        [ƒ        X5        gs  snf s  snf s  snf ! , (       d  f       GNR= fs  snf s  snnf s  snf ).aN  
Loads a (potentially sharded) checkpoint inside a model, potentially sending weights to a given device as they are
loaded.

<Tip warning={true}>

Once loaded across devices, you still need to call [`dispatch_model`] on your model to make it able to run. To
group the checkpoint loading and dispatch in one single call, use [`load_checkpoint_and_dispatch`].

</Tip>

Args:
    model (`torch.nn.Module`):
        The model in which we want to load a checkpoint.
    checkpoint (`str` or `os.PathLike`):
        The folder checkpoint to load. It can be:
        - a path to a file containing a whole model state dict
        - a path to a `.json` file containing the index to a sharded checkpoint
        - a path to a folder containing a unique `.index.json` file and the shards of a checkpoint.
        - a path to a folder containing a unique pytorch_model.bin or a model.safetensors file.
    device_map (`Dict[str, Union[int, str, torch.device]]`, *optional*):
        A map that specifies where each submodule should go. It doesn't need to be refined to each parameter/buffer
        name, once a given module name is inside, every submodule of it will be sent to the same device.
    offload_folder (`str` or `os.PathLike`, *optional*):
        If the `device_map` contains any value `"disk"`, the folder where we will offload weights.
    dtype (`str` or `torch.dtype`, *optional*):
        If provided, the weights will be converted to that type when loaded.
    offload_state_dict (`bool`, *optional*, defaults to `False`):
        If `True`, will temporarily offload the CPU state dict on the hard drive to avoid getting out of CPU RAM if
        the weight of the CPU state dict + the biggest shard does not fit.
    offload_buffers (`bool`, *optional*, defaults to `False`):
        Whether or not to include the buffers in the weights offloaded to disk.
    keep_in_fp32_modules(`List[str]`, *optional*):
        A list of the modules that we keep in `torch.float32` dtype.
    offload_8bit_bnb (`bool`, *optional*):
        Whether or not to enable offload of 8-bit modules on cpu/disk.
    strict (`bool`, *optional*, defaults to `False`):
        Whether to strictly enforce that the keys in the checkpoint state_dict match the keys of the model's
        state_dict.
    full_state_dict (`bool`, *optional*, defaults to `True`): if this is set to `True`, all the tensors in the
        loaded state_dict will be gathered. No ShardedTensor and DTensor will be in the loaded state_dict.
    broadcast_from_rank0 (`False`, *optional*, defaults to `False`): when the option is `True`, a distributed
        `ProcessGroup` must be initialized. rank0 should receive a full state_dict and will broadcast the tensors
        in the state_dict one by one to other ranks. Other ranks will receive the tensors and shard (if applicable)
        according to the local shards in the model.

r   )Úquantize_and_offload_8bitr   rm  Nr)  zeAt least one of the model submodule will be offloaded to disk, please pass along an `offload_folder`.T)Úexist_okrþ   rÿ   z.jsonz.index.jsonz6 is not a folder containing a `.index.json` file or a z or a z filezI containing more than one `.index.json` file, delete the irrelevant ones.z¼`checkpoint` should be the path to a file containing a whole state dict, or the index of a sharded checkpoint, or a folder containing a sharded checkpoint or the whole state dict, but got rQ   Ú
weight_mapr   rP   z2.2.0z2.7.0)ÚStateDictOptionsÚset_model_state_dictz2.4.0)rÝ   )rý  rü  rþ  )Úoptions)rü  rŽ   r:   z doesn't have any device set.FrŸ   r  r0   r/   )ry   rN   rz   z(Some weights of the model checkpoint at z! were not used when initializing r   z­. This may or may not be an issue - make sure that the checkpoint does not have unnecessary parameters, or that the model definition correctly corresponds to the checkpoint.r€  )BÚbnbr   r÷   rÙ   rà   râ   rã   rç   rá   rI   r@  Úmakedirsr)   rZ   r   r’   r3   rA  ÚisfilerG   ÚisdirÚlistdirr   r   rÛ   r‘   ÚopenÚjsonÚloadsÚreadrí   rî   r²   ÚtempfileÚmkdtemprÀ  rê   r´   rš   r4   r    Ú'torch.distributed.checkpoint.state_dictr  r  ÚdistÚget_rankrç  rÝ  rë   rë  Úis_floating_pointrg   rd   rN   rj   r«   r   ÚgcÚcollectrž   r–   r   rF  ÚshutilÚrmtreerü   )-r*   rø  rÝ   rB  rN   rù  r•  rú  rû  rü  rý  rþ  r   rä   Úcheckpoint_filesÚindex_filenamerá  Úpotential_state_binÚpotential_state_safetensorÚpotential_indexÚcheckpoint_folderr1   Úoffload_indexÚstate_dict_folderÚstate_dict_indexÚunexpected_keysÚ
model_keysr·   r¸   Úbuffer_namesÚtÚmodel_devicesÚmodel_physical_devicesrà  r  r  Úloaded_checkpointrõ   r¥   r  Úparam_deviceÚ	new_dtypeÚproceedr
  rz   s-                                                r+   Úload_checkpoint_in_modelr,  ü  s  € öz Ý2ä& uÓ-€Kä& u×-Ñ-´#°kÓ2BÀaÓ2GÜ�‰ð Aô	
ð ÑÜ,¨[ÔEàÑ *Ñ"8¸VÀz×GXÑGXÓGZÓ=ZÜØsó
ð 	
ð 
Ñ	#¨
Ñ(>À6ÈZ×M^ÑM^ÓM`ÓC`Ü
�Š�N¨TÒ2ä�%œ×Ñà—‘˜h¨Ó+ˆÜœ˜uÓ%ˆàÐØ€NÜ	‡w�w‡~�~�j×!Ñ!Üˆz‹?×#Ñ# G×,Ñ,Ø'ŠNà *˜|ÒÜ	�‰�‰�z×	"Ò	"ä*,¯*ª*°ZÔ*@ÓVÒ*@ QÀAÌÑDUŸqÑ*@ÐÐVÜ13·²¸JÔ1GÓ%bÒ1G¨AÈ1ÔPaÑKa§aÑ1GÐ"Ð%bÜÐ"Ó# qÓ(Ü "§¡§¡¨ZÐ9LÈQÑ9OÓ PÐQÑÜÐ+Ó,°Ó1Ü "§¡§¡¨ZÐ9SÐTUÑ9VÓ WÐXÑô +-¯*ª*°ZÔ*@Ó^Ò*@ QÀAÇJÁJÈ}×D]ŸqÑ*@ˆOÐ^Ü�?Ó# qÓ(Ü Ø!�lÐ"XÔYeÐXfÐflÔm~Ðlð  @Eð  Fóð ô �_Ó%¨Ó*Ü!#§¡§¡¨j¸/È!Ñ:LÓ!M‘ä Ø!�lÐ"kÐlóð ô ðhØhrÐgsÐstðvó
ð 	
ð
 Ñ!ÜŸG™GŸM™M¨.Ó9¸!Ñ<ÐÜ�.Ô! QÜ—J’J˜qŸv™v›xÓ(ˆE÷ "ð ˜5Ó Ø˜,Ñ'ˆEÜ!¤$¤s¨5¯<©<«>Ó':Ó";Ó<ÐÙHXÓYÒHXÀ1œBŸG™GŸL™LÐ):¸AÖ>ÑHXÐÐYð €MÞÜ$×,Ò,Ó.ÐØÐä“e€OÜ�U×%Ñ%Ó'×,Ñ,Ó.Ó/€JØ(-×(;Ñ(;Ô(=Ô>Ò(=™W˜T 1“DÑ(=€LÑ>Ø',×'7Ñ'7Ó'9×'@Ñ'@Ô'BÓbÒ'B !ÄjÐQRÔTY×T`ÑT`×Fa“X�Q—X”XÑ'B€MÐbØ*¬e¯lªl¸6Ó.BÐ-CÑCÐÜ+ˆØÑô    g×.Ñ.Ü! $¨×0Ñ0´SÐ9OÓ5PÐTUÓ5UÔZ]Ð^kÓZlÐpqÓZqçjà$Ô(8¸¸wÓ(GÑGÐ$ö 0´4·=²=³?ÀaÓ3Gô $ OÀ
ÒKàð "ñ
 %ØØ%Ù,ð Ø(7Ø%ñô N^Ð^bÐdk×MlÑMlÐ2Ð4HÑIÐrtñóô %4°OÐPZÑ$[Ð!Ø×%Ñ%Ð&7ÀÐ%ÑGà×"Ñ"¤3Ð'8×'=Ñ'=Ó'?Ó#@À:Ñ#MÖNä /°ÈJÑ WÐà%6×%<Ñ%<×%>Ñ!�
˜Eà˜JÓ&Ùà ZÓ/Ø#×'Ñ'¨
Ô3Þ!Ù à(�ä˜+Ó&¨Ó*¨{À*Ó/LØ"%§(¡(¨;×+<Ñ+<¸SÓ+AÀ#À2Ð+FÓ"G�Kô ˜+Ó&¨Ó*¨{À*Õ/Là "Ó$¨°:Ó)=ä$¨
 |Ð3PÐ%QÓRÐRØ)¨+Ñ6�Ø!�	ØÑ$¬×)@Ò)@À×)GÑ)GØ+Ñ7¸EÄUÇ]Á]Ó<RØ"'˜Û#7˜CØ!$¨
Ó!2¸¸s¹ÀjÓ9PÐVYÐ]gÕVgØ*. Ù %ñ $8ö #Ü(-¯©˜Ià˜zÓ)¨j×.@Ñ.@ÀÈ5Ó.QÐUf×UkÑUkÓUmÓ.mØ—{‘{¤e§j¡jÓ0Ø*;¸J×<NÑ<NÈxÐY^Ó<_Ñ*`˜øà&*�Oà 6Ó)Þ&¨*¸LÓ*HØ$Ñ,Ø(-¯©˜IÞ+Ù5Ø % u¨j¸)À^ÐUbÐdsôò %ä7¸¸zÈ6ÐYbÒcÜ& u¨j¸.ÐP]Õ^ò +Ið " UÓ*Ö/AØ Ñ(Ø$)§K¡K˜	Þ'Ù1Ø! 5¨*°iÐARÐTdÐfu÷ô 4°E¸:ÀvÐU^Ò_Ü& u¨jÐ:KÐScÕdä/ØØ"Ø$Ø#Ø'Ø(7õñu &?ðH Ü
�
Š
�ñM ,öP ”c˜/Ó*¨QÓ.Ü�‰Ø6°z°lð CØ"Ÿ_™_×5Ñ5Ð6°b¸Ð8Ið  Jwðxô	
ô
 �} nÔ5ö Ü˜uÐ&6Ð8IÔJÜ�ŠÐ'Ô(ä�UÕ(ùòI WùÚ%bùò _÷& "Ö!üò Zùó ?ùÚbsH   Å3a1Æa1Æ%a6Æ7a6È?a;Éa;Ì%b Í7*bÐbÐ9#bÑ bâ 
bÚ
native_ampÚautocast_kwargsc                 ó˜  • [        5       nUc  0 nOUR                  5       nU (       GaŽ  UR                  [        R                  :X  a  [        SS9(       a  SOUR                  R                  nUR                  S:X  a'  [        R                  " SU[        R                  S.UD6$ UR                  S;   aë  UR                  [        R                  [        R                  [        R                  [        R                  [        R                   [        R"                  [        R$                  [        R&                  [        R(                  [        R*                  [        R,                  [        R                  4;   a'  [        R                  " SU[        R.                  S.UD6$ [        R                  " SSU0UD6$ [0        R2                  " 5       $ )	a,  
Return a context manager for autocasting mixed precision

Args:
    native_amp (`bool`, *optional*, defaults to False):
        Whether mixed precision is actually enabled.
    cache_enabled (`bool`, *optional*, defaults to True):
        Whether the weight cache inside autocast should be enabled.
T©Úcheck_is_gpur‚   Úfp16)Údevice_typerN   )Úbf16Úfp8r3  r€  )r
   Ú	to_kwargsÚdistributed_typer   ÚXLAr   r4   r2   Úmixed_precisionr3   Úautocastrg   ÚNOÚ	MULTI_CPUÚ	MULTI_GPUÚ	MULTI_MLUÚ
MULTI_SDAAÚ
MULTI_MUSAÚ	MULTI_NPUÚ	MULTI_XPUÚ	MULTI_HPUÚMULTI_NEURONÚFSDPrf   Ú
contextlibÚnullcontext)r-  r.  Ústater3  s       r+   Ú#get_mixed_precision_context_managerrI    s_  € ô Ó€EØÑØ‰à)×3Ñ3Ó5ˆßð ×&Ñ&¬/×*=Ñ*=Ó=ÔBXÐfj×Bkñ à—‘×"Ñ"ð 	ð
 × Ñ  FÓ*Ü—>’>Ðb¨kÄÇÁÑbÐRaÑbÐbØ×"Ñ" oÓ5¸%×:PÑ:PÜ×ÑÜ×%Ñ%Ü×%Ñ%Ü×%Ñ%Ü×&Ñ&Ü×&Ñ&Ü×%Ñ%Ü×%Ñ%Ü×%Ñ%Ü×(Ñ(Ü× Ñ Ü×ÑðU
ó ;
ô —>’>Ðc¨kÄÇÁÑcÐSbÑcÐcä—>’>ÑM¨kÐM¸_ÑMÐMä×%Ò%Ó'Ð'r-   r7  c                 ób  • U [         R                  :X  a  SSKJn  U" S
0 UD6$ [	        SS9(       a  SSKJn  UR                  " S
0 UD6$ [        5       (       a*  [        R                  R                  R                  " S
0 UD6$ [        5       (       a*  [        R                  R                  R                  " S
0 UD6$ [        5       (       a*  [        R                  R                  R                  " S
0 UD6$ [        5       (       a*  [        R                   R                  R                  " S
0 UD6$ [#        5       (       a   [        R                  R                  " S0 UD6$ [%        5       (       a   [        R                  R                  " S0 UD6$ ['        5       (       a<  [)        SS5      (       d  [+        S5      e[        R                  R                  " S0 UD6$ [)        SS	5      (       a   [        R                  R                  " S0 UD6$ [        R,                  R                  R                  " S
0 UD6$ )aH  
A generic helper which will initialize the correct `GradScaler` implementation based on the environment and return
it.

Args:
    distributed_type (`DistributedType`, *optional*, defaults to None):
        The type of distributed environment.
    kwargs:
        Additional arguments for the utilized `GradScaler` constructor.
r   )ÚShardedGradScalerTr0  NrP   z2.8.0z7Grad Scaler with MPS device requires a Pytorch >= 2.8.0z2.3r€  )r‡   )rƒ   )r(  )r‚   )r   rE  Ú*torch.distributed.fsdp.sharded_grad_scalerrK  r   Útorch_xla.ampÚampÚ
GradScalerr   r3   r%  r   r&  r   r'  r   r$  r   r   r   r    rI   r‚   )r7  r©   rK  Úxamps       r+   Úget_grad_scalerrQ  -  s‘  € ð œ?×/Ñ/Ó/ÝPá Ñ* 6Ñ*Ð*Ü¨4×0Ý$à�ŠÑ( Ñ(Ð(Ü	×	Ñ	Ü�y‰y�}‰}×'Ò'Ñ1¨&Ñ1Ð1Ü	×	Ñ	Ü�z‰z�~‰~×(Ò(Ñ2¨6Ñ2Ð2Ü	×	Ñ	Ü�z‰z�~‰~×(Ò(Ñ2¨6Ñ2Ð2Ü	×	Ñ	Ü�y‰y�}‰}×'Ò'Ñ1¨&Ñ1Ð1Ü	×	Ñ	Ü�y‰y×#Ò#Ñ4¨VÑ4Ð4Ü	×	Ñ	Ü�y‰y×#Ò#Ñ4¨VÑ4Ð4Ü	×	Ñ	Ü  g×.Ñ.ÜÐVÓWÐWÜ�y‰y×#Ò#Ñ4¨VÑ4Ð4ä˜D %×(Ñ(Ü—9‘9×'Ò'Ñ9°&Ñ9Ð9ä—:‘:—>‘>×,Ò,Ñ6¨vÑ6Ð6r-   c                 óš   • SSK Jn  [        U S5      =(       a3    [        U R                  U5      =(       a    U R                  R
                  $ )a@  
Checks if a module has offloaded parameters by checking if the given module has a AlignDevicesHook attached with
offloading enabled

Args:
    module (`torch.nn.Module`): The module to check for an offload hook.

Returns:
    bool: `True` if the module has an offload hook and offloading is enabled, `False` otherwise.
r	   )ÚAlignDevicesHookÚ_hf_hook)ÚhooksrS  rË   r)   rT  Úoffload)rw   rS  s     r+   rô  rô  W  s7   € õ )ä�6˜:Ó&×t¬:°f·o±oÐGWÓ+X×tÐ]c×]lÑ]l×]tÑ]tÐtr-   Úexecution_devicec              #   óÖ  #   • [        U 5      (       a{  Ub&  U R                  R                  nXR                  l         U R                  R                  U 5        Sv •  U R                  R	                  U S5        Ub  WU R                  l        ggUbm  U R                  SS9 VVs0 s H  u  p4X4R                  _M     nnn U H  n[        XU5        M     Sv •  UR                  5        H  u  p6[        XU5        M     gSv •  g! U R                  R	                  U S5        Ub  WU R                  l        f f = fs  snnf ! UR                  5        H  u  p6[        XU5        M     f = f7f)a^  
Context manager that moves a module's parameters to the specified execution device.

Args:
    module (`torch.nn.Module`):
        Module with parameters to align.
    execution_device (`torch.device`, *optional*):
        If provided, overrides the module's execution device within the context. Otherwise, use hook execution
        device or pass
NFr°   )	rô  rT  rW  Úpre_forwardÚpost_forwardr±   r4   r«   rë   )rw   rW  Úoriginal_devicer·   r¥   rn  r4   s          r+   ré  ré  g  s?  é € ô ˜F×#Ñ#ØÑ'Ø$Ÿo™o×>Ñ>ˆOØ/?�O‰OÔ,ð	CØ�O‰O×'Ñ'¨Ô/Ûà�O‰O×(Ñ(¨°Ô6ØÑ+Ø3B�—‘Õ0ð ,ð 
Ñ	%Ø9?×9PÑ9PÐY^Ð9PÑ9_Ô`Ò9_©+¨$�4Ÿ™Ò%Ñ9_ˆÑ`ð	BÛ�Ü+¨FÐ:JÖKñ  ãà '§¡¦‘�Ü+¨F¸&ÖAò !0ô 	øð �O‰O×(Ñ(¨°Ô6ØÑ+Ø3B�—‘Õ0ð ,üó aøð !(§¡¦‘�Ü+¨F¸&ÖAò !0üsA   ‚:E)½D ÁAE)Â#D9Â;E)Â?D? Ã+E)Ä3D6Ä6	E)Ä?'E&Å&E))NNNNFT)TFF)FF)NNF)NNr�  )rÿ   )NNNNF)NNNN)NNNNFTFF)r/   )
NNNFFNFFTF)FN)prF  r  rÏ   r  Úloggingr@  rX   r  r  r¤  Úcollectionsr   r   Útypingr   r   r3   r   r  r   rH  r
   Ú	constantsr   r   Údataclassesr   r   r   Úimportsr   r   r   r   r   r   r   r   r   Úmemoryr   rV  r   r   r   r   r   Úversionsr    Ú	torch_npuÚ	torch_mluÚ
torch_sdaaÚ
torch_musaÚsafetensorsr"   Úsafetensors.torchr#   rØ  ÚWEIGHTS_INDEX_NAMEÚ	getLoggerr–   râ   r,   r7   rE   rZ   rM   rN   r^   rš   rT  r4   rv   r  Ú
HalfTensorr¾  rR   r«   r¹   r³   rÙ   rÜ   rç   rî   r÷   rü   r  r  r  r!  r6  r;  rF  rL  rd  rk  rr  r|  r’  r¼  rÆ  rç  rð  r_   r÷  ÚPathLiker,  rI  rQ  rô  Úcontextmanagerré  r€  r-   r+   Ú<module>ro     s×	  ðó Û 	Û Û Û Û 	Û 	Û Û Û ß 0ß "ã Ý %Ý å $ß 6ß EÑ E÷
÷ 
õ 
õ 'ß NÑ Nß )Ý &ñ  ×'Ûá ×'Ûá %×(Ûá %×(Ûå !Ý 9ð 4Ð à	×	Ò	˜8Ó	$€ò]ò)ð6) 5¨¨c¨¡?ô )ðX˜5Ÿ;™;ô ð8!4˜eŸl™lð !4¨u°U·\±\À3ÈÐ5KÑ/Lô !4ðP %)Ø/3Ø26ØMQØØñO>Ø�I‰IðO>àðO>ð �#�s˜EŸL™LÐ(Ñ)ðO>ð �E—L‘LÑ!ð	O>ð
 �E˜#˜uŸ{™{Ð*Ñ+Ñ,ðO>ð ˜e×.Ñ.Ñ/ðO>ð ˜d 3¨¨U¯\©\¸5¿<¹<Ð-GÑ(HÐ#HÑIÑJðO>ð ðO>ð õO>ðf kpñ#Ø�I‰Ið#Ø(,ð#Ø>Bð#Øcgõ#ñ<& r§y¡yð &¸4ð &Ètõ &ð0%U¨2¯9©9ô %UòP;òð.4^ §¡§¡ð 4^¸dÀ4ÈÁ9¹oô 4^òn:ð>˜U 3¨¯©Ð#4Ñ5ð ¸%¿+¹+ô ð 15ØDHØñ	'Ø�9‰9ð'à�E˜#˜uŸ|™|Ð+Ñ,Ñ-ð'ð ˜T # u¨S°%·,±,Ð->Ñ'?Ð"?Ñ@ÑAð'ð õ	'ðX 15ØDHñ	#Ø�9‰9ð	#à�E˜#˜uŸ|™|Ð+Ñ,Ñ-ð	#ð ˜T # u¨S°%·,±,Ð->Ñ'?Ð"?Ñ@ÑAõ	#ð$!Ø�%˜˜UŸX™XŸ_™_Ð,Ñ-Ñ.ð$!Ø>BÀ3ÈÀ8¹nð$!ØgkÐloÑgpô$!ñNl˜x¨¨U°3¸°8©_¸eÀCÈÀH¹oÐ-MÑ(NÑOõ lñ^  c¨5°°c¸5¿<¹<Ð1GÑ+HÐ&HÑ!Ið ÐX[õ ò,mò<ð DHØ37Ø/3ØDHØñCØ�9‰9ðCà˜˜e C¨ H™o¨u°S¸#°X©Ð>Ñ?Ñ@ðCð & d¨3¡iÑ0ðCð �E˜#˜uŸ{™{Ð*Ñ+Ñ,ð	Cð
 ˜T # u¨S°%·,±,Ð->Ñ'?Ð"?Ñ@ÑAðCð õCðL% 5§8¡8§?¡?ô %ð( DHØ37Ø/3ØDHñ=Ø�9‰9ð=à˜˜e C¨ H™o¨u°S¸#°X©Ð>Ñ?Ñ@ð=ð & d¨3¡iÑ0ð=ð �E˜#˜uŸ{™{Ð*Ñ+Ñ,ð	=ð
 ˜T # u¨S°%·,±,Ð->Ñ'?Ð"?Ñ@ÑAð=ð Øˆˆs�Cˆx‰ÑØˆˆs�Cˆx‰˜%  S ™/Ð	)Ñ*Øˆˆs�Cˆx‰ÑØˆ�IØˆˆcˆ�NØˆˆc‰�OØˆ�IØˆˆs�B—I‘Iˆ~Ñ	Ñð!ñ	õ=ð@!Bð
 ˆ3��S‘	˜4 §	¡	™?Ð*Ñ+ô!BðP 48Ø15ñi!Ø�%˜˜RŸY™Y˜Ñ'Ñ(ði!à�s˜C�x‘.ði!ð �c˜3�h‘ði!ð & d¨3¡iÑ0ð	i!ð
 ˜d 4¨¡9™oÑ.ði!ð ˆ8�C‰=˜( 2§9¡9Ñ-¨t°E¸#¸r¿y¹y¸.Ñ4IÑ/JÐJÑKõi!ð\ DHØ37Ø/3ØCGØØØ!Ø %ñqØ�9‰9ðqà˜˜e C¨ H™o¨u°S¸#°X©Ð>Ñ?Ñ@ðqð & d¨3¡iÑ0ðqð �E˜#˜uŸ{™{Ð*Ñ+Ñ,ð	qð
 ˜T # u¨S°%·+±+Ð-=Ñ'>Ð">Ñ?Ñ@ðqð ðqð ðqð ðqð õqðh	
˜BŸI™Ið 
°4¸¸UÀ3ÈÈUÏ\É\ÐCYÑ=ZÐ8ZÑ3[ô 
ôD\`ð~"¨"¯)©)ô "ðR <Añ	!Ø�I‰Ið!àð!ð �S˜%  U§\¡\Ð 1Ñ2Ð2Ñ3ð!ð !  c¨5¯<©<Ð!7Ñ8õ	!ðN FJØ8<Ø/3Ø$Ø!Ø04Ø"ØØ Ø!&ñB)Ø�9‰9ðB)à�c˜2Ÿ;™;Ð&Ñ'ðB)ð ˜˜c 5¨¨c°5·<±<Ð)?Ñ#@Ð@ÑAÑBðB)ð ˜U 3¨¯©Ð#3Ñ4Ñ5ð	B)ð
 �E˜#˜uŸ{™{Ð*Ñ+Ñ,ðB)ð ðB)ð ðB)ð # 4¨¡9Ñ-ðB)ð ðB)ð ðB)ð ðB)ð õB)ñJ)(°Dð )(ÐSaõ )(ñX'7 oõ '7ðTu §¡§¡ð u°Tô uð  ×Ññ# §¡§¡ð #À8ÈEÏLÉLÑCYô #ó ñ#r-   