ó
    Eñi  ã                   ó(   • S SK r S SKr " S S5      rg)é    Nc                   ó˜   • \ rS rSrSrSS jrS\R                  SS4S jrS\R                  S-  4S jr	S\R                  S-  4S	 jr
S
rg)Ú_FreeEventQueueé   zÒ
This tracks all pending frees corresponding to inflight all-gathers. The
queueing pattern is iterative enqueues with a single dequeue per iteration
once the limit ``_max_num_inflight_all_gathers`` is reached.
ÚreturnNc                 óF   • [         R                  " 5       U l        SU l        g )Né   )ÚcollectionsÚdequeÚ_queueÚ_max_num_inflight_all_gathers©Úselfs    Úb/home/mande/repo/quber/.venv/lib/python3.13/site-packages/torch/distributed/fsdp/_limiter_utils.pyÚ__init__Ú_FreeEventQueue.__init__   s   € Ü6A×6GÒ6GÓ6IˆŒØ-.ˆÕ*ó    Ú
free_eventc                 ó:   • U R                   R                  U5        g)zEnqueues a free event.N)r   Úappend)r   r   s     r   ÚenqueueÚ_FreeEventQueue.enqueue   s   € à�‰×Ñ˜:Õ&r   c                 ój   • [        U R                  5      U R                  :¼  a  U R                  5       $ g)z0Dequeues a single event if the limit is reached.N)Úlenr   r   Ú_dequeuer   s    r   Údequeue_if_neededÚ!_FreeEventQueue.dequeue_if_needed   s(   € äˆt�{‰{Ó˜t×AÑAÓAØ—=‘=“?Ð"Ør   c                 ó^   • U R                   (       a  U R                   R                  5       nU$ g)z"Dequeues a free event if possible.N)r   Úpopleft)r   Úevents     r   r   Ú_FreeEventQueue._dequeue   s#   € à�;�;Ø—K‘K×'Ñ'Ó)ˆEØˆLØr   )r   r   )r   N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   ÚtorchÚEventr   r   r   Ú__static_attributes__© r   r   r   r      sM   † ñô/ð' %§+¡+ð '°$ô 'ð 5§;¡;°Ñ#5ô ð˜%Ÿ+™+¨Ñ,÷ r   r   )r	   r&   r   r)   r   r   Ú<module>r*      s   ðÛ ã ÷ò r   