§
    “©ºjÆJ  ã            
       ó:  — d dl Z d dlmZmZ d dlmZ d dlmZmZ d dl	m
Z
mZmZmZmZmZ d dlZd dlmZ d dlmZ d dlmZ d d	lmZ d d
lmZ d dlmZ d dlmZ d dlmZ d dl m!Z! d dl"m#Z# d dl$m%Z% d dl&m'Z' d dl(m)Z)m*Z*m+Z+m,Z, e
rd dl-m.Z.  ed¦  «        Z/ ed¦  «        Z0 e j1        e2¦  «        Z3 G d„ de¦  «        Z4 G d„ de¦  «        Z5 G d„ de¦  «        Z6dee7         dee7         de8ddfd „Z9d!e7d"e:e7ee7ege8f         f         d#e;d$e:e7ef         ddf
d%„Z<dS )&é    N)ÚABCÚabstractmethod)ÚIterable)ÚAbstractContextManagerÚ	ExitStack)ÚTYPE_CHECKINGÚAnyÚCallableÚOptionalÚTypeVarÚUnion)ÚTensor)ÚModule)Ú	Optimizer)Ú
DataLoader)ÚAccelerator)ÚCheckpointIO)ÚTorchCheckpointIO)Ú	Precision)Ú	_Launcher)Ú_StrategyRegistry)Úmove_data_to_device)Ú
_EmptyInit)Ú_PATHÚOptimizableÚReduceOpÚ	_Stateful)Ú_LRSchedulerÚ
TBroadcastÚTReducec                   óú  — e Zd ZdZ	 	 	 dSdee         dee         dee         ddfd„Ze	e
dej        fd„¦   «         ¦   «         Ze	e
defd	„¦   «         ¦   «         Ze	dee         fd
„¦   «         Ze	dee         fd„¦   «         Zej        deddfd„¦   «         Ze	defd„¦   «         Zej        deddfd„¦   «         Ze	defd„¦   «         Zej        dee         ddfd„¦   «         ZdTd„ZdTd„Zdedefd„Zdefd„ZdUdee         defd„Z	 dUdedee         ded         de eee         ed         f         fd„Z!dedefd„Z"dedefd „Z#e
deddfd!„¦   «         Z$dUd"e%d#eej                 de%fd$„Z&d%e'dee         d&e%d'e%ddf
d(„Z(de)d'e%de%fd)„Z*e
dVd%e'd+ee%         d,ede'fd-„¦   «         Z+e
	 	 dWd%e,e'e%f         d+ee%         d/ee,e-e.f                  de,e'e%f         fd0„¦   «         Z/e
dUd1ee.         ddfd2„¦   «         Z0e
dXd4e1d5e2de1fd6„¦   «         Z3dYd8ed9edefd:„Z4	 	 dZd;e5d<e6e.e,eee%f         f         d=ee%         d>ee6e.e7e.e%gef         f                  ddf
d?„Z8dede6e.e,e%e'f         f         fd@„Z9	 dYdedAe6e.e,e%e'f         f         dBeddfdC„Z:dede6e.e'f         fdD„Z;	 	 	 d[d;e5d<ee,eee6e.e,eee%f         f         f                  dBedEee         de6e.e%f         f
dF„Z<dTdG„Z=	 	 d\dej>        j        dedIe,e?e2f         dJe,e?e2f         dKedej'        fdL„Z@dej>        j        dedMe,e?e2f         ddfdN„ZAeBdOeCddfdP„¦   «         ZDde.fdQ„ZEd<e6e.e,eee%f         f         d>e6e.e7e.e%gef         f         de6e.e%f         fdR„ZFdS )]ÚStrategyzcBase class for all strategies that change the behaviour of the training, validation and test- loop.NÚacceleratorÚcheckpoint_ioÚ	precisionÚreturnc                 óZ   — || _         || _        d | _        || _        d | _        d | _        d S ©N)Ú_acceleratorÚ_checkpoint_ioÚ
_precisionr%   Ú	_launcherÚ_backward_sync_control)Úselfr#   r$   r%   s       út/root/private/project/pallet_detection_v2/.venv/lib/python3.11/site-packages/lightning_fabric/strategies/strategy.pyÚ__init__zStrategy.__init__0   s7   € ð 4?ˆÔØ6CˆÔØ/3ˆŒà"ˆŒØ.2ˆŒØFJˆÔ#Ð#Ð#ó    c                 ó   — dS )zReturns the root device.N© ©r.   s    r/   Úroot_devicezStrategy.root_device>   ó   € € € r1   c                 ó   — dS )zcWhether the current process is the rank zero process not only on the local node, but for all nodes.Nr3   r4   s    r/   Úis_global_zerozStrategy.is_global_zeroC   r6   r1   c                 ó   — | j         S r(   )r,   r4   s    r/   ÚlauncherzStrategy.launcherH   s
   € àŒ~Ðr1   c                 ó   — | j         S r(   ©r)   r4   s    r/   r#   zStrategy.acceleratorL   s   € àÔ Ð r1   c                 ó   — || _         d S r(   r<   )r.   r#   s     r/   r#   zStrategy.acceleratorP   s   € à'ˆÔÐÐr1   c                 óD   — | j         €t          ¦   «         | _         | j         S r(   )r*   r   r4   s    r/   r$   zStrategy.checkpoint_ioT   s"   € àÔÐ&Ý"3Ñ"5Ô"5ˆDÔØÔ"Ð"r1   Úioc                 ó   — || _         d S r(   )r*   )r.   r?   s     r/   r$   zStrategy.checkpoint_ioZ   s   € à ˆÔÐÐr1   c                 ó:   — | j         �| j         nt          ¦   «         S r(   )r+   r   r4   s    r/   r%   zStrategy.precision^   s   € à"&¤/Ð"=ˆtŒˆÅ9Á;Ä;ÐNr1   c                 ó   — || _         d S r(   )r+   )r.   r%   s     r/   r%   zStrategy.precisionb   s   € à#ˆŒˆˆr1   c                 ó   — dS )z&Attach the launcher based on Strategy.Nr3   r4   s    r/   Ú_configure_launcherzStrategy._configure_launcherf   r6   r1   c                 óV   — | j         €J ‚| j                              | j        ¦  «         dS )zÄSetup any processes or distributed connections.

        This must be called by the framework at the beginning of every process, before any distributed communication
        takes place.

        N)r#   Úsetup_devicer5   r4   s    r/   Úsetup_environmentzStrategy.setup_environmenti   s3   € ð ÔÐ+Ð+Ð+ØÔ×%Ò% dÔ&6Ñ7Ô7Ð7Ð7Ð7r1   Ú
dataloaderc                 ó   — |S )z“Wraps the dataloader if necessary.

        Args:
            dataloader: iterable. Ideally of type: :class:`torch.utils.data.DataLoader`

        r3   )r.   rH   s     r/   Úprocess_dataloaderzStrategy.process_dataloaders   s
   € ð Ðr1   c                 ó²   — | j                              ¦   «         }t          ¦   «         }|                     | j        ¦  «         |                     |¦  «         |S )z1Controls how tensors get created (device, dtype).)r%   Útensor_init_contextr   Úenter_contextr5   )r.   Úprecision_init_ctxÚstacks      r/   rL   zStrategy.tensor_init_context|   sP   € à!œ^×?Ò?ÑAÔAÐÝ‘”ˆØ×Ò˜DÔ,Ñ-Ô-Ð-Ø×ÒÐ.Ñ/Ô/Ð/Øˆr1   Ú
empty_initc                 ó  — | j                              ¦   «         }t          ¦   «         }|                     | j        ¦  «         |                     t          t          |¦  «        ¬¦  «        ¦  «         |                     |¦  «         |S )a¨  A context manager wrapping the model instantiation.

        Here, the strategy can control how the parameters of the model get created (device, dtype) and or apply other
        patches to the model.

        Args:
            empty_init: Whether to initialize the model with empty weights (uninitialized memory).
                If ``None``, the strategy will decide. Some strategies may not support all options.

        )Úenabled)r%   Úmodule_init_contextr   rM   r5   r   Úbool)r.   rP   Úprecision_module_ctxrO   s       r/   rS   zStrategy.module_init_context„   sy   € ð  $œ~×AÒAÑCÔCÐÝ‘”ˆØ×Ò˜DÔ,Ñ-Ô-Ð-Ø×Ò�J­t°JÑ/?Ô/?Ð@Ñ@Ô@ÑAÔAÐAØ×ÒÐ0Ñ1Ô1Ð1Øˆr1   ÚmoduleÚ
optimizersÚ	schedulerr   c                 óT   ‡ — ‰                       |¦  «        }ˆ fd„|D ¦   «         }|||fS )zÿSet up a model and multiple optimizers together.

        The returned objects are expected to be in the same order they were passed in. The default implementation will
        call :meth:`setup_module` and :meth:`setup_optimizer` on the inputs.

        c                 ó:   •— g | ]}‰                      |¦  «        ‘ŒS r3   )Úsetup_optimizer)Ú.0Ú	optimizerr.   s     €r/   ú
<listcomp>z8Strategy.setup_module_and_optimizers.<locals>.<listcomp>    s'   ø€ ÐRÐRÐR¸)�d×*Ò*¨9Ñ5Ô5ÐRÐRÐRr1   )Úsetup_module)r.   rV   rW   rX   s   `   r/   Úsetup_module_and_optimizersz$Strategy.setup_module_and_optimizers–   s>   ø€ ð ×"Ò" 6Ñ*Ô*ˆØRÐRÐRÐRÀzÐRÑRÔRˆ
Ø�z 9Ð,Ð,r1   c                 ó   — |S )zDPerforms setup for the model, e.g., by wrapping it by another class.r3   ©r.   rV   s     r/   r_   zStrategy.setup_module£   s   € àˆr1   r]   c                 ó   — |S )zHPerforms setup for the optimizer, e.g., by wrapping it by another class.r3   ©r.   r]   s     r/   r[   zStrategy.setup_optimizer§   s   € àÐr1   c                 ó   — dS )z&Moves the model to the correct device.Nr3   rb   s     r/   Úmodule_to_devicezStrategy.module_to_device«   r6   r1   ÚbatchÚdevicec                 ó4   — |p| j         }t          ||¦  «        S )a&  Moves the batch to the correct device.

        The returned batch is of the same type as the input batch, just
        having all tensors on the correct device.

        Args:
            batch: The batch of samples to move to the correct device
            device: The target device

        )r5   r   )r.   rg   rh   s      r/   Úbatch_to_devicezStrategy.batch_to_device¯   s!   € ð Ð+˜4Ô+ˆÝ" 5¨&Ñ1Ô1Ð1r1   ÚtensorÚargsÚkwargsc                 ó    — | j                              ||¦  «          | j         j        ||g|¢R i |¤Ž | j                              ||¦  «         dS )z0Forwards backward-calls to the precision plugin.N)r%   Úpre_backwardÚbackwardÚpost_backward)r.   rk   rV   rl   rm   s        r/   rp   zStrategy.backward½   s_   € àŒ×#Ò# F¨FÑ3Ô3Ð3ØˆŒÔ ¨Ð@°Ð@Ð@Ð@¸Ð@Ð@Ð@ØŒ×$Ò$ V¨VÑ4Ô4Ð4Ð4Ð4r1   c                 ó(   —  | j         j        |fi |¤ŽS )zµPerforms the actual optimizer step.

        Args:
            optimizer: the optimizer performing the step
            **kwargs: Any extra arguments to ``optimizer.step``

        )r%   Úoptimizer_step)r.   r]   rm   s      r/   rs   zStrategy.optimizer_stepÃ   s!   € ð -ˆtŒ~Ô,¨YÐAÐA¸&ÐAÐAÐAr1   FÚgroupÚ
sync_gradsc                 ó   — dS )a  Perform an all_gather on all processes.

        Args:
            tensor: the tensor to all_gather
            group: the process group to gather results from
            sync_grads: flag that allows users to synchronize gradients for all_gather op

        Nr3   )r.   rk   rt   ru   s       r/   Ú
all_gatherzStrategy.all_gatherÑ   r6   r1   ÚmeanÚ	reduce_opc                 ó   — dS )a,  Reduces the given tensor (e.g. across GPUs/processes).

        Args:
            tensor: the tensor to sync and reduce
            group: the process group to reduce
            reduce_op: the reduction operation. Defaults to 'mean'.
                Can also be a string 'sum' or ReduceOp.

        Nr3   )r.   rk   rt   ry   s       r/   Ú
all_reducezStrategy.all_reduceÜ   r6   r1   Únamec                 ó   — dS )z¯Synchronizes all processes which blocks processes until the whole group enters this function.

        Args:
            name: an optional name to pass into barrier.

        Nr3   )r.   r|   s     r/   ÚbarrierzStrategy.barrierí   r6   r1   r   ÚobjÚsrcc                 ó   — dS )z…Broadcasts an object to all processes.

        Args:
            obj: the object to broadcast
            src: source rank

        Nr3   )r.   r   r€   s      r/   Ú	broadcastzStrategy.broadcastö   r6   r1   TÚdecisionÚallc                 ó   — |S )z/Reduce a boolean decision across all processes.r3   )r.   rƒ   r„   s      r/   Úreduce_boolean_decisionz Strategy.reduce_boolean_decision   s   € àˆr1   ÚpathÚstateÚstorage_optionsÚfilterc                 ó„   — |                       ||pi ¬¦  «        }| j        r| j                             |||¬¦  «         dS dS )aÝ  Save model, optimizer, and other state as a checkpoint file.

        Args:
            path: A path to where the file(s) should be saved
            state: A dictionary with contents to be saved. If the dict contains modules or optimizers, their
                state-dict will be retrieved and converted automatically.
            storage_options: Additional options for the ``CheckpointIO`` plugin
            filter: An optional dictionary containing filter callables that return a boolean indicating whether the
                given item should be saved (``True``) or filtered out (``False``). Each filter key should match a
                state key, where its filter will be applied to the ``state_dict`` generated.

        )rŠ   )Ú
checkpointr‡   r‰   N)Ú"_convert_stateful_objects_in_stater8   r$   Úsave_checkpoint)r.   r‡   rˆ   r‰   rŠ   s        r/   rŽ   zStrategy.save_checkpoint  s^   € ð& ×7Ò7¸ÀvÀ|ÐQSÐ7ÑUÔUˆØÔð 	mØÔ×.Ò.¸%ÀdÐ\kÐ.ÑlÔlÐlÐlÐlð	mð 	mr1   c                 ó*   — |                      ¦   «         S )zReturns model state.)Ú
state_dictrb   s     r/   Úget_module_state_dictzStrategy.get_module_state_dict  s   € à× Ò Ñ"Ô"Ð"r1   r�   Ústrictc                 ó4   — |                      ||¬¦  «         dS )z%Loads the given state into the model.©r’   N)Úload_state_dict)r.   rV   r�   r’   s       r/   Úload_module_state_dictzStrategy.load_module_state_dict  s#   € ð 	×Ò˜z°&ÐÑ9Ô9Ð9Ð9Ð9r1   c                 ó¬   — t          |d¦  «        r1|                     ¦   «          | j        r|                     ¦   «         ni S |                     ¦   «         S )z€Returns state of an optimizer.

        Allows for syncing/collating optimizer state from processes in custom plugins.

        Úconsolidate_state_dict)Úhasattrr˜   r8   r�   rd   s     r/   Úget_optimizer_statezStrategy.get_optimizer_state%  s_   € õ �9Ð6Ñ7Ô7ð 	Ið ×,Ò,Ñ.Ô.Ð.Ø-1Ô-@ÐH�9×'Ò'Ñ)Ô)Ð)ÀbÐHð ×#Ò#Ñ%Ô%Ð%r1   Úweights_onlyc                 ó4  — t           j                             ¦   «          | j                             ||¬¦  «        }|s|S t          |t          ¦  «        r|                      |||¬¦  «         i S t          |t          ¦  «        r| 	                    |¦  «         i S t          |                     ¦   «         |                     ¦   «         |¬¦  «         |                     ¦   «                              ¦   «         D ]¡\  }}||vrŒ
t          |t          ¦  «        rjt          |t          ¦  «        r,|                      ||                     |¦  «        |¬¦  «         Œ`| 	                    |                     |¦  «        ¦  «         Œ‰|                     |¦  «        ||<   Œ¢|S )aÍ  Load the contents from a checkpoint and restore the state of the given objects.

        Args:
            path: A path to where the file is located
            state: Can be one of:

                - A dictionary of objects whose state will be restored in-place from the checkpoint path.
                - ``None`` or the empty dict: The loaded checkpoint will be returned in full.
                - A :class:`~torch.nn.Module` instance, if the checkpoint file contains a raw module state dict.
                - A :class:`~torch.optim.Optimizer` instance, if the checkpoint file contains a raw optimizer state.

            strict: Whether to enforce that the keys in `state` match the keys in the checkpoint.
            weights_only: Defaults to ``None``. If ``True``, restricts loading to ``state_dicts`` of plain
                ``torch.Tensor`` and other primitive types. If loading a checkpoint from a trusted source that contains
                an ``nn.Module``, use ``weights_only=False``. If loading checkpoint from an untrusted source, we
                recommend using ``weights_only=True``. For more information, please refer to the
                `PyTorch Developer Notes on Serialization Semantics <https://docs.pytorch.org/docs/main/notes/serialization.html#id3>`_.

        Returns:
            The remaining items that were not restored into the given state dictionary. If no state dictionary is
            given, the full checkpoint will be returned.

        )r›   )rV   r�   r’   r”   )ÚtorchÚcudaÚempty_cacher$   Úload_checkpointÚ
isinstancer   r–   r   r•   Ú!_validate_keys_for_strict_loadingÚkeysÚcopyÚitemsr   Úpop)r.   r‡   rˆ   r’   r›   rŒ   r|   r   s           r/   r    zStrategy.load_checkpoint4  sŒ  € õ< 	Œ
×ÒÑ Ô Ð ØÔ'×7Ò7¸È<Ð7ÑXÔXˆ
Øð 	ØÐå�e�VÑ$Ô$ð 	Ø×'Ò'¨uÀÐTZÐ'Ñ[Ô[Ð[ØˆIå�e�YÑ'Ô'ð 	Ø×!Ò! *Ñ-Ô-Ð-ØˆIå)¨%¯*ª*©,¬,¸
¿ºÑ8IÔ8IÐRXÐYÑYÔYÐYØŸš™œ×+Ò+Ñ-Ô-ð 		3ð 		3‰IˆD�#Ø˜:Ð%Ð%ØÝ˜#�yÑ)Ô)ð 3Ý˜c¥6Ñ*Ô*ð >Ø×/Ò/°sÀzÇ~Â~ÐVZÑG[ÔG[ÐdjÐ/ÑkÔkÐkÐkà×'Ò'¨
¯ª°tÑ(<Ô(<Ñ=Ô=Ð=Ð=à(Ÿnšn¨TÑ2Ô2��d‘�ØÐr1   c                 ó®   — | j                              ¦   «          | j        €J ‚| j                             ¦   «          | j                             ¦   «          dS )zŒThis method is called to teardown the training process.

        It is the right place to release memory and free other resources.

        N)r%   Úteardownr#   r$   r4   s    r/   r¨   zStrategy.teardownl  sW   € ð 	Œ×ÒÑ!Ô!Ð!ØÔÐ+Ð+Ð+ØÔ×!Ò!Ñ#Ô#Ð#ØÔ×#Ò#Ñ%Ô%Ð%Ð%Ð%r1   ç       @Úmax_normÚ	norm_typeÚerror_if_nonfinitec                 óº   — | j                              |¦  «         | j                              |¦  «        }t          j        j                             ||||¬¦  «        S )zClip gradients by norm.)rª   r«   r¬   )r%   Úunscale_gradientsÚmain_paramsr�   ÚnnÚutilsÚclip_grad_norm_)r.   rV   r]   rª   r«   r¬   Ú
parameterss          r/   Úclip_gradients_normzStrategy.clip_gradients_normw  sZ   € ð 	Œ×(Ò(¨Ñ3Ô3Ð3Ø”^×/Ò/°	Ñ:Ô:ˆ
ÝŒxŒ~×-Ò-Ø °YÐSeð .ñ 
ô 
ð 	
r1   Úclip_valc                 ó¶   — | j                              |¦  «         | j                              |¦  «        }t          j        j                             ||¬¦  «        S )zClip gradients by value.)Ú
clip_value)r%   r®   r¯   r�   r°   r±   Úclip_grad_value_)r.   rV   r]   rµ   r³   s        r/   Úclip_gradients_valuezStrategy.clip_gradients_value†  sJ   € àŒ×(Ò(¨Ñ3Ô3Ð3Ø”^×/Ò/°	Ñ:Ô:ˆ
ÝŒxŒ~×.Ò.¨zÀhÐ.ÑOÔOÐOr1   Ústrategy_registryc                 ó   — d S r(   r3   )Úclsrº   s     r/   Úregister_strategieszStrategy.register_strategiesŒ  s   € àˆr1   c                 ó2   — dt          | ¦  «        j        › d�S )NzThe `z£` does not support setting up the module and optimizer(s) independently. Please call `setup_module_and_optimizers(model, [optimizer, ...])` to jointly set them up.)ÚtypeÚ__name__r4   s    r/   Ú_err_msg_joint_setup_requiredz&Strategy._err_msg_joint_setup_required�  s*   € ðj•D˜‘J”JÔ'ð jð jð jð	
r1   c                 ój  — i }|                      ¦   «         D ]›\  }}t          |t          ¦  «        r|                      |¬¦  «        }nXt          |t          ¦  «        r|                      |¬¦  «        }n,t          |t          ¦  «        r|                     ¦   «         }n|}t          ||||¦  «         Œœ|S )N)rV   )r]   )	r¥   r¡   r   r‘   r   rš   r   r�   Ú_apply_filter)r.   rˆ   rŠ   Úconverted_stateÚkeyr   Ú	converteds          r/   r�   z+Strategy._convert_stateful_objects_in_state–  s¿   € ð +-ˆØŸš™œð 
	Cð 
	C‰HˆC�å˜#�vÑ&Ô&ð  Ø ×6Ò6¸cÐ6ÑBÔB�	�	Ý˜C¥Ñ+Ô+ð  Ø ×4Ò4¸sÐ4ÑCÔC�	�	Ý˜C¥Ñ+Ô+ð  ØŸNšNÑ,Ô,�	�	à�	Ý˜#˜v y°/ÑBÔBÐBÐBØÐr1   )NNN)r&   Nr(   )NF)Nrx   )r   )T)NN)NTN)r©   T)GrÀ   Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r0   Úpropertyr   r�   rh   r5   rT   r8   r   r:   r#   Úsetterr$   r%   rD   rG   r   rJ   r   rL   rS   r   Úlistr   Útupler`   r_   r[   rf   r	   rj   r   rp   r   rs   rw   r   r   Ústrr{   r~   r   Úintr‚   r†   r   Údictr
   rŽ   r‘   r–   rš   r    r¨   r°   Úfloatr´   r¹   Úclassmethodr   r½   rÁ   r�   r3   r1   r/   r"   r"   -   sç  € € € € € ØmÐmð .2Ø04Ø)-ð	Kð Kà˜kÔ*ðKð   Ô-ðKð ˜IÔ&ð	Kð
 
ðKð Kð Kð Kð Øð'˜Uœ\ð 'ð 'ð 'ñ „^ñ „Xð'ð Øðr ð rð rð rñ „^ñ „Xðrð ð˜( 9Ô-ð ð ð ñ „Xðð ð!˜X kÔ2ð !ð !ð !ñ „Xð!ð Ôð( {ð (°tð (ð (ð (ñ Ôð(ð ð#˜|ð #ð #ð #ñ „Xð#ð
 Ôð! ð !°ð !ð !ð !ñ Ôð!ð ðO˜9ð Oð Oð Oñ „XðOð Ôð$ 8¨IÔ#6ð $¸4ð $ð $ð $ñ Ôð$ð5ð 5ð 5ð 5ð8ð 8ð 8ð 8ð¨Zð ¸Jð ð ð ð ðÐ%;ð ð ð ð ðð ¨h°t¬nð ÐH^ð ð ð ð ð& bfð-ð -Øð-Ø*.¨y¬/ð-ØFNÈ~ÔF^ð-à	ˆv�t˜I”¨°Ô(@Ð@Ô	Að-ð -ð -ð -ð 6ð ¨fð ð ð ð ð¨ð °yð ð ð ð ð ð5 vð 5°$ð 5ð 5ð 5ñ „^ð5ð2ð 2 Sð 2°(¸5¼<Ô2Hð 2ÐTWð 2ð 2ð 2ð 2ð5˜vð 5¨x¸Ô/?ð 5Èð 5ÐWZð 5Ð_cð 5ð 5ð 5ð 5ðBàðBð ðBð 
ð	Bð Bð Bð Bð ðð  ð °¸´ð ÐRVð Ðcið ð ð ñ „^ðð ð  $Ø4:ð	ð à�f˜c�kÔ"ðð ˜Œ}ðð ˜E (¨C -Ô0Ô1ð	ð
 
ˆv�sˆ{Ô	ðð ð ñ „^ðð  ðð ˜H SœMð °Tð ð ð ñ „^ðð ðð ˜Zð ¨cð ¸*ð ð ð ñ „^ððð °ð ¸4ð È4ð ð ð ð ð *.ØBFðmð màðmð �C˜˜v y°#Ð5Ô6Ð6Ô7ðmð " #œð	mð
 ˜˜c 8¨S°#¨J¸Ð,<Ô#=Ð=Ô>Ô?ðmð 
ðmð mð mð mð.#¨Fð #°t¸CÀÀsÈFÀ{ÔASÐ<SÔ7Tð #ð #ð #ð #ð
 Y]ð:ð :Øð:Ø*.¨s°E¸#¸v¸+Ô4FÐ/FÔ*Gð:ØQUð:à	ð:ð :ð :ð :ð&¨Yð &¸4ÀÀVÀÔ;Lð &ð &ð &ð &ð$ _cØØ'+ð6ð 6àð6ð ˜˜f i°°c¸5ÀÈÐTWÐAWÔ;XÐ6XÔ1YÐYÔZÔ[ð6ð ð	6ð
 ˜t”nð6ð 
ˆc�3ˆhŒð6ð 6ð 6ð 6ðp	&ð 	&ð 	&ð 	&ð  (+Ø#'ð
ð 
à””ð
ð ð
ð ˜˜s˜
Ô#ð	
ð
 ˜ ˜Ô$ð
ð !ð
ð 
Œð
ð 
ð 
ð 
ðP¨5¬8¬?ð PÀyð PÐ\aÐbgÐilÐblÔ\mð PÐrvð Pð Pð Pð Pð ðÐ4Eð È$ð ð ð ñ „[ðð
¨sð 
ð 
ð 
ð 
ðØ˜#˜u V¨Y¸Ð%;Ô<Ð<Ô=ðØGKÈCÐQYÐ[^Ð`cÐZdÐfjÐZjÔQkÐLkÔGlðà	ˆc�3ˆhŒðð ð ð ð ð r1   r"   c                   ó6   — e Zd ZdZedededefd„¦   «         ZdS )Ú_BackwardSyncControla†  Interface for any :class:`Strategy` that wants to offer a functionality to enable or disable gradient
    synchronization during/after back-propagation.

    The most common use-case is gradient accumulation. If a :class:`Strategy` implements this interface, the user can
    implement their gradient accumulation loop very efficiently by disabling redundant gradient synchronization.

    rV   rR   r&   c                 ó   — dS )z©Blocks the synchronization of gradients during the backward pass.

        This is a context manager. It is only effective if it wraps a call to `.backward()`.

        Nr3   )r.   rV   rR   s      r/   Úno_backward_syncz%_BackwardSyncControl.no_backward_sync±  r6   r1   N)	rÀ   rÇ   rÈ   rÉ   r   r   rT   r   rÖ   r3   r1   r/   rÔ   rÔ   ¨  sT   € € € € € ðð ð ð vð ¸ð ÐAWð ð ð ñ „^ðð ð r1   rÔ   c                   ó.   — e Zd ZdZedefd„¦   «         ZdS )Ú_ShardedzkMixin-interface for any :class:`Strategy` that wants to expose functionality for sharding model parameters.r&   c                 ó   — dS )a  A context manager that goes over the instantiation of an :class:`torch.nn.Module` and handles sharding of
        parameters on creation.

        By sharding layers directly on instantiation, one can reduce peak memory usage and initialization time.

        Nr3   r4   s    r/   Úmodule_sharded_contextz_Sharded.module_sharded_context½  r6   r1   N)rÀ   rÇ   rÈ   rÉ   r   r   rÚ   r3   r1   r/   rØ   rØ   º  s@   € € € € € ØuÐuàðÐ(>ð ð ð ñ „^ðð ð r1   rØ   Úrequested_keysÚcheckpoint_keysr’   r&   c                 ób   ‡— ˆfd„| D ¦   «         }|r|rt          d|d         › d�¦  «        ‚d S d S )Nc                 ó   •— g | ]}|‰v¯|‘Œ	S r3   r3   )r\   ÚkrÜ   s     €r/   r^   z5_validate_keys_for_strict_loading.<locals>.<listcomp>Ê  s#   ø€ ÐJÐJÐJ˜!°¸/Ð1IÐ1I�AÐ1IÐ1IÐ1Ir1   z$The requested state contains a key 'r   z^' that does not exist in the loaded checkpoint. To disable strict loading, set `strict=False`.)ÚKeyError)rÛ   rÜ   r’   Úinvalid_keyss    `  r/   r¢   r¢   Ç  sn   ø€ ð KÐJÐJÐJ˜~ÐJÑJÔJ€LØð 
�,ð 
Ýð?°<À´?ð ?ð ?ð ?ñ
ô 
ð 	
ð
ð 
ð 
ð 
r1   rÅ   rŠ   Úsource_dictÚtarget_dictc                 óä   — | |v rft          |t          ¦  «        rQ||          }|                     ¦   «         D ]2\  }} |||¦  «        r!|                     | i ¦  «         |||          |<   Œ3d S ||| <   d S r(   )r¡   rÐ   r¥   Ú
setdefault)rÅ   rŠ   râ   rã   Ú	filter_fnrß   Úvs          r/   rÃ   rÃ   Ò  s—   € ð ˆf€}€}� KµÑ6Ô6€}Ø˜3”Kˆ	Ø×%Ò%Ñ'Ô'ð 	(ð 	(‰DˆAˆqØˆy˜˜A‰Œð (à×&Ò& s¨BÑ/Ô/Ð/Ø&'�˜CÔ  Ñ#øð		(ð 	(ð 'ˆ�CÑÐÐr1   )=ÚloggingÚabcr   r   Úcollections.abcr   Ú
contextlibr   r   Útypingr   r	   r
   r   r   r   r�   r   Útorch.nnr   Útorch.optimr   Útorch.utils.datar   Úlightning_fabric.acceleratorsr   Ú)lightning_fabric.plugins.io.checkpoint_ior   Ú$lightning_fabric.plugins.io.torch_ior   Ú"lightning_fabric.plugins.precisionr   Ú.lightning_fabric.strategies.launchers.launcherr   Ú$lightning_fabric.strategies.registryr   Ú%lightning_fabric.utilities.apply_funcr   Úlightning_fabric.utilities.initr   Ú lightning_fabric.utilities.typesr   r   r   r   Útorch.optim.lr_schedulerr   r   r    Ú	getLoggerrÀ   Úlogr"   rÔ   rØ   rÎ   rT   r¢   rÐ   ÚobjectrÃ   r3   r1   r/   ú<module>rý      sþ  ðð €€€Ø #Ð #Ð #Ð #Ð #Ð #Ð #Ð #Ø $Ð $Ð $Ð $Ð $Ð $Ø 8Ð 8Ð 8Ð 8Ð 8Ð 8Ð 8Ð 8Ø IÐ IÐ IÐ IÐ IÐ IÐ IÐ IÐ IÐ IÐ IÐ IÐ IÐ IÐ IÐ Ià €€€Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø !Ð !Ð !Ð !Ð !Ð !Ø 'Ð 'Ð 'Ð 'Ð 'Ð 'à 5Ð 5Ð 5Ð 5Ð 5Ð 5Ø BÐ BÐ BÐ BÐ BÐ BØ BÐ BÐ BÐ BÐ BÐ BØ 8Ð 8Ð 8Ð 8Ð 8Ð 8Ø DÐ DÐ DÐ DÐ DÐ DØ BÐ BÐ BÐ BÐ BÐ BØ EÐ EÐ EÐ EÐ EÐ EØ 6Ð 6Ð 6Ð 6Ð 6Ð 6Ø TÐ TÐ TÐ TÐ TÐ TÐ TÐ TÐ TÐ TÐ TÐ Tàð 6Ø5Ð5Ð5Ð5Ð5Ð5àˆW�\Ñ"Ô"€
Ø
ˆ'�)Ñ
Ô
€à€gÔ˜Ñ!Ô!€ðxð xð xð xð xˆsñ xô xð xðvð ð ð ð ˜3ñ ô ð ð$
ð 
ð 
ð 
ð 
ˆsñ 
ô 
ð 
ð
Ø˜S”Mð
Ø4<¸S´Mð
ØKOð
à	ð
ð 
ð 
ð 
ð'Ø	ð'Ø˜3 ¨#¨s¨°TÐ)9Ô :Ð:Ô;ð'ØJPð'Ø_cÐdgÐilÐdlÔ_mð'à	ð'ð 'ð 'ð 'ð 'ð 'r1   