+
    QV-jð  ã                   ó  € R t ^ RIHt ^ RIHtHt ^ RIHtHt ^RI	H
t
 ]! R4      t]].]3,          t]].]R,          3,          tRtRRR	RR
RRR/t]
P"                  ! ]4      t] ! R R4      4       tRR R]/R R lltR R ltR# )z.Contains helpers to split tensors into shards.)ÚCallable)Ú	dataclassÚfield)ÚAnyÚTypeVar)ÚloggingÚTensorTNÚ5GBÚTBÚGBÚMBÚKBc                   óD   a € ] tR t^'t o ]! RR7      tR tV 3R ltRtV t	R# )ÚStateDictSplitF)Úinitc                ó@   € \        V P                  4      ^8„  V n        R# )é   N)ÚlenÚfilename_to_tensorsÚ
is_sharded)Úselfs   &Út/Volumes/fast/ai/experiments/ui-tars-smoke/.venv/lib/python3.14/site-packages/huggingface_hub/serialization/_base.pyÚ__post_init__ÚStateDictSplit.__post_init__.   s   € Ü˜d×6Ñ6Ó7¸!Ñ;ˆŽó    c                óœ   <€ V ^8„  d   Qh/ S[ ;R&   S[S[S[3,          ;R&   S[S[S[S[,          3,          ;R&   S[S[S[3,          ;R&   # )é   r   Úmetadatar   Útensor_to_filename)ÚboolÚdictÚstrr   Úlist)ÚformatÚ__classdict__s   "€r   Ú__annotate__ÚStateDictSplit.__annotate__'   sT   ø‡ ‚ áÑ(ñ ñ ‘3™�8�nÑñ ñ ™c¡4©¥9˜nÕ-Ñ-ñ	 ñ
 ™S¡#˜X�Ñ&ò r   )r   N)
Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__r   r   r   Ú__annotate_func__Ú__static_attributes__Ú__classdictcell__)r$   s   @r   r   r   '   s   ø‡ € á %Ô(€Jò
<÷ ƒ r   r   Úget_storage_idc                 ó   € R # )N© )Útensors   &r   Ú<lambda>r2   7   s   € ±4r   Úmax_shard_sizec                ó˜   € V ^8„  d   QhR\         \        \        3,          R\        R\        R\        R\
        \        ,          R\        /# )r   Ú
state_dictÚget_storage_sizeÚfilename_patternr.   r3   Úreturn)r    r!   r   ÚTensorSizeFn_TÚStorageIDFn_TÚintr   )r#   s   "r   r%   r%   2   s[   € ÷ }ñ }Ü”Sœ'�\Õ"ð}ô %ð}ô ð	}ô
 "ð}ô œ#•Ið}ô ñ}r   c          	     óž  € / p. p/ p^ p^ p	\        V\        4      '       d   \        V4      pV P                  4        FÃ  w  r«\        V\        4      '       d   \        P                  RV
4       K3  V! V4      pVe%   WÅ9   d   W\,          P                  V
4       K^  V
.W\&   V! V4      pWÔ8”  d   W�,          p	VP                  W«/4       K�  W�,           V8”  d   VP                  V4       / p^ pW·V
&   W�,          pW�,          p	KÅ  	  \        V4      ^ 8”  d   VP                  V4       \        V4      pVP                  4        F3  w  rÏV F(  pV^ ,          V9   g   K  V F  p
W
,          VV
&   K  	   K1  	  K5  	  V^8X  dZ   VP                  RR7      p\        RV	/V\        V P                  4       4      /V P                  4        U
u/ uF  qªVbK  	  up
R7      # / p/ p\        V4       FQ  w  ppVP                  RV^,           R RVR 2R7      pV F  p
VVV
&   K
  	  \        VP                  4       4      VV&   KS  	  \        RV	/VVR7      # u up
i )	aÄ  
Split a model state dictionary in shards so that each shard is smaller than a given size.

The shards are determined by iterating through the `state_dict` in the order of its keys. There is no optimization
made to make each shard as close as possible to the maximum size passed. For example, if the limit is 10GB and we
have tensors of sizes [6GB, 6GB, 2GB, 6GB, 2GB, 2GB] they will get sharded as [6GB], [6+2GB], [6+2+2GB] and not
[6+2+2GB], [6+2GB], [6GB].

> [!WARNING]
> If one of the model's tensor is bigger than `max_shard_size`, it will end up in its own shard which will have a
> size greater than `max_shard_size`.

Args:
    state_dict (`dict[str, Tensor]`):
        The state dictionary to save.
    get_storage_size (`Callable[[Tensor], int]`):
        A function that returns the size of a tensor when saved on disk in bytes.
    get_storage_id (`Callable[[Tensor], Optional[Any]]`, *optional*):
        A function that returns a unique identifier to a tensor storage. Multiple different tensors can share the
        same underlying storage. 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.
    filename_pattern (`str`, *optional*):
        The pattern to generate the files names in which the model will be saved. Pattern must be a string that
        can be formatted with `filename_pattern.format(suffix=...)` and must contain the keyword `suffix`
    max_shard_size (`int` or `str`, *optional*):
        The maximum size of each shard, in bytes. Defaults to 5GB.

Returns:
    [`StateDictSplit`]: A `StateDictSplit` object containing the shards and the index to retrieve them.
z8Skipping tensor %s as it is a string (bnb serialization)Ú )ÚsuffixÚ
total_size)r   r   r   Ú-Ú05dz-of-)Ú
isinstancer!   Úparse_size_to_intÚitemsÚloggerÚinfoÚappendr   r#   r   r"   ÚkeysÚ	enumerate)r5   r6   r7   r.   r3   Ústorage_id_to_tensorsÚ
shard_listÚcurrent_shardÚcurrent_shard_sizer?   Úkeyr1   Ú
storage_idÚtensor_sizeÚ	nb_shardsrH   ÚshardÚfilenameÚtensor_name_to_filenamer   Úidxs   &$$$$                r   Ú$split_state_dict_into_shards_factoryrV   2   s  € ðL 35Ðà+-€JØ(*€MØÐØ€Jä�.¤#×&Ò&Ü*¨>Ó:ˆà!×'Ñ'Ö)‰ˆô �fœc×"Ò"Ü�K‰KÐRÐTWÔXÙñ $ FÓ+ˆ
ØÒ!ØÔ2à%Õ1×8Ñ8¸Ô=Ùð 69°EÐ%Ñ1ñ ' vÓ.ˆð Ô'ØÕ%ˆJØ×Ñ˜s˜mÔ,Ùð Õ+¨nÔ<Ø×Ñ˜mÔ,ØˆMØ!"Ðð $�cÑØÕ)ÐØÕ!Š
ñM *ôR ˆ=Ó˜AÔØ×Ñ˜-Ô(Ü�J“€Ið 2×7Ñ7Ö9Ñˆ
ãˆEØ�A�w˜%ÖÛ�CØ!+¥�E˜#“Jñ  âó	  ñ :ð �A„~Ø#×*Ñ*°"Ð*Ó5ˆÜØ" JÐ/Ø!)¬4°
·±Ó0AÓ+BÐ CØ9C¿¹Ô9JÓKÑ9J°# X¢Ñ9JÑKô
ð 	
ð !ÐØÐÜ 
Ö+‰
ˆˆUØ#×*Ñ*°A°c¸Aµg¸c°]À$ÀyÐQTÀoÐ2VÐ*ÓWˆÛˆCØ+3Ð# CÓ(ñ ä(,¨U¯Z©Z«\Ó(:Ð˜HÓ%ñ	 ,ô Ø 
Ð+Ø/Ø2ôð ùò  Ls   ÇI
c                ó0   € V ^8„  d   QhR\         R\        /# )r   Úsize_as_strr8   )r!   r;   )r#   s   "r   r%   r%   ²   s   € ÷ #ñ #¤3ð #¬3ñ #r   c                óB  € V P                  4       p V RR P                  4       pV\        9  d   \        RV RV  R24      h\        V,          p \	        V RR P                  4       4      p\        Y2,          4      #   \         d   p\        RT  RT 24      ThRp?ii ; i)a%  
Parse a size expressed as a string with digits and unit (like `"5MB"`) to an integer (in bytes).

Supported units are "TB", "GB", "MB", "KB".

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

Example:

```py
>>> parse_size_to_int("5MB")
5000000
```
NzUnit 'z:' not supported. Supported units are TB, GB, MB, KB. Got 'z'.z%Could not parse the size value from 'z': éþÿÿÿ)ÚstripÚupperÚ
SIZE_UNITSÚ
ValueErrorÚfloatr;   )rX   ÚunitÚ
multiplierÚvalueÚes   &    r   rC   rC   ²   s»   € ð  ×#Ñ#Ó%€Kð �r�sÐ×!Ñ!Ó#€DØ”:ÔÜ˜6 $ Ð'aÐbmÐanÐnpÐqÓrÐrÜ˜DÕ!€Jð]Ü�k # 2Ð&×,Ñ,Ó.Ó/ˆô ˆuÕ!Ó"Ð"øô ô ]ÜÐ@ÀÀÈSÐQRÐPSÐTÓUÐ[\Ð\ûð]ús   ÁA< Á<BÂBÂBl    J)£i Êš;i@B iè  )Ú__doc__Úcollections.abcr   Údataclassesr   r   Útypingr   r   r=   r   r   r;   r9   r:   ÚMAX_SHARD_SIZEr]   Ú
get_loggerÚ__file__rE   r   rV   rC   r0   r   r   Ú<module>rk      s´   ðñ 5å $ß (ß å ñ �)Ó
€Ø˜7˜) S˜.Õ)€Ø˜'˜ C¨$¥JÐ.Õ/€à€àˆ&Øˆ%Øˆ%Øˆ%ð	€
ð 
×	Ò	˜HÓ	%€ð ÷<ð <ó ð<ð}ñ
 %8ð}ð !/÷}÷@#r   