Ë
    g^(h\ ã                   ó¶  — d dl Z d dlmZmZ d dlmZmZ d dlmZm	Z	 d dl
mZmZmZmZmZmZ d dlmZ d dlZd dlZd dlmZ d dlmc mZ d dlZd dlmZ d dlmZmZ d d	l m!Z! d d
l"m#Z# d dl$m%Z%m&Z&m'Z'm(Z( d dl)m*Z* d dl+m,Z, d dl-m.Z.m/Z/ d dl0m1Z1m2Z2 d dl3m4Z4 d dl5m6Z6 d dl7m8Z8 ejr                  ju                  e;d«      Z<ddl=m>Z> ddl?m@Z@mAZAmBZBmCZC ddlDmEZE ddlFmGZGmHZHmIZImJZJmKZKmLZLmMZMmNZNmOZOmPZPmQZQ ddlRmSZSmTZTmUZUmVZV ddlWmXZXmYZYmZZZ ddl[m\Z\m]Z]m^Z^m_Z_m`Z`maZambZbmcZcmdZdmeZemfZfmgZg ddlhmiZimjZj ddlkmlZlmmZmmnZnmoZompZpmqZqmrZrmsZsmtZtmuZumvZvmwZwmxZxmyZy ddlzm{Z{m|Z|m}Z}m~Z~mZ ddl€m�Z�m‚Z‚mƒZƒm„Z„m…Z…m†Z†m‡Z‡ dd lˆm‰Z‰mŠZŠm‹Z‹mŒZŒm�Z�mŽZŽm�Z�m�Z�m‘Z‘m’Z’m“Z“m”Z” dd!l•m–Z– e”Z— e �j0                  «       Z™i Zš ed"e›e   «      Zœ ed#e,¬$«      Z� G d%„ d&e«      Zž G d'„ d(ež«      ZŸd)e›e   d*eld+e2d,ee6   d-eœf
d.„Z d)e›e   d*eld-e¡e2ee6   f   fd/„Z¢d0eœd*eld+e2d,ee6   d-e¡eeyf   f
d1„Z£d0eœd*eld+e2d,ee6   d-e¡eeyf   f
d2„Z¤de–dd d3dfd3d4d5œd6ed7ed8ee   d9ed:ee¥   d;e¦d<e§d=ee   d-efd>„Z¨d?e�jR                  d-e�jR                  fd@„Zªd?ej,                  �jR                  dAee«   dBe¦d-e¡ee›e�jX                  �jZ                        e›e¦   f   fdC„Z®de–dd3ddfd?e�jR                  d7ežd8eež   d9ed:ee¥   d=eež   dDee.   d-e�jR                  fdE„Z¯ddd3dddFœd?e�jR                  d:ee¥   dGe§dHee¦   dIe§dJee§   d-e¡e�j`                  �jb                  eqf   fdK„Z²d ddLœdMedGe§d;e¦d:ee¥   d-e�j`                  �jb                  f
dN„Z³d dd3d3dddOœdMed;e¦d:ee¥   dPe§dIe§dJee§   d-e¡e�j`                  �jb                  eye�jh                  e�jh                  f   fdQ„Zµed?ej,                  �jR                  fdR„«       Z¶e¨Z·eªZ¸y)Sé    N)ÚKeysViewÚSequence)ÚcontextmanagerÚnullcontext)ÚpartialÚwraps)ÚAnyÚCallableÚNewTypeÚOptionalÚProtocolÚTypeVar)Úpatch)ÚTensor)ÚPhiloxStateTrackerÚrng_decompositions)Úenable_python_dispatcher)Úcompiled_autograd)ÚCompileEventLoggerÚdynamo_timedÚpreserve_rng_stateÚset_feature_use)Údetect_fake_mode)Ú
OutputCode)Ú	BoxedBoolÚ	InputType)Ú
FakeTensorÚFakeTensorMode)Úmake_fx)ÚShapeEnv)Úis_traceable_wrapper_subclassÚcudagraph_static_inputsé   )Úconfig)ÚAOTAutogradCacheÚautograd_cache_keyÚshould_use_local_autograd_cacheÚ should_use_remote_autograd_cache)Ú*run_functionalized_fw_and_collect_metadata)Ú"_check_if_mutation_can_be_in_graphÚ&are_all_mutations_hidden_from_autogradÚ1are_all_mutations_under_no_grad_or_inference_modeÚassert_functional_graphÚfrom_funÚgen_alias_from_baseÚhas_data_mutationÚhas_metadata_mutationÚis_funÚsync_functional_tensorÚto_fun)Úcompute_overlapping_inputsÚcreate_graph_signatureÚcreate_synthetic_base_metadataÚremove_dupe_metadata)Úaot_dispatch_autogradÚaot_dispatch_baseÚaot_dispatch_export)Úcallback_setÚdescribe_inputÚformat_guard_bug_msgÚget_aot_compilation_contextÚget_aot_graph_nameÚget_graph_being_compiledÚgraph_being_compiledÚ
model_nameÚ	nth_graphÚset_model_nameÚ#setup_stacktrace_preservation_hooksÚtrack_graph_compiling)ÚAOTDedupeWrapperÚAOTSyntheticBaseWrapper)Ú	AOTConfigÚBackwardSignatureÚFQNÚGraphInputNameÚGraphOutputNameÚGraphSignatureÚInputAliasInfoÚMutationTypeÚOutputAliasInfoÚ
OutputTypeÚSubclassCreationMetaÚSubclassMetaÚTensorAliasÚViewAndMutationMeta)Úrequires_subclass_dispatchÚunwrap_tensor_subclassesÚ1unwrap_tensor_subclasses_with_indices_to_originalÚwrap_tensor_subclassesÚ"wrap_tensor_subclasses_maybe_joint)Úaot_dispatch_subclassÚcreate_functional_callÚcreate_functionalized_fnÚ%create_functionalized_rng_ops_wrapperÚcreate_jointÚfn_input_mutations_to_outputsÚfn_prepped_for_autograd)Ú_get_autocast_statesÚ_get_symint_hintsÚcall_func_at_runtime_with_argsÚcreate_tree_flattened_fnÚKNOWN_TYPESÚmake_boxed_compilerÚmake_boxed_funcÚmaybe_to_fresh_inputÚnormalize_as_listÚpartial_flatten_asdictÚ%root_module_when_exporting_non_strictÚ
strict_zip)Údefault_partitionÚFakifiedFlatArgsÚTOutputCode)Úboundc                   óR   — e Zd ZdZdej
                  j                  dee   de	fd„Z
y)ÚAOTDispatchCompilerz?
    Represents a fw or bw_compiler passed to AOTAutograd.
    ÚgmÚexample_inputsÚreturnc                  ó   — y ©N© ©Úselfrv   rw   s      ú[/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/torch/_functorch/aot_autograd.pyÚ__call__zAOTDispatchCompiler.__call__Á  s   € ð
 	ó    N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚtorchÚfxÚGraphModuler   r   r	   r   r{   r€   r~   ru   ru   ¼  s7   „ ñðà�H‰H× Ñ ðð ! Ñ+ðð 
ô	r€   ru   c                   ó¤   — e Zd ZdZdee   deej                  j                  e
e   gef   fd„Zdej                  j                  de
e   defd„Zy	)
ÚSerializableAOTDispatchCompilera)  
    Represents an AOTDispatchCompiler that returns an OutputCode, and is
    therefore cacheable. SerializableAOTDispatchCompiler always return an OutputCode.
    A _CompileFxCallable usually gets converted into an AOTDispatchCompiler after binding all of
    the kwargs in _CompileFxKwargs.
    Úoutput_code_tyÚcompiler_fnc                 ó    — || _         || _        y rz   )rŠ   r‹   )r}   rŠ   r‹   s      r~   Ú__init__z(SerializableAOTDispatchCompiler.__init__Ò  s   € ð
 -ˆÔØ&ˆÕr€   rv   rw   rx   c                 ó&   — | j                  ||«      S rz   )r‹   r|   s      r~   r   z(SerializableAOTDispatchCompiler.__call__Ú  s   € ð
 ×Ñ  NÓ3Ð3r€   N)r�   r‚   rƒ   r„   Útyperr   r
   r…   r†   r‡   r   r   r�   r   r   r{   r€   r~   r‰   r‰   Ê  sq   „ ñð'à˜[Ñ)ð'ð ˜uŸx™x×3Ñ3°X¸iÑ5HÐIÈ;ÐVÑWó'ð4à�H‰H× Ñ ð4ð ! Ñ+ð4ð 
ô	4r€   r‰   Ú	flat_argsÚ
aot_configÚ	fake_modeÚ	shape_envrx   c                 ó®   ‡‡‡— ‰5  ˆˆˆfd„}t        t        | «      D ��cg c]  \  }} |||«      ‘Œ c}}«      cd d d «       S c c}}w # 1 sw Y   y xY w)Nc                 ó”  •‡— ‰�Sddl m} t        ‰t        «      r=‰	j                  r‰S  |d| › �«      }‰j                  ‰j                  ‰|«      ‰|¬«      S t        ‰t        j                  «      r*t        j                  j                  j                  ‰
‰«      S t        ‰t        j                  «      s‰S t        ‰t        «      r‰j                  ‰
u sJ ‚‰S t        ‰«      r@‰j!                  «       \  }}t#        ˆfd„|D «       «      rt#        ˆ
ˆfd„|D «       «      sJ ‚‰S d }d }d}t        j$                  j&                  j)                  «       x}r+‰|j*                  v r|j*                  ‰   }|j,                  }d}| ‰	j.                  k  r%t0        j2                  r|s‰
j5                  ‰d¬	«      S ‰
j5                  ‰d|||¬
«      S )Nr   )ÚConstantSourceÚsym_)ÚhintÚsourcec              3   óR   •K  — | ]  }t        t        ‰|«      t        «      –— Œ  y ­wrz   )Ú
isinstanceÚgetattrr   )Ú.0ÚattrÚxs     €r~   ú	<genexpr>z2process_inputs.<locals>.convert.<locals>.<genexpr>  s   øè ø€ ÒRÀD”z¤'¨!¨TÓ"2´J×?ÑRùs   ƒ$'c              3   óN   •K  — | ]  }t        ‰|«      j                  ‰u –— Œ y ­wrz   )rœ   r’   )r�   rž   r’   rŸ   s     €€r~   r    z2process_inputs.<locals>.convert.<locals>.<genexpr>  s(   øè ø€ ò ØDHœ  4Ó(×2Ñ2°iÔ?ñùs   ƒ"%TF)Ústatic_shapes)r¢   Úsymbolic_contextr™   Útrace)Útorch._dynamo.sourcer–   r›   ÚintÚ	is_exportÚcreate_symintnodeÚcreate_symbolr…   ÚScriptObjectÚ_libraryÚfake_class_registryÚmaybe_to_fake_objr   r   r’   r!   Ú__tensor_flatten__ÚallÚ_guardsÚTracingContextÚtry_getÚtensor_to_contextÚtensor_sourceÚnum_params_buffersr$   Ústatic_weight_shapesÚfrom_tensor)ÚidxrŸ   r–   r™   ÚattrsÚ_r£   r¤   Útracing_contextr‘   r’   r“   s    `       €€€r~   Úconvertzprocess_inputs.<locals>.convertê  sÒ  ù€ ØÐ$Ý?ä˜a¤Ô%à!×+Ò+Ø ˜Ù+¨d°3°%¨LÓ9�FØ$×6Ñ6Ø!×/Ñ/°°6Ó:ÀÈ6ð 7ó ð ô ˜!œU×/Ñ/Ô0Ü—~‘~×9Ñ9×KÑKØ˜qóð ô ˜a¤§¡Ô.Ø�Ü˜!œZÔ(Ø—{‘{ iÑ/Ð/Ð/Ø�Ü,¨QÔ/Ø×/Ñ/Ó1‘��qÜÓRÈEÔRÔRÜô ØLQôô ð ð ð �Hð  $ÐØˆFØˆEÜ"'§-¡-×">Ñ">×"FÑ"FÓ"HÐHˆÐHØ˜×9Ñ9Ñ9Ø'6×'HÑ'HÈÑ'KÐ$Ø-×;Ñ;�Fð "�Eà�j×3Ñ3Ò3Ü×/Ò/Ù(ð !×,Ñ,¨Q¸dÐ,ÓCÐCà×(Ñ(ØØ#Ø!1ØØð )ó ð r€   )rq   Ú	enumerate)r�   r‘   r’   r“   r¼   r¸   rŸ   s    ```   r~   Úprocess_inputsr¾   â  sZ   ú€ ð 
ñ ;Vö7	ôr  ¼yÈÓ?S× T±V°S¸!¡¨¨a¥Ó TÓU÷w;Vñ ;Vùóv !U÷w;Vð ;Vús   †A¡A´AÁAÁAc                 óŒ   — t        | «      }|€(|j                  r
t        «       nd }t        |¬«      }||fS |j                  }||fS )N)r“   )r   Údynamic_shapesr    r   r“   )r�   r‘   r’   r“   s       r~   Úconstruct_fake_moderÁ   &  sT   € ô ! Ó+€IØÐØ",×";Ò";”H”JÀˆ	Ü"¨YÔ7ˆ	ð �yÐ!Ð!ð ×'Ñ'ˆ	Ø�yÐ!Ð!r€   Úfake_flat_argsc                 óf   — t        dd¬«      5  t        | ||||«      cd d d «       S # 1 sw Y   y xY w)NÚcreate_aot_dispatcher_functionT)Úlog_pt2_compile_event)r   Ú_create_aot_dispatcher_function)Úflat_fnrÂ   r‘   r’   r“   s        r~   rÄ   rÄ   2  s7   € ô 
Ð6ÈdÔ	Sñ 
Ü.Ø�^ Z°¸Ió
÷
÷ 
ò 
ús   Ž'§0c                 óŒ	  ‡‡‡— |j                   €i |_         i t        ¥|j                   ¥|_         t        j                  ri t        ¥|j                   ¥|_         |�
t        «       n	t        «       }t        j                  j                  d«      5  t        «       5  |5  |5  t        «       5  t        j                  j                  j                  «       5  ddlmŠmŠ ˆˆfd„}t%        d„ |D «       «      }t        «       5  t'        dd„ «      5  t)        | «      }|�t+        |«      }	n
t        «       }	|	5   t-        | |j.                  |j0                  ||j2                  |j4                  ¬	«       ||«      Ž Šddd«       t7        |‰«      }
t9        j:                  d
|
¬«       t%        ˆfd„‰j<                  D «       «       xr t%        d„ ‰j>                  D «       «       }|r²|r°d}|
r2 t-        | |j0                  d|j2                  |j.                  ¬«      |Ž ŠnztA        ‰j>                  ‰j<                  ‰jB                  |j0                  ‰jD                  ‰jF                  ‰jH                  ‰jJ                  d‰jL                  ‰j.                  ¬«      Šddd«       ddd«       ‰jB                  dkD  r<
r:J ddjO                  |D �cg c]  }tQ        tS        |«      «      ‘Œ c}«      › d�«       ‚|j4                  rÇtU        ‰j>                  D �cg c]  }|jV                  sŒ|‘Œ c}«      dk7  rtY        dtQ        ‰«      › �«      ‚tU        ‰j>                  D �cg c]  }|jZ                  r|j\                  r|‘Œ c}«      dk7  rtY        dtQ        ‰«      › �«      ‚
rtY        d«      ‚t        j                  rtY        d«      ‚d„ } |||«      } ||  ||«      |‰¬«      \  }Š|‰fcddd«       cddd«       cddd«       cddd«       cddd«       cddd«       S # 1 sw Y   �Œ¨xY w# 1 sw Y   �Œ˜xY w# 1 sw Y   �Œ�xY wc c}w c c}w c c}w # 1 sw Y   nxY wddd«       n# 1 sw Y   nxY wddd«       n# 1 sw Y   nxY wddd«       n# 1 sw Y   nxY wddd«       n# 1 sw Y   nxY wddd«       y# 1 sw Y   yxY w)a(  
    Traces the forward and backward graphs of the attr:`flat_fn` to generate a
    joint graph. The joint graph is an Fx graph with Aten ops. Please refer to
    the tracing mechanism to understand the graph capturing details.

    The joint graph is then passed through attr:`partition_fn` to isolate the
    forward and backward portions, which are then respectively compiled via the
    provided attr:`fw_compiler` and attr:`bw_compiler`.

    The resulting compiled forward and backward graphs are then wrapped up in a
    ``torch.autograd.Function`` object.

    The calling convention here is that the first aot_config.num_params_buffers
    inputs in flat_args are parameters and buffers, and the rest are inputs.

    We use this to assume that parameters/buffer's shapes don't change.

    Note: this function is used both by aot_function and aot_export (controlled by aot_config.is_export)
        When aot_config.is_export is True, we return an FX graph + metadata
        When aot_config.is_export is False, we return an ordinary runtime function
    NFr   )ÚFakeScriptObjectr­   c                 ó~   •— | D �cg c],  }t        |‰«      r ‰t        | «      |j                  «      n|‘Œ. c}S c c}w rz   )r›   r   Úreal_obj)rÂ   ÚargrÉ   r­   s     €€r~   Ú_dup_fake_script_objz=_create_aot_dispatcher_function.<locals>._dup_fake_script_obj‰  sM   ø€ ð
 *ö	ð ô ˜cÐ#3Ô4ñ "Ô"2°>Ó"BÀCÇLÁLÔQàñòð ùò s   †1:c              3   óV   K  — | ]!  }t        |t        «      sŒ|j                  –— Œ# y ­wrz   )r›   r   Úrequires_grad©r�   rŸ   s     r~   r    z2_create_aot_dispatcher_function.<locals>.<genexpr>‘  s"   è ø€ ò 
Ø !´zÀ!ÄVÕ7LˆA�O�Oñ
ùs   ‚)˜)ztorch.cuda.set_rng_statec                   ó   — y rz   r{   )Úargss    r~   ú<lambda>z1_create_aot_dispatcher_function.<locals>.<lambda>˜  s   � r€   )Ústatic_input_indicesÚkeep_input_mutationsÚis_trainÚpre_dispatchr§   Úbackend_compile)rX   c              3   óÞ   •K  — | ]d  }|j                   xrR |j                  t        j                  t        j                  fv xr# ‰j
                  |j                     j                    –— Œf y ­wrz   )rÏ   Úoutput_typerS   Úalias_of_inputÚis_inputÚ
input_infoÚbase_idx)r�   rŸ   Úfw_metadatas     €r~   r    z2_create_aot_dispatcher_function.<locals>.<genexpr>¯  so   øè ø€ ò 3ð ð —O‘Oò 	ð Ÿ™Ü&×5Ñ5´z×7JÑ7JÐKðLò Mà'×2Ñ2°1·:±:Ñ>×LÑLðó	ñ3ùs   ƒA*A-c              3   óŒ   K  — | ]<  }|j                   xr* |j                  xr |j                   xr |j                   –— Œ> y ­wrz   )rÏ   Úmutates_dataÚ)mutations_under_no_grad_or_inference_modeÚmutations_hidden_from_autogradrÐ   s     r~   r    z2_create_aot_dispatcher_function.<locals>.<genexpr>»  sS   è ø€ ò ð
 ð	 —O‘Oò =ØŸ™ò=à×GÑGÐGò=ð ×<Ñ<Ð<ó=ñùs   ‚AA)rÕ   rÖ   r×   rÔ   )rÝ   Úoutput_infoÚnum_intermediate_basesrÕ   Útraced_tangentsÚsubclass_inp_metaÚsubclass_fw_graph_out_metaÚsubclass_tangent_metarÖ   ÚtokensrÔ   zCtorch.compile is currently being used with tensor subclass inputs:
ú,zÁ. We are attempting to a compile a graph with two graph outputs
that alias one another, which is currently unsupported in the subclass use case. If you run into this,
please file a github issuezèFound an input that received a metadata mutation, through e.g. a call to `.resize_()` or `.transpose_()`.
This is currently banned in the aot_export workflow. If you need this functionality, please file a github issue.

fw_metadata=zÄFound a graph input that requires gradients, and received a mutation.
This is currently banned in the aot_export workflow. If you need this functionality, please file a github issue.

fw_metadata=z…aot_export is not currently supported with traceable tensor subclass.
If you need this feature, please comment on <CREATE_ISSUE_LINK>z­Functionalized RNG is not currently supported in the aot_export workflow. Please file a github issue,
or otherwise set torch._functorch.config.functionalize_rng_ops = False.c                 óú   — |j                   r(t        j                  dd¬«       t        t        | ¬«      S | r)|j
                  st        j                  dd¬«       t        S t        j                  dd¬«       t        S )zF
            Pick a dispatcher based on the config rules.
            rØ   Úexport)Údispatch_mode)Úneeds_autogradÚautogradÚ	inference)r§   r   Útry_add_pt2_compiler   r;   r×   r9   r:   )rï   r‘   s     r~   Úchoose_dispatcherz:_create_aot_dispatcher_function.<locals>.choose_dispatcher  ss   € ð ×#Ò#ô #×6Ñ6Ø%°Xõô Ô2À>ÔRÐRÙ¨
×(?Ò(?Ü"×6Ñ6Ø%°Zõô -Ð,ä"×6Ñ6Ø%°[õô )Ð(r€   )rß   )/ÚdecompositionsÚaot_autograd_decompositionsr$   Úfunctionalize_rng_opsr   r   r   r…   rð   Úset_multithreading_enabledr   r   Ú_dynamoÚutilsÚ+_disable_saved_tensors_hooks_during_tracingÚ"torch._library.fake_class_registryrÉ   r­   Úanyr   rn   Ú_detect_attribute_assignmentr)   rÔ   Úkeep_inference_input_mutationsr×   r§   rX   r   rò   rä   rÝ   rW   rå   ræ   rç   rè   ré   rê   ÚjoinÚstrr�   ÚlenÚmutates_metadataÚRuntimeErrorrÏ   rá   )rÇ   rÂ   r‘   r’   r“   Úpython_dispatcher_moderÍ   rï   ÚmodÚctxÚreq_subclass_dispatchÚoutput_and_mutation_saferŸ   ró   r‹   Úcompiled_fnrÉ   rß   r­   s                   @@@r~   rÆ   rÆ   ?  s0  ú€ ðB × Ñ Ð(Ø$&ˆ
Ô!ð!Ü
%ð!à
×
#Ñ
#ð!€JÔô
 ×#Ò#ð%
Ü ð%
à×'Ñ'ð%
ˆ
Ô!ð '0Ð&;Ô Ô"ÄÃð ô 
�‰×	2Ñ	2Øó
ñ @(äÓñ@(ð 	ñ@(ð
 	ñ@(ô Óñ@(ô #Ÿ]™]×0Ñ0×\Ñ\Ó^ñ@(÷	
õ	ô ñ 
Ø%3ô
ó 
ˆô &Ó'ñ M	ô Ð1Ñ3EÓFñ JÜ;¸GÓD�Ø�?Ü6°sÓ;‘Cä%›-�CØñ =ð#Ô"LØØ-7×-LÑ-LØ-7×-VÑ-VØ!/Ø%/×%<Ñ%<Ø",×"6Ñ"6ô#ñ ,¨NÓ;ð#=�K÷=ô )CØ" Kó)Ð%ô #×6Ñ6Ø%ÐBWõô 03ó 3ð )×4Ñ4ô3ó 0ð ,ò ,ô ñ ð
 )×3Ñ3ôó ð ð )ñ( "Ñ&>ð &+�Nñ -ð'Ô&PØ#Ø1;×1ZÑ1ZØ%*Ø)3×)@Ñ)@Ø1;×1PÑ1Pô'ð *ð'+™ô ':Ø'2×'=Ñ'=Ø(3×(?Ñ(?Ø3>×3UÑ3UØ1;×1ZÑ1ZØ,7×,GÑ,GØ.9×.KÑ.KØ7B×7]Ñ7]Ø2=×2SÑ2SØ%*Ø#.×#5Ñ#5Ø1<×1QÑ1Qô'˜÷}J÷M	ð^ ×-Ñ-°Ò1Ù,ð ð 3à‡� Ö
0˜AŒ3Œt�A‹w�<Ò
0Ó1Ð 2ð 3ð/ó Ð,ð ×Òô ˜{×5Ñ5ÖL˜!¸×9KÓ9K’AÒLÓMÐQRÒRÜ"ðô �ÓÐð	"óð ô ð "-×!7Ñ!7öàØŸ?š?¨q¯~ª~ò òóð òô #ðô �ÓÐð	"óð ñ %Ü"ðCóð ô ×+Ò+Ü"ðKóð ò	)ñ, (¨¸
ÓCˆá#.ØÙ  Ó0ØØ#ô	$
Ñ ˆ�[ð ˜KÐ'÷A@(÷ @(÷ @(÷ @(÷ @(÷ @(ö @(÷H=ñ =ú÷Jñ Jú÷M	ñ M	üòd 1ùò Mùò÷G@(ð @(ú÷ @(÷ @(ñ @(ú÷ @(÷ @(ñ @(ú÷ @(÷ @(ñ @(ú÷ @(÷ @(ñ @(ú÷ @(÷ @(ñ @(ús  ÂR:ÂR%ÂRÂQ;	Â*)Q&Ã+QÃ>P5Ä&P(Ä2APÅ5DP(ÊP5Ê*QËQË-QÌQÌQÌ"4QÍ!QÍ7A-QÏ$	Q&Ï-	Q;	Ï6	RÏ?	R%Ð	R:ÐP%Ð P(Ð(P2Ð-P5Ð5P?Ð:QÑQÑQ&Ñ	Q;	Ñ&Q/Ñ+Q;	Ñ2	RÑ;RÒ RÒ	R%ÒRÒR%Ò	R:Ò%R.	Ò*R:Ò:SFT)ÚdynamicÚ
enable_logÚfnÚfw_compilerÚbw_compilerÚpartition_fnrô   rµ   rþ   Úinference_compilerc                ó”   ‡ ‡‡— |€|}|€|}t        ||||||t        t        «      ||ddd|	¬«      ŠdŠt        ‰ «      ˆˆˆ fd„«       }
|
S )a¥
  
    Traces the forward and backward graph of :attr:`fn` using torch dispatch
    mechanism, and then compiles the generated forward and backward graphs
    through :attr:`fw_compiler` and :attr:`bw_compiler`.

    :func:`aot_function` traces the forward and backward graph ahead of time,
    and generates a joint forward and backward graph.  :attr:`partition_fn` is
    then used to separate out forward and backward graphs. The partitioner
    function can be used to perform optimizations such as recomputation. One can
    set `decompositions` dictionary to decompose the operators into a sequence
    of core or simpler operators supported by the backend compilers.

    .. warning::
        This API is experimental and likely to change.

    Args:
        fn (Callable): A Python function that takes one ore more arguments. Must
            return one or more Tensors.
        fw_compiler (Callable): A Python function that accepts an Fx graph with
            Aten ops and input args, and returns a Callable that semantically is
            equivalent to the input Fx graph.
        bw_compiler (Optional[Callable]): A Python function that accepts an
            Fx graph with Aten ops and input args, and returns a Callable that
            semantically is equivalent to the input Fx graph.  Default: None
            (when None, it defaults to the :attr:`fw_compiler`)
        partition_fn (Callable): A Python function that takes a joint forward
            and backward graph, and partitions it into separate forward and
            backward graphs.
        decompositions (Dict): A dictionary to define the decomposition of
            larger Aten ops into simpler or core Aten ops.
        inference_compiler (Optional[Callable]): A Python function that accepts an
            Fx graph with Aten ops and input args, and returns a Callable that
            semantically is equivalent to the input Fx graph. inference_compiler is invoked
            if no autograd is needed. Default: None
            (when None, it defaults to the :attr:`fw_compiler`)
    Returns:
        Returns a ``Callable`` that retains the eager behavior of the original
        :attr:`fn`, but with forward and backward graph compiled via
        :attr:`fw_compile` and :attr:`bw_compile`.

    A simple example usage of :func:`aot_function` is as follows. This example
    will print the forward and backward graphs of the function ``fn``

        >>> fn = lambda x : x.sin().cos()
        >>> def print_compile_fn(fx_module, args):
        >>>     print(fx_module)
        >>>     return fx_module
        >>> aot_fn = aot_function(fn, print_compile_fn)
        >>> x = torch.randn(4, 5, requires_grad=True)
        >>> aot_fn(x)
    NF)r  r  r  r  rô   rµ   Úaot_idrþ   rÀ   Úaot_autograd_arg_pos_to_sourcer§   Úno_tangentsr  c                  óô   •— t        j                  | i |¤Ž}‰€Ct        ‰| |«      \  }}t        |‰«      \  }}t	        |‰||«      }t        ||‰||«      \  }}	||fŠ‰\  }
} |
|«      }|j                  |«      S rz   )ÚpytreeÚarg_tree_leavesrg   rÁ   r¾   rÄ   Ú	unflatten)rÒ   Úkwargsr�   rÇ   Úout_specr’   r“   rÂ   r	  rº   Ú	cached_fnÚoutr‘   Ú
cached_resr  s               €€€r~   Úreturned_functionz'aot_function.<locals>.returned_function”  s©   ø€ ô ×*Ñ*¨DÐ;°FÑ;ˆ	ð ÐÜ 8¸¸TÀ6Ó JÑˆG�XÜ%8¸ÀJÓ%OÑ"ˆY˜	Ü/=Ø˜: y°)ó0ˆNô <ØØØØØó‰NˆK˜ð & xÐ0ˆJà(Ñˆ	�8Ù˜	Ó"ˆØ×!Ñ! #Ó&Ð&r€   )rJ   ÚnextÚAOT_COUNTERr   )r  r  r  r  rô   rµ   rþ   r  r
  r  r  r‘   r  s   `          @@r~   Úaot_functionr!  =  sx   ú€ ðD ÐØ!ˆØÐ!Ø(ÐÜØØØ-Ø!Ø%Ø-Ü”KÓ Ø'EØØ'+ØØØô€Jð €Jä
ˆ2ƒYõ'ó ð'ð2 Ðr€   r  c                 ól  ‡ ‡‡‡— t         j                  j                  j                  ‰ «       ˆ fd„}t	        ‰ j                  d¬«      «      Št	        ‰ j                  d¬«      «      Št        ‰«      t        ‰«      z   }t        |g|¢­d|i|¤ŽŠ G ˆˆ ˆˆfd„dt        j                  «      } |«       S )a  
    Traces the forward and backward graph of :attr:`mod` using torch dispatch
    tracing mechanism. It is wrapper function, that underneath uses
    :func:`aot_function` to perform tracing and compilation.

    :func:`aot_module` lifts the parameters and buffers of ``nn.Module`` as inputs
    to a new callable which is then compiled through :func:`aot_function`.

    .. warning::
        This API is experimental and likely to change.

    Args:
        mod (Callable): A ``nn.Module`` module.
        args : args to be passed to :func:`aot_function`
        kwargs : kwargs to be passed to :func:`aot_function`

    Returns:
        Returns a ``nn.Module`` that retains the eager behavior of the original
        :attr:`mod`, but with forward and backward graph compiled.

    c                 óT   •— i | ¥|¥}t         j                  j                  ‰|||«      S rz   )r…   ÚfuncÚfunctional_call)Únamed_paramsÚnamed_buffersrÒ   r  Úparams_and_buffersr  s        €r~   r%  z#aot_module.<locals>.functional_callÊ  s/   ø€ Ø> Ð>°Ð>ÐÜ�z‰z×)Ñ)¨#Ð/AÀ4ÈÓPÐPr€   F©Úremove_duplicaterµ   c                   ó2   •‡ — e Zd Zdˆ ˆfd„Zˆˆˆfd„Zˆ xZS )úaot_module.<locals>.AOTModulec                 ó0   •— t         ‰| �  «        ‰| _        y rz   )Úsuperr�   Úorig_module)r}   Ú	__class__r  s    €€r~   r�   z&aot_module.<locals>.AOTModule.__init__Ö  s   ø€ Ü‰GÑÔØ"ˆDÕr€   c                 ó   •—  ‰‰‰g|¢­i |¤ŽS rz   r{   )r}   rÒ   r  Ú
compiled_fr'  r&  s      €€€r~   Úforwardz%aot_module.<locals>.AOTModule.forwardÚ  s*   ø€ ÙØØðð òð ñ	ð r€   )rx   N)r�   r‚   rƒ   r�   r3  Ú__classcell__)r0  r2  r  r'  r&  s   @€€€€r~   Ú	AOTModuler,  Õ  s   ù„ ö	#÷	ò 	r€   r5  )r…   rø   rù   Ú assert_no_fake_params_or_buffersÚdictÚnamed_parametersr'  r  r!  ÚnnÚModule)	r  rÒ   r  r%  rµ   r5  r2  r'  r&  s	   `     @@@r~   Ú
aot_moduler;  ±  s®   û€ ô. 
‡M�M×Ñ×8Ñ8¸Ô=ôQô ˜×,Ñ,¸eÐ,ÓDÓE€LÜ˜×*Ñ*¸EÐ*ÓBÓC€MÜ˜\Ó*¬S°Ó-?Ñ?ÐÜØðØòØ3EðØIOñ€J÷ñ ”B—I‘Iô ñ ‹;Ðr€   Ú
param_keysÚfull_args_numc                 ót  — t        | t        j                  j                  «      rd| j                  v sdg fS t        | d«      sdg fS | j                  }t        «       }g }|D ]B  }||v s
J |› d�«       ‚||   }||vsJ |«       ‚|j                  |«       |j                  |«       ŒD g }t        | j                  j                  d¬«      «      D ]Ö  \  }	}
t        |
d«      sJ ‚|
j                  }||vsJ |«       ‚|j                  |«       |j                  |«       |r|j                  «       n
t        |«      }d|
j                  v rH|
j                  d   j!                  d	d«      r)t"        j%                  d
|	|«       |j                  |	«       ŒÀt"        j%                  d|	|«       ŒØ |t'        |«      k(  sJ ‚||fS )au  
    Metadata is forwarded from Dynamo to AOTDispatch via special fields on GraphModule.
    We first verify that `mod` does come from Dynamo, then we handle cases where
    metadata might be missing.

    Returns:
        aot_autograd_arg_pos_to_source: used to dedup params and their guards
        static_input_indices: used to identify static inputs for cudagraphs
    Údynamo_compile_idNÚ_param_name_to_sourcez not found.Úplaceholder)ÚopÚ_dynamo_sourceÚtensor_dictÚ_dynamo_static_input_typez(Adding static input pos %s for source %sz%Non-static input pos %s for source %s)r›   r…   r†   r‡   ÚmetaÚhasattrr@  ÚsetÚaddÚappendr½   ÚgraphÚ
find_nodesrC  Únamer   ÚgetÚstatic_inputs_logÚdebugr  )r  r<  r=  Úparam_name_to_sourceÚseen_sourcesr  rM  r™   rÔ   ÚposÚnodeÚsource_names               r~   Ú_try_get_metadata_from_dynamorV  å  sÔ  € ô �sœEŸH™H×0Ñ0Ô1Ð6IÈSÏXÉXÑ6Uà�Rˆxˆä�3Ð/Ô0à�Rˆxˆð ×4Ñ4ÐÜ“5€Là%'Ð"àò 6ˆØÐ+Ñ+ÐA°¨v°[Ð-AÓAÐ+Ø% dÑ+ˆØ˜\Ñ)Ð1¨6Ó1Ð)Ø×Ñ˜Ô Ø&×-Ñ-¨fÕ5ð6ð ÐÜ˜sŸy™y×3Ñ3°}Ð3ÓEÓFò ‰	ˆˆTÜ�tÐ-Ô.Ð.Ð.Ø×$Ñ$ˆØ˜\Ñ)Ð1¨6Ó1Ð)Ø×Ñ˜Ô Ø&×-Ñ-¨fÔ5Ù'-�f—k‘k”m´3°v³;ˆà˜DŸI™IÑ%¨$¯)©)°MÑ*B×*FÑ*FØ'¨ô+
ô ×#Ñ#Ø:¸CÀôð !×'Ñ'¨Õ,ä×#Ñ#Ø7¸¸kõð!ð( œCÐ >Ó?Ò?Ð?Ð?Ø)Ð+?Ð?Ð?r€   Ú
cudagraphsc	                 óÊ  ‡ ‡‡‡‡‡‡‡‡— i t        ‰ j                  d¬«      «      ¥t        ‰ j                  d¬«      «      ¥}	t        j                  |	«      \  ŠŠt        ‰«      Št        ‰«      Š|€7t        t        j                  j                  j                  j                  «      }|€|}|€|}g }
|
j                  ‰«       t        j                  j                  j!                  «       x}r‰|_        t%        ‰«      \  |_        |_        |
j                  |«       t+        ‰ |	j-                  «       t        |
«      «      \  }}d}|
D ],  }t/        |t0        «      sŒ|j2                  j4                  du} n t7        |||||‰t9        t:        «      ||||ddd¬«      Št=        |
‰«      \  ŠŠt?        |
‰‰‰«      Šˆˆˆˆ ˆˆˆfd„}t/        |t@        «      rHtC        «       }tE        «       }|s|r(tG        d|«       tI        jJ                  |‰ ‰‰|||«      Šn |«       Šn |«       Št/        ‰ t        jL                  jN                  jP                  «      rIdt
        tR           fˆˆfd„}‰ jT                  |_*        ‰ j                  |_        ‰ j                  |_        |S dtV        tR           fˆˆfd	„}‰ jT                  |_*        ‰ j                  |_        ‰ j                  |_        |S )
a·  
    This is the simplified or low overhead version of aot_module. For frontends
    like TorchDynamo, the input functions/modules to AOT are static and have
    unpacked inputs/outputs. This gives us an opportunity to remove the
        (1) pytree overhead to parse inputs/outputs,
        (2) AOT Autograd cache,
        (3) Reading of params/buffers in every forward call

    :func:`aot_module_simplified` removes these overheads.
    Fr)  N)r  r  r  r  rô   rµ   r  rþ   rÀ   r  rÔ   r§   r  Ú
cache_infoc                  óš   •— t        ‰‰‰«      } t        j                  «       5  t        | ‰‰‰‰	«      \  }}d d d «       |S # 1 sw Y   S xY wrz   )r^   r   Ú_disablerÄ   )
r%  r	  rº   r‘   rÂ   r’   r  Ú
params_lenÚparams_specr“   s
      €€€€€€€r~   Údispatch_and_compilez3aot_module_simplified.<locals>.dispatch_and_compilev  sZ   ø€ Ü0°°kÀ:ÓNˆÜ×'Ñ'Ó)ñ 	Ü;ØØØØØó‰NˆK˜÷	ð Ð÷	ð Ðús   £A Á A
Úaot_autograd_remote_cacheÚruntime_argsc                 ó|   •— g }|j                  ‰«       |j                  | «       | j                  «         ‰|«      S rz   )ÚextendÚclear)r`  r�   r	  Úparams_flats     €€r~   Úboxed_forwardz,aot_module_simplified.<locals>.boxed_forward›  s;   ø€ ØˆIØ×Ñ˜[Ô)Ø×Ñ˜\Ô*Ø×ÑÔ Ù˜yÓ)Ð)r€   c                  ó\   •— g }|j                  ‰«       |j                  | «        ‰|«      S rz   )rb  )r`  Ú	full_argsr	  rd  s     €€r~   r3  z&aot_module_simplified.<locals>.forward­  s/   ø€ Øˆ	Ø×Ñ˜Ô%Ø×Ñ˜Ô&Ù˜9Ó%Ð%r€   ),r7  r8  r'  r  Útree_flattenÚlistr  r   r…   Ú	_inductorr$   ÚtritonrW  rb  r°   r±   r²   rd  rZ   Úparams_flat_unwrap_subclassesÚparams_unwrapped_to_flat_indexrV  Úkeysr›   r   r’   r“   rJ   r  r   rÁ   r¾   r‰   r'   r(   r   r%   Úloadrø   rù   Ú	GmWrapperr	   Ú	zero_gradÚtuple)r  rÒ   r  r  r  rô   rþ   r  rW  Úparamsrg  r»   r  rÔ   rÀ   rŸ   r^  ÚlocalÚremotere  r3  r‘   r	  rÂ   r’   rd  r\  r]  r“   s   `                    @@@@@@@@r~   Úaot_module_simplifiedrv  %  sÌ  ÿø€ ð*Ü
ˆs×#Ñ#°UÐ#Ó;Ó
<ðä
ˆs× Ñ °%Ð Ó8Ó
9ð€Fô  &×2Ñ2°6Ó:Ñ€K�Ü�{Ó#€KÜ�[Ó!€JàÐÜœuŸ™×5Ñ5×<Ñ<×GÑGÓHˆ
àÐØ!ˆØÐ!Ø(Ðà€Ià×Ñ�[Ô!äŸ-™-×6Ñ6×>Ñ>Ó@Ð@€Ð@Ø&1ˆÔ#ô >¸kÓJñ	
ØÔ9ØÔ:ð ×Ñ�TÔô
 	& c¨6¯;©;«=¼#¸i».ÓIñØ&Øð €NØò ˆÜ�aœÕ$ØŸ[™[×2Ñ2¸$Ð>ˆNÙðô
 ØØØ-Ø!Ø%Ø%Ü”KÓ Ø'EØ%Ø'EØ1ØØØô€Jô  /¨y¸*ÓEÑ€IˆyÜ# I¨z¸9ÀiÓP€N÷
ò 
ô �+Ô>Ô?Ü/Ó1ˆÜ1Ó3ˆÙ‘FÜÐ7¸Ô@Ü*×/Ñ/Ø$ØØØØØØó‰Kñ /Ó0‰Ká*Ó,ˆä�#”u—}‘}×*Ñ*×4Ñ4Ô5ð
	*¬¬S©	ö 	*ð #&§-¡-ˆÔØ),×)=Ñ)=ˆÔ&Ø&)×&7Ñ&7ˆÔ#ØÐð&œu¤S™zö &ð Ÿ™€GÔØ"×3Ñ3€GÔØ×-Ñ-€GÔà€Nr€   )rô   Úoutput_loss_indexr×   rÀ   r  Útrace_jointrw  r×   rÀ   c                óV  ‡‡‡‡‡— |r|rt        d«      ‚t        | j                  d¬«      «      }t        | j                  d¬«      «      }	i t        |«      ¥t        |	«      ¥}
t	        j
                  |
«      \  }}t        |«      }t        |«      }|xs i }t        | ||d¬«      ŠdŠ|rˆˆˆfd„}t        }n|rt        nt        j                  }‰}g }|j                  |«       |j                  |«        |«       5  t        ||||d|||¬«      \  ŠŠ}}ddd«       |r$t        ‰«      ˆˆfd	„«       } t        |d¬
«      |Ž Št	        j                   |i |¤Ž}‰t#        ‰‰||t%        |j'                  «       «      t%        |	j'                  «       «      |‰‰¬«      fS # 1 sw Y   ŒŠxY w)aÏ  
    This function takes in a module, and returns:
    (1) an FX graph that can be exported
    (2) some metadata about the graph

    If `trace_joint=True` we will return a joint graph of the forward + backward.

    The traced FX graph will have the following properties compared to the original module:
    (1) Inputs and outputs to the module will be pytree-flattened
    (2) Parameters and buffers on the module will be lifted into graph inputs,
        graph_inputs = (*parameters, *buffers, *user_inputs)
    (3) The graph will be fully functionalized
    (4) Any input mutations will be converted into additional outputs in the graph,
        meaning whoever calls this graph is responsible for applying the mutations
        back to the original inputs.
    (5) If is_joint is provided the graph will return parameter gradients in addition to user outputs.
        The graph output will look like:
        graph_outputs = (*updated_inputs, *user_outputs, *param_gradients)

    There are also several restrictions on what modules can use this API. In particular:
    (1) If trace_joint is specified, we expect the loss function to be **fused**
        into the module forward. One of the outputs to the forward must be a scalar loss,
        which is specified with `output_loss_index`.
        All other outputs to the forward are presumed to not require gradients.
    (2) This API cannot capture optimizers (although in theory we could build an API for this).
    (3) Metadata mutations on params/buffers/inputs are banned.
    (4) Data mutations on anything that requires gradients are banned (parameters)
    (5) If an input is mutated, it is not allowed to alias any other inputs.
    (6) Parameters must not be duplicated.
    z7pre_dispatch is not supported when trace_joint is True.Fr)  T)Ústore_orig_modNc                  óà  •—  ‰| Ž }‰€t        d«      ‚t        |t        j                  «      r|f}t        |t        t
        f«      st        dt        |«      › �«      ‚t        |«      D ])  \  }}|j                  sŒ|‰k7  sŒt        d‰› d|› d�«      ‚ |‰   }t        |«      Š|j                  st        d‰› d�«      ‚|j                  «       dk7  rt        d	‰› d
|j                  › �«      ‚|S )Nz§If trace_joint=Trueit is required that one of your forward outputs must be a scalar loss.
You must specify the which (index) output is the loss with output_loss_index.zPExpected forward output to be either a tensor or a list/tuple of tensors. found au  Found an output of the forward that requires gradients, that was not the scalar loss.
We require all outputs to the forward that are not the scalar loss to not require gradient,
because we will only compute a backward graph against the scalar loss.
You can fix this by calling .detach() on each of your forward outputs that is not the loss.
You specified that output index z4 is the loss, but we found that
the output at index z requires gradients.zThe output at index z: was marked as the loss, but it does not require gradientsr#   z3We require the output marked as the loss (at index z#) to be a scalar, but it has shape )r  r›   r…   r   rr  ri  r�   r½   rÏ   r  ÚnumelÚshape)rÒ   r  ÚiÚoÚout_lossr%  Únum_fw_outsrw  s        €€€r~   Úfn_to_tracez&aot_export_module.<locals>.fn_to_trace  sE  ø€ á! 4Ð(ˆCØ Ð(Ü"ðQóð ô
 ˜#¤§¡Ô.Ø�f�Ü˜c¤E¬4 =Ô1Ü"ØfÔgkÐloÓgpÐfqÐróð ô " #›ò ‘��1ð —?“? qÐ,=Ó'=Ü&ð!ð
 "3Ð 3ð 4Ø�CÐ+ð/óð ðð  Ð,Ñ-ˆHÜ˜c›(ˆKØ×)Ò)Ü"ðØ&Ð'Ð'aðeóð ð �~‰~Ó 1Ò$Ü"ð4Ø4EÐ3FÐFiÐjr×jxÑjxÐiyð}óð ð ˆJr€   )rô   rµ   r  r×   rÀ   r  c                  óz  •— t        ‰	j                  ‰	j                  z   «      D �cg c]  }d ‘Œ }} ‰| |«      \  }}t        |«      t        | «      k(  sJ ‚g }t	        | |«      D ]J  \  }}t        |t        j                  «      r'|j                  r|€J d«       ‚|j                  |«       ŒG|€ŒJJ ‚ g |¢|¢­S c c}w )NzÇFound a parameter that did not receive a gradient.
"This is most likely a bug, but if this needs to be supported please comment on this Github issue:
https://github.com/pytorch/pytorch/issues/101192
)
ÚrangeÚnum_outputsÚnum_mutated_inp_runtime_indicesr  Úzipr›   r…   r   rÏ   rJ  )
rÒ   rº   Úfake_tangentsÚfw_outsÚ	gradientsÚoutput_gradientsÚaÚgradÚfx_gÚmetadatas
           €€r~   Úflattened_jointz*aot_export_module.<locals>.flattened_jointO  sâ   ø€ ô( Ø×(Ñ(¨8×+SÑ+SÑSóöàò ðˆMð ñ "& d¨MÓ!:ÑˆG�YÜ�y“>¤S¨£YÒ.Ð.Ð.Ø!ÐÜ˜t YÓ/ò (‘��4Ü˜a¤§¡Ô.°1·?²?àÐ(ððóØ(ð %×+Ñ+¨DÕ1à™<Ð'˜<ð(ð /�GÐ.Ð.Ñ.Ð.ùò+s   ¦	B8)Úrecord_module_stack)Úuser_args_flatÚparams_and_buffers_flatÚparam_namesÚbuffer_namesrx  Únum_user_fw_outsÚ
loss_index)r  r7  r8  r'  r  rh  rr  r  r^   r   r…   Úno_gradrb  Ú_aot_export_functionr   r   r  r6   ri  rn  )r  rÒ   rô   rx  rw  r×   rÀ   r  r8  r'  r(  r“  r]  r\  r‚  r  rg  Úin_specr  r�  r’  r%  rŽ  r�  r�  s       `                @@@@r~   Úaot_export_moduler›  »  sç  ü€ ñ\ ™ÜÐTÓUÐUÜ˜C×0Ñ0À%Ð0ÓHÓIÐÜ˜×*Ñ*¸EÐ*ÓBÓC€MðÜ
ÐÓ
 ðä
ˆ}Ó
ðÐô ,2×+>Ñ+>Ð?QÓ+RÑ(Ð˜[Ü#Ð$;Ó<ÐÜÐ,Ó-€JàŠ\�r€Fä,Øˆ[˜*°Tô€Oð €Káö
,	ô\ ‰ñ *�k¬u¯}©}ˆØ%ˆà€Ið ×ÑÐ,Ô-à×Ñ�TÔá	‹ñ 

Ü,@ØØØ)Ø)ØØ%Ø)Øô	-
Ñ)ˆˆh˜ ÷

ñ ä	ˆÓ	ô&	/ó 
 ð&	/ðP BŒw�¸DÔAÀ9ÐMˆä×+Ñ+¨TÐ<°VÑ<€NØÔ'ØØØØØ%Ø 7ÜÐ)×.Ñ.Ó0Ó1Ü˜-×,Ñ,Ó.Ó/ØØ$Ø$ôð ð ÷s

ð 

ús   Ã=FÆF()rµ   rô   r$  c                ó„  — |rt         }nt        j                  } |«       5  t        | ||¬«      \  }}}}	|j                  \  }}
ddd«       t        j                  D �cg c]  }|j                  s|j                  sŒ|‘Œ c}«      dk7  rt        dt        |«      › �«      ‚t        |j                  D �cg c]"  }|j                  t        j                  k7  sŒ!|‘Œ$ c}«      dk7  rt        dt        |«      › �«      ‚j                  «       rt        dt        |«      › �«      ‚t!        d„ |j                  D «       «      st        dt        |«      › �«      ‚	j                  «       rt        d	t        |	«      › �«      ‚t!        d
„ |	j                  D «       «      st        dt        |	«      › �«      ‚t"        j$                  r[t&        j)                  |t        t*        j,                  «      ¬«      \  }}t/        |«      }|€
t1        «       }|5   ||Ž  ddd«       |S S # 1 sw Y   �ŒÜxY wc c}w c c}w # 1 sw Y   |S xY w)aÇ  
    A simplified version of export. Used by higher order operators.

    This function makes a high-level "no calling convention changes" guarantee:
    - If no inputs require grad (so we export an inference graph),
      there are *no* calling convention change between the exported graph, and "func".
    - If at least one input requires grad (so we trace out and export a joint fw-bw graph),
      Then if you were partition the graph into a separate forward and backward graph,
      The forward graph will have no calling convention changes compared to "func".

    The above also relies on some strong restrictions around which functions this API accepts:
    (1) `args` cannot contain any pytrees (they must have been pytree_flattened already)
    (2) `func` cannot mutate any inputs
    (3) The outputs of `func` cannot alias any inputs.

    Note: this function is only lightly tested today. It will probably be tested more heavily by higher order ops.
    )rô   Nr   z:aot_export_joint_simple does not support input mutations. zDaot_export_joint_simple does not support outputs that alias inputs. zKaot_export_joint_simple requires inputs to be a single list/tuple. in_spec=c              3   ó<   K  — | ]  }|j                  «       –— Œ y ­wrz   ©Úis_leaf©r�   Úchilds     r~   r    z*aot_export_joint_simple.<locals>.<genexpr>Í  s   è ø€ ÒC 5ˆu�}‰}�ÑCùó   ‚zNaot_export_joint_simple requires individual inputs not to be pytrees. in_spec=zMaot_export_joint_simple requires outputs to be a single list/tuple. out_spec=c              3   ó<   K  — | ]  }|j                  «       –— Œ y ­wrz   rž  r   s     r~   r    z*aot_export_joint_simple.<locals>.<genexpr>Õ  s   è ø€ ÒD 5ˆu�}‰}�ÑDùr¢  zPaot_export_joint_simple requires individual outputs not to be pytrees. out_spec=)Únum_fwd_outputs)r   r…   r˜  r™  Úchildren_specsr  rÝ   rá   r  r  r   rä   rÚ   rS   Ú	non_aliasrŸ  r¯   r$   Údebug_assertr‘   rp   rß   Úoutput_infosr   r   )r$  rÒ   rx  rµ   rô   r  rŽ  r�  rš  r  Ú_kw_in_specrŸ   Ú	fw_moduleÚ
_bw_moduler’   s                  r~   Úaot_export_joint_simpler¬  Š  sK  € ñ8 Ü‰ô �m‰mˆá	‹ñ 6Ü,@ØØØ)ô-
Ñ)ˆˆh˜ ð
  '×5Ñ5Ñˆ�÷6ô 	˜×+Ñ+ÖT�1¨q¯~ª~À×ASÓASŠQÒTÓUØò	ô ØHÌÈXËÈÐXó
ð 	
ô
 	˜×,Ñ,ÖV�1°·±Ä×AUÑAUÓ0UŠQÒVÓWØò	ô ØRÔSVÐW_ÓS`ÐRaÐbó
ð 	
ð ‡�ÔÜØYÔZ]Ð^eÓZfÐYgÐhó
ð 	
ô ÑC¨G×,BÑ,BÔCÔCÜØ\Ô]`ÐahÓ]iÐ\jÐkó
ð 	
ð ×ÑÔÜØ[Ô\_Ð`hÓ\iÐ[jÐkó
ð 	
ô ÑD¨H×,CÑ,CÔDÔDÜØ^Ô_bÐckÓ_lÐ^mÐnó
ð 	
ô ×Òä *× <Ñ <Ø�$¬¬K×,DÑ,DÓ(Eð !=ó !
Ñˆ	�:ô % TÓ*ˆ	ØÐÜ&Ó(ˆIØñ 	Ù�tÑ÷	à€Kˆ4€K÷w6ñ 6üò Uùò W÷F	à€Kús/   ¡#HÁH+Á=H+Â5"H0ÃH0ÈH5ÈH(È5H?)rµ   rô   r  r×   rÀ   r  r  c                ó¶  — |xs i }t        | ||«      \  }}	t        j                  ||f«      \  }
}d }|€®t        |
«      }|€�t	        | d«      r�t        | j                  t        j                  j                  «      rS| j                  j                  j                  D �cg c]  }d|j                  v r|j                  d   ‘Œ! }}t        |«      }|d uxr |j                  d u}t        d d d d ||t        t         «      d|d d||¬«      }|€t#        |
|«      \  }}n|j                  }t%        |
|||«      }t'        |||||«      \  }}||||	j(                  fS c c}w )NÚ	_orig_modÚvalFT)r  r  r  r  rô   rµ   r  rþ   rÀ   r  r§   r  r×   )rg   r  rh  r   rG  r›   r®  r…   r†   r‡   rK  ÚnodesrF  r“   rJ   r  r   rÁ   r¾   rÄ   Úspec)r$  rÒ   rµ   rô   r  r×   rÀ   r  rÇ   r  r�   rš  r’   rT  Úvalsr‘   r“   rÂ   rŽ  rF  s                       r~   r™  r™  î  s†  € ð& Š\�r€Fä0°°t¸VÓDÑ€GˆXÜ×,Ñ,¨d°F¨^Ó<Ñ€Iˆwà€IØÐä$ YÓ/ˆ	àÐÜ˜˜kÔ*Ü˜4Ÿ>™>¬5¯8©8×+?Ñ+?Ô@ð !ŸN™N×0Ñ0×6Ñ6öàØ˜DŸI™IÑ%ð —	‘	˜%Ó ðˆDð ô
 )¨Ó.ˆIØ"¨$Ð.ÒR°9×3FÑ3FÈdÐ3Rˆô
 ØØØØØ%Ø-Ü”KÓ ð (-Ø%Ø'+ØØØ!ô!€Jð$ ÐÜ2°9¸jÓIÑˆ	‘9à×'Ñ'ˆ	Ü# I¨z¸9ÀiÓP€Nä/ØØØØØó�J€Dˆ$ð ��w §¡Ð-Ð-ùòUs   Â$Ec              #   ó†  ‡	‡
K  — g d¢}ddg}h |£|£Š	ˆ	fd„}d„ }t        j                  d„  || «      |¬«      }	 d –— g Š
ˆ
fd„}t        j                  || || «      «       | j                  j	                  |«       ‰
r=t        ‰
«      d	kD  rd
\  }}nd\  }}t        d|› ddj                  ‰
«      › d|› d�«      ‚y # g Š
ˆ
fd„}t        j                  || || «      «       | j                  j	                  |«       ‰
r=t        ‰
«      d	kD  rd
\  }}nd\  }}t        d|› ddj                  ‰
«      › d|› d�«      ‚w xY w­w)N)Ú_backward_hooksÚ_backward_pre_hooksÚ_buffersÚ_forward_hooksÚ_forward_hooks_always_calledÚ_forward_hooks_with_kwargsÚ_forward_pre_hooksÚ_forward_pre_hooks_with_kwargsÚ_is_full_backward_hookÚ_load_state_dict_post_hooksÚ_load_state_dict_pre_hooksÚ_modulesÚ_non_persistent_buffers_setÚ_parametersÚ_state_dict_hooksÚ_state_dict_pre_hooksÚtrainingÚ_initialize_hookÚ
_load_hookc                 óv   •— | j                   j                  «       D ��ci c]  \  }}|‰vsŒ||“Œ c}}S c c}}w rz   )Ú__dict__Úitems)r  ÚkÚvÚ	STD_ATTRSs      €r~   Ú_get_attributesz5_detect_attribute_assignment.<locals>._get_attributes]  s3   ø€ à!$§¡×!3Ñ!3Ó!5×L™˜˜A¸À)Ò9K��1‘ÓLÐLùÓLs   Ÿ5¬5c                 ó<   — t         j                  f}t        | |«      S rz   )r…   ÚSizer›   )rŸ   Úknown_subclasses_that_lose_infos     r~   rŸ  z-_detect_attribute_assignment.<locals>.is_leafa  s#   € ô
 �J‰Jð+
Ð'ô ˜!Ð<Ó=Ð=r€   c                 ó   — | S rz   r{   )rŸ   s    r~   rÓ   z._detect_attribute_assignment.<locals>.<lambda>l  s   € ¨€ r€   rž  c                 ó´   •— ||urS| ^}}t        |t        j                  «      r4‰j                  d|j                  › t        j                  |«      › �«       y y y )Nzself.)r›   r…   r   rJ  Úkeyr  Úkeystr)ÚkprË  Ú_vrž   ÚrestÚassigned_tensor_attributess        €r~   Ú#_collect_assigned_tensor_attributeszI_detect_attribute_assignment.<locals>._collect_assigned_tensor_attributest  sU   ø€ Ø˜‰{Ø ���tÜ˜a¤§¡Ô.Ø.×5Ñ5Ø §¡˜z¬&¯-©-¸Ó*=Ð)>Ð?õð /ð r€   r#   )Ú
attributesÚwere)Ú	attributeÚwaszThe tensor ú z, zÈ assigned during export. Such attributes must be registered as buffers using the `register_buffer` API (https://pytorch.org/docs/stable/generated/torch.nn.Module.html#torch.nn.Module.register_buffer).)r  Útree_mapÚtree_map_with_pathrÈ  Úupdater  Ú
ValueErrorrÿ   )r  ÚNN_MODULE_STD_ATTRSÚNN_MODULE_LAZY_STD_ATTRSrÍ  rŸ  ÚsnapshotrÙ  ÚnounÚverbrÌ  rØ  s            @@r~   rý   rý   <  s�  ùè ø€ ò
Ðð( 	Øð ÐðØ	ðà	!ð€Iô
Mò>ô �‰™{©O¸CÓ,@È'ÔR€Hð Ûð &(Ð"ô	ô 	×!Ñ!Ø/°¹?È3Ó;Oô	
ð 	�‰×Ñ˜HÔ%á%ÜÐ-Ó.°Ò2Ø1‘
�‘dà/‘
��dÜØ˜d˜V 1 T§Y¡YÐ/IÓ%JÐ$KÈ1ÈTÈFð Stð tóð ð &øð% &(Ð"ô	ô 	×!Ñ!Ø/°¹?È3Ó;Oô	
ð 	�‰×Ñ˜HÔ%á%ÜÐ-Ó.°Ò2Ø1‘
�‘dà/‘
��dÜØ˜d˜V 1 T§Y¡YÐ/IÓ%JÐ$KÈ1ÈTÈFð Stð tóð ð &üs   „6E»B> ¿A?EÂ>B D>Ä>E)¹Ú	itertoolsÚcollections.abcr   r   Ú
contextlibr   r   Ú	functoolsr   r   Útypingr	   r
   r   r   r   r   Úunittest.mockr   r…   Útorch._dynamo.loggingÚtorch.nnr9  Útorch.utils._pytreerù   Ú_pytreer  Útorch.utils.dlpackr   Ú$torch._decomp.decompositions_for_rngr   r   Útorch._dispatch.pythonr   Útorch._dynamor   Útorch._dynamo.utilsr   r   r   r   Útorch._guardsr   Útorch._inductor.output_coder   Útorch._inductor.utilsr   r   Útorch._subclassesr   r   Ú"torch.fx.experimental.proxy_tensorr   Ú%torch.fx.experimental.symbolic_shapesr    Útorch.utils._python_dispatchr!   Ú_loggingÚgetArtifactLoggerr�   rO  Ú r$   Ú_aot_autograd.autograd_cacher%   r&   r'   r(   Ú'_aot_autograd.collect_metadata_analysisr)   Ú_aot_autograd.functional_utilsr*   r+   r,   r-   r.   r/   r0   r1   r2   r3   r4   Ú#_aot_autograd.input_output_analysisr5   r6   r7   r8   Ú*_aot_autograd.jit_compile_runtime_wrappersr9   r:   r;   Ú_aot_autograd.logging_utilsr<   r=   r>   r?   r@   rA   rB   rC   rD   rE   rF   rG   Ú_aot_autograd.runtime_wrappersrH   rI   Ú_aot_autograd.schemasrJ   rK   rL   rM   rN   rO   rP   rQ   rR   rS   rT   rU   rV   rW   Ú_aot_autograd.subclass_utilsrX   rY   rZ   r[   r\   Ú(_aot_autograd.traced_function_transformsr]   r^   r_   r`   ra   rb   rc   Ú_aot_autograd.utilsrd   re   rf   rg   rh   ri   rj   rk   rl   rm   rn   ro   Úpartitionersrp   r‡  Úcountr   rõ   ri  rq   rr   ru   r‰   r¾   rr  rÁ   rÄ   rÆ   r7  r¦   Úboolr!  r:  r;  r   r°   ÚSourcerV  rv  r†   r‡   r›  r¬  ÚTreeSpecr™  rý   Úcompiled_functionÚcompiled_moduler{   r€   r~   ú<module>r     s¯  ðó ß .ß 2ß $ß F× FÝ ã Û Ý ß $Ð $Û Ý ß WÝ ;Ý +÷ó õ +Ý 2ß 6ß 8Ý 6Ý :Ý Fð —N‘N×4Ñ4ØÐ'óÐ õ ÷ó õ÷÷ ÷ ñ ÷ó ÷ñ ÷
÷ ÷ ó ÷÷÷ ÷ ÷ ÷ õ ÷÷ ñ ÷÷ ÷ ó õ ,ð €ð ˆi�oŠoÓ€ðz !Ð áÐ-¨t°C©yÓ9Ð ñ �m¨:Ô6€ô
˜(ô 
ô4Ð&9ô 4ð0AVØ�C‰yðAVàðAVð ðAVð ˜Ñ!ð	AVð
 óAVðH	"Ø�C‰yð	"Ø&/ð	"à
ˆ>˜8 HÑ-Ð-Ñ.ó	"ð

à$ð

ð ð

ð ð	

ð
 ˜Ñ!ð

ð ˆ8Ð(Ð(Ñ)ó

ð{(à$ð{(ð ð{(ð ð	{(ð
 ˜Ñ!ð{(ð ˆ8Ð(Ð(Ñ)ó{(ðB '+Ø.Ø%)ØØ+0Ø-1ðqð ØòqØðqàðqð ˜(Ñ#ðqð ð	qð
 ˜T‘Nðqð ðqð %)ðqð ! Ñ*ðqð óqðh1�B—I’Ið 1°2·9²9ó 1ðh=@Ø	�‰�Šð=@Ø&.¨s¡mð=@ØDGð=@à
ˆ8�D˜Ÿš×-Ò-Ñ.Ñ/°°c±Ð:Ñ;ó=@ðH 26Ø.Ø%)Ø#(Ø8<Ø&*ñSØ	�ŠðSð %ðSð Ð-Ñ.ð	Sð
 ðSð ˜T‘NðSð !Ð!4Ñ5ðSð ˜Ñ#ðSð ‡Y‚YóSðt &*ð (,Øà%)ØòLØ	�ŠðLð ˜T‘Nð	Lð ðLð   ‘}ðLð ðLð ˜T‘NðLð ˆ5�8Š8×Ò Ð/Ñ0óLðn  Ø%)ò]Ø
ð]ð ð	]ð ð]ð ˜T‘Nð]ð ‡X‚X×Òó]ðP  Ø%)ð Øà%)Øò#K.Ø
ðK.ð ð	K.ð
 ˜T‘NðK.ð ðK.ð ðK.ð  ˜T‘Nð!K.ð$ ˆ5�8Š8×ÒÐ!4°f·o²oÀvÇÂÐVÑWó%K.ð\ ðP e§h¡h§o¢oò Pó ðPðf !Ð Ø�r€   