+
    –°³j  ã                   ó¸   € ^ RI Ht ^ RIHtHtHt ^ RIHt ^ RIt^ RI	H
t
 ^ RIHtHt ^RIHtHt ]RR R ll4       t ! R	 R
]4      t]! ]4      R R l4       tR# )é    )Ú	Generator)ÚAbstractContextManagerÚcontextmanagerÚnullcontext)ÚAnyN)Ú,_checkpoint_without_reentrant_generator_implÚ_DEFAULT_DETERMINISM_MODE)Ú_StateÚcontractc                óR   € V ^8„  d   QhR\         P                  R\        R,          /# )é   ÚmoduleÚuser_ctxN)ÚnnÚModuler   )Úformats   "Út/home/luca/screen-checking/.venv/lib/python3.14/site-packages/torch/distributed/_composable/checkpoint_activation.pyÚ__annotate__r      s(   € ÷ Dñ D”R—Y‘Yð DÔ*@À4Õ*Gñ Dó    c              #  óp  "  € V'       d   TM	\        4       ;_uu_ 4        \        P                  V 4      P                  pR\        P                  V 4      n         Rx € V\        P                  V 4      n         RRR4       R#   T\        P                  T 4      n        i ; i  + '       g   i     R# ; i5i)zg
Disable hooks installed by checkpoint to avoid unintentional recursion
during backward recomputation.
FN)r   Ú
checkpointÚstateÚenable_hook)r   r   Úorig_enable_hooks   && r   Ú_no_hookr      s‡   é € ÷ ‰¤;£=×	0Ñ	0Ü%×+Ñ+¨FÓ3×?Ñ?ÐØ/4Œ
×Ñ˜Ó Ô,ð	DÛà3CŒJ×Ñ˜VÓ$Õ0÷ 
1Ñ	0øð 4DŒJ×Ñ˜VÓ$Õ0ú÷ 
1×	0Ð	0üs4   ‚B6Ÿ:B"ÁBÁB"Á9
B6ÂBÂB"Â"B3	Â-	B6c                   ó0   a € ] tR t^ t o RtV 3R ltRtV tR# )Ú_CheckpointStateFc                óN   <€ V ^8„  d   Qh/ S[ ;R&   S[R,          R,          ;R&   # )r   r   NÚ_ac_generator)NNN)Úboolr   )r   Ú__classdict__s   "€r   r   Ú_CheckpointState.__annotate__    s&   ø‡ ‚ ÙÑñ áÐ-Õ.°Õ5Ñ5ò r   © N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__r   Ú__annotate_func__Ú__static_attributes__Ú__classdictcell__)r!   s   @r   r   r       s   ø‡ € Ø€K÷ ƒ r   r   c                óX   € V ^8„  d   QhR\         P                  R\         P                  /# )r   r   Úreturn)r   r   )r   s   "r   r   r   &   s&   € ÷ añ a”r—y‘yð a¬r¯y©yñ ar   c                ó\  aaaaa	€ \         P                  P                  R4       VP                  RR4      pV'       d   \	        R4      hVP                  RR4      oVP                  RR4      o	VP                  R	\
        4      oVP                  R
R4      oVP                  RR4      oV'       d)   \        RRP                  R V 4       4      ,           4      hR VVVVV	3R llpR R lpR\        P                  V 4      n
        V P                  VRR7       V P                  VRRR7       V # )a;  
This is a composable activation checkpointing API. Unlike functional
activation checkpointing APIs, this one does not require changing model
source code. Unlike ``nn.Module`` wrapper activation checkpointing APIs,
this one does not modify model structure or fully-qualified names either.
Under the hood, it registers activation checkpointing logic as pre- and
post-forward hooks. Hence, this API can be easily applied to any model or
sub-modules in the model.

Args:
    module (nn.Module): the target model or sub-module to apply activation
        checkpointing.

Example::
    >>> # xdoctest: +SKIP
    >>> import torch.nn as nn
    >>>
    >>> class MyModel(nn.Module):
    >>>     def __init__(self) -> None:
    >>>         super().__init__()
    >>>         self.l1 = nn.Linear(10, 10)
    >>>         self.l2 = nn.Linear(10, 10)
    >>>
    >>>     def forward(self, x):
    >>>         return self.l2(self.l1(x))
    >>>
    >>> model = MyModel()
    >>> checkpoint(model.l1)  # apply activation checkpointing only to l1
    >>> model(torch.zeros(2, 10)).sum().backward()

ztorch.distributed.checkpointÚuse_reentrantFzsuse_reentrant=True is not supported in composable checkpoint. Please use torch.utils.checkpoint.checkpoint instead.Úpreserve_rng_stateTÚ
context_fnNÚdeterminism_checkÚdebugÚ
early_stopzUnexpected keyword arguments: Ú,c              3   ó$   "  € T F  qx € K  	  R # 5i©Nr#   )Ú.0Úargs   & r   Ú	<genexpr>Úcheckpoint.<locals>.<genexpr>V   s   é € Ð7NÁvÀ¼Ãvùs   ‚c                ó�   € V ^8„  d   QhR\         P                  R\        \        R3,          R\        \
        \        3,          RR/# )r   r   Úargs.Úkwargsr,   N)r   r   Útupler   ÚdictÚstr)r   s   "r   r   Ú checkpoint.<locals>.__annotate__Y   s@   € ÷ ñ Ü—	‘	ðÜ!&¤s¨C x¥ðÜ:>¼sÄC¸x½.ðà	ñr   c                 óÖ   <a € \         P                  S 4      P                  '       dB   V V	3R  lp\        S VVSVSSSR7      pV\         P                  S 4      n        \        V4       R# R# )c                  ód   <€ Se   S! 4       w  rV \        SV4      3# \        4       \        S4      3# r6   )r   r   )Úctx1Úctx2r   Úuser_context_fnss     €€r   Úcontext_fnsÚ9checkpoint.<locals>.forward_pre_hook.<locals>.context_fns^   s7   ø€ Ø#Ò/Ù!1Ó!3‘J�DØ¤¨&°$Ó!7Ð7Ð7ä&›=¬(°6Ó*:Ð:Ð:r   )r/   r0   r1   r2   r3   N)r   r   r   r   r   Únext)
r   r<   r=   rG   Úgenr2   r1   r3   r/   rF   s
   f&&  €€€€€r   Úforward_pre_hookÚ$checkpoint.<locals>.forward_pre_hookY   sf   ù€ ô ×Ñ˜FÓ#×/×/Ð/ö;ô ?ØØØØ#5Ø&Ø"3ØØ%ô	ˆCð 69ŒJ×Ñ˜VÓ$Ô2Ü�ŽIñ) 0r   c                óv   € V ^8„  d   QhR\         P                  R\        \        R3,          R\        R\        /# )r   r   Úinputs.Úoutputr,   )r   r   r>   r   )r   s   "r   r   rA   r   s5   € ÷ 6ñ 6œRŸY™Yð 6´´c¸3°hµð 6Ìð 6ÔQTñ 6r   c                 ó&  € \         P                  V 4      P                  '       dA    \         P                  V 4      P                  pVf   \        h\        V4       \        R4      hR \         P                  V 4      n        R #   \         d     L)i ; i)NzWExpected non-reentrant activation checkpoint generator to be exhausted, but it was not!)r   r   r   r   ÚAssertionErrorrI   ÚRuntimeErrorÚStopIteration)r   rN   rO   rJ   s   &&& r   Úforward_hookÚ checkpoint.<locals>.forward_hookr   s�   € Ü×Ñ˜FÓ#×/×/Ð/ð
Ü ×&Ñ& vÓ.×<Ñ<�Ø’;Ü(Ð(Ü�S”	ô #Ømóð ð 26Œ
×Ñ˜Ó Ö.øô !ô Ùðús   §4B ÂBÂB)Úwith_kwargs)ÚprependÚalways_call)ÚtorchÚ_CÚ_log_api_usage_onceÚpopÚNotImplementedErrorr	   Ú
ValueErrorÚjoinr   r   r   Úregister_forward_pre_hookÚregister_forward_hook)
r   r=   r.   rK   rT   r2   r1   r3   r/   rF   s
   &,   @@@@@r   r   r   %   s  ü€ ôB 
‡H�H× Ñ Ð!?Ô@à—J‘J˜°Ó6€MßÜ!ðDó
ð 	
ð  Ÿ™Ð$8¸$Ó?ÐØ—z‘z ,°Ó5ÐØŸ
™
Ð#6Ô8QÓRÐØ�J‰J�w Ó&€EØ—‘˜L¨$Ó/€JçÜØ,¨s¯x©xÑ7NÁvÓ7NÓ/NÕNó
ð 	
÷ô õ26ð$ ,0„J×Ñ�VÓÔ(Ø
×$Ñ$Ð%5À4Ð$ÔHØ
× Ñ  °tÈÐ ÔNØ€Mr   r6   )Úcollections.abcr   Ú
contextlibr   r   r   Útypingr   rY   Útorch.nnr   Útorch.utils.checkpointr   r	   r   r
   r   r   r   r#   r   r   Ú<module>rg      s_   ðå %ß JÑ JÝ ã Ý ÷÷
 'ð öDó ðDô6�vô 6ñ
 
Ð
Óôaó òar   