+
    –°³j%:  ã                   ó¬  € ^ RI t ^ RIt^ RIt^ RIt^ RIHtHtHt ^ RIH	t	 ^ RI
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 ^R
IHt ^RIHtHtH t  ]'       d   ^ RI!H"t" RR.t#]PH                  ! 4       t%]	! R]&R7      R!R R ll4       t']! RR7      ]RRRRRRRRRR/R R ll4       4       t(R!R R llt)R"RRRRRR/R R  lllt*R# )#é    N)ÚAnyÚcastÚTYPE_CHECKING)Ú
deprecated)Ú_EmptyStateDictLoadPlanner)Ú_dcp_method_logger)ÚStateful)Ú_storage_setup)ÚDefaultLoadPlanner)ÚLoadPlanÚLoadPlanner)ÚStorageReader)Ú_api_bc_checkÚ_DistWrapperÚ_profile)ÚMetadataÚload_state_dictÚloadzb`load_state_dict` is deprecated and will be removed in future versions. Please use `load` instead.)ÚcategoryFc                ó¶   € V ^8„  d   QhR\         \        \        3,          R\        R\        P
                  R,          R\        R\        R\        R,          RR/# ©	é   Ú
state_dictÚstorage_readerÚprocess_groupNÚcoordinator_rankÚno_distÚplannerÚreturn©	ÚdictÚstrr   r   ÚdistÚProcessGroupÚintÚboolr   )Úformats   "Úo/home/luca/screen-checking/.venv/lib/python3.14/site-packages/torch/distributed/checkpoint/state_dict_loader.pyÚ__annotate__r)   $   sf   € ÷ 
ñ 
Ü”Sœ#�X•ð
ä!ð
ô ×$Ñ$ tÕ+ð
ô ð	
ô
 ð
ô ˜4Õð
ð 
ñ
ó    c           
     ó¤   € VP                  4        \        4       ;_uu_ 4        \        V VVVVV4      uuRRR4       #   + '       g   i     R# ; i)z3This method is deprecated. Please switch to 'load'.N)Úresetr   Ú_load_state_dict)r   r   r   r   r   r   s   &&&&&&r(   r   r      s=   € ð ×ÑÔÜ	��äØØØØØØó
÷ 
��‹ús	   £>¾A	T)Úlog_exceptionsÚcheckpoint_idr   r   r   r   c                óü   € V ^8„  d   QhR\         \        \        3,          R\        \        P                  ,          R,          R\
        R,          R\        R,          R\        P                  R,          R\        RR/# )	r   r   r/   Nr   r   r   r   r   )
r!   r"   r   ÚosÚPathLiker   r   r#   r$   r&   )r'   s   "r(   r)   r)   <   s„   € ÷ L3ñ L3Ü”Sœ#�X•ðL3ô œŸ™Õ$ tÕ+ðL3ô " DÕ(ð	L3ô
 ˜4ÕðL3ô ×$Ñ$ tÕ+ðL3ô ðL3ð 
ñL3r*   c               óæ  € T;'       g=    \         P                  ! 4       '       * ;'       g    \         P                  ! 4       '       * pV'       d   \        P                  ! R^R7       \        4       ;_uu_ 4        \        \        \        W!RR7      4      p\        V P                  4       4      p/ pV F=  pW€9  d   K  W,          p	\        V	\        4      '       d   V	P                  4       MT	Wx&   K?  	  \        VVVVVR7       V FL  pW€9  d   K  W,          p	\        V	\        4      '       d   V	P                  Wx,          4       KB  Wx,          W&   KN  	  RRR4       R#   + '       g   i     R# ; i)a  
Load a checkpoint into a distributed state dict in SPMD style.

Each rank must have the same keys in their ``state_dict`` provided to this
API. Mismatched keys may result in hangs or errors. If unsure, you can use
the ``utils._assert_same_keys`` API to check (but may incur communication
costs).

Each rank will try to read the least amount of data necessary
to fulfill the requested `state_dict`. When loading :class:`ShardedTensor`
or :class:`DTensor` instances, each rank only reads data for their local shards.

For each ``Stateful`` object (having both a ``state_dict`` and a ``load_state_dict``),
load will first call ``state_dict`` before attempting deserialization, followed by
``load_state_dict`` once the deserialization is complete.
For each non-``Stateful`` object, load will deserialize the object, and then replace
it in the ``state_dict`` with the deserialized object.

.. warning::
    All tensors in ``state_dict`` must be allocated on their
    destination device *prior to* calling this function.

    All non-tensor data is loaded using `torch.load()` and modified in place
    on state_dict.

.. warning::
    Users must call `load_state_dict` on the root module to ensure load
    post-processing and non-tensor data properly propagates.

.. note:
    If no process group is initialized, this function will assume the intent
    is to load a checkpoint into the local process. This can be useful in the
    case of local inference, and when using regular Tensors (as opposed to DTensor
     or ShardedTensor)

.. note:
    Rank 0 is assumed to be the coordinator rank.

Args:
    state_dict (Dict[str, Any]): The state_dict to load the checkpoint into.
    checkpoint_id (Union[str, os.PathLike, None]):
        The ID of this checkpoint instance. The meaning of the checkpoint_id
        depends on the storage. It can be a path to a folder or to a file.
        It can also be a key if the storage is a key-value store.
        (Default: ``None``)
    storage_reader (Optional[StorageReader]):
        Instance of StorageWriter used to perform reads. If this is not
        specified, DCP will automatically infer the reader based on the
        checkpoint_id. If checkpoint_id is also None, an exception will
        be raised. (Default: ``None``)
    planner (Optional[LoadPlanner]):
        Instance of LoadPlanner. If this is not specified, the default
        planner will be used. (Default: ``None``)
    process_group (Optional[ProcessGroup]):
        ProcessGroup to be used for cross-rank synchronization.
        (Default: ``None``)
    no_dist (bool): If ``True``, this function will assume the intent is to load
        a checkpoint without using cross-rank synchronization. (Default: ``False``)
Returns:
    None.

Examples
    >>> # xdoctest: +SKIP
    >>> my_model = MyModule()
    >>> optimizer = Adagrad(my_model.parameters())
    >>> model_state_dict = my_model.state_dict()
    >>> fs_storage_reader = torch.distributed.checkpoint.FileSystemReader(
    ...     "/checkpoint/1"
    ... )

    >>> torch.distributed.checkpoint.load_state_dict(
    >>>     state_dict=model_state_dict,
    >>>     storage_reader=fs_storage_reader,
    >>> )

    >>> # module.load_state_dict() function might have customized steps
    >>> # to flush the state_dict, must call it to
    >>> # ensure correct behavior.
    >>> my_model.load_state_dict(model_state_dict)

.. note::
    load_state_dict uses collectives to coordinate reads across ranks.
    For NCCL-based process groups, internal tensor representations of
    objects must be moved to the GPU device before communication takes place.
    In this case, the device used is given by ``torch.cuda.current_device()``
    and it is the user's responsibility to ensure that this is set so that each
    rank has an individual GPU, via ``torch.cuda.set_device()``.
zptorch.distributed is disabled, unavailable or uninitialized, assuming the intent is to load in a single process.©Ú
stacklevelT©Úreader©r   r   r   r   r   N)r#   Úis_availableÚis_initializedÚwarningsÚwarnr   r   r   r
   ÚsortedÚkeysÚ
isinstancer	   r   r-   r   )
r   r/   r   r   r   r   r>   Ústateful_sdÚkeyÚelems
   &$$$$$    r(   r   r   :   s$  € ðH ×QÐQœd×/Ò/Ó1Ô1×QÐQ¼4×;NÒ;NÓ;PÔ7P€GßÜ�ŠØ~Øõ	
ô
 
��ÜÜœ>¨.ÐPTÔUó
ˆô �j—o‘oÓ'Ó(ˆàˆÛˆCØÔ$ÙØ•?ˆDÜ4>¸tÄX×4NÒ4N˜tŸ™Ô0ÐTXˆKÓñ	 ô 	Ø"Ø)Ø'ØØõ	
ó ˆCØÔ$ÙØ•?ˆDÜ˜$¤×)Ò)ð ×$Ñ$ [Õ%5Ö6ð #.Õ"2�
“ñ ÷3 
��Šús   Á9CEÅE0	c                ó¶   € V ^8„  d   QhR\         \        \        3,          R\        R\        P
                  R,          R\        R\        R\        R,          RR/# r   r    )r'   s   "r(   r)   r)   Ë   so   € ÷ rñ rÜ”Sœ#�X•ðrä!ðrô ×$Ñ$ tÕ+ðrô ð	rô
 ðrô ˜4Õðrð 
ñrr*   c                 ó>  a aaaaaa€ \         P                  P                  R 4       \        W$'       * V4      oSf   \	        4       o/ p\        SRR4      ;pe   WvR&   SP                  VR&   RoRo\        R
/ VB VVVV VV3R l4       p\        R
/ VB VV3R l4       p	RoS'       d   SP                  RW‰4      oMV! 4       p
V	! V
.4      pV^ ,          o\        R
/ VB VVV3R l4       pS'       d   SP                  R	V4      pR# V! 4        SP                  4        R# )z,torch.distributed.checkpoint.load_state_dictNr/   r   Tc                  óÌ  <€ R p R p S	P                  4       oS'       gO   R\        P
                  ! S	P                   4      P                  9   d     S	P                  SP                  R7      oRo
Sf   \        R4      hSfN   R	.pV e   VP                  R
V  24       Ve   VP                  RV 24       \        RP                  V4      4      hSP                  SSSP                  4       R\        P
                  ! S	P                  4      P                  9   d+   S	P                  SSP                  SP                  S
R7       MS	P                  SSP                  4       SP                  4       pS	P                  V4      pV#   \         d%   pTp \        P                  RRR7        R p?EL•R p?ii ; i  \         d%   pTp\        P                  RRR7        R p?ELqR p?ii ; i)NzBGlobal metadata is not found. Falling back to rank local metadata.T)Úexc_infoÚkwargs)ÚrankFz!Rank local metadata is not found.úplanner is Nonezmetadata is Nonezglobal metadata read failed: z!rank local metadata read failed: z; )rH   Úuse_collectives)Úread_metadataÚ	ExceptionÚloggerÚwarningÚinspectÚ	signatureÚ
parametersrH   ÚAssertionErrorÚappendÚjoinÚset_up_plannerÚis_coordinatorÚset_up_storage_readerÚcreate_local_planÚprepare_local_plan)Úglobal_metadata_excÚrank_metadata_excÚeÚerror_partsÚ
local_planÚdistWÚmetadatar   r   r   rJ   s        €€€€€€r(   Ú
local_stepÚ$_load_state_dict.<locals>.local_stepá   sé  ø€ ð 15ÐØ.2Ðð	Ø%×3Ñ3Ó5ˆH÷ ØœG×-Ò-¨n×.JÑ.JÓK×VÑVÔVðSØ)×7Ñ7¸U¿Z¹ZÐ7ÓH�Ø"'�ð
 Š?Ü Ð!2Ó3Ð3ØÒØ-Ð.ˆKØ"Ò.Ø×"Ñ"Ø3Ð4GÐ3HÐIôð !Ò,Ø×"Ñ"Ø7Ð8IÐ7JÐKôô ! §¡¨;Ó!7Ó8Ð8Ø×Ñ˜z¨8°U×5IÑ5IÔJð Ü× Ò  ×!EÑ!EÓF×QÑQôRð ×0Ñ0ØØ×$Ñ$Ø—Z‘ZØ /ð	 1õ ð ×0Ñ0°¸5×;OÑ;OÔPà×.Ñ.Ó0ˆ
Ø#×6Ñ6°zÓBˆ
ØÐøôa ô 	Ø"#ÐÜ�N‰NØTØð ÷ ò ûð	ûô ô SØ$%Ð!Ü—‘ÐBÈT�×RÒRûðSús/   ‡F ÁF4 ÆF1ÆF,Æ,F1Æ4G#Æ?GÇG#c                 ój   <€ Sf   \        R4      hSP                  V 4      p SP                  V 4      p V # )NrI   )rR   Úcreate_global_planÚprepare_global_plan)Úall_local_plansr   r   s   &€€r(   Úglobal_stepÚ%_load_state_dict.<locals>.global_step  s:   ø€ àŠ?Ü Ð!2Ó3Ð3Ø!×4Ñ4°_ÓEˆØ(×<Ñ<¸_ÓMˆØÐr*   Úplanc                  óª   <€ Sf   \        R4      hSf   \        R4      hSP                  S4      p SP                  V S4      pVP                  4        R # )NrI   zcentral_plan is None)rR   Úfinish_planÚ	read_dataÚwait)Úfinal_local_planÚ	all_readsÚcentral_planr   r   s     €€€r(   rl   Ú#_load_state_dict.<locals>.read_data-  sW   ø€ àŠ?Ü Ð!2Ó3Ð3ØÒÜ Ð!7Ó8Ð8Ø"×.Ñ.¨|Ó<ÐØ"×,Ñ,Ð-=¸wÓGˆ	à�‰ÔÙr*   Úread© )ÚtorchÚ_CÚ_log_api_usage_oncer   r   ÚgetattrÚgroupr   Úreduce_scatterÚ
all_gatherÚbarrier)r   r   r   r   r   r   Úckpt_kwargsÚckpt_idra   rg   r^   Úglobal_planrl   Ú_rp   r_   r`   rJ   s   ff&&&f        @@@@r(   r-   r-   Ë   s   þ€ ô 
‡H�H× Ñ Ð!OÔPä˜¬Ð5EÓF€EØ‚Ü$Ó&ˆà€KÜ˜>¨?¸DÓAÐAˆÒNØ'.�OÑ$Ø',§{¡{ˆ�OÑ$à€OØ $€HäÑ&˜+Ñ&÷9ñ 9ó 'ð9ôv Ñ&˜+Ñ&õó 'ðð %)€LßØ×+Ñ+¨F°JÓL‰á)›|ˆ
Ù&1°:°,Ó&?ˆØ" 1•~ˆäÑ&˜+Ñ&ö	ó 'ð	÷ Ø×Ñ˜V YÓ/ŠáŒØ�‰Žr*   c                ó  € V ^8„  d   QhR\         \        ,          \        ,          R,          R\        \        P                  ,          R,          R\        R,          R\
        P                  R,          R\        \        \        3,          /# )r   r>   Nr/   r   r   r   )	Úsetr"   r1   r2   r   r#   r$   r!   r   )r'   s   "r(   r)   r)   @  sv   € ÷ Qñ QÜ
Œc�(”S�.˜4Õ
ðQô œŸ™Õ$ tÕ+ðQô " DÕ(ð	Qô
 ×$Ñ$ tÕ+ðQô 
Œ#Œsˆ(…^ñQr*   c          
     ó’  € \         P                  P                  R4       \        P                  ! 4       ;'       d    \        P
                  ! 4       '       * pV'       d   \        P                  ! R^R7       \        \        \        W!RR7      4      p\        V \        4      '       d   V 0p / p\        VVVV\        V R7      R7       V# )aí  
Load only the specified keys from the checkpoint, if no keys are specified, the entire
checkpoint will be loaded. Note, this method completely loads the checkpoint into the
current process and is not distributed.

.. warning::


.. warning::

    All non-tensor data is loaded using `torch.load()`

.. note:
    As opposed to the usual pattern, this function does not take a state dict as input
    and does not load inplace. Instead, a new state dict is directly initialized and read
    from file.

.. note:
    If no process group is initialized, this function will assume the intent
    is to load a checkpoint into the local process. This can be useful in the
    case of local inference, and when using regular Tensors (as opposed to DTensor
     or ShardedTensor)

.. note:
    Rank 0 is assumed to be the coordinator rank.

Args:
    keys (Optional[Union[set[str], str]]):
        Loads any key specified in this set. If no keys are specified, the entire checkpoint
        is loaded.
    checkpoint_id (Union[str, os.PathLike, None]):
        The ID of this checkpoint instance. The meaning of the checkpoint_id
        depends on the storage. It can be a path to a folder or to a file.
        It can also be a key if the storage is a key-value store.
        (Default: ``None``)
    storage_reader (Optional[StorageReader]):
        Instance of StorageWriter used to perform reads. If this is not
        specified, DCP will automatically infer the reader based on the
        checkpoint_id. If checkpoint_id is also None, an exception will
        be raised. (Default: ``None``)
    process_group (Optional[ProcessGroup]):
        ProcessGroup to be used for cross-rank synchronization.
        (Default: ``None``)

Returns:
    State dict from specified keys
z7torch.distributed.checkpoint._load_state_dict_from_keyszftorch.distributed is unavailable or uninitialized, assuming the intent is to load in a single process.r4   Tr6   )r>   r8   )rt   ru   rv   r#   r9   r:   r;   r<   r   r   r
   r?   r"   r-   r   )r>   r/   r   r   r   Úsds   &$$$  r(   Ú_load_state_dict_from_keysr„   @  s©   € ôl 
‡H�H× Ñ ØAôô ×$Ò$Ó&×@Ð@¬4×+>Ò+>Ó+@ÔA€GßÜ�ŠØtØõ	
ô
 Ü”~ nÈDÔQó€Nô �$œ×ÒØˆvˆà€BÜØØ%Ø#ØÜ*°Ô5õð €Ir*   )Nr   FN)N)+rO   Úloggingr1   r;   Útypingr   r   r   Útyping_extensionsr   rt   Útorch.distributedÚdistributedr#   Ú,torch.distributed.checkpoint.default_plannerr   Ú#torch.distributed.checkpoint.loggerr   Ú%torch.distributed.checkpoint.statefulr	   Ú_storage_utilsr
   Údefault_plannerr   r   r   r   Ústorager   Úutilsr   r   r   Ú%torch.distributed.checkpoint.metadatar   Ú__all__Ú	getLoggerrM   ÚFutureWarningr   r   r-   r„   rs   r*   r(   Ú<module>r•      s  ðó Û Û 	Û ß +Ñ +Ý (ã Ý  Ý SÝ BÝ :å *Ý /ß *Ý "ß 8Ñ 8÷ Ý>à˜fÐ
%€à	×	Ò	Ó	€ñ ð!àôö

óð

ñ,  4Ô(ØðL3ð /3ðL3ð ,0ð	L3ð
 #'ðL3ð /3ðL3ð öL3ó ó )ðL3÷^rñjQð /3ðQð ,0ð	Qð
 /3÷Qò Qr*   