ó
    EñiŽ  ã                   óT   • S SK r SSKJrJr  \ R                  " S\SS9   " S S5      rg)	é    Né   )ÚAcceleratorStateÚGradientStateÚignoreztorch.optim.lr_scheduler)ÚcategoryÚmodulec                   óR   • \ rS rSrSrSS\S\4S jjrS rS rS r	S	 r
S
 rS rSrg)ÚAcceleratedScheduleré   a1  
A wrapper around a learning rate scheduler that will only step when the optimizer(s) have a training step. Useful
to avoid making a scheduler step too fast when gradients went overflow and there was no training step (in mixed
precision training)

When performing gradient accumulation scheduler lengths should not be changed accordingly, Accelerate will always
step the scheduler to account for it.

Args:
    scheduler (`torch.optim.lr_scheduler._LRScheduler`):
        The scheduler to wrap.
    optimizers (one or a list of `torch.optim.Optimizer`):
        The optimizers used.
    step_with_optimizer (`bool`, *optional*, defaults to `True`):
        Whether or not the scheduler should be stepped at each optimizer step.
    split_batches (`bool`, *optional*, defaults to `False`):
        Whether or not the dataloaders split one batch across the different processes (so batch size is the same
        regardless of the number of processes) or create batches on each process (so batch size is the original
        batch size multiplied by the number of processes).
Ústep_with_optimizerÚsplit_batchesc                 ó�   • Xl         [        U[        [        45      (       a  UOU/U l        X@l        X0l        [        5       U l        g ©N)	Ú	schedulerÚ
isinstanceÚlistÚtupleÚ
optimizersr   r   r   Úgradient_state)Úselfr   r   r   r   s        ÚQ/home/mande/repo/quber/.venv/lib/python3.13/site-packages/accelerate/scheduler.pyÚ__init__ÚAcceleratedScheduler.__init__/   s:   € Ø"ŒÜ(2°:ÄÄe¸}×(MÑ(M™*ÐT^ÐS_ˆŒØ*ÔØ#6Ô Ü+›oˆÕó    c                 ó
  • U R                   (       d  U R                  R                  " U0 UD6  g U R                  R                  (       d;  U R                  R
                  (       a  U R                  =R                  S-  sl        g U R                   H  nUR                  (       d  M    g    U R                  (       a  U R                  R                  " U0 UD6  g [        5       R                  n[        U5       Hˆ  n[        U R                  S5      (       aN  U R                  R                  U R                  R                  ::  a  U R                  R                  " U0 UD6  Mj  Ml  U R                  R                  " U0 UD6  MŠ     g )Nr   Útotal_steps)r   r   Ústepr   Úsync_gradientsÚadjust_schedulerÚ_step_countr   Ústep_was_skippedr   r   Únum_processesÚrangeÚhasattrr   )r   ÚargsÚkwargsÚoptr"   Ú_s         r   r   ÚAcceleratedScheduler.step6   s  € Ø×'×'à�N‰N×Ò Ð0¨Ò0Øð ×"Ñ"×1×1Ø×"Ñ"×3×3Ø—‘×*Ò*¨aÑ/Õ*Øà—?”?ˆCØ×#×#Ñ#Ùñ #ð ××à�N‰N×Ò Ð0¨Ó0ô -Ó.×<Ñ<ˆMÜ˜=Ö)�ä˜4Ÿ>™>¨=×9Ñ9Ø—~‘~×1Ñ1°T·^±^×5OÑ5OÓOØŸ™×+Ò+¨TÐ<°VÔ<ñ Pð —N‘N×'Ò'¨Ð8°Ô8ò *r   c                 ó6   • U R                   R                  5       $ r   )r   Úget_last_lr©r   s    r   r+   Ú AcceleratedScheduler.get_last_lrU   s   € Ø�~‰~×)Ñ)Ó+Ð+r   c                 ó6   • U R                   R                  5       $ r   )r   Ú
state_dictr,   s    r   r/   ÚAcceleratedScheduler.state_dictX   s   € Ø�~‰~×(Ñ(Ó*Ð*r   c                 ó:   • U R                   R                  U5        g r   )r   Úload_state_dict)r   r/   s     r   r2   Ú$AcceleratedScheduler.load_state_dict[   s   € Ø�‰×&Ñ& zÕ2r   c                 ó6   • U R                   R                  5       $ r   )r   Úget_lrr,   s    r   r5   ÚAcceleratedScheduler.get_lr^   s   € Ø�~‰~×$Ñ$Ó&Ð&r   c                 ó:   • U R                   R                  " U0 UD6$ r   )r   Úprint_lr)r   r%   r&   s      r   r8   ÚAcceleratedScheduler.print_lra   s   € Ø�~‰~×&Ò&¨Ð7°Ñ7Ð7r   )r   r   r   r   r   N)TF)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Úboolr   r   r+   r/   r2   r5   r8   Ú__static_attributes__© r   r   r
   r
      s9   † ññ*.À4ð .Ð_cõ .ò9ò>,ò+ò3ò'õ8r   r
   )ÚwarningsÚstater   r   ÚfilterwarningsÚUserWarningr
   rA   r   r   Ú<module>rF      s.   ðó" ç 2ð 	× Ò ˜¨;Ð?YÒ Z÷I8ò I8r   