+
    –°³j  ã                  ó    € ^ RI Ht ^ RIHtHtHt ^ RIt^RIHtH	t	 R.t
] ! R R]4      4       tR R ltR	 R
 ltR R ltR R ltR R ltR# )é    )Úannotations)ÚProtocolÚruntime_checkableÚ	TypeGuardN)ÚChunkStorageMetadataÚMetadataIndexÚCheckpointableTensorc                  óD   € ] tR t^t$ RtR]R&   R]R&   R]R&   R]R&   RtR	# )
r	   a¨  Protocol fields for checkpointing a local tensor as global tensor shards.

A tensor does not need to be wrapped or subclassed for DCP to checkpoint it
as a shard. It can stay a regular local ``torch.Tensor``; implementing
these fields is enough for DCP to map one or more slices of that tensor
into a logical global tensor.

Attributes:
    global_shape: Full logical tensor shape to write into checkpoint
        metadata; needed because ``tensor.size()`` is only the local buffer
        size.
    global_offsets: Global start coordinate for each local shard; needed to
        name checkpoint chunks and match load requests by global offset.
    local_offsets: Start coordinate for each local shard inside the local
        tensor; needed when one tensor stores multiple shards or includes
        padding.
    local_sizes: Shape of each local shard; needed to build checkpoint
        chunks and slice the local tensor during load.
ztuple[int, ...]Úglobal_shapeztuple[tuple[int, ...], ...]Úglobal_offsetsÚlocal_offsetsÚlocal_sizes© N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú__annotations__Ú__static_attributes__r   ó    Úf/home/luca/screen-checking/.venv/lib/python3.14/site-packages/torch/distributed/checkpoint/protocol.pyr	   r	      s!   ‡ ñð( "Ó!Ø/Ó/Ø.Ó.Ø,×,r   c               ó    € V ^8„  d   QhRRRR/# )é   ÚobjÚobjectÚreturnzTypeGuard[CheckpointableTensor]r   )Úformats   "r   Ú__annotate__r   )   s   € ÷ Sñ S 6ð SÐ.Mñ Sr   c                óf   € \        V \        P                  4      ;'       d    \        V \        4      # ©N)Ú
isinstanceÚtorchÚTensorr	   )r   s   &r   Ú_is_checkpointable_tensorr%   )   s#   € Ü�cœ5Ÿ<™<Ó(×RÐR¬Z¸Ô=QÓ-RÐRr   c               ó$   € V ^8„  d   QhRRRRRR/# )r   Úsrcr	   Údstútorch.Tensorr   ÚNoner   )r   s   "r   r   r   -   s$   € ÷ 1ñ 1Ø	ð1Ø$0ð1à	ñ1r   c                ó¾   € \        VR V P                  4       \        VRV P                  4       \        VRV P                  4       \        VRV P                  4       R# )r   r   r   r   N)Úsetattrr   r   r   r   )r'   r(   s   &&r   Ú$_copy_checkpointable_tensor_metadatar-   -   sK   € ô ˆC� ×!1Ñ!1Ô2ÜˆCÐ! 3×#5Ñ#5Ô6ÜˆC� #×"3Ñ"3Ô4ÜˆC� §¡Ö0r   c               ó    € V ^8„  d   QhRRRR/# )r   Útensorr	   r   zlist[ChunkStorageMetadata]r   )r   s   "r   r   r   6   s   € ÷ ñ Ø ðàñr   c           
     óö   € \        V 4       \        V P                  V P                  R R7       UUu. uF:  w  r\	        \
        P                  ! V4      \
        P                  ! V4      R7      NK<  	  upp# u uppi )T©Ústrict)ÚoffsetsÚsizes)Ú(_validate_checkpointable_tensor_metadataÚzipr   r   r   r#   ÚSize)r/   Úglobal_offsetÚ
local_sizes   &  r   Ú!_get_checkpointable_tensor_chunksr:   6   sq   € ô -¨VÔ4ô *-Ø×!Ñ!Ø×ÑØõ*
ô
ñ
*
Ñ%ˆMô	 	Ü—J’J˜}Ó-Ü—*’*˜ZÓ(÷	
ñ*
ò
ð 
ùó 
s   ±A A5c               ó$   € V ^8„  d   QhRRRRRR/# )r   r/   r	   Úindexr   r   r)   r   )r   s   "r   r   r   G   s&   € ÷ +ñ +Ø ð+àð+ð ñ+r   c           
     óä  € \        V 4       VP                  f8   \        V P                  4      ^8X  d   ^ pEM\	        RVP
                   R24      hVP                  er   VP                  \        V P                  4      8  dN   \        P                  ! V P                  VP                  ,          4      VP                  8X  d   VP                  pMvR
p\        V P                  4       F.  w  r4\        P                  ! V4      VP                  8X  g   K,  Tp M	  V^ 8  d'   \	        RVP                   RVP
                   R24      hV P                  V,          pV P                  V,          p\        V \        P                  4      '       g   \        R4      hT pV'       g   V# T\        ;QJ d%    . R \!        WVRR	7       4       F  NK  	  5,          # ! R \!        WVRR	7       4       4      ,          # )NzCannot lookup z2 with multiple checkpointable shards and no offsetz/Could not find checkpointable tensor shard at 'z' for FQN: 'Ú'ú0CheckpointableTensor must also be a torch.Tensorc              3  óJ   "  € T F  w  r\        WV,           4      x € K  	  R # 5ir!   )Úslice)Ú.0ÚoffsetÚsizes   &  r   Ú	<genexpr>Ú3_get_checkpointable_tensor_shard.<locals>.<genexpr>n   s%   é € ð 
á J‘�ô �& 4�-×(Ð(Û Jùs   ‚!#Tr1   éÿÿÿÿ)r5   rC   Úlenr   Ú
ValueErrorÚfqnr<   r#   r7   Ú	enumerater   r   r"   r$   Ú	TypeErrorÚtupler6   )r/   r<   Ú	shard_idxÚidxr8   Úlocal_offsetr9   Úlocal_tensors   &&      r   Ú _get_checkpointable_tensor_shardrR   G   s©  € ô -¨VÔ4à‡|�|ÒÜˆv×$Ñ$Ó%¨Ô*ØŠIäØ  §¡ Ð+]Ð^óð ð 	�‰ÒØ�K‰Kœ#˜f×3Ñ3Ó4Ô4Ü�JŠJ�v×,Ñ,¨U¯[©[Õ9Ó:¸e¿l¹lÔJà—K‘K‰	àˆ	Ü"+¨F×,AÑ,AÖ"BÑˆCÜ�zŠz˜-Ó(¨E¯L©LÖ8Ø�	Ùñ #Cð �qŒ=ÜØAÀ%Ç,Á,Àð PØ"ŸY™Y˜K qð*óð ð
 ×'Ñ'¨	Õ2€LØ×#Ñ# IÕ.€JÜ�fœeŸl™l×+Ò+ÜÐJÓKÐKØ€LßØÐØßŒñ 
ä # LÀTÕ Jó
�õð Øñ 
ä # LÀTÕ Jó
ó 	
õð r   c               ó    € V ^8„  d   QhRRRR/# )r   r/   r	   r   r*   r   )r   s   "r   r   r   u   s   € ÷ 2ñ 2Ð5Ið 2Èdñ 2r   c           
     óÒ  € \        V P                  4      p\        V P                  4      V8w  d   \        R 4      h\        V P                  4      V8w  d   \        R4      hV P
                  p\        V \        P                  4      '       g   \        R4      h\        V P                  4       4      p\        \        V P                  V P                  V P                  RR7      4       EF|  w  pw  rVp\        V4      \        V4      8w  d   \        RV R\        V4       R24      h\        V4      \        V4      8w  d   \        RV R\        V4       R24      h\        V4      \        V4      8w  d   \        R	V R\        V4       R24      h\        V4      \        V4      8w  d   \        R	V R\        V4       R
24      h\        \        WWVRR7      4       F6  w  pw  ršpV	^ 8  g   V
^ 8  g   Wš,           V8”  g   K&  \        RV RV R24      h	  \        \        WgVRR7      4       F6  w  pw  ršpV	^ 8  g   V
^ 8  g   Wš,           V8”  g   K&  \        RV RV R24      h	  EK  	  R# )z:global_offsets and local_offsets must have the same lengthz8global_offsets and local_sizes must have the same lengthr?   Tr1   zglobal_offsets[z] must have z dimensionszlocal_offsets[zlocal_sizes[z local dimensionszglobal shard z dimension z is outside global_shapezlocal shard z is outside tensor shapeN)rH   r   r   rI   r   r   r"   r#   r$   rL   rM   rD   rK   r6   )r/   Ú
num_shardsr   Útensor_shaperO   r8   rP   r9   ÚdimrC   rD   Ú
global_dimÚ	local_dims   &            r   r5   r5   u   si  € Ü�V×*Ñ*Ó+€JÜ
ˆ6×ÑÓ  JÔ.ÜÐUÓVÐVÜ
ˆ6×ÑÓ *Ô,ÜÐSÓTÐTà×&Ñ&€LÜ�fœeŸl™l×+Ò+ÜÐJÓKÐKÜ˜Ÿ™›Ó'€LÜ:CÜØ×!Ñ!Ø× Ñ Ø×ÑØô		
÷;Ñ6ˆÑ6ˆm¨:ô ˆ}Ó¤ \Ó!2Ô2ÜØ! #  l´3°|Ó3DÐ2EÀ[ÐQóð ô ˆ|Ó¤ LÓ 1Ô1ÜØ    \´#°lÓ2CÐ1DÀKÐPóð ô ˆz‹?œc ,Ó/Ô/ÜØ˜s˜e <´°LÓ0AÐ/BÀ+ÐNóð ô ˆz‹?œc ,Ó/Ô/ÜØ˜s˜e <´°LÓ0AÐ/BÐBSÐTóð ô 09Ü�¨<ÀÔEö0
Ñ+ˆCÑ+�& 
ð ˜Œz˜T AœX¨­¸Ö)CÜ Ø# C 5¨°C°5Ð8PÐQóð ñ	0
ô /8Ü�¨,¸tÔDö/
Ñ*ˆCÑ*�& 	ð ˜Œz˜T AœX¨­¸Ö)BÜ Ø" 3 % {°3°%Ð7OÐPóð ô	/
óC;r   )Ú
__future__r   Útypingr   r   r   r#   Úmetadatar   r   Ú__all__r	   r%   r-   r:   rR   r5   r   r   r   Ú<module>r^      sT   ðÝ "ç 9Ñ 9ã ç 9ð "Ð
"€ð ô-˜8ó -ó ð-õ6Sõ1õõ"+÷\2r   