+
    –°³jI  ã                   óà   € ^ RI t ^ RIt^ RIHtHt ^ RIHt ^ RIHt ^ RI	H
t
 ^ RIHt ^ RIHt ^ RIHtHtHtHt ]
'       d   ^ R	IHt R
R.t ! R R]4      t ! R R
]4      t ! R R]4      tR# )é    N)Ú	GeneratorÚSequence)Úcontextmanager)ÚPath)ÚTYPE_CHECKING)Ú	url_to_fs)ÚStreamTransformExtension)ÚFileSystemBaseÚFileSystemReaderÚFileSystemWriterÚSerializationFormat)ÚAbstractFileSystemÚFsspecWriterÚFsspecReaderc                   óè   a € ] tR t^ t o V 3R lR lt]V 3R lR l4       tV 3R lR ltV 3R lR ltV 3R	 lR
 lt	V 3R lR lt
]V 3R lR l4       tV 3R lR ltV 3R lR ltV 3R lR ltRtV tR# )Ú
FileSystemc                ó   <€ V ^8„  d   QhRR/# )é   ÚreturnN© )ÚformatÚ__classdict__s   "€Úp/home/luca/screen-checking/.venv/lib/python3.14/site-packages/torch/distributed/checkpoint/_fsspec_filesystem.pyÚ__annotate__ÚFileSystem.__annotate__!   s   ø€ ÷ 2ñ 2˜$ñ 2ó    c                ó   € R V n         R # ©N©Úfs)Úselfs   &r   Ú__init__ÚFileSystem.__init__!   s	   € Ø-1ˆŽr   c          	      óz   <€ V ^8„  d   QhRS[ S[P                  ,          RS[ RS[S[P
                  RR3,          /# )r   ÚpathÚmoder   N)ÚstrÚosÚPathLiker   ÚioÚIOBase)r   r   s   "€r   r   r   %   s>   ø€ ÷ ñ Ù™"Ÿ+™+Õ%ðÙ-0ðá	‘2—9‘9˜d DÐ(Õ	)ñr   c              #  ó¼  a"  € V P                   f   \        R4      h\        P                  ! V4      pV P                   P	                  VS4      ;_uu_ 4       p Vx €  R R R 4       R #    \
        ;QJ d    T3R lR 4       F  '       g   K   RM	  RM! T3R lR 4       4      '       d    T P                  T4       h     h ; ih ; i  + '       g   i     R # ; i5i)Nzfs should not be Nonec              3   ó,   <"  € T F	  qS9   x € K  	  R # 5ir   r   )Ú.0Úchr&   s   & €r   Ú	<genexpr>Ú+FileSystem.create_stream.<locals>.<genexpr>3   s   øé € Ð2©E b˜T–z«Eùs   ƒzw+aTF)r    ÚAssertionErrorr(   ÚfspathÚopenÚanyÚrm_file)r!   r%   r&   Ústreams   &&f r   Úcreate_streamÚFileSystem.create_stream$   s­   øé € ð �7‰7Š?Ü Ð!8Ó9Ð9Ü�yŠy˜‹ˆð
 �W‰W�\‰\˜$ ×%Ô%¨ðØ“÷ &Ñ%øðß“3Ô2©EÓ2—3—3’3Ô2©EÓ2×2Ò2ðØŸ™ TÔ*ð øðØØú�ú÷ &×%Ð%üsN   ƒACÁCÁA(Á
CÁ(!CÂCÂ+B=Â<CÂ=C	Â?CÃCÃC	Ã	Cc                ót   <€ V ^8„  d   QhRS[ S[P                  ,          RS[ RS[ S[P                  ,          /# )r   r%   Úsuffixr   ©r'   r(   r)   )r   r   s   "€r   r   r   :   s4   ø€ ÷ *ñ *¡¡b§k¡kÕ 1ð *¹3ð *Á3ÉÏÉÕCTñ *r   c                ó@   € \         P                  P                  W4      # r   )r(   r%   Újoin)r!   r%   r;   s   &&&r   Úconcat_pathÚFileSystem.concat_path:   s   € Ü�w‰w�|‰|˜DÓ)Ð)r   c                ón   <€ V ^8„  d   QhRS[ S[P                  ,          RS[ S[P                  ,          /# ©r   r%   r   r<   )r   r   s   "€r   r   r   =   s-   ø€ ÷ ñ ™c¡B§K¡KÕ/ð ¹cÁBÇKÁKÕ>Oñ r   c                ó.   € \        V3/ VB w  V n        pV# r   )r   r    )r!   r%   ÚkwargsÚ_s   &&, r   Ú	init_pathÚFileSystem.init_path=   s   € Ü˜tÑ. vÑ.‰
ˆŒ�Øˆr   c                ór   <€ V ^8„  d   QhRS[ S[P                  ,          RS[ S[P                  ,          RR/# )r   r%   Únew_pathr   Nr<   )r   r   s   "€r   r   r   A   s4   ø€ ÷ 'ñ '™3¡§¡Õ,ð '¹¹b¿k¹kÕ8Ið 'Èdñ 'r   c                ó<   € V P                   P                  W4       R # r   )r    Úrename)r!   r%   rI   s   &&&r   rK   ÚFileSystem.renameA   s   € Ø�‰�‰�tÖ&r   c                óH   <€ V ^8„  d   QhRS[ S[P                  ,          RR/# ©r   r%   r   Nr<   )r   r   s   "€r   r   r   D   s$   ø€ ÷ .ñ .™#¡§¡Õ+ð .°ñ .r   c                ó@   € V P                   P                  VR R7       R# )T)Úexist_okN)r    Úmakedirs©r!   r%   s   &&r   ÚmkdirÚFileSystem.mkdirD   s   € Ø�‰×Ñ˜¨ÐÖ-r   c                óJ   <€ V ^8„  d   QhRS[ S[P                  ,          RS[/# ©r   Úcheckpoint_idr   ©r'   r(   r)   Úbool)r   r   s   "€r   r   r   H   s$   ø€ ÷ 	ñ 	±3¹¿¹Õ3Dð 	Éñ 	r   c                ór   € \        V\        4      '       d   R #  \        V4       R#   \         d     R # i ; i)FT)Ú
isinstancer   r   Ú
ValueError©ÚclsrW   s   &&r   Úvalidate_checkpoint_idÚ!FileSystem.validate_checkpoint_idG   s8   € ä�m¤T×*Ò*Ùð	Ü�mÔ$ñ øô ô 	Úð	ús   š' §6µ6c                óJ   <€ V ^8„  d   QhRS[ S[P                  ,          RS[/# rB   rX   )r   r   s   "€r   r   r   S   s$   ø€ ÷ $ñ $™3¡§¡Õ,ð $±ñ $r   c                ó8   € V P                   P                  V4      # r   )r    ÚexistsrR   s   &&r   rc   ÚFileSystem.existsS   s   € Ø�w‰w�~‰~˜dÓ#Ð#r   c                óH   <€ V ^8„  d   QhRS[ S[P                  ,          RR/# rN   r<   )r   r   s   "€r   r   r   V   s$   ø€ ÷ ñ ™C¡"§+¡+Õ-ð °$ñ r   c                ó<   € V P                   P                  V4       R # r   )r    ÚrmrR   s   &&r   r6   ÚFileSystem.rm_fileV   s   € Ø�‰�
‰
�4Ör   c                óZ   <€ V ^8„  d   QhRS[ S[P                  ,          RS[S[ ,          /# rB   )r'   r(   r)   Úlist)r   r   s   "€r   r   r   Y   s(   ø€ ÷ .ñ .‘s™RŸ[™[Õ(ð .©T±#­Yñ .r   c                ó<   € V P                   P                  VR R7      # )F)Údetail)r    ÚlsrR   s   &&r   rm   ÚFileSystem.lsY   s   € ð �w‰w�z‰z˜$ uˆzÓ-Ð-r   r   N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__r"   r   r8   r?   rF   rK   rS   Úclassmethodr_   rc   r6   rm   Ú__static_attributes__Ú__classdictcell__)r   s   @r   r   r       s}   ø‡ € ÷2ð 2ð ÷ó ð÷**ð *÷ð ÷'ð '÷.ð .ð ÷	ó ð	÷$ð $÷ð ÷.ö .r   r   c                   ó„   a a€ ] tR t^`t oRtRR^RRR]P                  3V3R lV 3R lllt]V3R lR l4       t	R	t
VtV ;t# )
r   aD  
Basic implementation of StorageWriter using fsspec.

This implementation makes the following assumptions and simplifications:

* The checkpoint path is an empty or non-existing directory.
* File creation is atomic

The checkpoint consist of one file per write request plus
a `.metadata` file with the serialized metadata.

Ti€–˜ Nc                ó�   <€ V ^8„  d   QhRS[ S[P                  ,          RS[RS[RS[RS[RS[RS[S[,          R,          R	S[R
R/	# )r   r%   Úsingle_file_per_rankÚ
sync_filesÚthread_countÚper_thread_copy_aheadÚ	overwriteÚ_extensionsNÚserialization_formatr   )r'   r(   r)   rY   Úintr   r	   r   )r   r   s   "€r   r   ÚFsspecWriter.__annotate__n   sy   ø€ ÷ %6ñ %6á‘B—K‘KÕð%6ñ #ð%6ñ ð	%6ñ
 ð%6ñ  #ð%6ñ ð%6ñ Ñ6Õ7¸$Õ>ð%6ñ 2ð%6ð 
ñ%6r   c	                ó˜   <€ \         S
V `  VVVVVVVVR7       \        4       V n        V P                  P                  ! V3/ V	B V n        R# )aå  
Initialize the writer pointing to `path`.

Args:
    path: directory where the checkpoint will be written to.
    single_file_per_rank: Produce one file per rank instead of one file per tensor/blob. Default to True.
    sync_files : force files to be synced to permanent storage. Default to True.
    thread_count: Number of IO threads to use to write. Default to 1.
    per_thread_copy_ahead: How many bytes to copy from the GPU ahead of saving them. Default 10Mb.
    overwrite: Whether to allow overwriting existing checkpoints. Defaults to True.
    _extensions: Extensions to apply to output streams (EXPERIMENTAL)

N. B. If sync_files is disabled, there's no guarantee that the checkpoint will be consistent in the case of a failure.
)r|   r}   r~   N©Úsuperr"   r   r    rF   r%   )r!   r%   rx   ry   rz   r{   r|   r}   r~   rD   Ú	__class__s   &&&&&&&&&,€r   r"   ÚFsspecWriter.__init__n   sU   ø€ ô4 	‰ÑØØ ØØØ!ØØ#Ø!5ð 	ô 		
ô “,ˆŒØ—G‘G×%Ò% dÑ5¨fÑ5ˆŽ	r   c                óJ   <€ V ^8„  d   QhRS[ S[P                  ,          RS[/# rV   rX   )r   r   s   "€r   r   r€   –   ó(   ø€ ÷ @ñ @±3¹¿¹Õ3Dð @Éñ @r   c                ó,   € \         P                  V4      # r   ©r   r_   r]   s   &&r   r_   Ú#FsspecWriter.validate_checkpoint_id•   ó   € ä×0Ñ0°Ó?Ð?r   ©r    r%   )ro   rp   rq   rr   Ú__doc__r   Ú
TORCH_SAVEr"   rs   r_   rt   ru   Ú__classcell__©r„   r   s   @@r   r   r   `   sN   ù‡ € ñð  &*ØØØ%/ØØAEØ4G×4RÑ4R÷%6õ %6ðN ÷@ó ÷@ð @r   c                   óZ   a a€ ] tR t^št oV3R lV 3R llt]V3R lR l4       tRtVtV ;t	# )r   c                óH   <€ V ^8„  d   QhRS[ S[P                  ,          RR/# rN   r<   )r   r   s   "€r   r   ÚFsspecReader.__annotate__›   s$   ø€ ÷ 6ñ 6™S¡2§;¡;Õ.ð 6¸Tñ 6r   c                óˆ   <€ \         SV `  V4       \        4       V n        V P                  P                  ! V3/ VB V n        R # r   r‚   )r!   r%   rD   r„   s   &&,€r   r"   ÚFsspecReader.__init__›   s4   ø€ Ü‰Ñ˜ÔÜ“,ˆŒØ—G‘G×%Ò% dÑ5¨fÑ5ˆŽ	r   c                óJ   <€ V ^8„  d   QhRS[ S[P                  ,          RS[/# rV   rX   )r   r   s   "€r   r   r“   ¡   r‡   r   c                ó,   € \         P                  V4      # r   r‰   r]   s   &&r   r_   Ú#FsspecReader.validate_checkpoint_id    r‹   r   rŒ   )
ro   rp   rq   rr   r"   rs   r_   rt   ru   r�   r�   s   @@r   r   r   š   s+   ù‡ € ÷6ó 6ð
 ÷@ó ÷@ð @r   )r*   r(   Úcollections.abcr   r   Ú
contextlibr   Úpathlibr   Útypingr   Úfsspec.corer   Ú'torch.distributed.checkpoint._extensionr	   Ú'torch.distributed.checkpoint.filesystemr
   r   r   r   Úfsspecr   Ú__all__r   r   r   r   r   r   Ú<module>r¢      sl   ðó 
Û 	ß /Ý %Ý Ý  å !å L÷ó ÷ Ý)ð Øð€ô<.�ô <.ô@7@Ð#ô 7@ôt@Ð#ö @r   