+
    –°³jÕ  ã                   ó  € R 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 ^RIHtHtHt ^RIHtHt ^R	IHt ^R
IHt ^RIHt R R ltR R ltR R lt]! 4       RR3R R llt]! 4       R]R]R3R R lltR# )a  
Factory functions for creating checkpointer instances with sensible defaults.

This module provides high-level factory functions that simplify the creation
of checkpointer instances by automatically handling component initialization
and configuration with reasonable defaults.
)ÚCallable©ÚAnyN)Úcreate_barrier_from_config)ÚCheckpointProcess)ÚCheckpointReader)ÚCheckpointWriterÚCheckpointWriterConfigÚ
WriterHook)ÚAsyncCheckpointerÚSyncCheckpointer)ÚCheckpointerConfig)ÚDefaultStager©ÚRankInfoc                ó$   € V ^8„  d   QhR\         /# )é   Úreturnr   )Úformats   "Ús/home/luca/screen-checking/.venv/lib/python3.14/site-packages/torch/distributed/checkpoint/_experimental/builder.pyÚ__annotate__r      s   € ÷ <ñ <¤ñ <ó    c                 ó¸   € \         P                  ! 4       '       d4   \        \         P                  ! 4       \         P                  ! 4       R7      # \        ^^ R7      # )zÍ
Get default rank information from the current distributed environment.

Returns:
    RankInfo: Rank information from the default process group if initialized,
             otherwise single-rank fallback.
)Úglobal_world_sizeÚglobal_rank)ÚdistÚis_initializedr   Úget_world_sizeÚget_rank© r   r   Ú_get_default_rank_infor       sD   € ô ×Ò×ÒÜÜ"×1Ò1Ó3ÜŸš›ô
ð 	
ô ¨!¸Ô;Ð;r   c                ó(   € V ^8„  d   QhR\         RR/# )r   Ú_r   Nr   )r   s   "r   r   r   *   s   € ÷ >ñ >¤3ð >¨4ñ >r   c                 ó   € R# )z3Default subprocess initialization function (no-op).Nr   )r"   s   *r   Údefault_subprocess_init_fnr$   *   s   ‚ r   c                ó0   € V ^8„  d   QhR\         R\        /# )r   Ú	rank_infor   )r   r   )r   s   "r   r   r   .   s   € ÷ ñ ¤hð Ô3Cñ r   c                ó,   € \        \        4       V R7      # )z2Default checkpoint writer initialization function.)Úconfigr&   )r   r	   ©r&   s   &r   Údefault_writer_init_fnr*   .   s   € äÜ%Ó'Øôð r   c                ód   € V ^8„  d   QhR\         R\        R,          R\        R,          R\        /# )r   r(   r&   NÚcommit_hookr   )r   r   r
   r   )r   s   "r   r   r   6   s9   € ÷ 8ñ 8Üð8ä˜$�ð8ô ˜dÕ"ð8ô ñ	8r   c                ó¬   € Vf   \        4       p\        VR7      p\        V P                  4      p\	        V P
                  VVVR7      p\        VVR7      # )a-  
Factory function to create a SyncCheckpointer instance with sensible defaults.

This function creates a synchronous checkpointer with default components, automatically
detecting rank information from the default process group if available, and using the
provided component configurations.

Args:
    config: CheckpointerConfig containing component-specific configurations
           (writer_config, staging_config, process_config). Defaults to CheckpointerConfig().
    rank_info: RankInfo for distributed training. Defaults to auto-detection from
              the default PyTorch distributed process group if initialized, otherwise
              falls back to single-rank (world_size=1, rank=0).
    commit_hook: Optional hook for custom actions before and after checkpoint commits.

Returns:
    SyncCheckpointer: A configured synchronous checkpointer instance.

Examples:
    # Simplest usage - auto-detect rank, default config
    checkpointer = make_sync_checkpointer()

    # Explicit rank configuration
    checkpointer = make_sync_checkpointer(
        rank_info=RankInfo(global_world_size=4, global_rank=0)
    )

    # Disable barrier
    from .barriers import BarrierConfig
    config = CheckpointerConfig(barrier_config=BarrierConfig(barrier_type=None))
    checkpointer = make_sync_checkpointer(config=config)
r)   )r(   r&   Úbarrierr,   )ÚwriterÚreader)r    r   r   Úbarrier_configr   Úwriter_configr   )r(   r&   r,   r0   r.   r/   s   &&&   r   Úmake_sync_checkpointerr3   6   sc   € ðJ ÒÜ*Ó,ˆ	äØô€Fô )¨×)>Ñ)>Ó?€GäØ×#Ñ#ØØØô	€Fô ØØôð r   c                óì   € V ^8„  d   QhR\         R\        R,          R\        R
,          R\        \        R3,          R\        R\
        3,          R\        \        \        3,          R,          R	\        /# )r   r(   r&   NÚsubprocess_init_fn.Úsubprocess_init_argsÚcheckpoint_writer_init_fnÚcheckpoint_writer_init_argsr   ).N)	r   r   r   Útupler   r   ÚdictÚstrr   )r   s   "r   r   r   q   sw   € ÷ =ñ =Üð=ä˜$�ð=ô ! Õ+ð=ô  ¤ S �/ð	=ô
  (¨Ô-=Ð(=Õ>ð=ô "&¤c¬3 h¥°$Õ!6ð=ô ñ=r   c           	     óÌ   € Vf   \        4       p\        VR7      p\        V P                  R7      pT;'       g    / p\	        VV P
                  VVVVR7      p\        VVVR7      # )a#  
Factory function to create an AsyncCheckpointer instance with sensible defaults.

This function creates an asynchronous checkpointer using the provided configuration,
automatically detecting rank information if not provided.

Args:
    config: CheckpointerConfig containing component-specific configurations.
    rank_info: RankInfo for distributed training. Defaults to auto-detection.
    subprocess_init_fn: Function to initialize the subprocess. Defaults to no-op.
    subprocess_init_args: Arguments to pass to subprocess_init_fn.
    checkpoint_writer_init_fn: Function to create CheckpointWriter instance.
    checkpoint_writer_init_args: Arguments to pass to checkpoint_writer_init_fn.

Returns:
    AsyncCheckpointer: A configured asynchronous checkpointer instance.

Examples:
    # Create with default config
    checkpointer = make_async_checkpointer()

    # Create with custom init functions
    checkpointer = make_async_checkpointer(
        subprocess_init_fn=my_subprocess_init_fn,
        checkpoint_writer_init_fn=my_writer_init_fn
    )
r)   )r(   )r&   r(   r5   r6   r7   r8   )Úcheckpoint_stagerÚcheckpoint_processr0   )r    r   r   Ústaging_configr   Úprocess_configr   )	r(   r&   r5   r6   r7   r8   r0   r=   r>   s	   &&&&&&   r   Úmake_async_checkpointerrA   q   s�   € ðF ÒÜ*Ó,ˆ	äØô€Fô &Ø×$Ñ$ôÐð #>×"CÐ"CÀÐä*ØØ×$Ñ$Ø-Ø1Ø";Ø$?ôÐô Ø+Ø-Øôð r   r   ) Ú__doc__Úcollections.abcr   Útypingr   Útorch.distributedÚdistributedr   Úbarriersr   r>   r   Úcheckpoint_readerr   Úcheckpoint_writerr   r	   r
   Úcheckpointerr   r   r(   r   Ústagingr   Útypesr   r    r$   r*   r3   rA   r   r   r   Ú<module>rM      st   ðñõ %Ý å  å 0Ý 1Ý /ß SÑ Sß =Ý &Ý "Ý õ<õ$>õñ "4Ó!5Ø!%Ø%)÷8ñx "4Ó!5Ø!%Ø.HØ,.ØAWØ9=÷=ñ =r   