ó
    Eñi^ ã                   ó¾  • S SK r S SKrS SKJr  S SKJrJr  S SKJrJ	r	  S SK
r
S SKJr  S SKJs  Js  Jr  S SKJr  S SKJs  Jr  S SKJr  S SKJr  S SKJr  S SKJrJrJ r J!r!J"r"J#r#J$r$J%r%  S S	K&J'r'J(r(J)r)J*r*J+r+  S S
K,J-r-  S SK.J/r/  S SK0J1r1J2r2J3r3J4r4  S SK5J6r7  \Rp                  " \95      r:Sr; " S S\5      r<S\Rz                  S\>\?\   \?\Rz                     4   4S jr@S\Rz                  S\?\   4S jrAS\S\Rz                  S\B4S jrC\	S\S\Rz                  S\4S j5       rDS\S\Rz                  4S jrE\	S\S\Rz                  SS4S j5       rF\	S\SS4S j5       rG\	S\S\(S\
R�                  S\
R�                  SS4
S  j5       rI\	S\S\(S!\B4S" j5       rJS\(S-  SS4S# jrKS\(S-  SS4S$ jrL\	S\S\(S-  S%\S\Rz                  S&\>\S'4   S(\M\N\4   S\>\>\S'4   \M\N\4   4   4S) j5       rO\	S\S\(S-  SS4S* j5       rP\	S\S\(S-  S+\S\Rz                  S,\S-\S\4S. j5       rQ\	S\S\(SS4S/ j5       rR\	S\S\Rz                  SS4S0 j5       rS\	S\S\
R&                  Rz                  S\>\\4   4S1 j5       rT\	S\S\Rz                  S\(S2\S\4
S3 j5       rU\	\
R¬                  " 5       S\S\(S2\4S4 j5       5       rWS\S\(S2\SS4S5 jrXS\S\(S2\SS4S6 jrY\	S\S\(S\B4S7 j5       rZ\	S\S\(SS4S8 j5       r[\	S\S9\
R¸                  S\>\
R¸                  \
R¸                  4   4S: j5       r]\	S\S\(S;\
R¸                  S\
R¸                  4S< j5       r^\	S\S\(SS4S= j5       r_\	S\S\(S>\
R¸                  4S? j5       r`\	S\S\(S>\
R¸                  4S@ j5       ra\	S\(4SA j5       rbSB\
R¸                  SC\cSS4SD jrd\	S\S;\
R¸                  SE\'4SF j5       reSG\
R¸                  SH\
R¸                  SS4SI jrf\	S\S\B4SJ j5       rg\	\
R¬                  " 5       S\S\Rz                  4SK j5       5       rh\	S\SS4SL j5       ri\	S\SS4SM j5       rj\	S\SN\(S-  SO\<SS4SP j5       rk\	S\SN\(S\(4SQ j5       rlS\(S\*4SR jrm\	S\S\Rz                  SS4SS j5       rn\	S\S\Rz                  SS4ST j5       ro\	S\S\Rz                  4SU j5       rp\	S\S\Rz                  SV\S\(SS4
SW j5       rqS\S\(S-  SS4SX jrrS\S\(S-  S&\>\S'4   S(\M\N\4   SS4
SY jrs\	S\S\Rz                  SS4SZ j5       rtS[\
R�                  S\
R�                  S\
R�                  4S\ jruS]\?\(   4S^ jrv\	S\S\Rz                  S\>\?\
R¸                     \?\
Rî                  S-     4   4S_ j5       rx\	S\S`\?\N   S\?\
Rî                     4Sa j5       rySb\?\
R¸                     Sc\?\
Rî                  S-     Sd\
Rô                  SS4Se jr{g)fé    N)ÚCallable)ÚautoÚEnum)ÚAnyÚno_type_check)ÚVariable)Úregister_multi_grad_hook)ÚLOW_PRECISION_HOOKS)Ú_assert_in_training_statesÚ
_FSDPStateÚ_get_module_fsdp_stateÚ_is_composableÚ_log_post_backward_hookÚ_no_dispatch_record_streamÚclean_tensor_nameÚTrainingState)ÚFlatParameterÚFlatParamHandleÚHandleShardingStrategyÚHandleTrainingStateÚ'RESHARD_AFTER_FORWARD_HANDLE_STRATEGIES)ÚHYBRID_SHARDING_STRATEGIES)ÚBackwardPrefetch)Ú_apply_to_tensorsÚ_cast_forward_inputsÚ	_p_assertÚ
_to_kwargs)Ú_pytree)Ú_use_orig_paramsÚlimit_all_gathersÚ_use_full_prec_in_evalc                   ó0   • \ rS rSr\" 5       r\" 5       rSrg)Ú_PrefetchModeé6   © N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__r   ÚBACKWARDÚFORWARDÚ__static_attributes__r%   ó    Úb/home/mande/repo/quber/.venv/lib/python3.13/site-packages/torch/distributed/fsdp/_runtime_utils.pyr#   r#   6   s   † Ù‹v€HÙ‹fƒGr-   r#   ÚmoduleÚreturnc                 ó
  • / n/ n[        5       nU R                  5        H_  n[        U5      nUc  M  XS;  d  M  [        XT5      (       d  M,  UR	                  U5        UR                  U5        UR                  U5        Ma     X4$ )a  
Returns a tuple containing:
1. A list of the root ``_FSDPState`` instances in the module tree rooted at
``module`` without any duplicates and following the ``module.modules()``
traversal order (which is assumed to be depth-first).
2. A corresponding list of the root modules owning the states in the first
list.

This is similar to :func:`_get_fsdp_states_with_modules` except that we
must call :func:`_is_fsdp_root` to force a lazy initialization to determine
the FSDP root in case lazy initialization has not yet happened.
)ÚsetÚmodulesr   Ú_is_fsdp_rootÚaddÚappend)r/   Úfsdp_root_statesÚfsdp_root_modulesÚvisited_fsdp_statesÚ	submoduleÚoptional_states         r.   Ú"_get_fsdp_root_states_with_modulesr<   ;   s   € ð *,ÐØ)+ÐÜ+.«5Ðà—^‘^Ö%ˆ	Ü/°	Ó:ˆàÓ&ØÕ9Ü˜n×8Ó8à×#Ñ# NÔ3Ø×#Ñ# NÔ3Ø×$Ñ$ YÖ/ñ &ð Ð.Ð.r-   c                 ó    • [        U 5      u  pU$ )z/See :func:`_get_fsdp_root_states_with_modules`.)r<   )r/   r7   Ú_s      r.   Ú_get_fsdp_root_statesr?   [   s   € ä<¸VÓDÑÐØÐr-   Ústatec                 ó`   • [        X5        U R                  c  [        S5      eU R                  $ )zÌ
Returns if ``state`` corresponds to that of an FSDP root.

For the wrapper code path, ``state`` and ``module`` should be the same. For
the non-wrapper code path, ``state`` should be ``module`` 's state.
z+Expected _is_root to be set after lazy init)Ú
_lazy_initÚ_is_rootÚAssertionError©r@   r/   s     r.   r4   r4   a   s,   € ô ˆuÔØ‡~�~ÑÜÐJÓKÐKØ�>‰>Ðr-   Úroot_modulec                 óÄ  • U R                   b  gU R                  R                  5       (       d  [        S5      eSU l         [	        U [
        R                  /5        [        X5        [        R                  " U5      U l
        [        U 5        [        X5      u  p#[        X#U R                  5        U R                  R!                  XU R"                  5        [%        X5        U $ )aÍ  
Performs initialization lazily, typically right before the first forward
pass. The laziness is needed to ensure that the parameter device/dtype and
the FSDP hierarchy have finalized. This method's actual logic only runs on
the root FSDP instance, which performs initialization for all non-root FSDP
instances to avoid partial initialization.

For the non-composable code path, ``state`` and ``root_module`` should be
the same, namely the FSDP instance itself.
Nz(FSDP does not support CPU only executionT)rC   Ú_device_handleÚis_availableÚRuntimeErrorr   r   ÚIDLEÚ%_check_flat_params_on_expected_deviceÚtraversal_utilsÚ_get_fsdp_statesÚ_all_fsdp_statesÚ_init_streamsÚ'_get_buffers_and_dtypes_for_computationÚ!_cast_buffers_to_dtype_and_deviceÚcompute_deviceÚ_exec_order_dataÚinitÚprocess_groupÚ"_share_state_and_init_handle_attrs)r@   rF   ÚbuffersÚbuffer_dtypess       r.   rB   rB   o   s¹   € ð ‡~�~Ñ!ØØ×Ñ×,Ñ,×.Ñ.ô ÐEÓFÐFð €E„NÜ˜u¤}×'9Ñ'9Ð&:Ô;Ü)¨%Ô=Ü,×=Ò=¸kÓJ€EÔÜ�%ÔÜDÀUÓXÑ€GÜ% g¸e×>RÑ>RÔSØ	×Ñ×Ñ °E×4GÑ4GÔHÜ& uÔ:Ø€Lr-   c                 óÔ  • [         R                  " S5      n[        R                  " U5       H¸  nUR                  (       dT  UR
                  R                  U R                  :w  a0  [        SUR
                  R                   SU R                   S35      eUR                  (       d  M{  UR
                  R                  U:w  d  M—  [        SUR
                  R                   S35      e   g)z…
Checks that all ``FlatParameter``s in ``module`` 's tree managed by
``state`` are on the expected device for *lazy initialization*.
Úcpuz6An FSDP-managed module unexpectedly has parameters on z". Make sure to move the module to z before training.zOAn FSDP-managed module with parameter CPU offloading enabled has parameters on zG. Make sure to not move the module from CPU when offloading parameters.N)ÚtorchÚdevicerM   Ú_get_fsdp_handlesÚ_offload_paramsÚ
flat_paramrS   rJ   )r@   r/   Ú
cpu_deviceÚhandles       r.   rL   rL   ’   sÔ   € ô
 —’˜eÓ$€JÜ!×3Ò3°FÖ;ˆà×&×&Ø×!Ñ!×(Ñ(¨E×,@Ñ,@Ó@äØHØ×$Ñ$×+Ñ+Ð,Ð,NØ×'Ñ'Ð(Ð(9ð;óð ð
 ×#×#Ñ#¨×(9Ñ(9×(@Ñ(@ÀJÕ(NÜð%Ø%+×%6Ñ%6×%=Ñ%=Ð$>ð ?KðLóð ò <r-   Ú
root_statec                 ó  • U R                   nU(       a  UR                  5         0 n[         H  n[        5       X4'   M     U R                  R
                  U l        U R                   H“  nUR                  n[        US5      (       a  [        S5      eUR                  SL=(       a    [        S UR                   5       5      Ul        UR                  (       d  Mt  [        R                  R                  S5        M•     U R                    GHG  n[         H7  n[#        [        Xd5      SU 35        X4   R%                  ['        Xd5      5        M9     X`L a  MK  [#        UR(                  SL =(       d    UR(                  (       + S5        SUl        U R*                  Ul        U R,                  Ul        U R.                  Ul        U R0                  Ul        U R2                  Ul        U R                  Ul        U R4                  Ul        UR6                  b  U R2                  UR6                  l        UR                   nU(       d  GM7  UR                  5         GMJ     UR;                  5        H%  u  pG[=        U5      S	:w  d  M  [?        S
U SU 35      e   g)zÐ
Shares data structure state from the ``root_state`` to all FSDP states in
``root_module`` 's module tree, and initializes handle attributes. These
are done together to require a single loop over the states.
Ú_in_backward_optimizerszDFSDP optimizer in backward only supported with use_orig_params=True!Nc              3   ó:   #   • U  H  n[        US 5      v •  M     g7f)re   N)Úhasattr)Ú.0Úparams     r.   Ú	<genexpr>Ú5_share_state_and_init_handle_attrs.<locals>.<genexpr>Â   s    é € ð O
ÚCU¸%ŒG�EÐ4×5Ð5ÒCUùs   ‚zfsdp.optimizer_in_backwardzFSDP state missing attribute zcNon-root FSDP instance's `_is_root` should not have been set yet or should have been set to `False`Fé   z"Expects one homogeneous value for z	 but got ) Ú_handleÚinit_flat_param_attributesÚHOMOGENEOUS_ATTR_NAMESr2   rT   Úall_handlesÚ_all_handlesr`   rg   rJ   Ú_paramsÚanyÚ_has_optim_in_backwardr\   Ú_CÚ_log_api_usage_oncerO   r   r5   ÚgetattrrC   Ú_unshard_streamÚ_post_backward_streamÚ_pre_unshard_streamÚ_all_reduce_streamÚ_default_streamÚ_free_event_queueÚ_fsdp_extensionÚcompute_streamÚitemsÚlenÚ
ValueError)rc   rF   rb   Úattr_name_to_valuesÚ	attr_namer`   Ú
fsdp_stateÚattr_valuess           r.   rW   rW   ª   sL  € ð ×Ñ€FÞØ×)Ñ)Ô+Ø/1Ðß+ˆ	Ü),«ÐÓ&ñ ,à(×9Ñ9×EÑE€JÔà×)Ô)ˆØ×&Ñ&ˆ
Ü�:Ð8×9Ñ9ÜØVóð ð )3×(:Ñ(:À$Ð(F÷ )
Ì3ñ O
ØCM×CUÒCUóO
ó L
ˆÔ%ð ×(×(Ñ(Ü�H‰H×(Ñ(Ð)EÖFñ *ð !×1Õ1ˆ
ß/ˆIÜÜ˜
Ó.Ø/°	¨{Ð;ôð  Ñ*×.Ñ.¬w°zÓ/MÖNñ 0ð Ò#Ùô 	Ø×Ñ 4Ð'×B¨z×/BÑ/BÔ+Bð9ô	
ð
 $ˆ
ÔØ%/×%?Ñ%?ˆ
Ô"Ø+5×+KÑ+Kˆ
Ô(Ø)3×)GÑ)Gˆ
Ô&Ø(2×(EÑ(Eˆ
Ô%Ø%/×%?Ñ%?ˆ
Ô"Ø&0×&AÑ&Aˆ
Ô#Ø'1×'CÑ'Cˆ
Ô$Ø×%Ñ%Ñ1Ø8B×8RÑ8RˆJ×&Ñ&Ô5Ø×#Ñ#ˆß‰6Ø×-Ñ-×/ñ; 2ð< #6×";Ñ";Ö"=Ñˆ	Üˆ{Ó˜qÕ ÜØ4°Y°K¸yÈÈÐVóð ò #>r-   c                 ó²  • U R                   (       d  [        S5      eU R                  R                  5       (       d  [        S5      e[	        S U R
                   5       5      nU R                  (       a	  U(       a  SOSnU R                  R                  5       U l        U R                  b  U R                  U R                  l
        U R                  R                  US9U l        U R                  R                  US9U l        U R                  R                  US9U l        U(       a   U R                  R                  5       U l        gU R                  U l        g)zŽ
Initializes CUDA streams for overlapping communication, computation, and
data transfers. The streams should be shared across FSDP instances.
zExpected state to be rootz&Expected device handle to be availablec              3   óH   #   • U  H  nUR                   [        ;   v •  M     g 7f©N)Úsharding_strategyr   )rh   r…   s     r.   rj   Ú _init_streams.<locals>.<genexpr>ø   s#   é € ð â0ˆJð 	×$Ñ$Ô(BÖBÚ0ùs   ‚ "éÿÿÿÿr   N)Úpriority)rC   rD   rH   rI   rs   rO   r    Úcurrent_streamr|   r~   r   ÚStreamrx   ry   rz   r{   )r@   Úuses_hybrid_shardingÚhigh_prioritys      r.   rP   rP   ì   s+  € ð �>�>ÜÐ8Ó9Ð9Ø×Ñ×,Ñ,×.Ñ.ÜÐEÓFÐFÜñ à×0Ò0óó Ðð  ×1×1Ö6J‘BÐPQ€Mà!×0Ñ0×?Ñ?ÓA€EÔØ×ÑÑ(à/4×/DÑ/Dˆ×ÑÔ,ð "×0Ñ0×7Ñ7ÀÐ7ÐO€EÔð #(×"6Ñ"6×"=Ñ"=À}Ð"=Ð"U€EÔð !&× 4Ñ 4× ;Ñ ;À]Ð ;Ð S€EÔö *>ˆ×Ñ×#Ñ#Ó%ð 
ÕØCH×CXÑCXð 
Õr-   rb   Úunshard_streamÚpre_unshard_streamc                 ón  • U(       d  gU R                   R                  U5         UR                  5       nSSS5        W(       a  UR                  U5        U R                  (       aY  U R
                  R                  5       nU(       a8  [        R                  R                  S5         UR                  5         SSS5        U R                   R                  U5         UR                  5         UR                  5         SSS5        g! , (       d  f       NÕ= f! , (       d  f       Nd= f! , (       d  f       g= f)a  
Unshards the handles in ``handles``. If the handles are in
:meth:`summon_full_params` and are using mixed precision, then they are
forced to full precision.

Postcondition: handle's ``FlatParameter`` 's data is the padded
unsharded flat parameter on the compute device.
Nz%FullyShardedDataParallel.rate_limiter)rH   ÚstreamÚpre_unshardÚwait_streamr    r}   Údequeue_if_neededr\   ÚprofilerÚrecord_functionÚsynchronizeÚunshardÚpost_unshard)r@   rb   r’   r“   Úran_pre_unshardÚevents         r.   Ú_unshardr      sÝ   € ö ØØ	×	Ñ	×	$Ñ	$Ð%7Õ	8Ø ×,Ñ,Ó.ˆ÷ 
9æØ×"Ñ"Ð#5Ô6Ø××Ø×'Ñ'×9Ñ9Ó;ˆÞÜ—‘×/Ñ/Ø7õð ×!Ñ!Ô#÷ð 
×	Ñ	×	$Ñ	$ ^Õ	4Ø�‰ÔØ×ÑÔ÷ 
5Ð	4÷ 
9Õ	8ú÷õ ú÷ 
5Õ	4ús#   ¤DÂ&DÃ!D&Ä
DÄ
D#Ä&
D4Úfree_unsharded_flat_paramc                 óh  • UR                  U5        U R                  (       ay  U(       ar  [        R                  R                  R                  5       (       dE  U R                  R                  5       nUR                  5         U R                  R                  U5        UR                  5         SUl        g)z|
Reshards the handle. ``free_unsharded_flat_param`` indicates whether to
free the handle's padded unsharded flat parameter.
FN)Úreshardr    r\   ÚdistributedÚ_functional_collectivesÚis_torchdynamo_compilingrH   ÚEventÚrecordr}   ÚenqueueÚpost_reshardÚ_prefetched)r@   rb   r¡   Ú
free_events       r.   Ú_reshardr­   5  s„   € ð ‡N�NÐ,Ô-Ø××Ö#<Ü× Ñ ×8Ñ8×QÑQ×SÑSð ×-Ñ-×3Ñ3Ó5ˆJØ×ÑÔØ×#Ñ#×+Ñ+¨JÔ7Ø
×ÑÔð €FÕr-   c                 ó4   • U (       a  U R                  5         g g r‰   )Úunshard_grad©rb   s    r.   Ú_unshard_gradsr±   M  ó   € ö Ø×ÑÕð r-   c                 ó4   • U (       a  U R                  5         g g r‰   )Úreshard_gradr°   s    r.   Ú_reshard_gradsrµ   T  r²   r-   Ú
unshard_fnÚargs.Úkwargsc                 óÎ  • [         R                  R                  S5         U(       a*  UR                  [        R
                  :X  a  XE4sSSS5        $ [        R                  U l        U R                  R                  XR                  5        U(       a  [        R                  Ul        Ub  U" X5        [        X5        U(       a‚  UR                  (       aq  UR                  R                   cZ  [         R"                  " UR                  R$                  [         R&                  " S5      S9R)                  5       UR                  l        U R*                  =(       a    U R*                  R,                  (       + nU(       aB  U R.                  R0                  (       a'  U R.                  R2                  n[5        U/UQ70 UD6u  pE[7        XXE5        XE4sSSS5        $ ! , (       d  f       g= f)aø  
Runs the pre-forward logic. This includes an opportunity to unshard
currently sharded parameters such as those for the current forward and
registering post-backward hooks for these current parameters. This function
also converts forward ``args`` and ``kwargs`` to the given precision.

Args:
    handles (List[FlatParamHandle]): Handles giving the parameters used in
        the current forward.
    unshard_fn (Optional[Callable]): A callable to unshard any currently
        sharded parameters or ``None`` to not do any unsharding.
    module (nn.Module): Module whose forward this method runs right before;
        expected by the hook signature.
    args (Tuple[Any, ...]): Module forward ``args``.
    kwargs (Dict[str, Any]): Module forward ``kwargs``.
z%FullyShardedDataParallel._pre_forwardNr[   ©r]   )r\   r™   rš   Ú_training_stater   ÚBACKWARD_PREr   ÚFORWARD_BACKWARDÚtraining_staterT   Úrecord_pre_forwardÚtrainingr+   Ú_register_post_backward_hookr_   r`   Ú	_cpu_gradÚ
zeros_likeÚ_local_shardr]   Ú
pin_memoryrm   Ú_force_full_precisionÚmixed_precisionÚcast_forward_inputsÚparam_dtyper   Ú)_register_post_backward_reshard_only_hook)r@   rb   r¶   r/   r·   r¸   Úshould_cast_forward_inputsÚinput_dtypes           r.   Ú_pre_forwardrÍ   [  sc  € ô2 
�‰×	'Ñ	'Ð(OÕ	Pö �f×,Ñ,Ô0C×0PÑ0PÓPð
 �<÷ 
QÑ	Pô  -×=Ñ=ˆÔØ×Ñ×1Ñ1°&¿/¹/ÔJÞÜ%8×%@Ñ%@ˆFÔ"ØÑ!Ù�uÔ%ô 	% UÔ3ö �f×,×,°×1BÑ1B×1LÑ1LÑ1TÜ*/×*:Ò*:Ø×!Ñ!×.Ñ.´u·|²|ÀEÓ7Jñ+ç‰j‹lð ×ÑÔ'ð
 �M‰M×E %§-¡-×"EÑ"EÔEð 	#ö &¨%×*?Ñ*?×*S×*Sà.3×.CÑ.C×.OÑ.OˆKÜ/°ÐM¸dÒMÀfÑM‰LˆDÜ1°%ÀÔNØˆ|÷G 
Q×	P×	Pús    (GÁE:GÇ
G$c                 óP  • U(       d  gUR                   (       d!  [        XU R                  U R                  5        SUl        [
        R                  R                  R                  5       (       de  U R                  R                  5       nU R                  b#  UR                  U R                  5        SU l        OUR                  U R                  5        [
        R                  R                  S5         [!        X["        R$                  5        SSS5        g! , (       d  f       g= f)z'Unshards parameters in the pre-forward.NFz.FullyShardedDataParallel._pre_forward_prefetch)r«   r    rx   rz   Ú_needs_pre_forward_unshardr\   r¤   r¥   r¦   rH   rŽ   Ú_unshard_eventÚ
wait_eventr—   r™   rš   Ú_prefetch_handler#   r+   )r@   rb   rŽ   s      r.   Ú_pre_forward_unshardrÓ   š  s×   € ö Øð ××Ü� × 5Ñ 5°u×7PÑ7PÔQØ(-€FÔ%ä×Ñ×4Ñ4×MÑM×OÑOØ×-Ñ-×<Ñ<Ó>ˆØ×ÑÑ+Ø×%Ñ% e×&:Ñ&:Ô;Ø#'ˆEÕ à×&Ñ& u×'<Ñ'<Ô=Ü	�‰×	'Ñ	'Ø8õ
ô 	˜¬×(=Ñ(=Ô>÷
÷ 
ö 
ús   Ã3DÄ
D%Ú
reshard_fnÚinputÚoutputc                 ó   • [         R                  R                  S5         U(       a)  UR                  [        R
                  :X  a  UsSSS5        $ U R                  R                  U5        Ub  U" X5        [        XXQ5      n[        R                  U l        U(       a  [        R                  Ul        UsSSS5        $ ! , (       d  f       g= f)a´  
Runs the post-forward logic. This includes an opportunity to reshard
currently unsharded parameters such as those used in the current forward
and registering pre-backward hooks on the forward outputs.

Args:
    handles (List[FlatParamHandle]): Handles giving the parameters used in
        the current forward.
    reshard_fn (Optional[Callable]): A callable to reshard any currently
        unsharded parameters (e.g. from the current forward) or ``None`` to
        not do any resharding.
    module (nn.Module): Module whose forward just ran, which should be a
        fully sharded module (see [Note: Fully Sharded Module]); expected
        by the hook signature.
    input (Any): Unused; expected by the hook signature.
    output (Any): Forward pass output; pre-backward hooks are registered on
        the tensors that require gradients in this output.

Postcondition: Each ``FlatParameter`` 's data points to the sharded flat
parameter.
z&FullyShardedDataParallel._post_forwardN)r\   r™   rš   r»   r   r¼   rT   Úrecord_post_forwardÚ_register_pre_backward_hooksr   rK   r¾   )r@   rb   rÔ   r/   rÕ   rÖ   s         r.   Ú_post_forwardrÚ   µ  s�   € ô< 
�‰×	'Ñ	'Ð(PÕ	Qö �f×,Ñ,Ô0C×0PÑ0PÓPØ÷	 
RÑ	Qð 	×Ñ×2Ñ2°6Ô:ØÑ!Ù�uÔ%ô .¨e¸VÓLˆÜ,×1Ñ1ˆÔÞÜ%8×%=Ñ%=ˆFÔ"Ø÷ 
R×	Q×	Qús    'B?ÁA$B?Â?
Cc                 ó‚   • U(       d  gU R                   (       + =(       a    UR                  [        ;   n[        XU5        g)z(Reshards parameters in the post-forward.N)rC   Ú_sharding_strategyr   r­   )r@   rb   r¡   s      r.   Ú_post_forward_reshardrÝ   å  s=   € ö Øð
 �N‰NÔ÷ 	QØ×%Ñ%Ô)PÑPð ô ˆUÐ5Õ6r-   c                 ó  • [         R                  R                  S5         [        X5        [	        U R
                  SLS5        U R
                  (       d1  [        U 5      (       a  [        XX#5      sSSS5        $ X#4sSSS5        $ U R                  nU(       a  UR                  nO([        R                  " U5      n[        S U 5       5      nU(       ac  [        [        UR                  5       5      R!                  5       [#        U R$                  R!                  5       5      U R&                  S9  SU l        O{[+        U SS5      (       ai  [-        X5      u  nn[/        U5      S	:”  aE  [/        U5      S	:”  a6  [        S
 [1        Xx5       5       5      (       a  [        XxU R&                  5        SU l        U R2                  (       aP  U R4                   V	s/ s H"  n	U	R                  (       d  M  U	R                  PM$     nn	U H  nSUl        SUl        M     [;        U R<                  R?                  5       U R@                  U RB                  5        [E        U RF                  5        [         R                  R                  S5         [I        X#U R&                  S5      u  p«SSS5        W
(       a  U
S	   O	[K        5       nW(       a  US	   O0 n[        XX#5      sSSS5        $ s  sn	f ! , (       d  f       NL= f! , (       d  f       g= f)aÅ  
Runs pre-forward logic specific to the root FSDP instance, which should run
before any individual module's pre-forward. This starts with an attempt at
lazy initialization (which only runs non-vacuously once). Otherwise, if
this is called on a non-root FSDP instance, then it returns directly.

Args:
    module (nn.Module): Module for which this logic tries to run. It may or
        may not be the root. If not, then this method does not do anything.
z*FullyShardedDataParallel._root_pre_forwardNz$Expects a root FSDP to have been setc              3   ó8   #   • U  H  oR                   v •  M     g 7fr‰   )rÆ   )rh   rb   s     r.   rj   Ú$_root_pre_forward.<locals>.<genexpr>!  s   é € ð 3Ú;B°×,Ö,º7ùs   ‚)rX   rY   r]   TÚ!_needs_buffer_dtype_restore_checkFr   c              3   óD   #   • U  H  u  pUR                   U:g  v •  M     g 7fr‰   ©Údtype)rh   ÚbufferÚbuffer_dtype_for_computations      r.   rj   rà   7  s*   é € ð òAÑ<˜ð —L‘LÐ$@Ö@òAùs   ‚ z#FullyShardedDataParallel._to_kwargs)&r\   r™   rš   rB   r   rC   r   Ú_root_cast_forward_inputrm   rÆ   rM   r^   rs   rR   ÚdictÚnamed_buffersÚvaluesÚlistÚ_buffer_name_to_orig_dtyperS   rá   rw   rQ   r�   ÚzipÚforward_prefetchrO   rÏ   r«   Ú_wait_for_computation_streamrH   rŽ   rx   rz   Ú%_reset_flat_param_grad_info_if_neededrq   r   Útuple)r@   r/   r·   r¸   rb   Ú should_cast_buffers_to_full_precÚhandlesrX   Úbuffer_dtypes_for_computationr…   Ú
args_tupleÚkwargs_tuples               r.   Ú_root_pre_forwardr÷   ÷  s�  € ô" 
�‰×	'Ñ	'Ð(TÕ	UÜ�5Ô!Ü�%—.‘.¨Ð,Ð.TÔUØ�~�~ô ˜e×$Ñ$Ü/°¸tÓL÷ 
VÑ	Uð �<÷ 
VÑ	Uð" —‘ˆÞØ/5×/KÑ/KÑ,ô
 &×7Ò7¸Ó?ˆGÜ/2ñ 3Ù;Bó3ó 0Ð,ö ,Ü-Ü˜V×1Ñ1Ó3Ó4×;Ñ;Ó=Ü" 5×#CÑ#C×#JÑ#JÓ#LÓMØ×+Ñ+òð 7;ˆEÕ3Ü�UÐ?À×GÑGô 8¸ÓFñØØ-ä�7‹|˜aÓ¤CÐ(EÓ$FÈÓ$JÜñ ä@CØôAó÷ ñ ô 6ØÀ×@TÑ@Tôð 7<ˆEÔ3à×!×!ð #(×"8Ò"8óâ"8�JØ×%Õ%ó #�
×"Ô"Ù"8ð ð ó
 "�Ø48�Ô1Ø%*�Ö"ñ "ô 	%Ø× Ñ ×/Ñ/Ó1Ø×!Ñ!Ø×%Ñ%ô	
ô
 	.¨e×.@Ñ.@ÔAô
 �^‰^×+Ñ+Ð,QÕRÜ'1Ø˜e×2Ñ2°Eó(Ñ$ˆJ÷ Sö !+ˆz˜!Š}´³ˆÞ$0�˜a’°bˆä'¨°tÓD÷m 
VÑ	Uùòz÷$ SÕRú÷_ 
VÕ	UúsJ    AK2Á:K2ÂEK2ÇKÇ+KÇ;BK2ÊK!Ê7K2ËK2Ë!
K/	Ë+K2Ë2
L c                 óV  • U R                   (       a  U R                   R                  (       + nOSnUR                  =(       d    U R                  (       + =(       a    U=(       a    U R                  R
                  nU(       a'  U R                  R                  n[        U/UQ70 UD6u  p#X#4$ ©NT)rm   rÆ   rÀ   r!   rÇ   Úcast_root_forward_inputsrÉ   r   )r@   r/   r·   r¸   Úforce_full_precisionrË   rÌ   s          r.   rç   rç   a  sŽ   € ð ‡}‡}Ø#(§=¡=×#FÑ#FÔFÑà#Ðð 
�‰×	< × <Ñ <Ô<×VÐBV÷"9à
×
Ñ
×
8Ñ
8ð ö "Ø*/×*?Ñ*?×*KÑ*KˆÜ+¨KÐI¸$ÒIÀ&ÑI‰ˆàˆ<Ðr-   Úunusedc                 óœ  • U(       a$  [        US5      (       a  UR                  (       a  U$ [        R                  R	                  S5         U R
                  (       a2  U R                  (       d!  [        X5        [        U R                  5        ORU(       aK  [        R                  /n[        U 5      (       a  UR                  [        R                  5        [        X5        [        R                  U l        U(       d  UsSSS5        $ ["        R$                  Ul        UR(                  (       a“  UR*                  (       d"  [-        U UU R.                  U R0                  5        [        R2                  R4                  R7                  5       (       d3  U R8                  R;                  5       R=                  U R.                  5        SUl        [        R                  R	                  S5         [?        X[@        RB                  5        SSS5        URE                  5         SUl        UsSSS5        $ ! , (       d  f       N0= f! , (       d  f       g= f)z§
Prepares ``_handle`` 's ``FlatParameter`` s for gradient computation.

Args:
    module (nn.Module): Fully sharded module (see [Note: Fully Sharded
        Module]).
Ú_ran_pre_backward_hookz+FullyShardedDataParallel._pre_backward_hookNFz/FullyShardedDataParallel._pre_backward_prefetchT)#rg   rþ   r\   r™   rš   rC   Ú_post_backward_callback_queuedÚ&_register_post_backward_final_callbackrð   rq   r   rK   r   r6   r½   r   r¾   r   r¼   r»   Ú_needs_pre_backward_unshardr«   r    rx   rz   r¤   r¥   r¦   rH   rŽ   r—   rÒ   r#   r*   Úprepare_gradient_for_backward)r@   r/   rb   Úgradrü   Úallowed_statess         r.   Ú_pre_backward_hookr  u  s¨  € ö$ 	Ü�FÐ4×5Ñ5Ø×)×)àˆä	�‰×	'Ñ	'Ð(UÕ	Vð �>�> %×"F×"FÜ2°5ÔAÜ1°%×2DÑ2DÕEÞÜ+×0Ñ0Ð1ˆNÜ˜e×$Ñ$Ø×%Ñ%¤m×&DÑ&DÔEÜ& uÔ=Ü,×=Ñ=ˆÔö Ø÷# 
WÑ	Vô$ "5×!AÑ!AˆÔà×-×-ð ×%×%ÜØØØ×)Ñ)Ø×-Ñ-ô	ô ×$Ñ$×<Ñ<×UÑU×WÑWØ×$Ñ$×3Ñ3Ó5×AÑAÀ%×BWÑBWÔXð .3ˆÔ*Ü�^‰^×+Ñ+Ø=õ
ô ˜U¬M×,BÑ,BÔC÷
ð 	×,Ñ,Ô.Ø(,ˆÔ%Ø÷W 
WÑ	V÷J
õ 
ú÷K 
WÕ	Vús,   ÁB3H=ÄCH=Ç'H,È H=È,
H:	È6H=È=
Ic                 ó–  • [        X[        5        UR                  nSUl        [        R
                  R                  R                  S5         [        U [        R                  /5        [        UR                  [        R                  [        R                  4;   SUR                   35        [        R                  Ul        UR                   c
   SSS5        gUR                   R"                  (       a  [%        S5      e['        X5        U R(                  (       d+  UR*                  (       a  UR-                  5          SSS5        g[        R.                  R0                  R3                  5       (       d3  U R4                  R7                  U R8                  R;                  5       5        U R8                  R=                  U R4                  5         UR                   R>                  n[A        U 5      (       di  UR                   RB                  URD                  :w  aE  URF                  (       d4  UR                   RI                  URD                  5      UR                   l        URJ                  (       a  [M        X5        O[O        X5        [Q        X@R4                  5        SSS5        SSS5        g! , (       d  f       N= f! , (       d  f       g= f)a˜  
Reduce-scatters the gradient of ``handle`` 's ``FlatParameter``.

Precondition: The ``FlatParameter`` 's ``.grad`` attribute contains the
unsharded gradient for the local batch.

Postcondition:
- If using ``NO_SHARD``, then the ``.grad`` attribute is the reduced
unsharded gradient.
- Otherwise, the ``_saved_grad_shard`` attribute is the reduced sharded
gradient (accumulating with any existing gradient).
Tz,FullyShardedDataParallel._post_backward_hookz8Expects `BACKWARD_PRE` or `BACKWARD_POST` state but got Nz,FSDP does not support gradients of gradients))r   Úloggerr`   Ú_post_backward_calledr\   Úautogradr™   rš   r   r   r½   r   r»   r   r¼   ÚBACKWARD_POSTr  Úrequires_gradrJ   Ú_post_backward_reshardÚ_sync_gradientsr   Ú_use_unsharded_grad_viewsr¤   r¥   r¦   ry   r—   rH   rŽ   r•   ÚdataÚ_low_precision_hook_enabledrä   Ú_reduce_dtyperÆ   ÚtoÚuses_sharded_strategyÚ_reduce_gradÚ_reduce_grad_no_shardr   )r@   rb   r`   rü   Úautograd_computed_grads        r.   Ú_post_backward_hookr  »  s  € ô( ˜E¬6Ô2Ø×"Ñ"€JØ'+€JÔ$Ü	�‰×	 Ñ	 ×	0Ñ	0Ø6õ
ô 	# 5¬=×+IÑ+IÐ*JÔKô
 	Ø×"Ñ"Ü#×0Ñ0Ô2E×2SÑ2SÐTñUàFÀv×G]ÑG]ÐF^Ð_ô	
ô
 "5×!BÑ!BˆÔà�?‰?Ñ"Ø÷!
ð 
ð" �?‰?×(×(ÜÐMÓNÐNä˜uÔ-Ø×$×$Ø×&×&Ø×0Ñ0Ô2Ø÷1
ð 
ô8 × Ñ ×8Ñ8×QÑQ×SÑSØ×'Ñ'×3Ñ3Ø×$Ñ$×3Ñ3Ó5ôð ×!Ñ!×(Ñ(¨×)DÑ)DÕEØ%/§_¡_×%9Ñ%9Ð"ä/°×6Ñ6Ø—O‘O×)Ñ)¨V×-AÑ-AÓAð ×4×4à'1§¡×'9Ñ'9¸&×:NÑ:NÓ'O�
—‘Ô$Ø×+×+Ü˜UÕ+ä% eÔ4ô 'Ø&×(CÑ(Cô÷# F÷C
ð 
÷B FÕEú÷C
õ 
ús4   ÁBJ:ÃA$J:ÅBJ:ÇCJ)ÊJ:Ê)
J7	Ê3J:Ê:
Kc                 óà   • [         R                  R                  S5         [        R                  U l        [        R                  Ul        [        X5        S S S 5        g ! , (       d  f       g = f)Nz9FullyShardedDataParallel._post_backward_hook_reshard_only)
r\   r™   rš   r   r½   r¾   r   r
  r»   r  )r@   rb   rü   s      r.   Ú _post_backward_reshard_only_hookr  	  sO   € ô
 
�‰×	'Ñ	'ØCõ
ô  -×=Ñ=ˆÔÜ!4×!BÑ!BˆÔÜ˜uÔ-÷
÷ 
ö 
ús    6AÁ
A-c                 óØ   • [        X5      n[        XU5        [        R                  R	                  S5         [        X[        R                  5        S S S 5        g ! , (       d  f       g = f)Nz0FullyShardedDataParallel._post_backward_prefetch)Ú_should_free_in_backwardr­   r\   r™   rš   rÒ   r#   r*   )r@   rb   rü   r¡   s       r.   r  r    sS   € ô
 !9¸Ó GÐÜˆUÐ5Ô6ô
 
�‰×	'Ñ	'Ø:õ
ô 	˜¬×(>Ñ(>Ô?÷
÷ 
ö 
ús   ·AÁ
A)c                 ór   • UR                   (       d  gU R                  =(       d    UR                  [        ;   $ )z\
Returns whether FSDP should free the unsharded flat parameter in the
post-backward or not.
F)r  r  rÜ   r   )r@   rb   s     r.   r  r  *  s5   € ð ×'×'Øð
 	×Ñ÷ 	PØ×$Ñ$Ô(OÑOðr-   c                 ó  • UR                   nUR                  [        R                  [        R                  4;   nUR
                  R                  nSUl        [        X5      u  pVU R                  GcS  [        XPR                  5        UR                  (       a  UR                  OU R                  n[        R                  " UUUS9  U(       aâ  [         R"                  R$                  R'                  5       (       d%  U R(                  R+                  U R,                  5        U R.                  R1                  U R(                  5         [3        X`R(                  5        [        R4                  " X`R6                  S9  [        X`R8                  5        [;        XU5      n[=        XU5         SSS5        g[        X`R8                  5        OU R                  U R>                  XV5        [;        XU5      n[=        XU5        g! , (       d  f       NY= f)z�
For sharded strategies, this runs gradient reduction, sharded gradient
accumulation if needed, and the post-reduction callback.
N©Úgroup) r`   rÜ   r   ÚHYBRID_SHARDÚ_HYBRID_SHARD_ZERO2r  r  Ú_get_reduce_scatter_tensorsÚ
_comm_hookÚ_div_if_neededÚ_gradient_predivide_factorÚ_use_fake_reduceÚ_fake_process_grouprV   ÚdistÚreduce_scatter_tensorr\   r¤   r¥   r¦   r{   r—   ry   rH   r•   r   Ú
all_reduceÚ_inter_node_pgÚ_gradient_postdivide_factorÚ_accumulate_sharded_gradÚ_post_reduce_grad_callbackÚ_comm_hook_state)	r@   rb   r`   Úuses_hybrid_sharded_strategyÚunsharded_gradÚpadded_unsharded_gradÚnew_sharded_gradÚpgÚgrad_to_offloads	            r.   r  r  >  s¸  € ð ×"Ñ"€JØ#)×#<Ñ#<Ü×+Ñ+Ü×2Ñ2ðAñ $Ð ð  —_‘_×)Ñ)€NØ€J„OÜ.IØó/Ñ+Ðð ×ÑÒÜÐ,×.NÑ.NÔOð ×&×&ð ×&Ò&à×$Ñ$ð 	ô
 	×"Ò"ØØ!Øò	
ö
 (ä×$Ñ$×<Ñ<×UÑU×WÑWØ×(Ñ(×4Ñ4°U×5PÑ5PÔQØ×%Ñ%×,Ñ,¨U×-EÑ-EÕFô +Ð+;×=UÑ=UÔVÜ—’Ð 0×8LÑ8LÒMÜÐ/×1RÑ1RÔSÜ":ØÐ#3ó#�ô +¨5¸/ÔJØ÷ GÐFô 	Ð'×)JÑ)JÕKà×ÑØ×"Ñ"Ð$9ô	
ô /¨uÐ>NÓO€OÜ˜u¨oÕ>÷' GÕFús   ÅA"G:Ç:
Hr1  c                 ó&  • [        UR                  U R                  5      5      nU R                  US   R                  5       -  UR                  5       -
  nUS:”  a  [        R
                  " USU/5      OUn[        R                  " US   5      nXE4$ )zG
Returns the input and output tensors to reduce-scatter, respectively.
r   )rë   ÚchunkÚ
world_sizeÚnumelÚFÚpadr\   Ú
empty_like)r@   r1  ÚchunksÚnumel_to_padr2  r3  s         r.   r"  r"  y  s‰   € ô �.×&Ñ& u×'7Ñ'7Ó8Ó9€FØ×#Ñ# f¨Q¡i§o¡oÓ&7Ñ7¸.×:NÑ:NÓ:PÑP€Là4@À1Ó4DŒ�Šˆn˜q ,Ð/Ô0È.ð ô ×'Ò'¨¨q©	Ó2ÐØ Ð2Ð2r-   Úsharded_gradc                 óÖ   • UR                   n[        XU5        [        US5      nU(       a+  [        X#R                  5        U=R                  U-  sl        OX#l        UR                  nU$ )z£
Accumulates the reduce-scattered sharded gradient with any existing sharded
gradient if needed, returning the gradient to offload (if CPU offloading is
enabled).
Ú_saved_grad_shard)r`   Ú_cast_grad_to_param_dtyperg   Ú_check_grad_to_accumulaterA  )r@   rb   r?  r`   Úaccumulate_gradr5  s         r.   r-  r-  ‰  sa   € ð ×"Ñ"€JÜ˜e°:Ô>ô ˜jÐ*=Ó>€OÞÜ! ,×0LÑ0LÔMØ×$Ò$¨Ñ4Ö$à'3Ô$Ø ×2Ñ2€OØÐr-   c                 óè  • UR                   nU R                  cj  [        UR                  U R                  5        [
        R                  " UR                  U R                  S9  [        UR                  U R                  5        O&U R                  U R                  UR                  5        UR                  (       d  [        XR                  U5        UR                  R                  n[        XU5        g)zŠ
For no-shard, this runs gradient reduction (which directly covers any
gradient accumulation implicitly) and the post-reduction callback.
Nr  )r`   r#  r$  r  r%  r(  r*  rV   r,  r/  Ú_keep_low_precision_gradsrB  r  r.  )r@   rb   r`   r5  s       r.   r  r  £  s§   € ð ×"Ñ"€JØ×ÑÑÜ�z—‘¨×(HÑ(HÔIÜ�Š˜
Ÿ™¨u×/BÑ/BÒCÜ�z—‘¨×(IÑ(IÕJà×Ñ˜×/Ñ/°·±ÔAð ×+×+Ü! %¯©¸*ÔEØ —o‘o×*Ñ*€OÜ˜u¨oÕ>r-   r5  c                 ó2   • [        XU5        [        U5        g)z×
This callback captures any logic to run after the gradient reduction
finishes. Currently, this offloads the gradient to CPU if CPU offloading is
enabled and uses sharded gradient views if ``use_orig_params=True``.
N)Ú_offload_gradÚ%_post_backward_use_sharded_grad_views)r@   rb   r5  s      r.   r.  r.  ¸  s   € ô �% Ô1Ü)¨&Õ1r-   c                 ó  • UR                   (       d  g UR                  =(       a    UR                  (       + nUR                  R                  R                  UR                  5       US9  [        UR                  U R                  5        g )N)Únon_blocking)
r_   r  rt   r`   rÂ   Úcopy_Údetachr   r  ry   )r@   rb   r5  rK  s       r.   rH  rH  È  sp   € ð ×!×!Øð ×/Ñ/×U¸×8UÑ8UÔ4U€LØ
×Ñ×Ñ×%Ñ%Ø×ÑÓ ¨|ð &ñ ô ˜×3Ñ3°U×5PÑ5PÕQr-   c                 óô  • U R                   (       d  g U R                  5         U R                  5         U R                  (       aµ  U R	                  5         U R
                  R                   HW  nUR                  c  M  [        US5      (       d  M%  UR                   H  nUR                  5         M     WR                  SS9  MY     U R                  5         U R                  (       a  S U R
                  l        g g g )Nre   T)Úset_to_none)r   Ú_reset_is_grad_noneÚ_use_sharded_grad_viewsrt   Úprepare_gradient_for_optimr`   rr   r  rg   re   ÚstepÚ	zero_gradrð   r_   rÂ   )rb   Ú
orig_paramÚoptims      r.   rI  rI  â  sÌ   € à×"×"Øð ×ÑÔ ð ×"Ñ"Ô$Ø×$×$Ø×)Ñ)Ô+Ø ×+Ñ+×3Ô3ˆJà�‰Ó*¬wØÐ5÷0ó 0ð (×?Ô?�EØ—J‘J–Lñ @ð —‘¨D�Ó1ñ 4ð 	×4Ñ4Ô6Ø×!×!Ø*.ˆF×ÑÕ'ð "ð! %r-   ÚtensorÚ
div_factorc                 ó4   • US:”  a  U R                  U5        g g )Nrl   )Údiv_)rW  rX  s     r.   r$  r$     s   € Ø�Aƒ~Ø�‰�JÕð r-   ri   c                 ó@  • [        U [        R                  /5        [        U 5      (       ds  UR                  UR                  :w  aX  UR
                  nUR
                  R                  UR                  S9Ul        [        X0R                  R                  5       5        ggg)aØ  
Casts ``sharded_grad`` back to the full parameter dtype so that the
optimizer step runs with that dtype. This performs an actual cast if
1. parameters were in reduced precision during the forward since then
gradients would be in that reduced precision, or
2. parameters were not in reduced precision but gradients were in
reduced precision for communication.
However, if a low precision communication hook is registered, then this
dtype cast happens in the hook instead.
rã   N)
r   r   r½   r  rä   r  r  r   rH   rŽ   )r@   r?  ri   Úlow_prec_grad_datas       r.   rB  rB    s„   € ô  ˜u¤}×'EÑ'EÐ&FÔGÜ& u×-Ñ-°,×2DÑ2DÈÏÉÓ2SØ)×.Ñ.ÐØ(×-Ñ-×0Ñ0°u·{±{Ð0ÐCˆÔô 	#Ø× 4Ñ 4× CÑ CÓ Eõ	
ð 3TÐ-r-   r3  Úaccumulated_gradc                 óø   • [        UR                  U R                  :H  SUR                   SU R                   35        [        UR                  U R                  :H  SUR                   SU R                   35        g )NzDShape mismatch when accumulating gradients: existing gradient shape=z new gradient shape=zFDevice mismatch when accumulating gradients: existing gradient device=z new gradient device=)r   Úshaper]   )r3  r]  s     r.   rC  rC  #  sŽ   € ô Ø×ÑÐ"2×"8Ñ"8Ñ8ð	#Ø#3×#9Ñ#9Ð":ð ;Ø.×4Ñ4Ð5ð	7ôô Ø×ÑÐ#3×#:Ñ#:Ñ:ð	$Ø$4×$;Ñ$;Ð#<ð =Ø/×6Ñ6Ð7ð	9õr-   c                 ó(   • U R                   [        ;   $ r‰   )r#  r
   )r@   s    r.   r  r  5  s   € à×ÑÔ2Ñ2Ð2r-   c                 óä  • [        U R                  S5        U nUR                  (       a¢  U R                  R	                  5       nUR                  UR                  5        UR                  ULa  UR                  UR                  5        UR                  R                  (       a(  U R                  R	                  5       R                  5         UR                  R                  5         U R                   Ht  n[        U5        [        U5        [         R"                  Ul        UR&                  nU(       d  MC  SUl        SUl        SUl        [.        R"                  Ul        SUl        Mv     SUl        g)z³
This waits for the post-backward to finish and performs some final cleanup.
This runs at the end of the entire backward pass and should only be called
on the root FSDP instance.
zJThe post-backward callback should only be called on the root FSDP instanceFN)r   rC   r  rH   rŽ   r—   ry   r{   Úcpu_offloadÚoffload_paramsr›   rT   Ú	next_iterrO   Ú_catch_all_reshardÚ_finalize_paramsr   rK   r¾   rm   rþ   r  Ú_post_forward_indexr   r»   r«   rÿ   )r@   r/   rc   rŽ   r…   rb   s         r.   Ú_post_backward_final_callbackrh  :  s&  € ô Ø�‰ØTôð €Jà×!×!Ø×-Ñ-×<Ñ<Ó>ˆð 	×"Ñ" :×#CÑ#CÔDØ×(Ñ(°Ò>Ø×&Ñ& z×'DÑ'DÔEØ×!Ñ!×0×0ð × Ñ ×/Ñ/Ó1×=Ñ=Ô?Ø×Ñ×)Ñ)Ô+à×,Ô,ˆ
Ü˜:Ô&Ü˜Ô$Ü$1×$6Ñ$6ˆ
Ô!Ø×#Ñ#ˆßˆ6Ø,1ˆFÔ)Ø16ˆFÔ.Ø)-ˆFÔ&Ü%8×%=Ñ%=ˆFÔ"Ø!&ˆFÖñ -ð 16€JÕ-r-   c           
      óÖ  •  U R                   (       a©  U R                   R                  R                  5       U R                   R                  R                  R                  5       :H  =(       a    U R                   R                  (       + nU(       a  g[        X R                   5      n[        X R                   U5        gg! [         a!  n[        SSU  S[        U5       3SS9  UeSnAff = f)ac  
Reshards the parameters that may not have been resharded in the
post-backward hook. This can happen when a module's output is used in the
forward pass, meaning that its pre-backward hook runs (unsharding the
parameter), but the post-backward hook does not run because the output was
not jused in the loss computation corresponding to this backward pass.
NFz+Got exception in the catch-all reshard for ú: )Úraise_assertion_error)
rm   r`   Údata_ptrrÄ   Ú_skipped_use_sharded_viewsr  r­   Ú	Exceptionr   Ústr)r@   Úalready_reshardedr¡   Úes       r.   re  re  i  sË   € ðØ�=�=ð —‘×(Ñ(×1Ñ1Ó3Ø—=‘=×+Ñ+×8Ñ8×AÑAÓCñD÷ Að
 Ÿ™×@Ñ@Ô@ð ö !ØÜ(@ÀÏÉÓ(VÐ%Ü�UŸM™MÐ+DÕEð øô ó ÜØØ9¸%¸ÀÄ3ÀqÃ6À(ÐKØ"'ò	
ð
 ˆûðús   ‚BB= Â+B= Â=
C(ÃC#Ã#C(c                 óÆ  • U R                   nU(       d  gUR                  n[        R                  R                  R                  5       (       a0  [        US5      (       a  UR                  nUR                  5         U?O‚[        US5      (       aq  [        UR                  5      n[        UR                  5      S-   n[        XE:H  SUR                   35        UR                  S   R                  5         [        US5        UR                  (       aQ  U R                  (       d  gUR                   (       d  UR#                  5         [        [        US5      S5        S	Ul        gg)
z3Finalizes the parameters before the next iteration.NÚ_post_backward_hook_handleÚ_post_backward_hook_staterl   z(Invalid: ``_post_backward_hook_state``: rŒ   r  z@Expects `_post_backward_called` to be set on the `FlatParameter`F)rm   r`   r\   r¤   r¥   r¦   rg   rs  Úremover�   rt  Úintr  r   Údelattrr  rt   rR  r  )r@   rb   r`   Úpbhs_handleÚpost_backward_hook_state_lenÚ%expected_post_backward_hook_state_lens         r.   rf  rf  �  s/  € ð
 �]‰]€FÞØØ×"Ñ"€JÜ×Ñ×0Ñ0×IÑI×KÑKÜ�:Ð;×<Ñ<Ø$×?Ñ?ˆKØ×ÑÔ ØÐ5øä�:Ð:×;Ñ;Ü+.¨z×/SÑ/SÓ+TÐ(Ü47¸
×8PÑ8PÓ4QÐTUÑ4UÐ1ÜØ,ÑUØ:¸:×;_Ñ;_Ð:`Ðaôð ×0Ñ0°Ñ4×;Ñ;Ô=Ü�JÐ ;Ô<Ø××Ø×$×$ð
 Ø×,×,Ø×-Ñ-Ô/ÜÜ�JÐ 7Ó8ØNô	
ð ,1ˆ
Õ(ð  r-   Úcurrent_handleÚprefetch_modec                 óŒ  • U(       d  g[        X5      nU(       d  gUR                  nU[        R                  :X  a  [        R
                  Ul        OEU[        R                  :X  a  [        R                  Ul        O[        SU R                   SU 35      e[        XU R                  U R                  5        XCl        SUl        g)zh
Prefetches the next handles if needed (without synchronization). An empty
handles key cannot prefetch.
NzInvalid prefetch mode on rank rj  T)Ú_get_handle_to_prefetchr»   r#   r*   r   r¼   r+   r‚   Úrankr    rx   rz   r«   )r@   r{  r|  rb   Úprev_training_states        r.   rÒ   rÒ   ·  s¥   € ö ØÜ$ UÓ;€FÞØð !×0Ñ0ÐØœ×.Ñ.Ó.Ü!4×!AÑ!AˆÕØ	œ-×/Ñ/Ó	/Ü!4×!<Ñ!<ˆÕäÐ9¸%¿*¹*¸ÀRÈÀÐWÓXÐXô ˆU˜E×1Ñ1°5×3LÑ3LÔMØ0ÔØ€FÕr-   c                 óÖ  • [        U5      n[        R                  [        R                  [        R                  4n[        X#;   SU SU 35        U R                  nSnU[        R                  :X  a  U R                  [        R                  :X  d2  U[        R                  :X  aa  U R                  [        R                  :X  aC  UR                  U5      nU(       a&  UR                  (       a  UR                  (       d  UnU$ Sn U$ U[        R                  :X  aQ  U R                  (       a@  UR                  U5      nU(       a&  UR                  (       a  UR                  (       d  UnU$ SnU$ )a;  
Returns a :class:`list` of the handles keys to prefetch for the next
module(s), where ``current_handle`` represents the current module.

"Prefetching" refers to running the unshard logic early (without
synchronization), and the "next" modules depend on the recorded execution
order and the current training state.
z!Prefetching is only supported in z but currently in N)Ú_get_training_stater   r¼   r
  r+   r   rT   Úbackward_prefetchr   Úget_handle_to_backward_prefetchr  r«   rî   Úget_handle_to_forward_prefetchrÏ   )r@   r{  r¾   Úvalid_training_statesÚeodÚtarget_handleÚtarget_handle_candidates          r.   r~  r~  Ö  sP  € ô )¨Ó8€Nä×(Ñ(Ü×)Ñ)Ü×#Ñ#ðÐô
 ØÑ/Ø
+Ð,AÐ+Bð CØ&Ð'ð	)ôð
 ×
 Ñ
 €CØ,0€MàÔ-×:Ñ:Ó:Ø×#Ñ#Ô'7×'DÑ'DÓDàÔ-×;Ñ;Ó;Ø×#Ñ#Ô'7×'EÑ'EÓEà"%×"EÑ"EÀnÓ"UÐæ#Ø'×C×CØ+×7×7à3ˆMð Ðð !‰Mð Ðð 
Ô.×6Ñ6Ó	6¸5×;Q×;QØ"%×"DÑ"DÀ^Ó"TÐæ#Ø'×B×BØ+×7×7à3ˆMð Ðð !ˆMàÐr-   c                 ó2   • [        U S5        U R                  $ )z8Returns the training state of the handles in ``handle``.zExpects a non-empty handle)r   r»   r°   s    r.   r‚  r‚    s   € ô ˆfÐ2Ô3Ø×!Ñ!Ð!r-   c                 óJ  • U R                    H  nUR                  5         M     U R                   R                  5         U R                  R	                  US5      n[
        R                  " [        X[        5      nU R                   R                  UR                  USSS95        g)z-
Registers a pre-forward hook on ``module``.
NT©ÚprependÚwith_kwargs)Ú_pre_forward_handlesru  ÚclearÚ_fully_sharded_module_to_handleÚgetÚ	functoolsÚpartialrÍ   rÓ   r6   Úregister_forward_pre_hook©r@   r/   Úforward_handleÚmodule_param_handleÚhooks        r.   Ú_register_pre_forward_hookrš    sŽ   € ð  ×4Ô4ˆØ×ÑÖñ 5à	×Ñ×$Ñ$Ô&Ø×?Ñ?×CÑCÀFÈDÓQÐÜ×ÒÜ�eÔ2Fó€Dð 
×Ñ×%Ñ%Ø×(Ñ(¨°tÈÐ(ÐNõr-   c                 óL  • U R                    H  nUR                  5         M     U R                   R                  5         U R                  R	                  US5      n[
        R                  " [        U U[        5      nU R                   R                  UR                  U5      5        g)z¤
Registers a post-forward hook on ``module``. Even if the module has no
handles, we should register the hook since it will register the module's
pre-backward hook.
N)Ú_post_forward_handlesru  r�  r‘  r’  r“  r”  rÚ   rÝ   r6   Úregister_forward_hookr–  s        r.   Ú_register_post_forward_hookrž  *  sˆ   € ð  ×5Ô5ˆØ×ÑÖñ 6à	×Ñ×%Ñ%Ô'Ø×?Ñ?×CÑCÀFÈDÓQÐÜ×ÒÜØØÜó	€Dð 
×Ñ×&Ñ& v×'CÑ'CÀDÓ'IÕJr-   c                 ó  • U R                    H  nUR                  5         M     U R                   R                  5         [        R                  " [
        U 5      nU R                   R                  UR                  USSS95        g)a›  
Registers root pre-forward hook on ``module``, which should be the local
FSDP root.

NOTE: For the current composable FSDP design, we have each application of
``fully_shard()`` to a module to indicate that that module is the local
FSDP root. We may remove this assumption in the future, in which case we
will need to register this root pre-forward hook on any candidate module
that may be the local FSDP root.
TrŒ  N)Ú_root_pre_forward_handlesru  r�  r“  r”  r÷   r6   r•  )r@   r/   r—  r™  s       r.   Ú_register_root_pre_forward_hookr¡  A  sn   € ð  ×9Ô9ˆØ×ÑÖñ :à	×#Ñ#×)Ñ)Ô+Ü×ÒÔ.°Ó6€DØ	×#Ñ#×*Ñ*Ø×(Ñ(¨°tÈÐ(ÐNõr-   Úoutputsc                 ó  ^ ^^• [         R                  " 5       (       d  U$ T R                  (       a  ST l        T(       a  STl        STl        S[         R                  S[         R                  4UUU 4S jjn[        XB5      $ )a|  
Registers pre-backward hooks on the tensors that require gradients in the
forward pass outputs ``outputs``, which were computed using the
``FlatParameter`` s of ``handles``.

Args:
    module (nn.Module): Fully sharded module (see [Note: Fully Sharded
        Module]).

Returns:
    Forward pass outputs with pre-backward hooks registered to tensors that
    require gradients.
FÚtr0   c           
      óì   >• U R                   (       aa  U R                  [        R                  R                  R                  [        R                  " [        TTT5      5      5        T(       a  STl	        U $ rù   )
r  Úregister_hookr\   ÚutilsÚhooksÚunserializable_hookr“  r”  r  r  )r¤  rb   r/   r@   s    €€€r.   Ú_register_hookÚ4_register_pre_backward_hooks.<locals>._register_hookz  sU   ø€ Ø�?�?Ø�O‰OÜ—‘×!Ñ!×5Ñ5Ü×%Ò%Ô&8¸%ÀÈÓPóôö
 Ø59�Ô2Øˆr-   )r\   Úis_grad_enabledrC   rÿ   r  rþ   ÚTensorr   )r@   r/   r¢  rb   rª  s   `` ` r.   rÙ   rÙ   Y  sj   ú€ ô, × Ò ×"Ñ"ØˆØ‡~‡~Ø/4ˆÔ,æØ-2ˆÔ*ð ).ˆÔ%ð	œ%Ÿ,™,ð 	¬5¯<©<÷ 	ñ 	ô ˜^Ó5Ð5r-   c                 óÀ  • [         R                  " 5       (       d  gU(       d  gUR                  n[         R                  R                  R                  5       (       aX  [        US5      nU(       d  UR                  (       d  g[        R                  " [        X5      nUR                  U5      nXRl        g[        US5      nU(       d  UR                  (       d  gUR                  U5      n[        UR                  SLS5        UR                  R                   S   S   nUc  [#        S5      eUR%                  [        R                  " [        X5      5      nXu4Ul        g)aQ  
Registers post-backward hooks on the ``FlatParameter`` s'
``AccumulateGrad`` objects to reshard and to reduce-scatter gradients.

The ``AccumulateGrad`` object represents the last function that finalizes
the ``FlatParameter`` 's gradient, so it only runs after its entire
gradient computation has finished.

We register the post-backward hook only once in the *first* forward that a
``FlatParameter`` participates in. This relies on the ``AccumulateGrad``
object being preserved through multiple forwards.

NOTE: We follow this heuristic to prefer the *first* forward to target the
parameter mixed precision case, where there are *separate*
``AccumulateGrad`` objects across the different forwards. (Without
parameter mixed precision, the ``AccumulateGrad`` objects are the same.) If
we instead prefer the *last* forward, then the hook runs early.
Nrs  rt  zZThe `grad_fn` is needed to access the `AccumulateGrad` and register the post-backward hookr   zExpected acc_grad to be set)r\   r¬  r`   r¤   r¥   r¦   rg   r  r“  r”  r  Ú"register_post_accumulate_grad_hookrs  Ú	expand_asr   Úgrad_fnÚnext_functionsrD   r¦  rt  )r@   rb   r`   Úalready_registeredr™  Úhook_handleÚtemp_flat_paramÚacc_grads           r.   rÁ   rÁ   ˆ  s+  € ô0 × Ò ×"Ñ"ØÞØØ×"Ñ"€Jä×Ñ×0Ñ0×IÑI×KÑKÜ$ ZÐ1MÓNÐÞ Z×%=×%=ØÜ× Ò Ô!4°eÓDˆØ ×CÑCÀDÓIˆØ0;Õ-ä$ ZÐ1LÓMÐÞ Z×%=×%=Øà$×.Ñ.¨zÓ:ˆÜØ×#Ñ#¨4Ð/ð.ô	
ð
 #×*Ñ*×9Ñ9¸!Ñ<¸QÑ?ˆØÑÜ Ð!>Ó?Ð?Ø×,Ñ,Ü×ÒÔ1°5ÓAó
ˆð 19Ð/Fˆ
Õ,r-   c                 óÂ  • [         R                  " 5       (       d  gSnU(       d  gUR                  n[         R                  R                  R                  5       (       a  [        US5      nO[        US5      nU(       d  UR                  (       a  gUcX  [        R                  " U0 UD6nU Vs/ s H5  n[         R                  " U5      (       d  M   UR                  (       d  M3  UPM7     nnUc  [        S5      e[        U[        R                  " [        X5      5      n	[         R                  R                  R                  5       (       a  X•l        gU	4Ul        gs  snf )a  
Registers post-backward hooks to reshard flat parameters that do not
require gradient. We register these using multi-post-grad hooks on the
input activations to ensure that all gradients that may depend on the
parameters have been computed before resharding.
Nrs  rt  zExpected inp_tensors to be set)r\   r¬  r`   r¤   r¥   r¦   rg   r  ÚpytreeÚarg_tree_leavesÚ	is_tensorrD   r	   r“  r”  r  rs  rt  )
r@   rb   r·   r¸   Úinp_tensorsr`   r³  Ú	args_flatÚobjr´  s
             r.   rÊ   rÊ   Á  s"  € ô × Ò ×"Ñ"Øð .2€KÞØØ×"Ñ"€Jä×Ñ×0Ñ0×IÑI×KÑKÜ$ ZÐ1MÓNÑä$ ZÐ1LÓMÐæ˜Z×5×5ØØÑÜ×*Ò*¨DÐ;°FÑ;ˆ	á$ó
Ú$�C¬¯ª¸×(<‹CÀ×ARÕAR�C™9ð 	ð 
ð ÑÜÐ=Ó>Ð>Ü*Ø”Y×&Ò&Ô'GÈÓWó€Kô ×Ñ×0Ñ0×IÑI×KÑKØ0;Õ-à0;¨~ˆ
Õ,ùò
s   Â.EÃEÃ$Ec                 ód  • [        U R                  S5        U R                  (       a  g[        U [        R
                  /5        [        R                  R                  R                  5       (       d@  SU l        [        R                  R                  [        R                  " [        X5      5        gg)z¯
Registers the post-backward final callback that runs at the end of the
backward pass. This should be called from the root FSDP instance at the
beginning of the pre-backward.
zFOnly the root FSDP instance should register the post-backward callbackNT)r   rC   rÿ   r   r   rK   r\   r¤   r¥   r¦   r   Ú_execution_engineÚqueue_callbackr“  r”  rh  rE   s     r.   r   r   ï  s…   € ô Ø�‰ØPôð ×+×+ØÜ˜u¤}×'9Ñ'9Ð&:Ô;ä×Ñ×4Ñ4×MÑM×OÑOØ/3ˆÔ,Ü×"Ñ"×1Ñ1Ü×ÒÔ;¸UÓKõ	
ð Pr-   Úcomputation_streamc                 ó¤   • [         R                  R                  R                  5       (       a  gUR	                  U 5        UR	                  U 5        g)z³
Has the unshard and pre-unshard streams wait for the computation stream.
For example, this should be called in the FSDP root's pre-forward to
respect optimizer step computation.
N)r\   r¤   r¥   r¦   r—   )rÁ  r’   r“   s      r.   rï   rï     sB   € ô ×Ñ×0Ñ0×IÑI×KÑKØØ×ÑÐ1Ô2ð ×"Ñ"Ð#5Õ6r-   ró   c                 óŒ   • [        U [        5      (       d  U /n U  H&  nUR                  (       d  M  UR                  5         M(     g)zÆ
Clears the original parameters' gradients if needed. This method's CPU
overhead is minimal, so we may call it throughout FSDP methods, which serve
as callsites to free the gradient memory earlier.
N)Ú
isinstancerë   r   rð   )ró   rb   s     r.   rð   rð     s:   € ô �gœt×$Ñ$Ø�)ˆÛˆØ×"×"Ñ"Ø×8Ñ8Ö:ò r-   c                 óH  • [        U R                  S5        / n/ n[        5       n[        R                  " U5      u  pV[        [        U5      [        U5      5       H‡  u  pxUR                  5        Hn  u  pšX¤;   a  M  UR                  U
5        [        U	5      UR                  ;   a  M8  UR                  U
5        UR                  UR                  R                  5        Mp     M‰     [        U5      [        U5      :w  a#  [        S[        U5       S[        U5       35      eX#4$ )zü
Returns all buffers in the module tree rooted at ``root_module`` and a
corresponding list of the buffer dtypes for computation. Each buffer dtype
is either ``None`` if buffer mixed precision is not enabled or the buffer
low precision dtype otherwise.
z Expects the root to cast buffersz@Expected buffers and buffer_dtypes to have the same length, got ú and )r   rC   r2   rM   Ú_get_fsdp_states_with_modulesrí   Úreversedré   r5   r   Ú_ignored_buffer_namesr6   rÇ   Úbuffer_dtyper�   rD   )r@   rF   rX   rY   Úvisited_buffersÚfsdp_statesÚfsdp_modulesr…   Úfsdp_moduleÚbuffer_namerå   s              r.   rQ   rQ   *  s  € ô ˆe�n‰nÐ@ÔAØ"$€GØ.0€MÜ),«€Oô !0× MÒ MØó!Ñ€Kô $'¤x°Ó'<¼hÀ|Ó>TÖ#UÑˆ
Ø#.×#<Ñ#<Ö#>ÑˆKØÓ(ÙØ×Ñ Ô'Ü  Ó-°×1QÑ1QÓQÙØ�N‰N˜6Ô"Ø× Ñ  ×!;Ñ!;×!HÑ!HÖIó $?ñ $Vô ˆ7ƒ|”s˜=Ó)Ó)ÜØNÌsÐSZË|ÈnÐ\aÔbeÐfsÓbtÐauÐvó
ð 	
ð Ð!Ð!r-   Úbuffer_namesc           
      óÜ   • / nU Hc  n[        X0R                  ;   U SU R                   SU R                  R                  5        35        UR	                  U R                  U   5        Me     U$ )z>
Returns the original buffer types of the given buffer names.
z+ is missing from pre-computed dict on rank z, which only has keys )r   rì   r  Úkeysr6   )r@   rÐ  rY   rÏ  s       r.   Ú_get_orig_buffer_dtypesrÓ  N  sx   € ð (*€MÛ#ˆÜØ×;Ñ;Ñ;ØˆmÐFØ�z‰zˆlÐ0Ø×/Ñ/×4Ñ4Ó6Ð7ð9ô	
ð 	×Ñ˜U×=Ñ=¸kÑJÖKñ $ð Ðr-   rX   rY   r]   c           	      óD  • [        USL =(       d    [        U 5      [        U5      :H  S[        U 5       S[        U5       35        [        X5       HM  u  p4[        R                  " U5      (       a  Uc  UR                  US9Ul        M9  UR                  X$S9Ul        MO     g)zÅ
Casts ``buffers`` to the dtypes given by ``buffer_dtypes`` and moves them
to ``device``. If an element in ``buffer_dtypes`` is ``None``, then the
corresponding buffer is only moved to ``device``.
NzfExpects `buffers` and `buffer_dtypes` to have the same length if `buffer_dtypes` is specified but got rÆ  rº   )r]   rä   )r   r�   rí   r\   Úis_floating_pointr  r  )rX   rY   r]   rå   rÊ  s        r.   rR   rR   b  s•   € ô Ø˜Ð×C¤ W£´°]Ó1CÑ!Cð0Ü03°G³¨~¸UÜˆ}ÓÐ
ð	 ôô !$ GÖ ;ÑˆÜ×&Ò& v×.Ñ.°,Ñ2FØ Ÿ)™)¨6˜)Ð2ˆFŽKà Ÿ)™)¨6˜)ÐFˆFŽKò	 !<r-   )|r“  ÚloggingÚcollections.abcr   Úenumr   r   Útypingr   r   r\   Útorch.distributedr¤   r(  Ú'torch.distributed.fsdp._traversal_utilsÚfsdpÚ_traversal_utilsrM   Útorch.nnÚnnÚtorch.nn.functionalÚ
functionalr:  Útorch.autogradr   Útorch.autograd.graphr	   Ú(torch.distributed.algorithms._comm_hooksr
   Ú$torch.distributed.fsdp._common_utilsr   r   r   r   r   r   r   r   Ú"torch.distributed.fsdp._flat_paramr   r   r   r   r   Ú"torch.distributed.fsdp._init_utilsr   Útorch.distributed.fsdp.apir   Útorch.distributed.utilsr   r   r   r   Útorch.utilsr   r¸  Ú	getLoggerr&   r  ro   r#   ÚModulerñ   rë   r<   r?   Úboolr4   rB   rL   rW   rP   r�   r    r­   r±   rµ   rè   ro  rÍ   rÓ   rÚ   rÝ   r÷   rç   r  Úno_gradr  r  r  r  r  r­  r"  r-  r  r.  rH  rI  Úfloatr$  rB  rC  r  rh  re  rf  rÒ   r~  r‚  rš  rž  r¡  rÙ   rÁ   rÊ   r   rï   rð   rä   rQ   rÓ  r]   rR   r%   r-   r.   Ú<module>rð     sŸ
  ðã Û Ý $ß ß %ã Ý  ß AÓ AÝ ß Ð Ý #Ý 9Ý H÷	÷ 	ó 	÷õ õ JÝ 7÷ó õ *ð 
×	Ò	˜8Ó	$€ðÐ ô�Dô ð
/Ø�I‰Ið/à
ˆ4�
Ñ˜T "§)¡)™_Ð,Ñ-ô/ð@ "§)¡)ð °°ZÑ0@ô ð˜ð ¨R¯Y©Yð ¸4ô ð ðØðà—‘ðð óó ððD°ð ÀRÇYÁYô ð0 ð>Øð>à—‘ð>ð 
ó>ó ð>ðB ð$Øð$à	ó$ó ð$ðN ðØðàðð —L‘Lðð Ÿ™ð	ð
 
óó ðð@ ðØðàðð  $óó ðð.Ø˜dÑ"ðà	ôðØ˜dÑ"ðà	ôð ð;Øð;à˜dÑ"ð;ð ð;ð �I‰Ið	;ð
 ��S�‰/ð;ð ��c�‰Nð;ð ˆ5��c�‰?˜D  c ™NÐ*Ñ+ó;ó ð;ð| ð?Øð?à˜dÑ"ð?ð 
ó?ó ð?ð4 ð,Øð,à˜dÑ"ð,ð ð,ð �I‰Ið	,ð
 ð,ð ð,ð 	ó,ó ð,ð^ ð7Øð7àð7ð 
ó7ó ð7ð" ðfEØðfEà�I‰IðfEð
 
ófEó ðfEðR ðØðØ$Ÿx™xŸ™ðà
ˆ3�ˆ8�_óó ðð& ðBØðBà�I‰IðBð ðBð
 ðBð 	óBó ðBðJ Ø‡‚ƒðIØðIàðIð ó	Ió ó ðIðX.Øð.àð.ð ð.ð 
ô	.ð @Øð@àð@ð ð@ð 
ô	@ð" ðØðàðð 
óó ðð& ð7?˜
ð 7?¨Oð 7?Àó 7?ó ð7?ðt ð3Øð3Ø',§|¡|ð3à
ˆ5�<‰<˜Ÿ™Ð%Ñ&ó3ó ð3ð ðØðàðð —,‘,ðð ‡\�\ó	ó ðð2 ð? ð ?°_ð ?Èó ?ó ð?ð( ð2Øð2àð2ð —\‘\ó	2ó ð2ð ðRØðRàðRð —\‘\óRó ðRð2 ð/°/ó /ó ð/ð: ˜5Ÿ<™<ð  °Uð  ¸tô  ð
 ð
Øð
à—,‘,ð
ð ó
ó ð
ð:Ø—l‘lðà—l‘lðð 
ôð$ ð3 zð 3°dó 3ó ð3ð Ø‡‚ƒð*6Øð*6à�I‰Ió*6ó ó ð*6ðZ ð"Øð"à	ó"ó ð"ðJ ð$1Øð$1à	ó$1ó ð$1ðN ðØðà# dÑ*ðð !ðð 
ó	ó ðð< ð4Øð4à#ð4ð ó4ó ð4ðn"Øð"àô"ð ðØðà�I‰Iðð 
óó ðð& ðKØðKà�I‰IðKð 
óKó ðKð, ðØðà�I‰Ióó ðð. ð+6Øð+6à�I‰Ið+6ð ð+6ð ð	+6ð
 
ó+6ó ð+6ð\6GØð6Gà˜dÑ"ð6Gð 
ô6Gðr+>Øð+>à˜dÑ"ð+>ð ��S�‰/ð+>ð ��c�‰Nð	+>ð
 
ô+>ð\ ð
Øð
Ø!Ÿy™yð
à	ó
ó ð
ð.7ØŸ™ð7à—L‘Lð7ð Ÿ™ô7ð(;Ø�/Ñ"ô;ð ð "Øð "à—‘ð "ð ˆ4�—‘Ñ˜t E§K¡K°$Ñ$6Ñ7Ð7Ñ8ó "ó ð "ðF ðØðà�s‘)ðð 
ˆ%�+‰+Ñóó ðð&GØ�%—,‘,ÑðGà˜Ÿ™ dÑ*Ñ+ðGð �L‰LðGð 
õ	Gr-   