+
    –°³jº  ã                   óÊ   € ^ RI t ^ RIt^ RIHt ^ RIHt ^ RIHt ^ RIH	t	 ^ RI
t
^ RIHt ^ RIHu Hu Ht ^ RIHtHtHt ] P,                  ! ]4      t ! R R4      tR	 R
 ltR# )é    N)Údefaultdict)ÚIterator)Úcontextmanager)ÚEnum)Ú_apply_to_modulesÚ_get_module_fsdp_stateÚclean_tensor_namec                   óÀ   a € ] tR t^t o  ! R R]]4      t]! ]4      t	]
! 4       t]V 3R lR l4       t]]V 3R lR l4       4       t]V 3R lR l4       tV 3R	 ltR
tV tR# )ÚSimpleProfilerc                   ó.   € ] tR t^tRtRtRtRtRtRt	Rt
R# )	ÚSimpleProfiler.TypeÚallÚ
all_gatherÚall_gather_objectÚ
reshardingÚH2DÚD2H© N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__ÚALLÚ	ALLGATHERÚALLGATHER_OBJÚ
RESHARDINGr   r   Ú__static_attributes__r   ó    Úd/home/luca/screen-checking/.venv/lib/python3.14/site-packages/torch/distributed/fsdp/_debug_utils.pyÚTyper      s    † ØˆØ ˆ	Ø+ˆØ!ˆ
ØˆØŒr   r    c                ó   <€ V ^8„  d   QhRR/# )é   ÚreturnNr   )ÚformatÚ__classdict__s   "€r   Ú__annotate__ÚSimpleProfiler.__annotate__#   s   ø€ ÷ ñ �dñ r   c                ón   € V P                   P                  4        V P                  P                  4        R # )N)ÚresultsÚclearÚ	profiling)Úclss   &r   ÚresetÚSimpleProfiler.reset"   s"   € à�‰×ÑÔØ�‰×ÑÖr   c                ó4   <€ V ^8„  d   QhRS[ RS[R,          /# )r"   Úprofile_typer#   N)Ústrr   )r$   r%   s   "€r   r&   r'   )   s   ø€ ÷ /ñ /¡3ð /©8°D­>ñ /r   c              #  ó  "  € WP                   9   d   \        V R 24      hV P                   P                  V4       \        P                  ! 4       p Rx € \        P                  ! 4       pV P
                  V;;,          W2,
          ,          uu&   V P                   P                  V4       R#   \        P                  ! 4       pT P
                  T;;,          Y2,
          ,          uu&   T P                   P                  T4       i ; i5i)zk is already being profiled. SimpleProfiler does not support profiling multiple instances at the same time. N)r+   ÚAssertionErrorÚaddÚtimeÚ	monotonicr)   Úremove)r,   r0   ÚbeginÚends   &&  r   ÚprofileÚSimpleProfiler.profile'   sÀ   é € ð Ÿ=™=Ô(Ü Ø�.ð !"ð "óð ð 	�‰×Ñ˜,Ô'Ü—’Ó ˆð	/Ûä—.’.Ó"ˆCØ�K‰K˜×%¨­Õ4Ó%Ø�M‰M× Ñ  Ö.øô —.’.Ó"ˆCØ�K‰K˜×%¨­Õ4Ó%Ø�M‰M× Ñ  Õ.üs    ‚ADÁB- ÁADÂ-ADÄDc                ó$   <€ V ^8„  d   QhRS[ RR/# )r"   Úmsgr#   N)r1   )r$   r%   s   "€r   r&   r'   ;   s   ø€ ÷ ñ ¡ð ¨ñ r   c                óþ   € \         P                  ! 4       ^ 8X  dS   \         P                  ! 4       \         P                  P                  8X  d!   \
        P                  RWP                  4       V P                  4        R# )r   z%s %sN)	ÚdistÚget_rankÚget_debug_levelÚ
DebugLevelÚINFOÚloggerÚinfor)   r-   )r,   r=   s   &&r   Údump_and_resetÚSimpleProfiler.dump_and_reset:   sG   € ô �=Š=‹?˜aÔ¤D×$8Ò$8Ó$:¼d¿o¹o×>RÑ>RÔ$RÜ�K‰K˜ §k¡kÔ2Ø�	‰	Žr   c                óX   <€ V ^8„  d   Qh/ S[ S[S[3,          ;R&   S[S[,          ;R&   # )r"   r)   r+   )Údictr1   ÚfloatÚset)r$   r%   s   "€r   r&   r'      s,   ø‡ ‚ ñ ‘#‘u�*ÕÑ2ñ ñ ‘3�xÑò r   r   N)r   r   r   r   r1   r   r    r   rJ   r)   rK   r+   Úclassmethodr-   r   r:   rF   Ú__annotate_func__r   Ú__classdictcell__)r%   s   @r   r   r      sp   ø‡ € ôˆs�Dô ñ !,¨EÓ 2€GÙ›%€Ià÷ó ðð Ø÷/ó ó ð/ð" ÷ó ð÷K ƒ r   r   c          	      ó²   € V ^8„  d   QhR\         P                  P                  R\        \        \
        \        \        \        ,          3,          3,          /# )r"   Úmodelr#   )ÚtorchÚnnÚModuleÚtupler1   rI   Úlist)r$   s   "r   r&   r&   C   s?   € ÷ \ñ \Ü�8‰8�?‰?ð\ä
Œ3””Sœ$œs�)�^Õ$Ð$Õ%ñ\r   c                óˆ   € R pR pR.p/ p\        T TTV P                  4        UUu. uF  w  rVVNK	  	  uppVV4      # u uppi )ao  
It is used for composable fully_shard() code path, it returns
  1. sharded module tree info: each line represents a submodule name that contains the
submodule's FQN and its submodule class name, if the submodule is sharded by `fully_shard`,
the submodule name will add a postfix with ' FULLY SHARDED'. Each increased tree
level adds 4 spaces before the printed name. A printed sharded module tree info for a toy model
is like this:
    [CompositeModel] FULLY SHARDED
        l1[Linear]
        u1[UnitModule] FULLY SHARDED
            u1.l1[Linear]
            u1.seq[Sequential]
                u1.seq.0[ReLU]
                u1.seq.1[Linear]
                u1.seq.2[ReLU]
            u1.l2[Linear]
        u2[UnitModule] FULLY SHARDED
            u2.l1[Linear]
            u2.seq[Sequential]
                u2.seq.0[ReLU]
                u2.seq.1[Linear]
                u2.seq.2[ReLU]
            u2.l2[Linear]
        l2[Linear]
  2. a dict mapping from the concated module FQN and class name to a list of its managed
original parameters' FQNs. An example of the dict for the above toy sharded model is like this:
        {'[CompositeModel]': ['l1.weight', 'l1.bias', 'l2.weight', 'l2.bias'],
         'u1[UnitModule]': ['u1.l1.weight', 'u1.l1.bias', 'u1.seq.1.weight', 'u1.seq.1.bias', 'u1.l2.weight', 'u1.l2.bias'],
         'u2[UnitModule]': ['u2.l1.weight', 'u2.l1.bias', 'u2.seq.1.weight', 'u2.seq.1.bias', 'u2.l2.weight', 'u2.l2.bias']
        }
All FQNs are prefixed starting from ``model``.

Args:
    model (torch.nn.Module): Root module (which may or may not be passed to
                             composable `fully_shard()`).
c                 ó8  € V^,          p\        V4      ^ 8”  d   VR	,          R8X  d   VRR	 MTpVR,           V P                  P                  ,           R,           pRV,          V,           p\        V 4      p	V	f   V^ ;;,          VR,           ,          uu&   R# V	P                  P                  V R4      p
V
'       d%   V^ ;;,          VR,           R,           ,          uu&   MV^ ;;,          VR,           ,          uu&   V
'       d“   V
P                  p\        V\        P                  4      '       g   \        R\        V4       24      hVP                   Uu. uF  p\        W,           4      NK  	  ppWt9   d   WG,          P                  V4       R# WÔV&   R# R# u upi )
é   Ú.NÚ[Ú]Ú Ú
z FULLY SHARDEDzExpected FlatParameter, got éÿÿÿÿ)ÚlenÚ	__class__r   r   Ú_fully_sharded_module_to_handleÚgetÚ
flat_paramÚ
isinstanceÚflat_param_fileÚFlatParameterr3   ÚtypeÚ_fqnsr	   Úextend)ÚmoduleÚprefixÚ
tree_levelÚsharded_tree_infoÚsharded_module_name_to_fqnsÚ
num_spacesÚtrimed_prefixÚprefixed_module_nameÚprinted_prefixed_module_nameÚstateÚhandleÚparamÚnameÚglobal_fqnss   &&&&&         r   Ú	module_fnÚD_get_sharded_module_tree_with_module_name_to_fqns.<locals>.module_fnk   sl  € ð   !•^ˆ
ä ›K¨!œO°°rµ
¸cÔ0AˆF�3�B‰KÈð 	ð  -¨sÕ2°V×5EÑ5E×5NÑ5NÕNÐQTÕTÐØ'*¨ZÕ'7Ð:NÕ'NÐ$ä& vÓ.ˆØŠ=Ø˜a× Ð$@À4Õ$GÕGÓ Ùà×6Ñ6×:Ñ:¸6À4ÓHˆçØ˜a× Ø,Ð/?Õ?À$ÕFõÔ ð ˜a× Ð$@À4Õ$GÕGÓ çØ×%Ñ%ˆEÜ˜e¤_×%BÑ%B×CÒCÜ$Ð'CÄDÈÃKÀ=Ð%QÓRÐRà=B¿[º[óÙ=H°TÔ! &¥-Ö0¹[ð ð ð $ÔBØ+ÕA×HÑHÈÖUàDOÐ,@ÓAñ ùòs   ÅFc                 ó   € V ^ ,          V3# )r   r   )rm   rn   s   &&r   Ú	return_fnÚD_get_sharded_module_tree_with_module_name_to_fqns.<locals>.return_fn�   s   € Ø  Õ#Ð%@Ð@Ð@r   Ú )r   Únamed_parameters)rP   rx   r{   rm   rn   ÚkeyÚ_s   &      r   Ú1_get_sharded_module_tree_with_module_name_to_fqnsr�   C   se   € òP#PòJAð
 	ð$Ðð 9;ÐÜØØØØ ×1Ñ1Ô3Ô4Ñ3‘�‹Ñ3Ò4ØØ#óð ùó 	5s   §>)Úloggingr5   Úcollectionsr   Úcollections.abcr   Ú
contextlibr   Úenumr   rQ   Útorch.distributedÚdistributedr?   Ú"torch.distributed.fsdp._flat_paramÚfsdpÚ_flat_paramre   Ú$torch.distributed.fsdp._common_utilsr   r   r	   Ú	getLoggerr   rD   r   r�   r   r   r   Ú<module>rŽ      sP   ðã Û Ý #Ý $Ý %Ý ã Ý  ß <Ó <÷ñ ð 
×	Ò	˜8Ó	$€÷*ñ *÷Z\r   