+
    –°³j¸Ç  ã                   ó„  € ^ RI t ^ RIt^ RIt^ RIHt ^ RIHt ^ RIHt ^ RI	H
t
HtHt ^ RIHt ^ RIHt ^ RIt^ RIHt ^ RIHt ^ R	IHt ^ R
IHtHtHtHt ^ RIHt ^ RIH t  ^RI!H"t"H#t# ^RI$H%t% ^RI&H't' ^RI(H)t) ]PT                  ! ]+4      t,Rt-R R lt.R t/R R lt0R R lt1R R lt2 ! R R]Pf                  Ph                  4      t5 ! R R]Pf                  Pl                  4      t7 ! R R ]74      t8]Pr                  Pu                  R!R"4       ]Pr                  Pw                  R!R#4      R$ 4       t<]Pr                  P{                  R!4      R% 4       t<]P|                  P~                  Px                  P€                  tA]P„                  P†                  P‰                  ]A4       R& tE ! R' R(]4      tF]F]G]H]F3,          ,          tI ! R) R*]P”                  4      tK ! R+ R,4      tL ! R- R.4      tMR/ tNR0 tOR1 R2 ltP ! R3 R4]Pf                  Pl                  4      tQ ! R5 R6]4      tR ! R7 R84      tSR9 tTR: tUR; R< ltVR?R= R> lltWR# )@é    N)Údefaultdict)ÚCallable)ÚEnum)Ú	ParameterÚ	SignatureÚ	signature)Ú
MethodType)ÚAny)ÚProcessGroup)ÚExportedProgram)Ú_assign_attrÚ	_AttrKindÚ_sink_paramsÚInterpreterModule)Úmap_aggregate)Úsplit_module)Ú_null_coalesce_accumulateÚstage_backward)Ú_outline_submodules©ÚPipeInfo)Ú_PipelineStageÚ	submod_ppc                ó$   € V ^8„  d   QhR\         /# )é   Ú	stage_idx)Úint)Úformats   "Úa/home/luca/screen-checking/.venv/lib/python3.14/site-packages/torch/distributed/pipelining/_IR.pyÚ__annotate__r    *   s   € ÷ 8ñ 8œsñ 8ó    c                óB   € RP                  \        \        V 4      .4      # )zhReturns the name of the submod for a given stage index.
For example, "submod_pp_0", "submod_pp_1", etc.
Ú_)ÚjoinÚPP_SUBMOD_PREFIXÚstr)r   s   &r   Úget_submod_namer'   *   s   € ð �8‰8Ô%¤s¨9£~Ð6Ó7Ð7r!   c                 ór  € VR J d   R# VRJ d1   \        V \        P                  4      '       g   \        RV  24      hV # \        V\        \
        34      '       d�   \        V \        \
        34      '       g   \        RV  RV 24      h\        V 4      \        V4      8w  d   \        RV  RV 24      h\        W4       F  w  r#\        W#4      pVf   K  Vu # 	  \        RV 24      h\        V\        4      '       d¥   \        V \        4      '       g   \        RV  RV 24      h\        V P                  4       4      \        VP                  4       4      8w  d   \        RV  RV 24      hV F#  p\        W,          W,          4      pVf   K!  Vu # 	  \        RV 24      h\        R	\        V4       R
24      h)FNTz/Loss spec must specify a dynamic value but got zOutput value z' must match type of loss specification z) must match length of loss specification z)Did not find loss value in specification z' must match keys of loss specification zUnsupported type z in loss specification)Ú
isinstanceÚfxÚNodeÚRuntimeErrorÚtupleÚlistÚlenÚzipÚ_find_loss_from_output_and_specÚdictÚsetÚkeysÚtype)Ú
output_valÚspec_valÚoutÚspecÚloss_valÚks   &&    r   r1   r1   1   sÌ  € Ø�5ÓÙØ�4ÓÜ˜*¤b§g¡g×.Ò.ÜØAÀ*ÀÐNóð ð Ðä�(œU¤D˜M×*Ò*Ü˜*¤u¬d m×4Ò4ÜØ 
˜|Ð+RØ�*ðóð ô ˆz‹?œc (›mÔ+ÜØ 
˜|Ð+TØ�*ðóð ô ˜ZÖ2‰IˆCÜ6°sÓAˆHØÔ#Ø’ñ 3ô ÐFÀxÀjÐQÓRÐRä�(œD×!Ò!Ü˜*¤d×+Ò+ÜØ 
˜|Ð+RØ�*ðóð ô ˆz�‰Ó Ó!¤S¨¯©«Ó%9Ô9ÜØ 
˜|Ð+RØ�*ðóð ó ˆAÜ6°zµ}ÀhÅkÓRˆHØÔ#Ø’ñ ô ÐFÀxÀjÐQÓRÐRä
Ð*¬4°«>Ð*:Ð:PÐQÓ
RÐRr!   c                ól   € V ^8„  d   QhR\         P                  P                  R\        P                  /# )r   ÚmodÚg)ÚtorchÚnnÚModuler*   ÚGraph)r   s   "r   r    r    `   s&   € ÷ 2ñ 2œ5Ÿ8™8Ÿ?™?ð 2¬r¯x©xñ 2r!   c                 ól  € VP                    Uu. uF  q3P                  R 8X  g   K  VNK  	  pp\        V4      ^8X  g   \        R\        V4       24      hV^ ,          pVP                  ^ ,          pRp\        V \        4      '       dO   \        VP                  4      ^8X  g"   \        R\        VP                  4       24      hTp\        P                  pMQVfA   \        V\        4      '       d&   RV9   d   VR,          pV U	u/ uF  q™V	R8H  bK
  	  pp	MRpRpM\        Wb4      pTpW…V3# u upi u up	i )ÚoutputzExpected 1 output node, got NzExpected 1 output arg, got Úloss)
ÚnodesÚopr/   ÚAssertionErrorÚargsr)   ÚTrivialLossWrapperÚ	loss_specr2   r1   )
r=   r>   Úoutput_loss_value_specÚnÚoutput_nodesÚoutput_noder6   Úgenerated_specÚ	loss_noder;   s
   &&&       r   Ú_find_loss_outputrR   `   s*  € Ø ŸwšwÓ;™w˜!¯$©$°(Ñ*:—A�A™w€LÐ;Üˆ|Ó Ô!ÜÐ;¼CÀÓ<MÐ;NÐOÓPÐPØ˜q•/€KØ×!Ñ! !Õ$€JØ€Nä�#Ô)×*Ò*ô �;×#Ñ#Ó$¨Ô)Ü Ð#>¼sÀ;×CSÑCSÓ?TÐ>UÐ!VÓWÐWØˆ	Ü+×5Ñ5‰Ø	Ò	'ä�j¤$×'Ò'¨F°jÔ,@Ø" 6Õ*ˆIÙ6@ÓA±j°  f¡šn±jˆNÐAˆNàˆIØ!‰Nä3°JÓWˆ	Ø/ˆà >Ð1Ð1ùò5 <ùò$ Bs   �D,¦D,ÄD1c                óx   € V ^8„  d   QhR\         P                  R\         P                  R\         P                  /# )r   r>   rQ   rO   )r*   rB   r+   )r   s   "r   r    r    ~   s7   € ÷ jñ jÜ	‡x�xðjä�w‰wðjô —‘ñjr!   c                 óÖ  a aa€ / p\        S P                  4       F÷  pVP                  R 8X  g   K  VP                  \        P
                  8X  g   \        R4      h\        VP                  4      ^8X  g   \        R4      h\        VP                  4      w  rVWS9   d   \        W5,          4      MRp\        V^,           V4      p\        V4       U	u. uF  p	RNK  	  p
p	WS9   d   \        W5,          4       F	  w  r¼WÊV&   K  	  WJV&   \        V
4      W5&   Kù  	  VR/oVR/oV V3R lpS P                  V4      ;_uu_ 4        \        S P                  4       EFé  pVS9  d   K  V3R lp\        P                  P!                  VP                  V4       \        P                  P!                  VP"                  V4       VP                  R8X  g   Kz  WC9   dv   W4,          p\        ;QJ d    . V3R lW4,           4       F  NK  	  5M! V3R lW4,           4       4      p\        W4,          4       UUu. uF  w  ppVS9   g   K  VNK  	  pppMV3pSV,          p^ .p\%        V\        4      '       g   V3MTpS P'                  \(        RVR	VR
\+        VP,                  4      RV/R7      p\/        VP"                  4      pVVn        \        P0                  ! V4      pVP                  p\+        VP,                  4      p\        P0                  ! V4      p\        V4       F   w  ppV! VVV,          P                  4       K"  	  EKì  	  RRR4       S # u up	i u uppi   + '       g   i     S # ; i)Úcall_functionzDFound non-getitem call in forward pass. Please report a bug to PiPPyz:Found malformed getitem call. Please report a bug to PiPPyNc                 ó€   <€ V S9   d1   V P                   R 8w  d    SP                  \        SV ,          V34      pVSV &   R# )ÚplaceholderN)rG   rU   r   )Úforward_nodeÚ
grad_valuer>   Úval_to_grads   &&€€r   Úassign_or_accumulate_gradÚB_insert_stage_symbolic_backward.<locals>.assign_or_accumulate_grad®   s@   ø€ Ø˜;Ô&¨<¯?©?¸mÔ+KØŸ™Ü)Ø˜\Õ*¨JÐ7óˆJð %/ˆ�LÓ!r!   c                 ó,   <€ SP                  V R 4       R # ©N)Ú
setdefault)rM   Ú
live_nodess   &€r   Úadd_to_live_nodesÚ:_insert_stage_symbolic_backward.<locals>.add_to_live_nodes»   s   ø€ Ø×%Ñ% a¨Ö.r!   Úcall_modulec              3   óF   <"  € T F  pSP                  V4      x € K  	  R # 5ir^   )Úget)Ú.0rM   rZ   s   & €r   Ú	<genexpr>Ú2_insert_stage_symbolic_backward.<locals>.<genexpr>Ä   s   øé € Ð(RÁ\À¨¯©¸×);Ð);Ã\ùs   ƒ!Ústage_outputÚoutput_gradsÚinput_valuesÚoutputs_with_grads_idxs)Úkwargséÿÿÿÿ)ÚreversedrF   rG   ÚtargetÚoperatorÚgetitemrH   r/   rI   r-   ÚmaxÚrangeÚ	enumerateÚinserting_beforer*   ÚnodeÚmap_argrm   r)   rU   r   r.   Úall_input_nodesr2   ÚProxy)r>   rQ   rO   Útuplesrw   Úindexed_valueÚnode_idxÚexisting_list_sizeÚnew_list_sizer#   Úreconstructed_listÚiÚvalr[   ra   ri   rj   rM   rl   Ú	grad_callÚkwargs_copyÚgrad_call_proxyÚgradsÚinput_nodesÚgrads_proxyÚ
input_noder`   rZ   s   f&&                       @@r   Ú_insert_stage_symbolic_backwardrŠ   ~   s  ú€ ð $&€FÜ˜Ÿ™Ö!ˆØ�7‰7�oÖ%ð —;‘;¤(×"2Ñ"2Ô2Ü$ØZóð ô �t—y‘y“> QÔ&Ü$ØPóð ô ',¨D¯I©IÓ&6Ñ#ˆMð /<Ô.E”�FÕ)Ô*È2ð ô   ¨1¥Ð.@ÓAˆMä05°mÔ0DÓ!EÑ0D¨1£$Ñ0DÐÐ!Eð Ô&Ü'¨Õ(=Ö>‘F�AØ,/ qÓ)ñ ?ð ,0˜xÑ(ä$)Ð*<Ó$=ˆFÓ!ñC "ðL ˜TÐ"€JØ2;¸TÐ1B€Kö/ð 
×	Ñ	˜K×	(Õ	(Ü˜QŸW™W×%ˆDØ˜:Ô%Ùõ/ô �G‰G�O‰O˜DŸI™IÐ'8Ô9Ü�G‰G�O‰O˜DŸK™KÐ):Ô;Ø�w‰w˜-Ö'à”>Ø#)¥<�Lß#(¤5Ô(RÀVÆ\Ó(R§5¡5Ô(RÀVÆ\Ó(RÓ#R�Lä&/°µÔ&=ô/Ù&=™d˜a ÀÀjÁŸ˜Ñ&=ð ,ñ /Ð+ð %) 7�LØ#.¨tÕ#4�LØ/0¨cÐ+ô & l´E×:Ò:ð "‘Oà%ð ð ŸO™OÜ"à&¨Ø&¨Ø&¬¨T×-AÑ-AÓ(BØ1Ð3Jð	ð ,ó �	ô # 9×#3Ñ#3Ó4�Ø#.�	Ô ä"$§(¢(¨9Ó"5�Ø'×,Ñ,�ä" 4×#7Ñ#7Ó8�Ü Ÿhšh u›o�Ü%.¨{Ö%;‘M�A�zÙ-¨j¸+Àa½.×:MÑ:MÖNô &<ñ] &÷ 
)ðd €HùòY "FùóR/÷ 
)Ö	(ðd €Hús3   ÃMÄ>BMÇA MÈ.MÈ?MÉC=MÍMÍM(	c                ó8   € V ^8„  d   QhR\         P                  /# )r   Úgraph)r*   rB   )r   s   "r   r    r    ë   s   € ÷ ñ ¤r§x¡xñ r!   c                ó"  € RpV P                    F  pVP                  R8X  g   K  TpK  	  Vf   R# . pV P                    F.  pW!J d    M(VP                  R8w  g   K  VP                  V4       K0  	  TpV F  pVP                  V4       TpK  	  R# )z�Ensure all placeholder nodes form a contiguous prefix of the graph.
split_module can interleave get_attr nodes with placeholders.NrW   )rF   rG   Úappend)rŒ   Úlast_phrw   Únodes_to_moveÚinsert_points   &    r   Ú_move_placeholders_to_frontr’   ë   s‹   € ð €GØ—”ˆØ�7‰7�mÖ#ØŠGñ ð ‚ÙØ€MØ—”ˆØ‹?ÙØ�7‰7�mÖ#Ø× Ñ  Ö&ñ	 ð
 €LÛˆØ×Ñ˜DÔ!ØŠó r!   c                   óB   a € ] tR tRt o ]V 3R lR l4       tR tRtV tR# )ÚPipeSequentialé   c                óH   <€ V ^8„  d   QhRS[ P                  P                  /# )r   Úsequential_instance)r?   r@   Ú
Sequential)r   Ú__classdict__s   "€r   r    ÚPipeSequential.__annotate__  s!   ø€ ÷ Lñ L©U¯X©X×-@Ñ-@ñ Lr!   c                óf   € \        V  Uu. uF  p\        P                  ! V4      NK  	  up!  # u upi r^   )r”   Úcopy)r—   Úms   & r   Úfrom_sequentialÚPipeSequential.from_sequential  s*   € äÑ6IÓJÑ6I°¤§	¢	¨!¦Ñ6IÑJÑKÐKùÒJs   Š.c                ó„   € \        V 4       F0  w  r#V! V4      pV\        V 4      ^,
          8w  g   K&  \        4        K2  	  V# )é   )ru   r/   Ú
pipe_split)ÚselfÚinputr�   Úmodules   &&  r   ÚforwardÚPipeSequential.forward  s7   € Ü" 4ž‰IˆAÙ˜5“MˆEØ”C˜“I •MÖ!Ü–ñ )ð ˆr!   © N)	Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ústaticmethodrž   r¦   Ú__static_attributes__Ú__classdictcell__©r™   s   @r   r”   r”      s#   ø‡ € Ø÷Ló ðL÷ð r!   r”   c                   ó<   a a€ ] tR tRt oRtV 3R ltR tRtVtV ;t	# )ÚLossWrapperi  a  
LossWrapper is a convenient abstract class that allows you to wrap up both
your model as well as its loss function and specify the connectivity between
the inputs, model, loss function, and output value. Example::

    class MyModelWrapper(LossWrapper):
        def forward(self, x, targets):
            model_out = self.module(x)
            loss_value = self.loss_fn(model_out, targets)
            return loss_value

The above example defines a connectivity where we expect the forward/loss/backward
training procedure to take two arguments (x and targets), pass x into the module
to get the output of the feedforward computation, pass the model output and the
targets value into the loss function, and get and return the loss value, which will
be backpropagated by PiPPy. The above class would then be instantiated like::

    model = ...  # instantiate the model
    loss_fn = torch.nn.MSELoss()  # for the sake of demonstration

    wrapper = MyModelWrapper(model, loss_fn)
    pipe = Pipe.from_tracing(wrapper, ...)

c                ó<   <€ \         SV `  4        Wn        W n        R # r^   )ÚsuperÚ__init__r¥   Úloss_fn)r£   r¥   r¶   Ú	__class__s   &&&€r   rµ   ÚLossWrapper.__init__'  s   ø€ Ü‰ÑÔØŒØŽr!   c                ó   € \        R 4      h)z¶This instance of LossWrapper does not have an overriddenforward(). Please implement forward() to specify the arguments, connection between the module and loss, and loss output value.)ÚNotImplementedError©r£   rI   rm   s   &*,r   r¦   ÚLossWrapper.forward,  s   € Ü!ðó
ð 	
r!   )r¶   r¥   )
r©   rª   r«   r¬   Ú__doc__rµ   r¦   r®   r¯   Ú__classcell__©r·   r™   s   @@r   r²   r²     s   ù‡ € ñõ2÷

ò 
r!   r²   c                   ó*   a € ] tR tRt o R tRtRtV tR# )rJ   i5  c                óF   € V P                  V4      pV P                  W24      # r^   )r¥   r¶   )r£   ÚxÚtargetsÚ	model_outs   &&& r   r¦   ÚTrivialLossWrapper.forward7  s   € Ø—K‘K “Nˆ	Ø�|‰|˜IÓ/Ð/r!   Tr¨   N)r©   rª   r«   r¬   r¦   rK   r®   r¯   r°   s   @r   rJ   rJ   5  s   ø‡ € ò0ð †Ir!   rJ   zpippy::_pipe_splitz() -> ()ÚBackendSelectc                  ó   € R # r^   r¨   r¨   r!   r   Ú_pipe_splitrÈ   X  ó   € ár!   c                  ó   € R # r^   r¨   r¨   r!   r   rÈ   rÈ   ]  rÉ   r!   c                 óR   € \         P                  P                  P                  4       # )aÊ  
pipe_split is a special operator that is used to mark the boundary between
stages in a module. It is used to split the module into stages. It is a
no-op if your annotated module is run eagerly.

Example:
    >>> # xdoctest: +SKIP
    >>> def forward(self, x):
    >>>     x = torch.mm(x, self.mm_param)
    >>>     x = torch.relu(x)
    >>>     pipe_split()
    >>>     x = self.lin(x)
    >>>     return x

The above example will be split into two stages.
)r?   ÚopsÚpippyrÈ   r¨   r!   r   r¢   r¢   k  s   € ô" �9‰9�?‰?×&Ñ&Ó(Ð(r!   c                   ó   € ] tR tRt^t^tRtR# )ÚMultiUseParameterConfigi  r¨   N)r©   rª   r«   r¬   ÚTRANSMITÚ	REPLICATEr®   r¨   r!   r   rÏ   rÏ     s   † Ø€HØ„Ir!   rÏ   c                   óf   a a€ ] tR tRt oRtR
V 3R lltRR/V 3R lltV 3R ltV 3R ltR	t	Vt
V ;t# )ÚDetachExecutori‡  z¿
Special interpreter to run the split_gm in testing that detaches all inputs to
a module invocation. This is needed so that the values at the boundary are
leaf modules in autograd execution.
c                ó8   <€ R p\         SV `  W4       / V n        R# )FN)r´   rµ   Úvalue_remap)r£   r¥   Úgarbage_collect_valuesr·   s   &&&€r   rµ   ÚDetachExecutor.__init__Ž  s   ø€ Ø!&ÐÜ‰Ñ˜Ô8ØˆÖr!   Úinitial_envNc               ó2   <€ / V n         \        SV `  ! VR V/ # )rØ   )rÕ   r´   Úrun)r£   rØ   rI   r·   s   &$*€r   rÚ   ÚDetachExecutor.run“  s   ø€ ØˆÔÜ‰wŠ{˜DÐ:¨kÑ:Ð:r!   c                ód   <a € V 3R  lp \        VV4      p\        VV4      p\        SS `	  WV4      # )c                 ó  <€ \        V \        P                  4      '       de   V P                  '       dS   V SP                  9  d/   V P                  4       P                  R 4      pVSP                  V &   SP                  V ,          # V # ©T)r)   r?   ÚTensorÚrequires_gradrÕ   ÚdetachÚrequires_grad_)ÚaÚnew_valr£   s   & €r   Údetach_tensorsÚ2DetachExecutor.call_module.<locals>.detach_tensors˜  sf   ø€ Ü˜!œUŸ\™\×*Ò*¨q¯¯¨Ø˜D×,Ñ,Ô,ØŸh™h›j×7Ñ7¸Ó=�GØ*1�D×$Ñ$ QÑ'Ø×'Ñ'¨Õ*Ð*à�r!   )r   r´   rc   )r£   rp   rI   rm   rå   r·   s   f&&& €r   rc   ÚDetachExecutor.call_module—  sE   ù€ õ	ð	ô
 ØØó
ˆô ØØó
ˆô
 ‰wÑ" 6°Ó8Ð8r!   c                óÀ   <€ V\         J d@   \        V4      pVR ,           Uu. uF  q@P                  P                  WD4      NK  	  upVR &   \        SV `  WV4      # u upi )rk   )r   r2   rÕ   re   r´   rU   )r£   rp   rI   rm   Úvr·   s   &&&& €r   rU   ÚDetachExecutor.call_function±  s`   ø€ à”^Ó#Ü˜&“\ˆFà4:¸>Ö4Jó&Ù4J¨q× Ñ ×$Ñ$ QÖ*Ñ4Jñ&ˆF�>Ñ"ô ‰wÑ$ V°6Ó:Ð:ùò&s   ¢#A)rÕ   rÞ   )r©   rª   r«   r¬   r½   rµ   rÚ   rc   rU   r®   r¯   r¾   r¿   s   @@r   rÓ   rÓ   ‡  s*   ù‡ € ñ÷ð
; T÷ ;õ9÷4;õ ;r!   rÓ   c                   ó2   a € ] tR tRt o R tV 3R ltRtV tR# )Ú_NodeReferencei»  c                ó   € Wn         R # r^   ©Úname)r£   rï   s   &&r   rµ   Ú_NodeReference.__init__¼  s   € ØŽ	r!   c                ó&   <€ V ^8„  d   Qh/ S[ ;R&   # )r   rï   )r&   )r   r™   s   "€r   r    Ú_NodeReference.__annotate__»  s   ø‡ ‚ ñ �Iò	 r!   rî   N)r©   rª   r«   r¬   rµ   Ú__annotate_func__r®   r¯   r°   s   @r   rì   rì   »  s   ø‡ € ò÷ ƒ r!   rì   c                   ó,   a € ] tR tRt o R tR tRtV tR# )Ú_LinearNodeListiÂ  c                óÜ  € . V n         V FÞ  p\        P                  P                  VP                  R  4      p\        P                  P                  VP
                  R 4      p\        P                  ! RVP                  VP                  VP                  VVVP                  R7      p\        P                  ! VP                  4      Vn        V P                   P                  V4       Kà  	  R# )c                 ó,   € \        V P                  4      # r^   ©rì   rï   ©rM   s   &r   Ú<lambda>Ú*_LinearNodeList.__init__.<locals>.<lambda>Æ  s   € ¼^ÈAÏFÉFÔ=Sr!   c                 ó,   € \        V P                  4      # r^   rø   rù   s   &r   rú   rû   Ç  s   € ÄÐPQ×PVÑPVÔAWr!   N)rŒ   rï   rG   rp   rI   rm   Úreturn_type)Úserialize_node_listr*   rw   rx   rI   rm   r+   rï   rG   rp   r5   rœ   ÚmetarŽ   )r£   Ú	node_listrw   Ú	node_argsÚnode_kwargsÚserialize_nodes   &&    r   rµ   Ú_LinearNodeList.__init__Ã  s¤   € Ø#%ˆÔ ÛˆDÜŸ™Ÿ™¨¯	©	Ñ3SÓTˆIÜŸ'™'Ÿ/™/¨$¯+©+Ñ7WÓXˆKÜŸWšWØØ—Y‘YØ—7‘7Ø—{‘{ØØ"Ø ŸI™IôˆNô #'§)¢)¨D¯I©IÓ"6ˆNÔØ×$Ñ$×+Ñ+¨NÖ;ó r!   c           
     ó\  a€ \         P                  ! 4       p/ oV3R  lpV P                   F}  p\        VP                  V4      p\        VP
                  V4      pVP                  VP                  VP                  VVVP                  VP                  R7      pVSVP                  &   K  	  V# )c                 óZ   <€ \        V \        4      '       d   SV P                  ,          # V # r^   )r)   rì   rï   )ÚargÚref_str_to_nodes   &€r   Úref_to_nodeÚ-_LinearNodeList.to_graph.<locals>.ref_to_nodeÙ  s$   ø€ Ü˜#œ~×.Ò.Ø& s§x¡xÕ0Ð0à�
r!   )rG   rp   rI   rm   rï   Ú	type_expr)r*   rB   rþ   r   rI   rm   Úcreate_noderG   rp   rï   r5   )r£   rŒ   r	  rw   r  r  Ú
deser_noder  s   &      @r   Úto_graphÚ_LinearNodeList.to_graphÔ  s˜   ø€ Ü—’“
ˆà.0ˆõ	ð ×,Ô,ˆDÜ% d§i¡i°Ó=ˆIÜ'¨¯©°[ÓAˆKØ×*Ñ*Ø—7‘7Ø—{‘{ØØ"Ø—Y‘YØŸ)™)ð +ó ˆJð *4ˆO˜DŸI™IÓ&ñ -ð ˆr!   )rþ   N)r©   rª   r«   r¬   rµ   r  r®   r¯   r°   s   @r   rõ   rõ   Â  s   ø‡ € ò<÷"ð r!   rõ   c                ó    €  ! R R\         P                  P                  4      pV! V 4      p\        P                  ! W1P                  4       4      # )a§  
Custom `__reduce__` method for serialization.
DO AS I SAY -- NOT AS I DO. This violates the principle that
GraphModules serialize via code export & re-tracing. We allow
for this here because **PIPE STAGES SHOULD NOT BE PERSISTED
TO DISK -- THIS IS ONLY FOR TRANSMISSION VIA RPC**. Persisting
these instances to disk will expose internal implementation
details of `fx.Graph` and related data structures and is
NOT advised.
c                   ó2   a a€ ] tR tRt oV 3R ltRtVtV ;t# )Ú6_direct_serialization_deserialize.<locals>.DummyModuleiû  c                óZ   <€ \         SV `  4        V P                  P                  V4       R # r^   )r´   rµ   Ú__dict__Úupdate)r£   Úbodyr·   s   &&€r   rµ   Ú?_direct_serialization_deserialize.<locals>.DummyModule.__init__ü  s    ø€ Ü‰GÑÔØ�M‰M× Ñ  Ö&r!   r¨   )r©   rª   r«   r¬   rµ   r®   r¯   r¾   r¿   s   @@r   ÚDummyModuler  û  s   ù‡ € ÷	'õ 	'r!   r  )r?   r@   rA   r*   ÚGraphModuler  )r  rF   r  Údummys   &&  r   Ú!_direct_serialization_deserializer  ï  s8   € ô'”e—h‘h—o‘oô 'ñ
 ˜Ó€Eä�>Š>˜%§¡Ó!1Ó2Ð2r!   c                 óœ   € \        V P                  4      pVP                  R 4       \        V\	        V P
                  P                  4      33# )Ú_graph)r2   r  Úpopr  rõ   rŒ   rF   )r£   Úserialization_dicts   & r   Ú_direct_serialization_reducer     sC   € Ü˜dŸm™mÓ,ÐØ×Ñ˜8Ô$ä)Ø	œ_¨T¯Z©Z×-=Ñ-=Ó>Ð?ðð r!   c                ól   € V ^8„  d   QhR\         P                  P                  R\         P                  /# )r   ÚgmÚ
new_device)r?   r*   r  Údevice)r   s   "r   r    r      s*   € ÷  ñ  Ü�‰×Ñð ä—‘ñ r!   c           	     ó  € RpV P                   P                   EFS  pVP                  R8X  d}   RVP                  9   dj   VP                  R,          V8w  dP   \        P                  RVP                   RVP                  R,           RV 24       VP                  RV4       RpK�  K�  K‘  VP                  R8X  g   K¤  V P                  VP                  4      p\        V\        P                  P                  4      '       d   \        WA4       Kö  \        V\        4      '       d   \        VP                   V4       EK%  \        P#                  R	VP                   R
\%        V4       24       EKV  	  V'       d   V P'                  4        R# R# )zµ
Modify the device argument of all "call_function" nodes in the graph.  This
is useful for moving the graph to a different device. In particular for
generator ops, like torch.ones.
FrU   r$  zChanging device of Node z from ú to Trc   z+Skipping device modification for submodule z because it is a N)rŒ   rF   rG   rm   ÚloggerÚdebugrï   Úupdate_kwargÚget_submodulerp   r)   r?   r*   r  Ú_modify_graph_op_devicer   Úgraph_moduleÚwarningr5   Ú	recompile)r"  r#  Úmodifiedrw   Úsubmods   &&   r   r+  r+    s1  € ð €HØ—‘—•ˆØ�7‰7�oÔ%Ø˜4Ÿ;™;Ô&¨4¯;©;°xÕ+@ÀJÔ+NÜ—‘Ø.¨t¯y©y¨k¸ÀÇÁÈHÕ@UÐ?VÐVZÐ[eÐZfÐgôð ×!Ñ! (¨JÔ7Ø’ñ ,OÑ&ð �W‰W˜Ö%à×%Ñ% d§k¡kÓ2ˆFÜ˜&¤%§(¡(×"6Ñ"6×7Ò7Ü'¨Ö;Ü˜FÔ$5×6Ò6ä'¨×(;Ñ(;¸Z×Hä—‘ØAÀ$Ç+Á+ÀÐN_Ô`dÐekÓ`lÐ_mÐn÷ñ# ÷* Ø
�‰Žñ r!   c                   ó   a € ] tR tRt o V 3R lR ltR tV 3R lR lt]V 3R lR l4       t]RV 3R
 lR ll4       t	R t
]RV 3R lR ll4       t]RV 3R lR ll4       tR tR tV 3R lR ltRV 3R lR lltRtV tR	# )ÚPipei1  c                ó@   <€ V ^8„  d   QhRS[ P                  RS[RS[/# )r   Úsplit_gmÚ
num_stagesÚhas_loss_and_backward)r*   r  r   Úbool)r   r™   s   "€r   r    ÚPipe.__annotate__2  s2   ø€ ÷ Mñ Má—.‘.ðMñ ðMñ  $ñ	Mr!   c                ó¬  € \         P                  P                  P                  V 4       Wn        \        V P                  4      V n        W n        W0n        W@n	        VP                  P                   Fº  pVP                  R9   d   K  VP                  VP                  3R\        P                  38X  d   KE  VP                  VP                  3R8X  d   Kd  VP                  VP                  3R\         38X  d   K‰  VP                  VP                  3R\"        38X  d   K®  \%        RV 24      h	  / pV P                  P'                  4        F;  w  rxVP)                  4        F"  w  ršVP+                  V
/ 4       W–V
,          V&   K$  	  K=  	  VP-                  4        Uu. uF  p\/        V4      ^8”  g   K  VNK  	  upV n        V P0                   F”  pVP3                  4        F}  w  rÞ\5        V P                  V4      pVP7                  R4      pVRR  F  p\5        VV4      pK  	  \9        VVR,          \:        P<                  ! \5        VVR,          4      4      4       K  	  K–  	  R pVV P                  n        ^ p  \A        V4      p\5        V P                  V4      p\B        VPD                  n#        V^,          pKC  u upi   \H         d     R# i ; i)	rc   rU   zUnexpected node: Ú.Nc                 ó   € \        R 4      h)zHTo run pipeline locally, invoke the Pipe object directly, not `split_gm`)r,   r»   s   &*,r   ÚthrowÚPipe.__init__.<locals>.throwo  s   € ÜØZóð r!   >   rD   rc   rW   )Úcall_methodÚbackwardrn   )%r?   r@   rA   rµ   r4  rÓ   Úexecutorr5  r6  rK   rŒ   rF   rG   rp   rq   rr   r   r   rH   Únamed_childrenÚnamed_parametersr_   Úvaluesr/   Úreplicated_paramsÚitemsÚgetattrÚsplitÚsetattrrœ   Údeepcopyr¦   r'   r   r·   Ú
__reduce__ÚAttributeError)r£   r4  r5  r6  rK   rw   Úparams_to_usersÚ
m_qualnamer=   Ú
p_qualnameÚparamÚuse_mappingÚparam_mappingÚsubmod_nameÚparam_qualnamer0  ÚatomsÚatomr<  r�   rï   s   &&&&&                r   rµ   ÚPipe.__init__2  sj  € ô 	�‰�‰× Ñ  Ô&Ø(0ŒÜ(6°t·}±}Ó(EˆŒØ)ŒØ%:Ô"Ø"Œà—N‘N×(Ô(ˆDà—‘ÐCÖCØ—G‘G˜TŸ[™[Ð)¨o¼x×?OÑ?OÐ-PÖPØ—G‘G˜TŸ[™[Ð)Ð-HÖHØ—G‘G˜TŸ[™[Ð)¨o¼~Ð-NÖNØ—G‘G˜TŸ[™[Ð)Ø#Ô%>Ð?ö@ô %Ð'8¸¸Ð%?Ó@Ð@ñ )ð( EGˆà#Ÿ}™}×;Ñ;Ö=‰OˆJØ%(×%9Ñ%9Ö%;Ñ!�
Ø×*Ñ*¨5°"Ô5Ø5? Õ& zÓ2ó &<ñ  >ð  /×5Ñ5Ô7ó8
á7�Ü�;Ó !Ñ#÷ ˆKÙ7ñ8
ˆÔð "×3Ô3ˆMØ/<×/BÑ/BÖ/DÑ+�Ü  §¡°Ó<�Ø&×,Ñ,¨SÓ1�Ø! # 2›J�DÜ$ V¨TÓ2’Fñ 'ä˜  b¥	¬4¯=ª=¼ÀÈÈrÍÓ9SÓ+TÖUó 0Eñ 4ò	ð
 !&ˆ�‰Ôð ˆØðÜ& qÓ)�Ü  §¡°Ó5�Ü.J�× Ñ Ô+Ø�Q•’ùòC8
øôD "ô Úðús   ÆJ?Æ4J?É>?K ËKËKc           	     ó¨  € Tp\        V4      ^ 8”  Ed¥   . pV P                  P                  P                   EF6  pVP                  R8X  g   K  VP
                  '       dc   \        VP
                  4      ^ 8”  dI   VP                  \        VP                  \        P                  VP
                  ^ ,          R7      4       K‹  \        P                  pVP                  pVP                  P                  R4      '       d   \        P                  pVR,          pM:VP                  P                  R4      '       d   \        P                  pVR,          pVP                  \        Wv4      4       EK9  	  \        V4      pVP                  ! V/ VB p	V	P                  4        V	P                   P#                  4       pV P$                  P&                  ! V!  p
V
# )r   rW   )Údefaultz**:r   NNÚ*:r¡   NN)r/   r4  rŒ   rF   rG   rI   rŽ   r   rp   ÚPOSITIONAL_OR_KEYWORDÚ
startswithÚVAR_KEYWORDÚVAR_POSITIONALr   ÚbindÚapply_defaultsÚ	argumentsrC  r@  rÚ   )r£   rI   rm   Úexecutor_argsÚ
parametersrw   Úparameter_kindÚ
param_namer   ÚbaÚress   &*,        r   r¦   ÚPipe.forward�  sW  € ØˆÜˆv‹;˜�?ØˆJØŸ™×+Ñ+×1Õ1�Ø—7‘7˜mÖ+Ø—y—y�y¤S¨¯©£^°aÔ%7Ø"×)Ñ)Ü%Ø $§¡Ü )× ?Ñ ?Ø(,¯	©	°!­ôöô *3×)HÑ)H˜Ø%)§[¡[˜
ØŸ;™;×1Ñ1°$×7Ò7Ü-6×-BÑ-B˜NØ)3°B­™JØ!Ÿ[™[×3Ñ3°C×8Ò8Ü-6×-EÑ-E˜NØ)3°B­˜JØ"×)Ñ)¬)°JÓ*O×Pñ' 2ô( " *Ó-ˆIØ—’ Ð0¨Ñ0ˆBØ×ÑÔØŸL™L×/Ñ/Ó1ˆMà�m‰m×Ò Ñ/ˆàˆ
r!   c                óN   <€ V ^8„  d   QhRS[ RS[P                  P                  /# )r   r   Úreturn)r   r?   r@   rA   )r   r™   s   "€r   r    r8  ¢  s#   ø€ ÷ 3ñ 3©#ð 3±%·(±(·/±/ñ 3r!   c                ó�   € V^ 8  g   WP                   8¼  d   \        RV R24      h\        V4      p\        V P                  V4      # )zC
Return a stage module corresponding to `stage_idx` of the `pipe`.
zInvalid stage index Ú!)r5  Ú
ValueErrorr'   rF  r4  )r£   r   rR  s   && r   Úget_stage_moduleÚPipe.get_stage_module¢  sD   € ð �qŒ=˜I¯©Ô8ÜÐ3°I°;¸aÐ@ÓAÐAä% iÓ0ˆÜ�t—}‘} kÓ2Ð2r!   c                ó4   <€ V ^8„  d   QhRS[ P                  /# )r   r"  )r*   r  )r   r™   s   "€r   r    r8  ­  s   ø€ ÷ ñ ©R¯^©^ñ r!   c                ó„  € ^ p/ pV P                   P                   F¡  pVP                  R8X  g   K  VP                  P	                  \
        4      '       g   K=  \        VP                  \        \
        4      ^,           R 4      VP                  R&   VP                  VP                  R,          4       V^,          pK£  	  V# )r   rc   Nr   )
rŒ   rF   rG   rp   r[  r%   r   r/   rÿ   r_   )r"  r5  Ú
found_idxsrw   s   &   r   Ú _number_and_count_forward_stagesÚ%Pipe._number_and_count_forward_stages¬  s’   € àˆ
Ø&(ˆ
Ø—H‘H—N”NˆDØ�w‰w˜-Ö'¨D¯K©K×,BÑ,BÔCS×,TÔ,TÜ),¨T¯[©[¼Ô=MÓ9NÐQRÕ9RÐ9TÐ-UÓ)V�—	‘	˜+Ñ&Ø×%Ñ% d§i¡i°Õ&<Ô=Ø˜a•’
ñ	 #ð Ðr!   Nc          
      óÞ   <€ V ^8„  d   QhRS[ P                  P                  RS[RS[R,          RS[S[ P                  P                  .S[ P                  P                  3,          R,          /# )r   r=   Úexported_programÚmulti_use_param_specNÚsplit_policy)r?   r@   rA   r   ÚMultiUseParamSpecr   r*   r  )r   r™   s   "€r   r    r8  Â  sm   ø€ ÷ N
ñ N
Ù�X‰X�_‰_ðN
á)ðN
ñ 0°$Õ6ðN
ñ
 ¡§¡× 4Ñ 4Ð5±u·x±x×7KÑ7KÐKÕLØ
õñN
r!   c                ó¼  a.a/a0a1€ VP                  RR7      pVe   \        P                  R4       V! V4      p\        P                  VP	                  RR7      4       / pVP
                  P                   F‡  pVP                  R8X  g   K  VP                  VP                  V4       WgP                  ,          V8w  g   KK  VP                  WgP                  ,          4       VP
                  P                  V4       K‰  	  Rp\        4       p	\        VP
                  P                  4       FJ  w  r§VP                  VP                  3R\        38X  g   K*  WŠ^,
          8X  d   V	P                  V4       T
pKL  	  V	 F  pVP
                  P                  V4       K   	  VP!                  4        ^ o/R V/3R	 llp\#        WPVR
R7      o0S0P
                  P%                  4        S0P'                  4        F’  p\)        V\*        P,                  4      '       g   K%  VP
                  P                   FC  pVP                  VP                  3R\.        38X  g   K(  VP
                  P                  V4       KE  	  VP!                  4        K”  	  S0P1                  4        Fb  w  rÜ\)        V\*        P,                  4      '       g   K'  \3        VP
                  4       \5        VP
                  4      pS0P7                  WÞ4       Kd  	  R p. o1R o.V.V0V13R lp\9        \;        R S0P
                  P                  4      4      pV F§  p\=        VP>                  4      ^8”  d1   \        P                  RVP                   RVP>                   R24       VP>                   FJ  pVP                  R8X  g   \A        RVP                   24      hV! S0VP                  VP                  4       KL  	  K©  	  \C        \        4      pV PE                  RR7      PG                  4        F'  w  ppV\I        V4      ,          P                  V4       K)  	  V PK                  4        F'  w  ppV\I        V4      ,          P                  V4       K)  	  / pV F„  pS.! V VP                  4      w  pp\9        V\I        V4      ,          4      pV'       d   VVVPL                  &   KM  VP                  VPN                  9   g   Kj  VP                  .VVPL                  &   K†  	  \C        \8        4      pV PE                  RR7      PG                  4        F™  w  ppS0P1                  4        F  w  pp\)        V\*        P,                  4      '       g   K(  S.! VV4      w  ppV'       g   K>  Ve   KD  VV,          PQ                  V4       \S        VVPU                  R4      R,          V4       K�  	  K›  	  S1 F  w  pp \W        VV4       K  	  S0P[                  4        F\  p\)        V\*        P,                  4      '       g   K%  \]        VV. 4       VP
                  P_                  4        VP!                  4        K^  	  VPG                  4        EFa  w  pp \a        S0V4      p\        V 4      p!RV3.p"V"'       dð   V"Pc                  4       w  p#p$\)        V$\*        P,                  \d        34      '       dp   V$P
                  P                   FU  pVP                  R8X  g   K  V#'       d   V#R,           VP                  ,           MVP                  pV!Pg                  V4       KW  	  V$P1                  4        F1  w  p%p&T"PQ                  V#'       d   V#R,           V%,           MT%V&34       K3  	  K÷  V! FA  pTVPU                  R4      p'pV'RR  F  p(\a        VV(4      pK  	  \W        VV'R,          4       KC  	  EKd  	  V Fw  p\h        Ph                  ! VP>                  4       F5  pVP                  R8X  g   \A        RVP                   24      hV! VV4       K7  	  S0P
                  P                  V4       Ky  	  S0Pk                  4        S0P
                  P_                  4        S0P!                  4        \l        Po                  S04      p)Rp*Tp+Ven   \q        V S0P
                  V4      w  p,p-p+V,e@   \s        S0P
                  V,V-4       S0P!                  4        Rp*\        P                  R4       M$\u        RV: 24      h\        P                  R4       \        P                  RS0 24       \m        S0V)V*V+4      #   \X         d     EKˆ  i ; i)aä  
Additionally, the ``output_loss_value_spec`` value can be specified to disambiguate
which value in the output of `forward` is the loss value on which PiPPy should apply
backpropagation. For example, if your ``forward`` returns a tuple ``(loss, model_out)``,
you can specify ``output_loss_value_spec=(True, False)``. Or, if your ``forward`` returns
a dict ``{'loss': loss_value, 'model_out': model_out}``, you can specify
``output_loss_value_spec={'loss': True, 'model_out': False}``
F)Úcheck_guardsNzAuto-splitting model)Úprint_outputÚget_attrrU   c                ó8   € V ^8„  d   QhR\         P                  /# )r   rM   )r*   r+   )r   s   "r   r    Ú'Pipe._from_traced.<locals>.__annotate__÷  s   € ÷ 	ñ 	œbŸg™gñ 	r!   c                 ó�   <€ V P                   V P                  3R \        38X  d"   \        P	                  RS 24       S^,          oS# )rU   zFound pipe_split )rG   rp   Úaten_pipe_split_aliasr'  r(  )rM   Úpart_idxs   &€r   Úsplit_callbackÚ)Pipe._from_traced.<locals>.split_callback÷  sG   ø€ à—‘�a—h‘hÐØÜ%ð$ô ô —‘Ð0°°
Ð;Ô<Ø˜A•�ØˆOr!   Úpp)Úpartition_affixc           	     óú  € \        VP                  4      ^ 8X  g"   \        R\        VP                  4       24      h\        VP                  4       UUu. uF  w  r#W08X  g   K  VNK  	  ppp\        V4      ^8X  g   \        R\        V4       24      h\        VP                  4      pVP                  V^ ,          4       \        V4      Vn        \        P                  RV  RV RV^ ,           24       R# u uppi )z�
Delete reference of `node` from `user`'s arg list.
Args:
    - node: a `get_attr` node at root.
    - user: a submodule node that uses `node`.
z&Expected user.kwargs to be empty, got zExpected 1 use index, got zDeleted z from user z, arg index = N)
r/   rm   rH   ru   rI   r.   r  r-   r'  r(  )rw   Úuserr�   r  Úuse_idxsÚ	args_copys   &&    r   Údelete_user_referenceÚ0Pipe._from_traced.<locals>.delete_user_reference  s×   € ô �t—{‘{Ó# qÔ(Ü$Ø<¼SÀÇÁÓ=MÐ<NÐOóð ô )2°$·)±)Ô(<ÔLÑ(<™f˜aÀÁŸ˜Ñ(<ˆHÑLÜ�x“= AÔ%Ü$Ð'AÄ#ÀhÃ-ÀÐ%QÓRÐRÜ˜TŸY™Y›ˆIØ�M‰M˜( 1�+Ô&Ü˜iÓ(ˆDŒIÜ�L‰LØ˜4˜& ¨D¨6°ÀÈÅ¸}ÐMöùó Ms   Á
C7Á#C7c                 óÞ   € VP                  R 4      pVRR  F#  p\        W4      '       g   Ru # \        W4      p K%  	  \        WR,          4      '       g   V R3# \        WR,          4      pW3# )r:  Nrn   ©NN)rG  ÚhasattrrF  )r=   ÚfqnrT  rU  Úattrs   &&   r   Ú_recursive_getattr_with_parentÚ9Pipe._from_traced.<locals>._recursive_getattr_with_parent3  sk   € à—I‘I˜c“NˆEØ˜c˜r›
�Ü˜s×)Ò)Ø%Ò%Ü˜cÓ(’ñ #ô ˜3 b¥	×*Ò*Ø˜D�yÐ Ü˜3 b¥	Ó*ˆDØ�9Ðr!   c           
     óâ  <€ VP                  R4      pS! S	V4      w  rEVR,          VP                  9   p\        V\        P                  4      '       gq   \        RV R\        P                   R\        V4       R2\        V\        P                  P                  4      '       d   RV RV R2,           4      hR,           4      hV P                  V4      p\        Wr4      '       d   \        R	V R
V 24      hV'       d    \        VVV\        P                  RR7       M\        VVV\        P                  R7       \        P!                  RV RV 24       S
P#                  WCR,          34       R# )zß
Move a parameter from the root module to a submodule.
Args:
    root: The root module.
    callee_name: The name of the submodule to move the parameter to.
    param_fqn: The fully qualified name of the parameter to move.
r:  z
Expected 'z' to be z	 but got z It might happen if module 'zu' was passed to some 'leaf function'(see https://pytorch.org/docs/stable/fx.html#fx.wrap). Please inspect usages of 'z' in the traced graph.Ú zModule z already has a parameter named T)Ú	attr_kindÚ
persistent)r•  zMoved parameter r&  Nrn   )rG  Ú_buffersr)   r?   rß   rH   r5   r@   rA   r*  rŽ  r   r   ÚBUFFERÚ	PARAMETERr'  r(  rŽ   )ÚrootÚcallee_nameÚ	param_fqnrT  Úmod_itrÚ	param_valÚ	is_bufferÚcalleer‘  rG  Ú	to_deletes   &&&     €€€r   Úmove_param_to_calleeÚ/Pipe._from_traced.<locals>.move_param_to_callee?  sr  ø€ ð —O‘O CÓ(ˆEÙ!?ÀÀyÓ!QÑˆGà˜b�	 W×%5Ñ%5Ñ5ˆIô ˜i¬¯©×6Ò6Ü$Ø   ¨8´E·L±L°>ÀÌ4ÐPYË?ÐJ[Ð[\Ð]ô
 & i´·±·±×AÒAð 7°y°kð B&à&/ [Ð0FðHõó	ð 	ð  õó	ð 	ð ×'Ñ'¨Ó4ˆFÜ�v×)Ò)Ü$Ø˜k˜]Ð*IÈ)ÈÐUóð ÷
 ÜØØØÜ'×.Ñ.Ø#öô ØØØÜ'×1Ñ1õ	ô �L‰LÐ+¨I¨;°d¸;¸-ÐHÔIð ×Ñ˜g¨R¥yÐ1Ö2r!   c                 ó    € V P                   R 8H  # )r|  )rG   rù   s   &r   rú   Ú#Pipe._from_traced.<locals>.<lambda>‚  s   € ¨1¯4©4°:Ò+=r!   z
Parameter z used in multiple stages: r:  rc   z*Expected user.op to be 'call_module', got T)Ú	keep_varsr”  z5Pipeline is in training mode, backward pass generatedz@Did not find any loss value according to output_loss_value_spec=z:Pipeline is in inference mode, backward pass not generatedzFull pipe model:
rn   );r¥   r'  Úinfor(  Úprint_readablerŒ   rF   rG   r_   rp   Úreplace_all_uses_withÚ
erase_noder3   ru   r¢   Úaddr.  r   Úeliminate_dead_codeÚmodulesr)   r*   r  r€  rA  r’   r   Úregister_moduler.   Úfilterr/   ÚusersrH   r   Ú
state_dictrE  ÚidÚnamed_buffersrï   Ú	constantsrŽ   rH  rG  ÚdelattrrK  Úchildrenr   ÚlintrF  r  r   Údiscardrœ   Údelete_all_unused_submodulesr2  rr  rR   rŠ   r,   )2r=   ru  rv  rL   rw  ÚtracedÚget_attr_nodesrw   Úprev_pipe_split_idxÚpipe_split_nodes_to_eraser�   r‚  Ú	submodulerï   Ú
new_submodrŠ  r¢  Ú
attr_nodesr‡  Ú
id_to_fqnsr�  ÚtensorÚinputs_to_stater�  r#   ÚfqnsÚadded_attributesr0  ÚparentÚchildr�  Ú	last_atomÚ
attributesÚunused_attributesÚstackÚscopeÚ_modÚ_nameÚ_submodrT  rU  r5  r6  Úgenerated_loss_specrQ   rO   r‘  r�  rG  r¡  s2   &&&&&                                         @@@@r   Ú_from_tracedÚPipe._from_tracedÁ  s   û€ ð$ "×(Ñ(°eÐ(Ó<ˆàÒ#Ü�K‰KÐ.Ô/Ù! &Ó)ˆFä�‰�V×*Ñ*¸Ð*Ó>Ô?ð
 .0ˆØ—L‘L×&Ô&ˆDØ�w‰w˜*Ö$Ø×)Ñ)¨$¯+©+°tÔ<à!§+¡+Õ.°$Ö6Ø×.Ñ.¨~¿k¹kÕ/JÔKØ—L‘L×+Ñ+¨DÖ1ñ 'ð !ÐÜ$'£EÐ!Ü  §¡×!3Ñ!3Ö4‰GˆAØ—‘˜Ÿ™Ð%¨/¼:Ð)FÖFØ&¨a­%Ô/Ø-×1Ñ1°$Ô7Ø&'Ò#ñ	 5ó .ˆDØ�L‰L×#Ñ# DÖ)ñ .ð 	×ÑÔàˆ÷	ð 	ô ˜V¨.È$ÔOˆà�‰×'Ñ'Ô)ð Ÿ™žˆIÜ˜)¤R§^¡^×4Ô4Ø%ŸO™O×1Ô1�DØŸ™ §¡Ð-Ø'Ü-ð2ö ð "Ÿ™×2Ñ2°4Ö8ñ 2ð ×#Ñ#Ö%ñ )ð  %×3Ñ3Ö5‰OˆDÜ˜)¤R§^¡^×4Ô4Ü+¨I¯O©OÔ<Ü0°·±ÓA�
à×%Ñ% dÖ7ñ  6ò	ð. ˆ	ò
	÷@	3ôF œ&Ñ!=¸u¿{¹{×?PÑ?PÓQÓRˆ
ÛˆDä�4—:‘:‹ Ô"Ü—‘Ø  §¡ Ð-GÈÏ
É
À|ÐSTÐUôð Ÿ
œ
�Ø—w‘w -Ô/Ü(ØDÀTÇWÁWÀIÐNóð ñ %ØØ—K‘KØ—K‘Köó #ñ ô( +6´cÓ*:ˆ
ØŸ>™>°D˜>Ó9×?Ñ?ÖA‰KˆC�Ø”r˜&“zÕ"×&Ñ& sÖ+ñ Bà×,Ñ,Ö.‰KˆC�Ø”r˜&“zÕ"×&Ñ& sÖ+ñ /ð 13ˆÛˆDÙ6°s¸D¿K¹KÓH‰IˆAˆvÜ˜
¤2 f£:Õ.Ó/ˆDßØ-1� §	¡	Ó*Ø—‘Ð 0× :Ñ :Ö:Ø.2¯k©k¨]� §	¡	Ó*ñ ô 2=¼TÓ1BÐØŸ>™>°D˜>Ó9×?Ñ?ÖA‰KˆC�Ø %× 4Ñ 4Ö 6‘��fÜ˜f¤b§n¡n×5Ô5Ù$BÀ6È3Ó$O‘M�F˜Eç™ 5¤=à(¨Õ.×5Ñ5°cÔ:Ü ¨¯	©	°#«°rÕ(:¸FÖCó !7ñ Bó #,ÑˆG�YðÜ˜ Ö+ñ #,ð —n‘nÖ&ˆFÜ˜&¤"§.¡.×1Ô1Ü˜V _°bÔ9Ø—‘×!Ñ!Ô#Ø× Ñ Ö"ñ	 'ð !1× 6Ñ 6× 8ÑˆD�*Ü˜U DÓ)ˆFÜ # J£Ðà˜&�\�NˆEßØ#Ÿi™i›k‘��tÜ˜d¤R§^¡^Ô5FÐ$G×HÒHØ $§
¡
× 0Ô 0˜ØŸ7™7 jÖ0ç?D %¨#¥+°·±Ö";È$Ï+É+˜CØ-×5Ñ5°cÖ:ñ	 !1ð
 '+×&9Ñ&9Ö&;‘N�E˜7Ø—L‘L¿ %¨#¥+°Ö"5ÀEÈ7Ð!SÖTó '<ó *�Ø!'¨¯©°C«˜�Ø! # 2›J�DÜ% g¨tÓ4’Gñ 'ä˜  r¥Ö+ô	 *ñ! !9ó, ˆDäŸ	š	 $§*¡*Ö-�Ø—w‘w -Ô/Ü(ØDÀTÇWÁWÀIÐNóð ñ & d¨DÖ1ñ .ð �K‰K×"Ñ" 4Ö(ñ ð 	×*Ñ*Ô,Ø�‰×ÑÔØ�‰Ôä×:Ñ:¸5ÓAˆ
à %ÐØ4Ðà!Ò-Ü:KØ�U—[‘[Ð"8ó;Ñ7ˆI�{Ð$7ð Ò$Ü/Ø—K‘KØØôð
 —‘Ô!Ø(,Ð%Ü—‘ÐTÕUä"ØWÐ@VÑ?XÐYóð ô �L‰LÐUÔVä�‰Ð)¨%¨Ð1Ô2äØØØ!Øó	
ð 	
øô] "ô ãðús   ×eåeåec                ó:   € V P                   P                  4        R# )zf
Print the pipe in a human-readable format.
This will print both the root pipe and each stage module.
N)r4  r¨  ©r£   s   &r   r¨  ÚPipe.print_readable  s   € ð
 	�‰×$Ñ$Ö&r!   c                ó’   <€ V ^8„  d   QhRS[ P                  P                  RS[S[R3,          RS[S[S[3,          R,          RS[/# )r   r=   Úexample_args.Úexample_kwargsNri  )r?   r@   rA   r-   r
   r2   r&   r   )r   r™   s   "€r   r    r8    sN   ø€ ÷ ñ Ù�X‰X�_‰_ðá™C ˜H•oðñ ™S¡#˜X�¨Õ-ðñ 
ñ	r!   c                ó°   € \         P                  R 4        \        P                  P                  WV4      pV#   \         d   p\        R4      ThRp?ii ; i)zTracing model ...a.  It seems that we cannot capture your model as a full graph. Typical reasons include graph breaks, data/shape-dependent control flow, or missing meta kernels for custom operators. You can use our manual pipeline interfaces, or try to fix the graph breaks, see https://pytorch.org/docs/stable/export.htmlN)r'  r§  r?   ÚexportÚ	Exceptionr,   )r=   r×  rØ  ÚepÚes   &&&  r   Ú_trace_with_exportÚPipe._trace_with_export  s]   € ô 	�‰Ð'Ô(ð		Ü—‘×$Ñ$ S¸ÓGˆBð ˆ	øô ô 	ÜðPóð ðûð	ús   — 9 ¹AÁAÁAc          
      óà   <€ V ^8„  d   QhRS[ P                  P                  RS[S[R3,          RS[S[S[3,          R,          RS[S[P                  .S[P                  3,          R,          /# )r   r=   r×  .rØ  Nrw  )
r?   r@   rA   r-   r
   r2   r&   r   r*   r  )r   r™   s   "€r   r    r8  .  sn   ø€ ÷ @ñ @Ù�X‰X�_‰_ð@á™C ˜H•oð@ñ ™S¡#˜X�¨Õ-ð@ñ ¡§¡Ð/±·±Ð?Õ@À4ÕGñ	@r!   c                ód  € \         P                  pR p \        P                  V VV4      p\        P	                  V VVVVR7      pVP
                  pVP                  4       p	\        \        VP                  4       4      4      p
\        V
P                  4      p\        V	P                  4      p\        VP                  4      \        VP                  4      8w  dE   \        P                  R\        VP                  4       R\        VP                  4       R24       V# \         P"                  ! V	P$                  P&                  4      V
P$                  n        V
P$                  P&                  P(                  P+                  R R7      V
P$                  P&                  n        V
P-                  4        V# )N)rL   rw  zOriginal model takes z) args but the first pipeline stage takes z4. Please provide args to respective pipeline stages.)Úout_spec)rÏ   rÑ   r2  rÞ  rÑ  r4  r¥   ÚnextÚiterr¶  r   r¦   r/   rb  r'  r§  rœ   rI  rŒ   Ú_codegenÚpytree_infoÚ_replacer.  )r=   r×  rØ  rw  rv  rL   ru  ÚpiperG  rº  Úsubmod0Úsubmod0_signÚ
model_signs   &&&&         r   Úfrom_tracingÚPipe.from_tracing-  s}  € ô  7×@Ñ@Ðð '+Ðð	ô  ×2Ñ2ØØØó
Ðô × Ñ ØØØ Ø#9Ø%ð !ó 
ˆð —‘ˆØ!×(Ñ(Ó*ˆÜ”t˜EŸN™NÓ,Ó-Ó.ˆÜ  §¡Ó1ˆÜ˜vŸ~™~Ó.ˆ
Üˆz×$Ñ$Ó%¬¨\×-DÑ-DÓ)EÔEô �K‰KØ'¬¨J×,AÑ,AÓ(BÐ'Cð D.Ü.1°,×2IÑ2IÓ.JÐ-Kð LEðEôð  ˆô &*§]¢]°6·<±<×3HÑ3HÓ%IˆG�M‰MÔ"ð
 —‘×&Ñ&×2Ñ2×;Ñ;ÀTÐ;ÓJð �M‰M×"Ñ"Ô.ð ×ÑÔàˆr!   c                ó6   € V P                   P                  4       # r^   )r4  Ú__str__rÔ  s   &r   rï  ÚPipe.__str__p  s   € Ø�}‰}×$Ñ$Ó&Ð&r!   c                ó6   € V P                   P                  4       # r^   )r4  Ú__repr__rÔ  s   &r   rò  ÚPipe.__repr__s  s   € Ø�}‰}×%Ñ%Ó'Ð'r!   c                ó    <€ V ^8„  d   QhRS[ /# )r   ri  r   )r   r™   s   "€r   r    r8  v  s   ø€ ÷ 
ñ 
‘hñ 
r!   c                ón   € \        V P                  P                  V P                  V P                  R7      # )zr
Get information about the pipe.

Returns
-------
PipeInfo
    A dataclass containing information about the pipe.
)rŒ   r5  r6  )r   r4  rŒ   r5  r6  rÔ  s   &r   r§  Ú	Pipe.infov  s.   € ô Ø—-‘-×%Ñ%Ø—‘Ø"&×"<Ñ"<ô
ð 	
r!   c                óT   <€ V ^8„  d   QhRS[ RS[P                  RS[R,          RS[/# )r   Ústage_indexr$  ÚgroupNri  )r   r?   r$  r   r   )r   r™   s   "€r   r    r8  …  sB   ø€ ÷  Sñ  Sáð Sñ —‘ð Sñ ˜dÕ"ð	 Sñ
 
ñ Sr!   c                ó  € V P                  V4      p\        V\        P                  P                  4      '       d   \        WB4       M!\        P                  R\        V4       24       V P                  4       p\        WAWRV4      # )z{
Create a `PipelineStage` given a stage index and distributed group.
The `PipelineStage` can run with `PipelineSchedule`s.
z*Expected a `torch.fx.GraphModule` but got )rm  r)   r?   r*   r  r+  r'  r-  r5   r§  r   )r£   rø  r$  rù  Ústage_moduleÚ	pipe_infos   &&&&  r   Úbuild_stageÚPipe.build_stage…  sm   € ð ×,Ñ,¨[Ó9ˆô �l¤E§H¡H×$8Ñ$8×9Ò9Ü# LÕ9ä�N‰NØ<¼TÀ,Ó=OÐ<PÐQôð —I‘I“Kˆ	Ü˜l¸ÈEÓRÐRr!   )r@  r6  rK   r5  rD  r4  ©NNNr^   r�  )r©   rª   r«   r¬   rµ   r¦   rm  r­   rr  rÑ  r¨  rÞ  rì  rï  rò  r§  rý  r®   r¯   r°   s   @r   r2  r2  1  s´   ø‡ € ÷Mð Mò^÷B3ð 3ð ÷ó ðð( ÷N
ñ N
ó ðN
ò`
'ð ÷ñ ó ðð& ÷@ñ @ó ð@òD'ò(÷
ð 
÷ S÷  Sð  Sr!   r2  c                   ó"   € ] tR tRtRt^t^tRtR# )Ú
SplitPointi¨  aO  
Enum representing the points at which a split can occur in the execution of a submodule.
Attributes:
    BEGINNING: Represents adding a split point *before* the execution of a certain submodule in the `forward` function.
    END: Represents adding a split point *after* the execution of a certain submodule in the `forward` function.
r¨   N)r©   rª   r«   r¬   r½   Ú	BEGINNINGÚENDr®   r¨   r!   r   r  r  ¨  s   † ñð €IØ
„Cr!   r  c                   ó   € ] tR tRt]tRtR# )ÚPipeSplitWrapperi¶  r¨   N)r©   rª   r«   r¬   r  r®   r¨   r!   r   r  r  ¶  s   † à„Jr!   r  c                 ó:   € \        4        V P                  ! V/ VB # r^   )r¢   Ú_orig_forwardr»   s   &*,r   Ú_split_before_forwardr  »  s   € Ü„LØ×Ò˜tÐ. vÑ.Ð.r!   c                 óZ   €  V P                   ! V/ VB \        4        #   \        4        i ; ir^   )r  r¢   r»   s   &*,r   Ú_split_after_forwardr
  À  s%   € ðØ×!Ò! 4Ð2¨6Ñ2ä�øŒ
�ús   ‚ ž*c                óz   € V ^8„  d   QhR\         P                  P                  R\        \        \
        3,          /# )r   r=   r9   )r?   r@   rA   r2   r&   r  )r   s   "r   r    r    Ç  s+   € ÷ :ñ :œuŸx™xŸ™ð :´d¼3Ä
¸?Õ6Kñ :r!   c                 ó(  € VP                  4        F¿  w  r#VP                  R 4      pT p\        VRR 4       F  w  rg \        WW4      pK  	  \        WTR,          4      p	V	P                  V	n        V\        P                  8X  d   \        \        V	4      V	n        KŠ  V\        P                  8X  d   \        \        V	4      V	n        K¶  \        R4      h	  R#   \         d1   p\	        RT RR P                  TRT^,            4       24      ThRp?ii ; i)r:  NzSpecified target z referenced nonexistent module zUnknown split point type.rn   )rE  rG  ru   rF  rK  r$   r¦   r  r  r  r	   r  r  r
  rl  )
r=   r9   ÚqualnameÚ
split_typerT  Úpredecessor_moduler�   rU  rÝ  Úmod_to_wraps
   &&        r   Úannotate_split_pointsr  Ç  s  € à $§
¡
¦ÑˆØ—‘˜sÓ#ˆØ ÐÜ   s¨ Ö,‰GˆAðÜ%,Ð-?Ó%FÒ"ñ -ô Ð0¸µ)Ó<ˆØ$/×$7Ñ$7ˆÔ!Øœ×-Ñ-Ô-Ü",Ô-BÀKÓ"PˆKÖØœ:Ÿ>™>Ô)Ü",Ô-AÀ;Ó"OˆKÖäÐ8Ó9Ð9ó' !-øô "ô Ü$Ø'¨ zð 2*Ø*-¯(©(°5¸¸1¸q½5°>Ó*BÐ)CðEóð ðûðús   ½CÃDÃ!+DÄDc                ó\  € V ^8„  d   QhR\         P                  P                  R\        \        R3,          R\
        \        \        3,          R,          R\
        \        \        3,          R,          R\        \        P                  .\        P                  3,          R,          R\        /# )	r   r¥   Úmb_args.Ú	mb_kwargsNÚ
split_specrw  ri  )r?   r@   rA   r-   r
   r2   r&   r  r   r*   r  r2  )r   s   "r   r    r    ß  s‰   € ÷ 1
ñ 1
Ü�H‰H�O‰Oð1
ä”3˜�8�_ð1
ô ”Cœ�H�~ Õ$ð1
ô ”Sœ*�_Õ%¨Õ,ð	1
ô
 œBŸN™NÐ+¬R¯^©^Ð;Õ<¸tÕCð1
ô 
ñ1
r!   c                ó¨   € Ve   Ve   \        R4      hVe$   \        W4       \        P                  V VVR7      # \        P                  V VVVR7      # )aî  
Split a module based on a specification.

See `Pipe` for more details.

Arguments
---------
module:
    The module to be split.
mb_args:
    Example positional inputs, in micro-batch form.
mb_kwargs:
    Example keyword inputs, in micro-batch form. (default: `None`)
split_spec:
    A dictionary using submodule names as split marker. (default: `None`)
split_policy:
    The policy to use for splitting the module. (default: `None`)

Returns
-------
A pipeline representation of class `Pipe`.
zQCannot specify both `split_spec` and `split_policy`. Please use only one of them.)r=   r×  rØ  )r=   r×  rØ  rw  )rl  r  r2  rì  )r¥   r  r  r  rw  s   &&&&&r   Úpipeliner  ß  sv   € ð: Ò ,Ò":ÜØ_ó
ð 	
ð Òä˜fÔ1Ü× Ñ ØØ Ø$ð !ó 
ð 	
ô × Ñ ØØ Ø$Ø%ð	 !ó 
ð 	
r!   rÿ  )Xrœ   Úloggingrq   Úcollectionsr   Úcollections.abcr   Úenumr   Úinspectr   r   r   Útypesr	   Útypingr
   r?   Útorch.fxr*   Útorch.distributedr   Útorch.exportr   Útorch.export.unflattenr   r   r   r   Útorch.fx.noder   Útorch.fx.passes.split_moduler   Ú	_backwardr   r   Ú
_unflattenr   Ú_utilsr   Ústager   Ú	getLoggerr©   r'  r%   r'   r1   rR   rŠ   r’   r@   r˜   r”   rA   r²   rJ   ÚlibraryÚdefineÚimplrÈ   Úregister_fakerÌ   rÍ   rX  r€  rw   Ú_side_effectful_functionsr«  r¢   rÏ   r2   r&   rx  ÚInterpreterrÓ   rì   rõ   r  r   r+  r2  r  r  r  r
  r  r  r¨   r!   r   Ú<module>r0     sý  ðó Û Û Ý #Ý $Ý ß 3Ñ 3Ý Ý ã Ý Ý *Ý (÷ó õ (Ý 5ç @Ý +Ý Ý !ð 
×	Ò	˜8Ó	$€ð Ð õ8ò,Sõ^2õ<jõZô*
�U—X‘X×(Ñ(ô 
ô%
�%—(‘(—/‘/ô %
ôP˜ô ð@ ‡�× Ñ Ð)¨:Ô 6ð ‡�×ÑÐ(¨/Ó:ñó ;ðð ‡�×ÑÐ1Ó2ñó 3ðð
 Ÿ	™	Ÿ™×3Ñ3×;Ñ;Ð ð ‡�× !Ñ !× %Ñ %Ð&;Ô <ò)ô(˜dô ð
 ,¨d°3Ð8OÐ3OÕ.PÕPÐ ô1;�R—^‘^ô 1;÷hñ ÷*ñ *òZ3ò,õ ôFt	Sˆ5�8‰8�?‰?ô t	Sôn	�ô 	÷ñ ò
/ò
õ:÷01
ñ 1
r!   