+
    \åûj@«  ã                   ó’  € ^ RI t ^ RIt^ RIHtHt ^ RIHt ^ RIHt ^ RI	t	^ RI
Ht ^ RIHtHt ^ RIHt ^ RIHt ^ R	IHt . R!Ot]P,                  ! ]4      ;tt]! RR7       ! R R
4      4       tR R lt]! RR7      R"RRRR/R R lll4       tR R ltR#R R lltR R ltR R lt R#R R llt!]! RR7      RR/R R  ll4       t"R# )$é    N)ÚdefaultdictÚOrderedDict)ÚCallable)ÚAny)Úcompatibility)Ú_LazyGraphModuleÚ_make_graph_module)Úlazy_format_graph_code©ÚGraphModule©ÚNodeÚ	PartitionT)Úis_backward_compatiblec                   óD   a € ] tR t^t o V 3R lR ltV 3R lR ltRtV tR# )r   c                ó$   <€ V ^8„  d   QhRS[ RR/# )é   ÚnameÚreturnN©Ústr)ÚformatÚ__classdict__s   "€ÚXC:\Ai_Coding\apps\studio\ComfyUI\.venv\Lib\site-packages\torch\fx\passes\split_module.pyÚ__annotate__ÚPartition.__annotate__   s   ø€ ÷ 
*ñ 
*™Sð 
* Tñ 
*ó    c                óâ   € Wn         R V 2V n        . V n        / V n        / V n        / V n        / V n        \        P                  P                  P                  4       V n	        / V n        / V n        R# )Úsubmod_N)r   Úsubmod_nameÚ
node_namesÚinputsÚoutputsÚdependenciesÚ
dependentsÚtorchÚfxÚgraphÚGraphÚenvironmentÚtargets)Úselfr   s   &&r   Ú__init__ÚPartition.__init__   sa   € ØŒ	Ø$ T FÐ+ˆÔØ%'ˆŒØ')ˆŒØ(*ˆŒØ-/ˆÔØ+-ˆŒÜ+0¯8©8¯>©>×+?Ñ+?Ó+AˆŒ
Ø-/ˆÔØ')ˆŽr   c                ó    <€ V ^8„  d   QhRS[ /# ©r   r   r   )r   r   s   "€r   r   r   !   s   ø€ ÷ 
ñ 
™#ñ 
r   c                ó¢   € R V P                    RV P                   RV P                   RV P                   RV P                   RV P
                   2# )zname: z
,
 nodes: z,
 inputs: z,
 outputs: z,
 partitions depended on: z,
 partition dependents: )r   r!   r"   r#   r$   r%   )r,   s   &r   Ú__repr__ÚPartition.__repr__!   sb   € à�T—Y‘Y�Kð  Ø—‘Ð'ð (ØŸ™�}ð %ØŸ™˜ð '(Ø(,×(9Ñ(9Ð':ð ;&Ø&*§o¡oÐ%6ð8ð	
r   )
r$   r%   r*   r(   r"   r   r!   r#   r    r+   N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__r-   r2   Ú__static_attributes__Ú__classdictcell__)r   s   @r   r   r      s   ø‡ € ÷
*ð 
*÷
ö 
r   c                ód   € V ^8„  d   QhR\         P                  P                  R\        R\        /# )r   ÚmodÚqualnamer   )r&   ÚnnÚModuler   r   )r   s   "r   r   r   ,   s)   € ÷ ñ ¤§¡§¡ð ¼Cð ÄCñ r   c                 ó�   € T pVP                  R 4       F.  p\        W#4      '       g   \        RV R24      h\        W#4      pK0  	  V# )Ú.zNode target z not found!)ÚsplitÚhasattrÚAttributeErrorÚgetattr)r;   r<   Úattr_valÚatoms   &&  r   Ú_get_attr_from_qualnamerG   ,   sJ   € Ø€HØ—‘˜sÖ#ˆÜ�x×&Ò&Ü  <°¨z¸Ð!EÓFÐFÜ˜8Ó*Šñ $ð €Or   FÚpartition_affixÚtuple_returnc                ó6  € V ^8„  d   QhR\         R\        P                  P                  R\        \
        .\        3,          R\        \        \        3,          R,          R\        R,          R\        R,          R\        R	\        R,          R
\        R\         /
# )r   ÚmÚroot_mÚsplit_callbackÚqualname_mapNÚkeep_original_orderÚkeep_original_node_nameÚkeep_original_input_namerH   rI   r   )
r   r&   r=   r>   r   r   ÚintÚdictr   Úbool)r   s   "r   r   r   7   s¤   € ÷ G
ñ G
ÜðG
ä�H‰H�O‰OðG
ô œd˜V¤S˜[Õ)ðG
ô ”sœC�x•. 4Õ'ð	G
ô
  �ðG
ô " D�[ðG
ô #ðG
ô ˜4•ZðG
ô ðG
ô ñG
r   c               óœ%  a aaaaa5aBaCaDaEaFaGaHaIaJaKaL€ \         P                  R\        RS RR7      4       R VCVV 3R llp	^ RIp
/ oJ/ oH/ oLR VJVL3R	 lloKR
 VVJV3R llp\        P
                  P                  \        P
                  P                  \        P                  P                  .p\        4       p\        4       p/ pRp\        4       pS P                  P                   EFo  o5S5P                  P                  R4      ;peƒ   \!        V\        P"                  \        P$                  34      '       dS   \!        VP&                  P(                  ;pV
P*                  4      '       d!   VSL9  d   S5SLVP&                  P(                  &   S5P,                  R79   d   K¸  V! S54       S5P,                  R8X  EdU   S5P.                  V9   EdC   S5P.                  \        P                  P                  J d¤   \1        S5P2                  4      ^8w  d"   \5        R\1        S5P2                  4       24      h\!        S5P2                  ^ ,          \6        4      '       g)   \5        R\9        S5P2                  ^ ,          4       24      hS5p\        S! S54      04      VV&   EMwS5P.                  \        P
                  P                  J d†   \:        ;QJ d&    R S5P2                   4       F  '       d   K   RM	  RM! R S5P2                   4       4      '       g   \5        R4      hVP=                  S54       \        S! S54      04      VS5&   RVS5&   MÊS5P.                  \        P
                  P                  J d£   \1        S5P2                  4      ^8w  d"   \5        R\1        S5P2                  4       24      hVS5P2                  ^ ,          ,          P=                  S! S54      4       VP?                  S5P2                  ^ ,          4       S5VS5P2                  ^ ,          &   Ve   VV,          P=                  S! S54      4       V F!  pVV,          P=                  S! S54      4       K#  	  EKr  	  \:        ;QJ d*    R VPA                  4        4       F  '       d   K   RM	  RM! R VPA                  4        4       4      '       g   \5        R4      hVPC                  4        UUu/ uF  w  ppV\E        V4      bK  	  pppVPC                  4        UUu/ uF  w  ppV\E        V4      bK  	  ppp\F        PI                  \J        PL                  4      '       d-   \F        P                  RV4       \F        P                  RV4       \7        V4      ;'       g    \7        V4      pR8pS P                  P                   EF'  o5S5SHS5PN                  &   S5P,                  R99   d   K&  S5P,                  R8X  dB   \        PP                  P                  PS                  S5P2                  ^ ,          VK3R l4       Kx  V'       d#   S! S54      pVV8”  d   \5        RV RV 24      hTpS5P.                  V9  g   Kµ  \        PP                  P                  PS                  S5P2                  V5VK3R l4       \        PP                  P                  PS                  S5PT                  V5VK3R l4       EK*  	  \W        SJPY                  4       4      p. pSJPC                  4        F4  w  poI\1        SIPZ                  4      '       d   K#  VP]                  V4       K6  	  . pV'       dŒ   VP_                  4       pVP]                  V4       SJV,          P`                   FQ  pSJV,          PZ                  P_                  V4       SJV,          PZ                  '       d   K@  VP]                  V4       KS  	  K“  \1        V4      \1        SJ4      8w  d   \c        R 4      hWí3 EF-  p V PC                  4        EF  w  o5p!\1        V!4      ^ 8X  d   \5        R!4      hS5SJ\e        V!^ ,          4      ,          Pf                  S5&   V!R",           F¿  p"SJ\e        V"4      ,          oISIP                  Pi                  S5P,                  S5P.                  \j        ;QJ d    . R# S5P2                   4       F  NK  	  5M! R# S5P2                   4       4      / S5P8                  R$7      p#S5P                  Pm                  4       V#n        V#SIPf                  S5&   KÁ  	  EK  	  EK0  	  V EF  pSJV,          oI/ oG^ oD. p$. p%SIPn                   FŸ  oFSHSF,          p&V&P,                  R8X  dr   \!        V&P.                  \d        4      '       dR   \!        \q        S V&P.                  4      \        Pr                  Pt                  4      '       d   V%P]                  SF4       KŽ  V$P]                  SF4       K¡  	  V$V%,            EF7  oFSHSF,          p&R% VDVFVVGVHVI3R& llp'V&P,                  R8X  dÉ   \!        V&P.                  \d        4      '       g"   \5        R'\9        V&P.                  4       24      h\q        S V&P.                  4      p(\!        V(\        Pr                  Pt                  4      '       d@   SIP                  Pw                  V&P.                  4      p)V(SIPx                  V&P.                  &   MV'! 4       p)MV'! 4       p)SHSF,          P                  Pm                  4       V)n        V)SIPf                  SHSF,          &   EK:  	  SGSIn7        EK  	  S P                  P                   EFý  o5\{        S5R(4      '       g   K  SJS5P|                  ,          oISIPf                  oE\        PP                  P                  PS                  S5P2                  VE3R) l4      p*\        PP                  P                  PS                  S5PT                  VE3R* l4      p+S5P,                  R:9  d   S5P.                  p,Me\q        S S5P.                  4      p-S5P.                  P                  R+R,4      p,V-SIPx                  V,&   Ve!   SIP€                   R+V, 2p.S5P.                  VV.&   \!        V*\j        4      '       g   \5        R-\9        V*4       24      h\!        V+\‚        4      '       g   \5        R.\9        V+4       24      hS'       d   S5PN                  MRp/SIP                  Pi                  S5P,                  V,V*V+S5P8                  V/R/7      p#S5P                  Pm                  4       V#n        V#SIPf                  S5&   EK   	  V3 FÞ  p \…        V 4       FÌ  o5V S5,          p!\1        V!4      ^ 8X  d   \5        R04      hV!RR8  Fœ  p"SJ\e        V"4      ,          oIVS5,          p0V0f   \5        R14      hSIP                  Pi                  V0P,                  V0P.                  SIPf                  S5,          3/ V0P8                  R$7      p#V0P                  Pm                  4       V#n        Kž  	  KÎ  	  Kà  	  / p1/ oB\        PP                  P                  P‡                  4       oC/ p2V'       g,   S P                  P                   F  o5V	! S5SBV24      w  oBp2K  	  M,S P                  P                   F  o5S5V1S5PN                  &   K  	  V'       g   TMTp3\        4       p4S P                  P                   U5u. uF  p5V5P,                  R8X  g   K  V5NK  	  p6p5V3 EF‚  pSJV,          oI\j        ;QJ d"    . VHVI3R2 lSIPˆ                   4       F  NK  	  5M! VHVI3R2 lSIPˆ                   4       4      p7\1        V74      ^8X  d,   V'       g$   SIP                  P‹                  V7^ ,          4       MSIP                  P‹                  V74       V'       dŒ   SIPn                   U8u. uF  p8V8V69  g   K  V1V8,          NK  	  p9p8V6 F*  o5S5V49   d   K  V	! S5SBV24      w  oBp:V4P=                  S54       K,  	  V9 F*  o5S5V49   d   K  V	! S5SBV24      w  oBp2V4P=                  S54       K,  	  \�        SIPx                  SIP                  4      V2SIP€                  &   SCP�                  SIP€                  \j        ;QJ d!    . VB3R3 lSIPn                   4       F  NK  	  5M! VB3R3 lSIPn                   4       4      4      p;\1        SIPˆ                  4      p<V<^8”  g   V<^8X  dj   V'       db   \        PP                  P�                  P“                  V;4      p=\•        SIPˆ                  4       F  w  p>p?V=V>,          P&                  SBV?&   K  	  EKW  V<^8X  g   EKa  V;SB\—        \™        SIPˆ                  4      4      &   EK…  	  V'       d3   SB'       g+   S P                  P                   F  o5V	! S5SBV24      w  oBp2K  	  S P                  P                   Fd  o5S5P,                  R8X  g   K  SCP‹                  \        PP                  P                  PS                  S5P2                  ^ ,          VB3R4 l4      4       Kf  	  \�        V2SC4      p@SJPA                  4        UAu0 uF  pAVAP€                  kK  	  upAX@P                  R5&   \         P                  R\        R6V@RR7      4       V@# u uppi u uppi u up5i u up8i u upAi );a>  
Creates subgraphs out of main graph

Args:
    m (GraphModule): Graph module to split
    root_m (torch.nn.Module): root nn module. Not currently used. Included
        because the root nn module is usually transformed via
        torch.fx._symbolic_trace.symbolic_trace (see example below)
    split_callback (Callable[[Node], int]): Callable function
        that maps a given Node instance to a numeric partition identifier.
        split_module will use this function as the policy for which operations
        appear in which partitions in the output Module.
    qualname_map: Optional[Dict[str, str]]: optional output parameter that returns a
        mapping from new target names in the module after split to old target
        names in the original module.
    keep_original_order: Optional[bool]: keep the original order of the GraphModule
        or use the Topological order of the new constructed GraphModule
    keep_original_node_name: Optional[bool]: If the partitioned graphs should
        have the same node names as the original graph.
    keep_original_input_name: bool: If the partitioned graphs should
        have the same input names as the original graph.
    partition_affix: Optional[str]: If specified, the submodules' names will contain
        the affix, e.g. "submod_<affix>_<idx>".
    tuple_return: bool: If True, submodule outputs are always wrapped in a tuple,
        even when there is only a single output value.  This makes all subgraphs
        conform to the convention expected by ``torch._inductor.compile_fx``.

Returns:
    GraphModule: the module after split.

Example:

    This is a sample setup:

        import torch
        from torch.fx._symbolic_trace import symbolic_trace
        from torch.fx.graph_module import GraphModule
        from torch.fx.node import Node
        from torch.fx.passes.split_module import split_module

        class MyModule(torch.nn.Module):
            def __init__(self) -> None:
                super().__init__()
                self.param = torch.nn.Parameter(torch.rand(3, 4))
                self.linear = torch.nn.Linear(4, 5)

            def forward(self, x, y):
                z = self.linear(x + self.param).clamp(min=0.0, max=1.0)
                w = self.linear(y).clamp(min=0.0, max=1.0)
                return z + w

        # symbolically trace model
        my_module = MyModule()
        my_module_traced = symbolic_trace(my_module)

        # random mod partitioning
        partition_counter = 0
        NPARTITIONS = 3

        def mod_partition(node: Node):
            global partition_counter
            partition = partition_counter % NPARTITIONS
            partition_counter = (partition_counter + 1) % NPARTITIONS
            return partition

        # split module in module with submodules
        module_with_submodules = split_module(
            my_module_traced, my_module, mod_partition
        )

    Output looks like this. Original graph is broken into partitions

        > print(module_with_submodules)
        GraphModule(
            (submod_0): GraphModule(
                (linear): Linear(in_features=4, out_features=5, bias=True)
            )
            (submod_1): GraphModule(
                (linear): Linear(in_features=4, out_features=5, bias=True)
            )
            (submod_2): GraphModule()
        )

        def forward(self, x, y):
            param = self.param
            submod_0 = self.submod_0(x, param, y);  x = param = y = None
            getitem = submod_0[0]
            getitem_1 = submod_0[1];  submod_0 = None
            submod_1 = self.submod_1(getitem, getitem_1);  getitem = getitem_1 = None
            getitem_2 = submod_1[0]
            getitem_3 = submod_1[1];  submod_1 = None
            submod_2 = self.submod_2(getitem_2, getitem_3);  getitem_2 = getitem_3 = None
            return submod_2

    Output of split module is the same as output of input traced module.
    This is an example within a test setting:

        > orig_out = my_module_traced(x, y)
        > submodules_out = module_with_submodules(x, y)
        > self.assertEqual(orig_out, submodules_out)
        True
z%szpre split_moduleT)Úcoloredc                ój  € V ^8„  d   QhR\         R\        \        \         3,          R\        \        \        P                  P
                  P                  3,          R\        \        \        \         3,          \        \        \        P                  P
                  P                  3,          3,          /# )r   ÚnodeÚbase_mod_envÚbase_mod_attrsr   )r   rS   r   r&   r'   Úgraph_moduler   Útuple)r   s   "r   r   Ú"split_module.<locals>.__annotate__¯   s~   € ÷ !,ñ !,Üð!,äœ3¤˜9•oð!,ô œS¤%§(¡(×"7Ñ"7×"CÑ"CÐCÕDð!,ô 
Œt”Cœ�I�¤¤S¬%¯(©(×*?Ñ*?×*KÑ*KÐ%KÕ LÐLÕ	Mñ	!,r   c                 óâ  <€ V P                   R 8X  Ed   \        V P                  4      ^ 8”  d   V P                  ^ ,          M\        P                  P
                  pS'       dZ   V\        P                  P
                  J d   RMV3pSP                  R V P                  VV P                  R7      WP                  &   M4SP                  V P                  V P                  VR7      WP                  &   V P                  P                  4       WP                  ,          n        W3# V P                   R8X  d¼   SP                  V P                  4      WP                  &   V P                  P                  4       WP                  ,          n        \        V P                  \        4      '       g"   \!        R\        V P                  4       24      h\#        SV P                  4      pWRV P                  &   W3# )Úplaceholder)ÚargsÚ	type_expr)ra   Údefault_valueÚget_attrúExpected str target, got © )ÚopÚlenr`   ÚinspectÚ	SignatureÚemptyÚcreate_noder   Útyper_   ÚtargetÚmetaÚcopyrc   Ú
isinstancer   ÚAssertionErrorrG   )	rX   rY   rZ   rb   r`   rE   Úbase_mod_graphrP   rK   s	   &&&   €€€r   Úconstruct_graphÚ%split_module.<locals>.construct_graph¯   sƒ  ø€ ð
 �7‰7�mÕ#ä # D§I¡I£°Ô 2�—	‘	˜!–¼×8IÑ8I×8OÑ8Oð ÷ 'à'¬7×+<Ñ+<×+BÑ+BÓB‘BÈÐHXð ð +9×*DÑ*DØ!Ø—I‘IØØ"Ÿi™ið	 +Eó +�ŸY™YÒ'ð +9×*DÑ*DØ—K‘KØ"Ÿi™iØ"/ð +Eó +�ŸY™YÑ'ð
 ,0¯9©9¯>©>Ó+;ˆLŸ™Õ#Ô(ð Ð+Ð+ð �W‰W˜
Ô"Ø&4×&=Ñ&=¸d¿k¹kÓ&JˆLŸ™Ñ#Ø+/¯9©9¯>©>Ó+;ˆLŸ™Õ#Ô(Ü˜dŸk™k¬3×/Ò/Ü$Ð'@ÄÀdÇkÁkÓARÐ@SÐ%TÓUÐUÜ.¨q°$·+±+Ó>ˆHØ*2˜4Ÿ;™;Ñ'ØÐ+Ð+r   Nc                óB   € V ^8„  d   QhR\         R\         R,          RR/# )r   Údef_nodeÚuse_nodeNr   r   )r   s   "r   r   r]   Ø   s*   € ÷ /Cñ /C¬Tð /C¼TÀD½[ð /CÈTñ /Cr   c                 ó  <€ ^ RI Hp \        V RR4      p\        VRR4      p\        P	                  RV P
                  TVe   VP
                  MRV4       W48w  Ed¦   VeN   SV,          pVP                  P                  V P
                  4       Ve   VP                  P                  V4       VEeN   SV,          pVP                  P                  V P
                  4       V P                  P                  R4      ;peÞ   \        V! V4      \        R7       FÂ  pSV,          p	VP                  P                  V	P
                  4       SV,          P                  R8w  g   KK  \        V	RR4      p
V
f   K^  SV
,          pVP                  P                  V	P
                  4       VP                  P                  V4       VP                  P                  V
4       KÄ  	  Ve   VP                  P                  V4       R# R# R# R# )	r   ©Úfree_symbolsÚ_fx_partitionNz*record_cross_partition_use %s (%s) %s (%s)Ú-Úexample_value©Úkeyr_   )Ú%torch.fx.experimental.symbolic_shapesrz   rD   ÚlogÚdebugr   r#   Ú
setdefaultr%   r"   rn   ÚgetÚsortedr   rf   r$   )rv   rw   rz   ÚdefinedÚusedÚdef_partitionÚuse_partitionÚdef_valÚsÚs_nodeÚ	s_definedÚs_def_partitionÚ
partitionsÚsymbol_to_nodes   &&          €€r   Úrecord_cross_partition_useÚ0split_module.<locals>.record_cross_partition_useØ   s°  ø€ ÝFä˜( O°TÓ:ˆÜ�x °$Ó7ˆä�	‰	Ø8Ø�M‰MØØ%Ò1ˆH�MŠM°sØô	
ð �?ØÒ"Ø *¨7Õ 3�Ø×%Ñ%×0Ñ0°·±Ô?ØÒ#Ø!×,Ñ,×7Ñ7¸Ô=àÓØ *¨4Õ 0�Ø×$Ñ$×/Ñ/°·±Ô>ð  (Ÿ}™}×0Ñ0°ÓAÐA�GÒNÜ#¡L°Ó$9¼s×C˜Ø!/°Õ!2˜Ø%×,Ñ,×7Ñ7¸¿¹ÔDØ)¨!Õ,×/Ñ/°=Ö@ô )0°¸ÈÓ(N˜IØ(Ô4Ø2<¸YÕ2G Ø /× 7Ñ 7× BÑ BÀ6Ç;Á;Ô OØ /× :Ñ :× EÑ EÀdÔ KØ -× :Ñ :× EÑ EÀiÖ Pñ# Dð$ Ò&Ø!×.Ñ.×9Ñ9¸'ÖBñ 'ñ3  ñ r   c                ó(   € V ^8„  d   QhR\         RR/# )r   rX   r   Nr   )r   s   "r   r   r]   	  s   € ÷ ,ñ ,´ð ,¸$ñ ,r   c                 ó>  <€ S! V 4      p\        V4      pSe   RP                  SV.4      p\        P                  RV P                  V4       SP                  V4      pVf   \        V4      ;SV&   pVP                  P                  V P                  4       W n	        R # )NÚ_z*instantiate_node_partition_mapping %s (%s))
r   Újoinr�   r‚   r   r„   r   r!   Úappendr{   )rX   Úpartition_idxÚpartition_nameÚ	partitionrH   r�   rM   s   &   €€€r   Ú"instantiate_node_partition_mappingÚ8split_module.<locals>.instantiate_node_partition_mapping	  s‘   ø€ Ù& tÓ,ˆÜ˜]Ó+ˆØÒ&ð !ŸX™X ¸Ð&GÓHˆNä�	‰	Ø8¸$¿)¹)À^ô	
ð
 —N‘N >Ó2ˆ	ØÒÜ5>¸~Ó5NÐNˆJ�~Ñ&¨à×Ñ×#Ñ# D§I¡IÔ.Ø+Ör   r}   r_   rc   ÚoutputÚcall_functionz*Expected 1 arg for _set_grad_enabled, got zExpected bool arg, got c              3   óL   "  € T F  p\        V\        4      '       * x € K  	  R # 5i©N)rp   r   ©Ú.0Úargs   & r   Ú	<genexpr>Úsplit_module.<locals>.<genexpr>Y  s   é € ÐJÁ	¸œz¨#¬tÓ4×4Ñ4Ã	ùs   ‚"$Fz3Expected all args to be python constants, not Nodesz'Expected 1 arg for _exit_autocast, got c              3   ó(   "  € T F  qR Jx € K
  	  R # 5ir    re   )r¢   Úvs   & r   r¤   r¥   o  s   é € Ð>Ñ&= ˜�}Ó&=ùs   ‚zautocast must exitzautocast_regions: %szgrad_regions: %sc                 ó   <€ S! V R 4      # r    re   )Únr‘   s   &€r   Ú<lambda>Úsplit_module.<locals>.<lambda>ˆ  s   ø€ Ñ(BÀ1ÀdÔ(Kr   zSautocast or set_grad_enabled require monotonically increasing partitions: highest: z, this node's: c                 ó   <€ S! V S4      # r    re   ©rv   rX   r‘   s   &€€r   rª   r«   ™  s   ø€ Ñ,FÀxÐQUÔ,Vr   c                 ó   <€ S! V S4      # r    re   r­   s   &€€r   rª   r«   œ  s   ø€ Ñ.HÈÐSWÔ.Xr   z cycle exists between partitions!z%Expected at least one region for node:é   NNc              3   ó$   "  € T F  qx € K  	  R # 5ir    re   r¡   s   & r   r¤   r¥   À  s   é € Ð8©i sœs«iùs   ‚©rf   rm   r`   Úkwargsra   c                ó$   € V ^8„  d   QhR\         /# r0   r   )r   s   "r   r   r]   ç  s   € ÷ #ñ #¤Tñ #r   c                  ó    <€ S'       d   Sp MR S 2p S^,          oSP                   P                  V SS,          P                  R7      pRSS&   V# )Úarg_©ra   N)r(   r_   rl   )r   r_   ÚcounterÚinprQ   Ú
new_inputsÚ
orig_nodesrš   s     €€€€€€r   Úadd_placeholderÚ%split_module.<locals>.add_placeholderç  s\   ø€ ß+Ø‘Dð " ' Ð+�DØ˜q•L�GØ'Ÿo™o×9Ñ9ØØ(¨�o×2Ñ2ð :ó �ð #'�
˜3‘Ø"Ð"r   rd   r{   c                 ó   <€ SV ,          # r    re   ©r©   r*   s   &€r   rª   r«     s
   ø€ ÈÐTUÎr   c                 ó   <€ SV ,          # r    re   r¾   s   &€r   rª   r«     s	   ø€  {°1¦~r   r@   r•   z&Expected tuple for gathered_args, got z'Expected dict for gathered_kwargs, got )rf   rm   r`   r²   ra   r   zExpected at least one regionzMissing exit nodec              3   óX   <"  € T F  pSP                   SV,          ,          x € K!  	  R # 5ir    )r*   )r¢   r   rº   rš   s   & €€r   r¤   r¥   p  s(   øé € ð 
Ù@Q¸ˆI×!Ñ! *¨TÕ"2×3Ò3Ó@Qùs   ƒ'*c              3   ó6   <"  € T F  pSV,          x € K  	  R # 5ir    re   )r¢   r   rY   s   & €r   r¤   r¥   ™  s   øé € ÐBÑ1A¨�,˜t×$Ò$Ó1Aùó   ƒc                 ó*   <€ SV P                   ,          # r    ©r   )r©   rY   s   &€r   rª   r«   ³  s   ø€ ¸|ÈAÏFÉFÖ?Sr   Úpartition_nameszpost split_module)r_   rc   r�   éÿÿÿÿ)r_   rc   )Úcall_modulerc   )Mr�   r‚   r
   Úsympyr&   ÚampÚ_enter_autocastÚ_exit_autocastÚ_CÚ_set_grad_enabledr   Úsetr(   Únodesrn   r„   rp   ÚSymIntÚSymFloatrX   ÚexprÚSymbolrf   rm   rg   r`   rq   rT   rl   ÚallÚaddÚremoveÚvaluesÚitemsr…   Ú_LOGGERÚisEnabledForÚloggingÚDEBUGr   r'   Úmap_argr²   ÚlistÚkeysr$   r—   Úpopr%   ÚRuntimeErrorr   r*   rk   r\   ro   r"   rG   r=   r>   rc   r+   rB   r{   Úreplacer    rS   Úreversedr)   r#   r�   r	   rÇ   ÚproxyÚProxyÚ	enumerateÚnextÚiter)MrK   rL   rM   rN   rO   rP   rQ   rH   rI   rs   rÈ   r›   ÚGLOBAL_STATE_NODESÚgrad_regionsÚautocast_regionsÚautocast_exitsÚactive_gradÚactive_autocastsÚvalÚs0ÚaÚkr§   Úassert_monotonically_increasingÚhighest_partitionÚpidÚoriginal_partition_orderÚroot_partitionsr™   Úsorted_partitionsÚroot_partitionÚ	dependentÚregions_mappingÚregionsÚrÚnew_nodeÚplaceholder_inputsÚget_attr_inputsÚ	orig_noder»   Ú	orig_attrr_   Úgathered_argsÚgathered_kwargsrm   Útarget_attrr<   r   Ú	exit_nodeÚorig_mod_envrZ   Úconstruct_order_partitionsÚalready_constructed_attr_nodesrX   Úoriginal_orderÚoutput_valsr   Úorig_mod_attr_nodesÚ_based_mod_attrsÚ
output_valÚnum_outputsÚoutput_val_proxyÚiÚoutput_nameÚretÚprY   rr   r·   r*   r¸   r¹   rº   rš   r�   r‘   r�   sM   f&f&&ffd$                                            `            @@@@@@@@@@@r   Úsplit_moduler  6   sI  ÿÿø€ ôh ‡I�IØÜÐ1°1¸dÔCô÷
!,ò !,óF à')€JØ"$€JØ/1€N÷/Cñ /C÷b,ò ,ô. 	�	‰	×!Ñ!Ü�	‰	× Ñ Ü�‰×"Ñ"ðÐô 1<³€Lô 5@³MÐØ.0€Nà€KÜ“uÐà—‘—•ˆð —I‘I—M‘M /Ó2Ð2ˆSÒ?Ü˜3¤§¡¬u¯~©~Ð >×?Ò?Ü §¡§¡Ð.˜2°·±×=Ò=Ø˜.Ô(à,0ˆN˜3Ÿ8™8Ÿ=™=Ñ)à�7‰7Ð;Ô;Ùá*¨4Ô0à�7‰7�oÕ%¨$¯+©+Ð9KÕ*KØ�{‰{œeŸh™h×8Ñ8Ó8Ü�t—y‘y“> QÔ&Ü(ØDÄSÈÏÉÃ^ÐDTÐUóð ô " $§)¡)¨A¥,´×5Ò5Ü(Ð+BÄ4ÈÏ	É	ÐRSÍÓCUÐBVÐ)WÓXÐXØ"�Ü,/±ÀÓ1EÐ0FÓ,G�˜[Ó)Ø—‘¤§	¡	× 9Ñ 9Ó9ç“sÑJÀÇ	Â	ÓJ—s—s’sÑJÀÇ	Â	ÓJ×JÒJÜ(ØMóð ð !×$Ñ$ TÔ*Ü),©n¸TÓ.BÐ-CÓ)DÐ  Ñ&Ø'+�˜tÒ$Ø—‘¤§	¡	× 8Ñ 8Ó8Ü�t—y‘y“> QÔ&Ü(ØAÄ#ÀdÇiÁiÃ.ÐAQÐRóð ð ! §¡¨1¥Õ.×2Ñ2±>À$Ó3GÔHØ ×'Ñ'¨¯	©	°!­Ô5Ø/3�˜tŸy™y¨�|Ñ,àÒ"Ø˜Õ%×)Ñ)©.¸Ó*>Ô?ã!ˆAØ˜QÕ×#Ñ#¡N°4Ó$8Ö9ô "ñi ÷n ‹3Ñ> n×&;Ñ&;Ô&=Ó>�3�3Š3Ñ> n×&;Ñ&;Ô&=Ó>×>Ò>ÜÐ1Ó2Ð2ð 2B×1GÑ1GÔ1IÔJÑ1I©¨¨A˜œ6 !›9šÑ1IÐÑJà-9×-?Ñ-?Ô-AÔBÑ-A¡T Q¨�A”v˜a“y’LÑ-A€LÑBä×ÑœGŸM™M×*Ò*Ü�‰Ð,Ð.>Ô?Ü�‰Ð(¨,Ô7ä&*Ð+;Ó&<×&RÐ&RÄÀ\Ó@RÐ#ð ÐØ—‘—•ˆØ $ˆ
�4—9‘9Ñð �7‰7Ð1Ô1ÙØ�7‰7�hÔÜ�H‰H�N‰N×"Ñ"Ø—	‘	˜!•ÔKôñ ç*Ù  Ó&ˆCØ  3Ô&Ü$ð,Ø,=Ð+>¸oÈcÈUðTóð ð !$Ðð �;‰;Ð0Ö0Ü�H‰H�N‰N×"Ñ"Ø—	‘	ÕVôô �H‰H�N‰N×"Ñ"Ø—‘ÕX÷ñ9 ô@  $ J§O¡OÓ$5Ó6Ðà!#€OØ%/×%5Ñ%5Ö%7Ñ!ˆ˜	Ü�9×)Ñ)×*Ô*Ø×"Ñ" >Ö2ñ &8ð
 $&Ðß
Ø(×,Ñ,Ó.ˆØ× Ñ  Ô0Ø# NÕ3×>Ô>ˆIØ�yÕ!×.Ñ.×2Ñ2°>ÔBØ˜iÕ(×5×5Ò5Ø×&Ñ& yÖ1ó ?ô ÐÓ¤ Z£Ô0ÜÐ=Ó>Ð>ð -Ô;ˆØ,×2Ñ2×4‰MˆD�'Ü�7‹|˜qÔ Ü$Ð%LÓMÐMà<@ˆJ”s˜7 1�:“Õ'×3Ñ3°DÑ9ð ˜R—[�[�Ø&¤s¨1£vÕ.�	Ø$Ÿ?™?×6Ñ6Ø—w‘wØŸ;™;ßœÑ8¨d¯iªiÓ8Ÿ™Ñ8¨d¯iªiÓ8Ó8ØØ"Ÿi™ið 7ó �ð —I‘I—N‘NÓ$ð ”ð /7�	×%Ñ% dÓ+ô !ô 5ñ <ô. ,ˆØ˜~Õ.ˆ	Ø&(ˆ
àˆð
 )+ÐØ%'ˆØ×#Ô#ˆCØ" 3�ˆIà—‘ 
Ô*Ü˜y×/Ñ/´×5Ò5ÜÜ+¨A¨y×/?Ñ/?Ó@Ä%Ç(Á(Ç/Á/÷ò ð  ×&Ñ& sÖ+à"×)Ñ)¨#Ö.ñ $ð &¨×7Ñ7ˆCØ" 3�ˆI÷#õ #ð �|‰|˜zÔ)Ü! )×"2Ñ"2´C×8Ò8Ü(Ø3´D¸×9IÑ9IÓ4JÐ3KÐLóð ô 4°A°y×7GÑ7GÓH�	Ü˜i¬¯©¯©×9Ò9Ø"+§/¡/×":Ñ":¸9×;KÑ;KÓ"L�KØ:C�I×%Ñ% i×&6Ñ&6Ò7á"1Ó"3‘Ká-Ó/�Ø)¨#�×3Ñ3×8Ñ8Ó:ˆKÔØ5@ˆI×!Ñ! *¨S¥/Ô2ñE 8ðF &ˆ	×ñw ,ð| —‘—•ˆÜ�4˜×)Ô)Ø" 4×#5Ñ#5Õ6ˆIð $×/Ñ/ˆKÜ!ŸH™HŸN™N×2Ñ2°4·9±9Ô>VÓWˆMÜ#Ÿh™hŸn™n×4Ñ4Ø—‘Ô5óˆOð �w‰wÐ9Ô9ØŸ™‘ä5°a¸¿¹ÓE�ØŸ™×,Ñ,¨S°#Ó6�Ø,7�	×!Ñ! &Ñ)àÒ+ð #,×"7Ñ"7Ð!8¸¸&¸ÐB�HØ-1¯[©[�L Ñ*ä˜m¬U×3Ò3Ü$Ø<¼TÀ-Ó=PÐ<QÐRóð ô ˜o¬t×4Ò4Ü$Ø=¼dÀ?Ó>SÐ=TÐUóð ÷ !8�4—9’9¸TˆDØ —‘×2Ñ2Ø—7‘7ØØ"Ø&ØŸ)™)Øð 3ó ˆHð !ŸI™IŸN™NÓ,ˆHŒMØ*2ˆI×!Ñ! $Ô'ñU ðZ -Ó-ˆÜ˜_Ö-ˆDØ% dÕ+ˆGÜ�7‹|˜qÔ Ü$Ð%CÓDÐDà˜S˜b“\�Ø&¤s¨1£vÕ.�	Ø*¨4Õ0�	ØÒ$Ü(Ð)<Ó=Ð=Ø$Ÿ?™?×6Ñ6Ø —|‘|Ø$×+Ñ+Ø#×/Ñ/°Õ5Ð7ØØ'Ÿn™nð 7ó �ð —N‘N×'Ñ'Ó)ð –ó "ó .ñ .ð. %'€Là$&€LÜ+0¯8©8¯>©>×+?Ñ+?Ó+A€NØCE€NßØ—G‘G—M”MˆDÙ+:Ø�l Nó,Ñ(ˆLš.ò "ð —G‘G—M”MˆDØ&*ˆL˜Ÿ™Ó#ñ "÷ "5ÑÐ:Rð ô &)£UÐ"ð ()§w¡w§}¢}ÓQ¡}˜t¸¿¹À=Ñ8P—d�d¡}€NÐQä4ˆØ˜~Õ.ˆ	÷ ”eõ 
Ø@I×@QÒ@Qó
—e‘eõ 
Ø@I×@QÒ@Qó
ó 
ˆô ˆ{Ó˜qÔ ¯Ø�O‰O×"Ñ" ;¨q¥>Õ2à�O‰O×"Ñ" ;Ô/çð %×+Ò+ó/á+�CØ˜nÑ,ô "�˜S×!Ð!Ù+ð  ð /ó '�ØÐ9Ô9ÙÙ1@Ø˜,¨ó2Ñ.�Ð.ð /×2Ñ2°4Ö8ñ 'ó ,�ØÐ9Ô9ÙÙ/>Ø˜,¨ó0Ñ,�˜nð /×2Ñ2°4Ö8ñ ,ô 1CØ×Ñ˜yŸ™ó1
ˆ�y×,Ñ,Ñ-ð
 $×/Ñ/Ø×!Ñ!ßŒEÔB°×1AÒ1AÓB�E‰EÔB°×1AÒ1AÓBÓBó
ˆ
ô
 ˜)×+Ñ+Ó,ˆØ˜Œ?˜{¨aÔ/·Lä$Ÿx™xŸ~™~×3Ñ3°JÓ?ÐÜ"+¨I×,=Ñ,=Ö">‘��;Ø,<¸QÕ,?×,DÑ,D�˜[Ó)ô #?à˜A×Ø:DˆLœœd 9×#4Ñ#4Ó5Ó6Ô7ño 5÷z §<Ø—G‘G—M”MˆDÙ+:Ø�l Nó,Ñ(ˆLš.ñ "ð —‘—”ˆØ�7‰7�hÖØ×!Ñ!Ü—‘—‘×&Ñ& t§y¡y°¥|Ô5SÓTöñ ô ˜^¨^Ó
<€Cð ;E×:KÑ:KÔ:MÓ"NÑ:M°Q 1§=¤=Ñ:MÑ"N€C‡H�HÐÑÜ‡I�IØÜÐ2°CÀÔFôð €JùóW
 KùãBùòj Rùò"/ùò| #Os2   ÓAJ3Ó9AJ9û+AJ?üAJ?ÿ	AKÿAKÁI*AK	c                ó(   € V ^8„  d   QhR\         RR/# )r   rK   r   Nr   )r   s   "r   r   r   Á  s   € ÷ )!ñ )!œ[ð )!¨Tñ )!r   c           	     ó\  € \        V P                  P                  RRR7      4      pV EFë  p\        VP                  4      ^8”  g   VP
                  '       d   K2  VP                  ^ ,          pVP                  P                  R4      pVf   Kf  . pV P                  P                  V4      ;_uu_ 4        \        VP                  4       F¹  w  rg\        V\        P                  4      '       dl   V P                  P                  \        P                  P                   P"                  P$                  W63R7      pWxP                  R&   VP'                  V4       K�  \        V\$        4      '       g   K¨  VP'                  V4       K»  	  RRR4       \        VP(                  4       FQ  p	. p
V	P                   F,  pW²J d   V
P+                  V4       K  V
P'                  V4       K.  	  \-        V
4      V	n        KS  	  V P                  P/                  V4       EKî  	  R#   + '       g   i     Lœ; i)a]  Decompose x.size() into per-dim sym_size.int calls.

torch.Size objects cannot cross split boundaries because aot_autograd
cannot handle them as submodule outputs. This replaces each size() call
with individual sym_size.int(x, dim) nodes:
  - Dynamic dims (SymInt) -> new sym_size.int node
  - Static dims (plain int) -> inlined as literal constant
Úcall_methodÚsize)rf   rm   r}   N)r`   )rÞ   r(   Ú
find_nodesrg   r`   r²   rn   r„   Úinserting_afterræ   Úshaperp   r&   rÐ   rž   ÚopsÚatenÚsym_sizerR   r—   ÚusersÚextendr\   Ú
erase_node)rK   Ú
size_nodesrX   Útensor_nodeÚevÚdimsr  Údim_valÚdnÚuserÚnew_argsr£   s   &           r   Ú_decompose_size_nodesr+  Á  s�  € ô �a—g‘g×(Ñ(¨MÀ&Ð(ÓIÓJ€Jäˆäˆt�y‰y‹>˜AÔ §§ ÙØ—i‘i •lˆØ×Ñ×!Ñ! /Ó2ˆØŠ:Ùà!#ˆØ�W‰W×$Ñ$ [×1Õ1Ü'¨¯©Ö1‘
�Ü˜g¤u§|¡|×4Ò4ØŸ™×.Ñ.ÜŸ	™	Ÿ™×/Ñ/×3Ñ3¸;Ð:Jð /ó �Bð 07—G‘G˜OÑ,Ø—K‘K –OÜ ¬×-Ô-Ø—K‘K Ö(ñ 2÷ 2ô ˜Ÿ™Ö$ˆDØˆHØ—y”y�Ø“;Ø—O‘O DÖ)à—O‘O CÖ(ñ	 !ô
 ˜h›ˆDŽIñ %ð 	
�‰×Ñ˜4× ó; ÷ 2×1ús   Â4B9HÅ2HÈH+c                ó¨   € V ^8„  d   QhR\         P                  P                  P                  R\        \
        \        3,          R,          R\        /# )r   r(   ÚmodulesNr   )r&   r'   r(   r)   rS   r   r   )r   s   "r   r   r   í  sC   € ÷ *ñ *Ü�8‰8�>‰>×Ñð*ä”#”{Ð"Õ# dÕ*ð*ô ñ*r   c                ó  € \        R\        3/ 4      p\        P                  V4      pVP                  pRVR&   \
        \        \        3,          ! 4       VR&   \
        \        \        3,          ! 4       VR&   Ve   TM\
        \        \        3,          ! 4       VR&   \        \        ,          ! 4       VR&   \        4       VR	&   \        4       VR
&   RVR&   \        4       VR&   \        4       VR&   \        4       VR&   \        4       VR&   \        4       VR&   \        4       VR&   \        4       VR&   \        4       VR&   \        4       VR&   WR&   \
        \        \        3,          ! 4       VR&   W0n
        \        P                  Vn        V# )a´  Construct a lightweight GraphModule that bypasses expensive init overhead.

Creates a ``_LazyGraphModule`` instance without going through
``GraphModule.__new__`` (MRO traversal + per-instance class creation),
``nn.Module.__init__`` (17+ container allocations), or
``GraphModule.__init__`` (node iteration + ``recompile()`` codegen).
Per-instance classes are still created for lazy forward dispatch.

Only suitable for parameterless graph containers (no parameters, buffers,
or ``get_attr``/``call_module`` targets to copy from a root module).

The dict entries below mirror nn.Module.__init__ (torch/nn/modules/module.py).
Update in lockstep if nn.Module adds or removes instance attributes.
ÚGraphModuleImplFÚtrainingÚ_parametersÚ_buffersNÚ_modulesÚ_non_persistent_buffers_setÚ_backward_pre_hooksÚ_backward_hooksÚ_is_full_backward_hookÚ_forward_hooksÚ_forward_hooks_with_kwargsÚ_forward_hooks_always_calledÚ_forward_pre_hooksÚ_forward_pre_hooks_with_kwargsÚ_state_dict_hooksÚ_state_dict_pre_hooksÚ_load_state_dict_pre_hooksÚ_load_state_dict_post_hooksÚ_graphrn   )rl   r   ÚobjectÚ__new__Ú__dict__rS   r   r   rÎ   r   Úowning_moduleÚ_lazy_forwardÚforward)r(   r-  ÚclsÚinstÚds   &&   r   Ú_make_lite_graph_modulerK  í  sY  € ô$ Ð Ô#3Ð"5°rÓ
:€CÜ�>‰>˜#Ó€DØ�‰€AØ€A€j�MÜœC¤˜H–~Ó'€A€mÑÜœœc˜–NÓ$€A€j�MØ&Ò2‘G¼¼SÄ#¸X¾Ó8H€A€j�MÜ'*¬3¦x£z€AÐ#Ñ$Ü*›}€AÐÑÜ&›=€AÐÑØ"&€AÐÑÜ%›-€AÐÑÜ&1£m€AÐ"Ñ#Ü(3«€AÐ$Ñ%Ü)›m€AÐÑÜ*5«-€AÐ&Ñ'Ü(›]€AÐÑÜ!,£€AÐÑÜ&1£m€AÐ"Ñ#Ü'2£}€AÐ#Ñ$Ø€h�KÜ”Sœ#�X–Ó €A€f�IØÔÜ"×0Ñ0€C„KØ€Kr   c                ó�  € V ^8„  d   QhR\         R\        \        \        3,          R\        \        \        \
        P                  P                  P                  3,          \        \        \        \        \        3,          3,          \        \        \        \        \        3,          3,          \        \        ,          3,          /# )r   rK   Únode_to_partitionr   )r   rS   r   rR   r\   r&   r'   r(   r)   r   rÞ   )r   s   "r   r   r     sŽ   € ÷ XRñ XRÜðXRäœD¤#˜I•ðXRô ÜŒŒe�h‰h�n‰n×"Ñ"Ð	"Õ#ÜŒŒd”3œ�9�oÐ	ÕÜŒŒd”3œ�9�oÐ	ÕÜŒ…IðõñXRr   c                óV  aa€ ^ RI o^ RIHo / p\        \        4      p\        \        4      p/ p. p\        4       pV3R R llpV P                  P                   EFÈ  p	V	P                  P                  R4      p
V
ek   \        V
R4      '       dY   \        V
P                  R4      '       d=   V
P                  P                  p\        VSP                  4      '       d   Wµ9  d   W•V&   V	P                  R8X  d   K   V	P                  R	8X  d>   \         P"                  P                  P%                  V	P&                  ^ ,          V4       Kî  W,          pWÉn        WÇ9  dM   VP+                  V4       VP-                  V4       \         P"                  P                  P/                  4       W,&   VVVV3V3R
 lV3R lllp\         P"                  P                  P%                  V	P&                  V4       \         P"                  P                  P%                  V	P0                  V4       EKË  	  W#WF3# )aw  Assign nodes to partitions and detect cross-partition dependencies.

Returns:
    partition_graphs: Maps partition ID to its Graph.
    partition_inputs: Maps partition ID to ordered dict of input names -> source nodes.
    partition_outputs: Maps partition ID to ordered dict of output names -> source nodes.
    seen_partitions: Partition IDs in order of first appearance.
Nry   c                ó€   € V ^8„  d   QhR\         R\        \        \        \        \         3,          3,          R\         /# )r   r©   Ú_outputsr   )r   rS   rR   r   )r   s   "r   r   Ú*_detect_dependencies.<locals>.__annotate__6  s8   € ÷ ñ Üðä”sœD¤¤d �OÐ+Õ,ðô 
ñr   c                 ó‚   € \        V R 4      '       d-   WP                  ,          P                  V P                  V 4       V # )r{   )rB   r{   rƒ   r   )r©   rP  s   &&r   Ú_record_output_depÚ0_detect_dependencies.<locals>._record_output_dep6  s1   € ô �1�o×&Ò&Ø—_‘_Õ%×0Ñ0°·±¸Ô;Øˆr   r}   rX   rÒ   r_   r�   c                ó  <€ V ^8„  d   QhR\         R\        R\        \        \        \        \         3,          3,          R\        \        \        \        \         3,          3,          R\        SP                  \         3,          R\         /# )r   rv   Úuse_pidÚ_inputsrP  Ú_symr   )r   rR   rS   r   rÓ   )r   rÈ   s   "€r   r   rQ  U  sw   ø€ ÷ 	ñ 	Üð	äð	ô œ#œt¤C¬ I�Ð.Õ/ð	ô œ3¤¤S¬$ Y¥Ð/Õ0ð		ô
 �u—|‘|¤TÐ)Õ*ð	ô ñ	r   c                 óL  <€ \        V R R4      pWQ8w  Ed   Ve#   W5,          P                  V P                  V 4       W!,          P                  V P                  V 4       V P                  P	                  R4      pVe¨   V'       d    \        S
! V4      \        R7       F„  pVP	                  V4      pVf   K  W!,          P                  VP                  V4       VP                  R8w  g   KO  \        VR R4      p	V	f   Kb  W9,          P                  VP                  V4       K†  	  V # )r{   Nr}   r~   r_   )rD   rƒ   r   rn   r„   r…   r   rf   )rv   rV  rW  rP  rX  Údef_pidrŠ   r‹   rŒ   Ús_pidrz   s   &&&&&     €r   Ú_record_cross_depÚ/_detect_dependencies.<locals>._record_cross_depU  sé   ø€ ô ˜h¨¸Ó>ˆGØÕ!ØÒ&ØÕ%×0Ñ0°·±ÀÔIØÕ ×+Ñ+¨H¯M©M¸8ÔDà"Ÿ-™-×+Ñ+¨OÓ<�ØÒ&¯4Ü#¡L°Ó$9¼s×C˜Ø!%§¡¨!£˜Ø!š>Ù$ØÕ(×3Ñ3°F·K±KÀÔHØ!Ÿ9™9¨Ö5Ü$+¨F°OÀTÓ$J˜EØ$Ô0Ø (¥× :Ñ :¸6¿;¹;ÈÖ Oñ Dð ˆOr   )rÈ   r€   rz   r   rS   rÎ   r(   rÏ   rn   r„   rB   rX   rÒ   rp   rÓ   rf   r&   r'   rÝ   r`   r{   r—   rÕ   r)   r²   )rK   rM  Úpartition_graphsÚpartition_inputsÚpartition_outputsr�   Úseen_partitionsÚseen_partitions_setrS  rX   rï   rð   rõ   r\  rz   rÈ   s   &&            @@r   Ú_detect_dependenciesrc    s£  ù€ ó" åBà8:ÐÜ3>¼tÓ3DÐÜ4?ÄÓ4EÐØ/1€NØ!#€OÜ$'£EÐð 0A÷ð —‘—•ˆà�i‰i�m‰m˜OÓ,ˆØŠ?œw s¨F×3Ò3¼ÀÇÁÈ&×8QÒ8QØ—‘—‘ˆBÜ˜"˜eŸl™l×+Ò+°Ô0HØ%)˜rÑ"à�7‰7�mÔ#Ùà�7‰7�hÔÜ�H‰H�N‰N×"Ñ" 4§9¡9¨Q¥<Ð1CÔDÙàÕ%ˆØ ÔàÔ)Ø×"Ñ" 3Ô'Ø×#Ñ# CÔ(Ü$)§H¡H§N¡N×$8Ñ$8Ó$:ÐÑ!ð Ø2BØ3DØ-;÷	õ 	ô4 	�‰�‰×Ñ˜tŸy™yÐ*;Ô<Ü�‰�‰×Ñ˜tŸ{™{Ð,=×>ñe ðh Ð/@ÐQÐQr   c                ó   € V ^8„  d   QhR\         R\        \        \        P                  P
                  P                  3,          R\        \        \        \        \        3,          3,          R\        \        \        \        \        3,          3,          R\        \        ,          R\        \        \        \        \        3,          3,          /# )r   rK   r^  r_  r`  ra  r   ©
r   rS   rR   r&   r'   r(   r)   r   r   rÞ   )r   s   "r   r   r   u  s—   € ÷ 9ñ 9Üð9äœ3¤§¡§¡× 4Ñ 4Ð4Õ5ð9ô œ3¤¤S¬$ Y¥Ð/Õ0ð9ô œC¤¤c¬4 i¥Ð0Õ1ð	9ô
 œ#•Yð9ô 
Œ#Œt”Dœ$�JÕÐ
Õ ñ9r   c           	     óö  a€ \        \        4      pV Fr  pW,          pWV,          oW&,          P                  4        FE  w  r‰VP                  W‰P                  R7      p
V	P
                  P                  4       V
n        V
SV	&   KG  	  Kt  	  V P                  P                   EF  p\        VR4      '       g   K  VP                  pW,          pWV,          o\        P                  P                  P                  VP                  SP                  4      p\        P                  P                  P                  VP                   SP                  4      pVP#                  VP$                  VP&                  VVVP                  R7      pVP
                  P                  4       Vn        VSV&   EK  	  V FÇ  pW,          pWV,          oW6,          p\(        ;QJ d%    . V3R lVP+                  4        4       F  NK  	  5M! V3R lVP+                  4        4       4      p\-        V4      ^8X  d   VP/                  V^ ,          4       K“  \-        V4      ^8”  d   VP/                  V4       K¶  VP/                  R4       KÉ  	  V# )z›Create placeholders, clone nodes, and set outputs for each partition.

Returns:
    partition_env: Maps partition ID to {original_node: cloned_node} dict.
r¶   r{   r±   c              3   ó6   <"  € T F  pSV,          x € K  	  R # 5ir    re   )r¢   r  Úenvs   & €r   r¤   Ú/_clone_nodes_into_partitions.<locals>.<genexpr>¦  s   øé € ÐOÑ<N¨y˜C 	ŸNšNÓ<NùrÂ   re   )r   rS   rØ   r_   rl   rn   ro   r(   rÏ   rB   r{   r&   r'   rÝ   r`   Ú__getitem__r²   rk   rf   rm   r\   r×   rg   r�   )rK   r^  r_  r`  ra  Úpartition_envrõ   ÚgÚinp_namer  r_   rX   r  r  rþ   Ú	out_nodesr  rh  s   &&&&&            @r   Ú_clone_nodes_into_partitionsro  u  sâ  ø€ ô 2=¼TÓ1B€Mó ˆØÕ!ˆØÕ ˆØ#3Õ#8×#>Ñ#>Ö#@ÑˆHØŸ-™-¨¿N¹N˜-ÓKˆKØ(Ÿ~™~×2Ñ2Ó4ˆKÔØ(ˆC�	‹Nó $Añ ð —‘—•ˆÜ�t˜_×-Ò-ÙØ× Ñ ˆØÕ!ˆØÕ ˆäŸ™Ÿ™×.Ñ.¨t¯y©y¸#¿/¹/ÓJˆÜŸ(™(Ÿ.™.×0Ñ0°·±¸c¿o¹oÓNˆà—=‘=Ø�w‰wØ—;‘;ØØ"Ø—i‘ið !ó 
ˆð Ÿ	™	Ÿ™Ó(ˆŒØˆˆDŒ	ñ% ó* ˆØÕ!ˆØÕ ˆØ%Õ*ˆ	ß”eÔO¸I×<LÑ<LÔ<NÓO—e‘eÔO¸I×<LÑ<LÔ<NÓOÓOˆÜˆ{Ó˜qÔ Ø�H‰H�[ •^Ö$Ü�Ó Ô!Ø�H‰H�[Ö!à�H‰H�RŽLñ ð Ðr   c                óv  € V ^8„  d   QhR\         R\        \        \        P                  P
                  P                  3,          R\        \        \        \        \        3,          3,          R\        \        \        \        \        3,          3,          R\        \        ,          R\        R,          R\         /# )	r   rK   r^  r_  r`  ra  rH   Nr   re  )r   s   "r   r   r   ±  s›   € ÷ .Eñ .EÜð.Eäœ3¤§¡§¡× 4Ñ 4Ð4Õ5ð.Eô œ3¤¤S¬$ Y¥Ð/Õ0ð.Eô œC¤¤c¬4 i¥Ð0Õ1ð	.Eô
 œ#•Yð.Eô ˜4•Zð.Eô ñ.Er   c                óÀ  a€ \         P                  P                  P                  4       p/ o/ pV P                  P                   Fk  pVP
                  R8X  g   K  VP                  VP                  VP                  R7      p	VP                  P                  4       V	n	        V	SVP                  &   Km  	  V EF  p
Ve
   RV RV
 2pMRV
 2p\        W,          4      W{&   \        ;QJ d    . V3R lW*,           4       F  NK  	  5M! V3R lW*,           4       4      pVP                  W¼4      p\        W:,          P!                  4       4      p\#        V4      ^8”  dW   \         P                  P$                  P'                  V4      p\)        V4       F  w  ppVV,          P*                  SV&   K  	  Ký  \#        V4      ^8X  g   EK  VSV^ ,          &   EK  	  V P                  P                   Fd  pVP
                  R8X  g   K  VP-                  \         P                  P                  P/                  VP0                  ^ ,          V3R l4      4       Kf  	  \        WgR7      # )	zDBuild the outer stitching graph that calls each partition submodule.r_   r¶   r   r•   c              3   ó6   <"  € T F  pSV,          x € K  	  R # 5ir    re   )r¢   r   Úbase_envs   & €r   r¤   Ú)_build_stitching_graph.<locals>.<genexpr>Î  s   øé € ÐMÑ7L¨t˜H TŸNšNÓ7LùrÂ   r�   c                 ó*   <€ SV P                   ,          # r    rÄ   )r©   rs  s   &€r   rª   Ú(_build_stitching_graph.<locals>.<lambda>Ü  s   ø€ ¸xÈÏÉÖ?Or   )r-  )r&   r'   r(   r)   rÏ   rf   r_   rm   rl   rn   ro   r   rK  r\   rÇ   rÞ   rß   rg   rä   rå   ræ   rX   r�   rÝ   r`   )rK   r^  r_  r`  ra  rH   Ú
base_graphÚbase_modulesrX   r  rõ   r    Úinput_nodesr  Ú	out_namesr  r  r   rs  s   &&&&&&            @r   Ú_build_stitching_graphr{  ±  sØ  ø€ ô —‘—‘×%Ñ%Ó'€JØ "€HØ+-€Là—‘—”ˆØ�7‰7�mÖ#Ø×&Ñ&Ø—‘ØŸ)™)ð 'ó ˆAð —Y‘Y—^‘^Ó%ˆAŒFØ"#ˆH�T—Y‘YÓñ ô ˆØÒ&Ø# OÐ#4°A°c°UÐ;‰Kà# C 5˜/ˆKÜ$;Ð<LÕ<QÓ$RˆÑ!ç”eÔMÐ7GÖ7LÓM—e‘eÔMÐ7GÖ7LÓMÓMˆØ×+Ñ+¨KÓEˆ
äÐ*Õ/×4Ñ4Ó6Ó7ˆ	Üˆy‹>˜AÔÜ$Ÿx™xŸ~™~×3Ñ3°JÓ?ÐÜ$ YÖ/‘��4Ø!1°!Õ!4×!9Ñ!9�˜“ó 0ä�‹^˜q× Ø%/ˆH�Y˜q•\Ô"ñ! ð$ —‘—”ˆØ�7‰7�hÖØ×ÑÜ—‘—‘×&Ñ& t§y¡y°¥|Ô5OÓPöñ ô # :ÔDÐDr   c                óx   € V ^8„  d   QhR\         R\        \        \        3,          R\        R,          R\         /# )r   rK   rM  rH   Nr   )r   rS   r   rR   r   )r   s   "r   r   r   ã  s<   € ÷ (ñ (Üð(äœD¤#˜I•ð(ô ˜4•Zð	(ô
 ñ(r   c               óX   € \        W4      w  r4rV\        WWEV4       \        V VVVVV4      # )uº  Lightweight graph splitter for simple partition patterns.

A faster alternative to :func:`split_module` for inference-only graphs
from ``torch.compile``/Dynamo. Because these graphs have no autocast/grad
regions, no ``get_attr`` nodes, and no non-linear partition dependencies,
we can skip the topological sort, autocast tracking, and ``get_attr``
special-casing that ``split_module`` performs. More importantly, we
construct partition submodules as lightweight ``_LazyGraphModule``
instances that bypass ``nn.Module.__init__`` and defer ``recompile()``
codegen â€” this eliminates the dominant cost when creating 70-100+
partition submodules for large models.

Args:
    m: Graph module to split.
    node_to_partition: Maps each operational node to a partition ID.
        Placeholders, get_attr, and output nodes should NOT be included.
    partition_affix: If set, submodule names become
        ``submod_{affix}_{idx}`` instead of ``submod_{idx}``.
)rc  ro  r{  )rK   rM  rH   r^  r_  r`  ra  s   &&$    r   Úsplit_module_simpler~  â  sK   € ô6 	˜QÓ2ñ KÐÐ(9ô !Ø	Ð-À/ôô "Ø	ØØØØØóð r   )r   r  r~  )NFFTr    )#rh   rÛ   Úcollectionsr   r   Úcollections.abcr   Útypingr   r&   Útorch.fx._compatibilityr   Útorch.fx._lazy_graph_moduler   r	   Útorch.fx._utilsr
   Útorch.fx.graph_moduler   Útorch.fx.noder   Ú__all__Ú	getLoggerr4   r�   rÙ   r   rG   r  r+  rK  rc  ro  r{  r~  re   r   r   Ú<module>r‰     sÛ   ðÛ Û ß 0Ý $Ý ã Ý 1ß LÝ 2Ý -Ý ò ?€Ø×!Ò! (Ó+Ð +€€gñ  dÔ+÷
ð 
ó ,ð
õ0ñ  dÔ+ñG
ð #'ðG
ð ÷G
ó ,ðG
õT)!÷X*õZXRõv9÷x.Eñb  eÔ,ð(ð #'ö	(ó -ò(r   