+
    –°³j� ã                  óö  a € 0 t $ R t^ RIHt ^ RIt^ RIt^ RIt^ RIHt ^ RI	H
t
HtHtHt ^ RIt^ RIHu Ht ^ RIHt ^ RIHt ^ RIHt ^ RIHt ]P4                  ! ]4      t]'       d   ^ R	IHtHt ^ R
I H!t! . t"R]#R&   Rt$^t%]! R]&4      t'](])]&R,          ]&R,          ]&R,          3,          t*]+]&](]&R,          ]&R,          3,          3,          R,          t,]! / 4      t-R]#R&    ! R R].4      t/R R lt0R R lt1R R lt2R R lt3R R lt4R R lt5R R  lt6R! R" lt7R# R$ lt8R% R& lt9R' R( lt:R) R* lt;R+ R, lt<RLR- R. llt= ! R/ R04      t>R1t?R2 R3 lt@R4 R5 ltAR6 R7 ltBR8tCR9 R: ltDR;tER< R= ltFR> R? ltGR@ RA ltH ! RB RC4      tIRD RE ltJ ! RF RG4      tK]K! 4       tLRH]Ln        RH]LnM        ]KPœ                  P                  ]Ln        RI]/nO        RJ]/nM        RI]KP                   nO        RK]KP                   nM        R# )MaŽ  Ahead-of-time precompilation (``make_fx`` tracer by default; Dynamo planned).

    python_code, cache = torch.compiler.precompile(fn, model, *example_inputs)
    f_c = torch.compiler.precompile.load(python_code, cache)
    out = f_c(model, *example_inputs)   # pass the model again at runtime

precompile captures your computation with ``make_fx`` -- a NON-STRICT trace of the ATen
ops that run when ``fn`` executes once on the example inputs. It does not analyze your
Python, so it comes with an explicit contract (the programming model): stay inside it
and the artifact faithfully reproduces ``fn``; step outside it and you get an artifact
that computes the wrong thing.

``precompile`` returns a self-contained, executable ``python_code`` string plus a
companion integrity-tagged ``cache``. With ``backend="inductor"`` (the default) the
captured graph is lowered through the AOT backend contract
(``torch._functorch.aot_autograd.compile_to_python``, AOTAutograd + Inductor);
``python_code`` JIT-compiles kernels on first call and the cache primes them so a warm
reload skips JIT. With ``backend="eager"`` ``python_code`` inlines the captured graph and
runs on its own. Reload with ``torch.compiler.precompile.load(python_code, cache)``.

The full contract, the calling convention, and the cache / code_hash design all live in
Note [precompile programming model] below; every public entry point and guard references
it.
)ÚannotationsN)ÚMappingProxyType)ÚAnyÚcastÚNewTypeÚTYPE_CHECKING)ÚTensor)Úmake_fx)Ú	stateless)Úis_traceable_wrapper_subclass)ÚCallableÚMapping©ÚFakeTensorModeú	list[str]Ú__all__útorch.compiler.precompileÚ_ModuleIndexzMapping[int, Any]Ú	_NO_MARKSc                  ó   € ] tR tRtRtRtR# )ÚPrecompileErrori  aÞ  The error type raised by ``torch.compiler.precompile`` and its artifacts.

Raised when capture, lowering, ``load``, or a runtime call violates the precompile
contract -- e.g. a tensor baked as a constant (invariant 1), an unsupported /
effectful op, a non-tensor output the inductor backend cannot lower, or a runtime
input whose shape or memory format differs from the example (invariants 3 and 6).
See Note [precompile programming model] in this module for the full contract.
© N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú__static_attributes__r   ó    ÚR/home/luca/screen-checking/.venv/lib/python3.14/site-packages/torch/_precompile.pyr   r     s   † õr   r   c               ó    € V ^8„  d   QhRRRR/# )é   ÚtÚobjectÚreturnztuple[int, ...] | Noner   )Úformats   "r   Ú__annotate__r&     s   € ÷ 	ñ 	�Fð 	Ð5ñ 	r   c                ó’   € \        V \        P                  4      '       d'   \        V 4      '       g   \	        V P
                  4      # R# )a  Return the shape of a plain dense tensor, else ``None`` (non-tensor / subclass).

Tensor subclasses (e.g. DTensor) go through AOTAutograd's flatten path, so their
outer shape is not the dense shape the inductor artifact bakes; record ``None`` and
skip them in the shape check.
N)Ú
isinstanceÚtorchr   r   ÚtupleÚshape©r"   s   &r   Ú_dense_shaper-     s1   € ô �!”U—\‘\×"Ò"Ô+HÈ×+KÒ+KÜ�Q—W‘W‹~ÐÙr   c               ó    € V ^8„  d   QhRRRR/# ©r!   r"   r#   r$   ú
str | Noner   )r%   s   "r   r&   r&   $  s   € ÷ 
ñ 
�Fð 
˜zñ 
r   c                ó’   € \        V \        P                  4      '       d'   \        V 4      '       g   \	        V P
                  4      # R# )as  Return the dtype of a plain dense tensor as a string, else ``None``.

Recorded as a string (e.g. ``"torch.float32"``) so it serializes into the artifact
metadata as a literal and compares cleanly against ``str(t.dtype)`` at runtime;
mirrors the _dense_shape convention (None for non-tensor / subclass leaves). The
graph is specialized to the example dtype (invariant 6).
N)r(   r)   r   r   ÚstrÚdtyper,   s   &r   Ú_dense_dtyper4   $  s1   € ô �!”U—\‘\×"Ò"Ô+HÈ×+KÒ+KÜ�1—7‘7‹|ÐÙr   c               ó    € V ^8„  d   QhRRRR/# r/   r   )r%   s   "r   r&   r&   1  s   € ÷ 	ñ 	�Vð 	 
ñ 	r   c                ó’   € \        V \        P                  4      '       d'   \        V 4      '       g   \	        V P
                  4      # R# )a4  Return the device (as a string) of a plain dense tensor, else ``None``.

Recorded as a string so it serializes into the artifact metadata as a literal and
compares cleanly at runtime; mirrors _dense_shape (None for non-tensor / subclass
leaves). The graph is specialized to the example device (invariant 6).
N)r(   r)   r   r   r2   Údevicer,   s   &r   Ú_dense_devicer8   1  s1   € ô �!”U—\‘\×"Ò"Ô+HÈ×+KÒ+KÜ�1—8‘8‹}ÐÙr   c               ó    € V ^8„  d   QhRRRR/# )r!   Úgmútorch.fx.GraphModuler$   zlist[tuple[str, object]]r   )r%   s   "r   r&   r&   =  s   € ÷ ñ Øðàñr   c                óê   € . pV P                   P                  RR7       FP  pT pVP                  P                  R4       F  p\	        W4R4      pK  	  VP                  VP                  V34       KR  	  V# )z”Return ``(target, attr)`` for every ``get_attr`` node, resolving dotted
qualnames the same way for both capture guards below (missing attr -> None).Úget_attr)ÚopÚ.N)ÚgraphÚ
find_nodesÚtargetÚsplitÚgetattrÚappend)r:   ÚresolvedÚnodeÚattrÚparts   &    r   Ú_resolved_get_attrsrJ   =  sk   € ð
 €HØ—‘×#Ñ# zÐ#Ö2ˆØˆØ—K‘K×%Ñ% cÖ*ˆDÜ˜4 tÓ,ŠDñ +à�‰˜Ÿ™ dÐ+Ö,ñ	 3ð
 €Or   c               ó    € V ^8„  d   QhRRRR/# )r!   Úargsútuple[object, ...]r$   Úboolr   )r%   s   "r   r&   r&   U  s   € ÷ 
ñ 
Ð0ð 
°Tñ 
r   c                óº   € \         ;QJ d0    R \        P                  ! V 4       4       F  '       g   K   R# 	  R# ! R \        P                  ! V 4       4       4      # )zXTrue if any tensor reachable in ``args`` carries a mark_unbacked dim (backed or
strict).c              3  óª   "  € T FI  p\        V\        P                  4      ;'       d#    \        VR R4      ;'       g    \        VRR4      x € KK  	  R# 5i)Ú_dynamo_unbacked_indicesNÚ_dynamo_strict_unbacked_indices)r(   r)   r   rD   ©Ú.0r"   s   & r   Ú	<genexpr>Ú&_has_unbacked_marks.<locals>.<genexpr>X  s[   é € ð ñ *ˆAô 	�1”e—l‘lÓ#÷ 	
ð 	
ä�AÐ1°4Ó8÷ Cð CÜ�qÐ;¸TÓBô	
ó
 *ùs   ‚%A¨A½ATF)ÚanyÚpytreeÚtree_leaves)rL   s   &r   Ú_has_unbacked_marksrZ   U  sY   € ÷ ‹3ñ ô ×#Ò# DÔ)ó�3Œ3ð Š3ð ˆ3ñ ô ×#Ò# DÔ)óó ð r   c               ó    € V ^8„  d   QhRRRR/# )r!   Ú	user_flatúlist[object]r$   ÚNoner   )r%   s   "r   r&   r&   b  s   € ÷ ,ñ ,¨ð ,¸$ñ ,r   c                ó  € V  Fý  p\        V\        P                  4      '       g   K%  \        V4      '       d2   \	        VRR4      '       g   \	        VRR4      '       d   \        R4      h\	        VRR4      '       d   \        R4      h\	        VRR4      pV'       g   Kœ  \        ;QJ d*    R VP                  4        4       F  '       g   K   R	M	  R
M! R VP                  4        4       4      '       g   Kô  \        R4      h	  R# )a"  Reject mark options precompile cannot honor, loudly (invariant 3).

precompile only honors mark_unbacked (backed unbacked dims) and mark_unbacked's
strict variant. Backed dynamic marks (mark_dynamic -> _dynamo_dynamic_indices) and
per-dim specialization (_specialize_on) have no analogue in the static/unbacked
capture path -- silently dropping them would bake a wrong artifact, so reject rather
than ignore. (mark_unbacked's hint_override is NOT rejected: it is a perf-only
autotuning size hint, never a guard, so the single artifact is valid regardless; it
is threaded into the capture ShapeEnv in _fakeify_with_unbacked.) A mark_unbacked dim
on a tensor SUBCLASS (e.g. DTensor) is rejected: the dynamic capture cannot preserve
the subclass through the refake, so it too would bake a wrong artifact.
rQ   NrR   zýprecompile: an input is a tensor subclass (e.g. DTensor) with a mark_unbacked dynamic dim, which precompile cannot honor: the dynamic capture cannot preserve the subclass. Mark a dense input instead, or capture that dim static (do not mark_unbacked it).Ú_dynamo_dynamic_indiceszÎprecompile: an input has a mark_dynamic (backed dynamic) dim, which precompile cannot honor; it supports only mark_unbacked dynamic dims. Use torch._dynamo.decorators.mark_unbacked, or leave the dim static.Ú_specialize_onc              3  ó$   "  € T F  qx € K  	  R # 5i©Nr   )rT   Úvs   & r   rU   Ú,_reject_unsupported_marks.<locals>.<genexpr>‰  s   é € Ð CÑ,B q¤Ó,Bùs   ‚TFz°precompile: an input has a mark_unbacked specialize_on list, which precompile cannot honor (it produces a single artifact, not per-value specializations). Remove specialize_on.)r(   r)   r   r   rD   r   rW   Úvalues)r\   r"   Úspecialize_ons   &  r   Ú_reject_unsupported_marksrh   b  sá   € ó ˆÜ˜!œUŸ\™\×*Ò*Ùô )¨×+Ò+Ü�AÐ1°4×8Ò8Ü�qÐ;¸T×BÒBä!ðEóð ô �1Ð/°×6Ò6Ü!ðWóð ô
   Ð#3°TÓ:ˆß‰=ŸS›SÑ C¨M×,@Ñ,@Ô,BÓ CŸSŸSšSÑ C¨M×,@Ñ,@Ô,BÓ C×CÔCÜ!ð:óð ó7 r   c               ó    € V ^8„  d   QhRRRR/# )r!   r\   r]   r$   úlist[dict[int, _MarkSpec]]r   )r%   s   "r   r&   r&   ‘  s   € ÷ %ñ % Lð %Ð5Oñ %r   c                ó¸  € . pV  EFK  p\        V\        P                  4      '       g   VP                  / 4       K7  \	        \        VRR4      ;'       g    R4      pT\	        \        VRR4      ;'       g    R4      ,          pV'       g   VP                  / 4       K™  \        VR\        4      ;'       g    \        p\        VR\        4      ;'       g    \        p\        VR\        4      ;'       g    \        pTP                  V Uu/ uF9  pWtP                  V4      .VP                  VR4      OVP                  V4      N5bK;  	  up4       EKN  	  V# u upi )	a�  Read ``torch._dynamo.decorators.mark_unbacked`` marks off the user-input tensors.

Dynamic shapes are opt-in via that decorator (the caller marks dims before calling
precompile), NOT via a precompile kwarg -- so the precompile signature stays simple.
Returns a per-leaf list aligned to ``user_flat``; each entry maps a marked dim to
``(shape_id, min, max, hint_override)`` (None when unset), empty when the leaf has no
marks. Dims sharing a ``shape_id`` get the SAME unbacked symbol (so they are equal by
construction); ``min``/``max`` become runtime range asserts; ``hint_override`` is a
perf-only autotuning size hint applied to the symbol in _fakeify_with_unbacked.
rQ   NrR   Ú_dynamo_shape_idsÚ_dynamo_unbacked_boundsÚ_dynamo_hint_overridesr   )NN)r(   r)   r   rE   ÚsetrD   r   Úget)r\   Úmarksr"   ÚidxÚ	shape_idsÚboundsÚhintsÚds   &       r   Ú_read_unbacked_marksrw   ‘  s*  € ð )+€EÜˆÜ˜!œUŸ\™\×*Ò*Ø�L‰L˜ÔÙô ”'˜!Ð7¸Ó>×DÐDÀ"ÓEˆØŒs”7˜1Ð?ÀÓF×LÐLÈ"ÓMÕMˆßØ�L‰L˜ÔÙÜ˜AÐ2´IÓ>×KÐKÄ)ˆ	Ü˜Ð5´yÓA×NÐNÄYˆÜ˜Ð3´YÓ?×LÐLÄ9ˆØ�‰ñ óá�Að —M‘M !Ó$ÐQ v§z¡z°!°\Ó'BÐQÀEÇIÁIÈaÃLÑQÒQÙñ÷	
ñ' ð2 €Lùòs   Ä
?E
c               ó    € V ^8„  d   QhRRRR/# )r!   rq   rj   r$   úlist[_LeafBounds]r   )r%   s   "r   r&   r&   ¹  s   € ÷ ñ Ð8ð Ð=Nñ r   c                ó®   € . pV  FL  p/ pVP                  4        F  w  pw  rVrxVf   Vf   K  Wg3W4&   K  	  TP                  T;'       g    R4       KN  	  V# )a–  Build the per-leaf runtime min/max bounds from the already-read mark_unbacked
marks, aligned to ``user_flat`` (so ``marks`` is the output of _read_unbacked_marks).

mark_unbacked promises (in its own docstring) a runtime check that the dim is >= min
and <= max; those bounds are applied as capture-time torch._check constraints in
_fakeify_with_unbacked, but unbacked symints cannot be guarded on, so they never
become a runtime guard on their own. We record them here so the driver enforces them.
Each entry is None when the leaf has no bounded marked dim, else a dict mapping a
marked dim index to ``(lo, hi)`` (either may be None); mirrors USER_INPUT_DTYPES.
N)ÚitemsrE   )	rq   rt   ÚperÚper_leafrv   Ú	_shape_idÚloÚhiÚ_hints	   &        r   Ú_read_input_boundsr‚   ¹  sa   € ð !#€FÛˆØ=?ˆØ-0¯Y©Y®[Ñ)ˆAÑ)�	˜rØŠ~ ¤Ø!˜h�“ñ .9ð 	�‰�h×&Ð& $Ö'ñ ð €Mr   c               ó    € V ^8„  d   QhRRRR/# )r!   r"   ztorch.Tensorr$   ztorch.memory_formatr   )r%   s   "r   r&   r&   Î  s   € ÷ ñ ˜\ð Ð.Añ r   c                ó\  € V P                  \        P                  R7      '       d   \        P                  # V P                  \        P                  R7      '       d   \        P                  # V P                  \        P                  R7      '       d   \        P                  # \        R4      h)a“  Return the example leaf's memory format so a refaked marked input preserves it.

A mark_unbacked dim refakes the leaf via torch.empty; defaulting to contiguous would
bake a contiguous assert_size_stride and reject a channels_last / transposed input
even at its own layout. Probe the recognized formats and raise on an exotic /
ambiguous layout we cannot capture rather than silently forcing contiguous.
)Úmemory_formata\  precompile: a mark_unbacked input has a memory format that is neither contiguous, channels_last, nor channels_last_3d (e.g. a transposed or otherwise non-standard layout); the dynamic-shape capture cannot preserve it. Pass the input in one of those layouts (.contiguous() to make it contiguous), or capture the dim static (do not mark_unbacked it).)Úis_contiguousr)   Úcontiguous_formatÚchannels_lastÚchannels_last_3dr   r,   s   &r   Ú_detect_memory_formatrŠ   Î  s   € ð 	‡�¤U×%<Ñ%<€×=Ò=Ü×&Ñ&Ð&Ø‡�¤U×%8Ñ%8€×9Ò9Ü×"Ñ"Ð"Ø‡�¤U×%;Ñ%;€×<Ò<Ü×%Ñ%Ð%Ü
ð	?óð r   c               ó(   € V ^8„  d   QhRRRRRRRR/# )	r!   Úpb_flatúlist[Tensor]r\   r]   rq   rj   r$   z#tuple[list[object], FakeTensorMode]r   )r%   s   "r   r&   r&   å  s2   € ÷ C-ñ C-ØðC-Ø&2ðC-Ø;UðC-à(ñC-r   c           
     ó*  € ^ RI Hp ^ RIHp V! 4       pV! VRR7      p/ pT;_uu_ 4        V  Uu. uF  q†P	                  VRR7      NK  	  p	p. p
\        W4       EF  w  r¼\        V\        P                  4      '       g   V
P                  V4       K9  V'       g%   V
P                  VP	                  VRR7      4       Ke  . p\        VP                  4       EF)  w  rïWì9  d   VP                  \        V4      4       K(  WÎ,          w  ppppVe^   VV9   dW   VV,          pVe   \        P                  ! VV8¬  4       Ve   \        P                  ! VV8*  4       VP                  V4       K–  VP                  4       p\        P                  ! V^ 8¬  4       Ve   \        P                  ! VV8¬  4       Ve   \        P                  ! VV8*  4       Ve   VP                  VV4       Ve   VVV&   VP                  V4       EK,  	  \!        V4      p\        P"                  ! VVP$                  VP&                  VR7      pVP)                  VP*                  4       V
P                  V4       EK  	  RRR4       . X	OX
OV3# u upi   + '       g   i     L; i)aë  Fakeify the flat capture inputs for an unbacked dynamic-shape capture.

Params/buffers and unmarked dims become static fakes; each mark_unbacked dim becomes
an UNBACKED SymInt (unguardable, so the artifact is valid for any runtime size and a
graph that needs to guard on it fails at capture). Dims sharing a ``shape_id`` reuse
one symbol; ``min``/``max`` add runtime asserts. Returns ``(flat_fake, fake_mode)``;
the fake_mode (ShapeEnv) is threaded to the lowering via from_tracing_context.
r   )ÚShapeEnvT)Ú	shape_envÚallow_non_fake_inputs)Ústatic_shapesN)r3   r7   r…   )Útorch._subclasses.fake_tensorr   Ú%torch.fx.experimental.symbolic_shapesr�   Úfrom_tensorÚzipr(   r)   r   rE   Ú	enumerater+   ÚintÚ_checkÚcreate_unbacked_symintÚ"_set_unbacked_var_to_hint_overriderŠ   Úemptyr3   r7   Úrequires_grad_Úrequires_grad)rŒ   r\   rq   r   r�   r�   Ú	fake_modeÚsharedr"   Úfake_pbÚ	fake_userÚleafr|   ÚsizesÚiÚsÚshape_idr   r€   ÚhintÚur…   Úfs   &&&                    r   Ú_fakeify_with_unbackedr«   å  s,  € õ =Ý>á“
€IÙ¨È$ÔO€Ià "€Fß	ŠÙIPÓQÉÀA×(Ñ(¨¸$Ð(Ö?ÉˆÐQØ"$ˆ	Ü˜Y×.‰IˆDÜ˜d¤E§L¡L×1Ò1Ø× Ñ  Ö&ßØ× Ñ  ×!6Ñ!6°tÈ4Ð!6Ó!PÖQà#%�Ü% d§j¡j×1‘D�AØ”|ØŸ™¤S¨£VÔ,Ù Ø-0­VÑ*�H˜b " dØÒ+°¸FÔ0BØ" 8Õ,˜ð š>Ü!ŸLšL¨¨b©Ô1Øš>Ü!ŸLšL¨¨b©Ô1ØŸ™ QœÙ Ø!×8Ñ8Ó:�AÜ—L’L  a¡Ô(Ø’~ÜŸš Q¨"¡WÔ-Ø’~ÜŸš Q¨"¡WÔ-ð Ò'Ø!×DÑDÀQÈÔMØÒ+Ø+,˜˜xÑ(Ø—L‘L —Oñ; 2ô< !6°dÓ ;�Ü—K’KØØŸ*™*ØŸ;™;Ø"/ô	�ð × Ñ  ×!3Ñ!3Ô4Ø× Ñ  ×#ñ[ /÷ 
ðb "ˆWÐ!�yÐ! 9Ð,Ð,ùòa R÷ 
�ús$   ªJ¯I=Á
AJÂGJÉ=JÊJ	c               ó    € V ^8„  d   QhRRRR/# ©r!   r:   r;   r$   r^   r   )r%   s   "r   r&   r&   +  s   € ÷ 
ñ 
Ð#7ð 
¸Dñ 
r   c           	     ó  € \        V 4       UUu. uFR  w  r\        V\        P                  4      '       g   K'  V\	        VP
                  4      \        VP                  4      3NKT  	  pppV'       d   \        RV R24      hR# u uppi )aÁ  Enforce invariant 1 of Note [precompile programming model]: everything live
is an input.

Every legitimate tensor in a non-strict capture is a placeholder (a lifted
parameter/buffer or user input) or the result of a ``call_function`` node.
A ``get_attr`` pointing at a tensor therefore means some tensor was closed
over (a global, captured local, or non-registered module attribute) and would
be baked into the graph as a constant, which we forbid.
a˜  precompile traced a tensor that is neither a graph input (module parameter/buffer or user input) nor an intermediate. Such tensors would be hard-coded into the graph. This fires for a tensor closed over by fn (a global or captured local) or a plain (non-registered) module attribute, and also for a tensor literal constructed inside fn (e.g. torch.tensor([...])). Offending constants (target, shape, dtype): z©. Fix by passing the tensor as an explicit argument; for module state register it as a parameter/buffer, and for a literal hoist it out of fn and pass it as an argument.N)	rJ   r(   r)   r   r*   r+   r2   r3   r   ©r:   rB   rH   Ú	offendings   &   r   Ú_check_no_constant_tensorsr±   +  s‡   € ô 0°Ô3ôá3‰LˆFÜ�dœEŸL™L×)ô 	5ˆ”�t—z‘zÓ"¤C¨¯
©
£OÓ4Ù3ð ñ ÷
 Üð'ð (1 kð 2OðOó

ð 
	
ñ ùós
   �$B¸/Bc               ó    € V ^8„  d   QhRRRR/# r­   r   )r%   s   "r   r&   r&   H  s   € ÷ 
ñ 
Ð*>ð 
À4ñ 
r   c                óÔ   € \        V 4       UUu. uF3  w  r\        V\        P                  P                  4      '       g   K1  VNK5  	  pppV'       d   \        RV R24      hR# u uppi )aÈ  Reject captured control-flow HOP subgraphs (e.g. from ``torch.cond``).

They appear as ``get_attr`` nodes pointing at nested ``GraphModule`` submodules.
The eager backend inlines ``gm.code`` and cannot reach such submodules (they are
not on the standalone ``_GraphSelf`` holder), and the standalone composition does
not inline them either, so the artifact would crash at runtime. Fail at capture
with a concrete reason instead, like ``_assert_supported``.
z“precompile cannot lower a captured control-flow subgraph (e.g. from torch.cond / torch.while_loop); not supported yet. Offending get_attr targets: r?   N)rJ   r(   r)   ÚfxÚGraphModuler   r¯   s   &   r   Ú!_assert_no_control_flow_subgraphsr¶   H  sn   € ô 0°Ô3ôá3‰LˆFÜ�dœEŸH™H×0Ñ0×1÷ 	ˆÙ3ð ñ ÷
 Üðà!�{ !ð%ó
ð 	
ñ ùós   �.A$ÁA$c               ó    € V ^8„  d   QhRRRR/# )r!   Úmodszlist[torch.nn.Module]r$   zStuple[list[Tensor], list[str], list[str], list[tuple[_ModuleIndex, str, int]], int]r   )r%   s   "r   r&   r&   ^  s"   € ÷ 4Hñ 4HØ
ð4Hðñ4Hr   c                óš  a
aaa€ \        V 4      ^8”  d   R R lo
MR R lo
. o/ o. oR V
VVV3R llp. p\        V 4       F3  w  r4VP                  RR7       F  w  rVV! \        V4      WVV4       K  	  K5  	  \        S4      p. p\        V 4       F3  w  r4VP	                  RR7       F  w  rYV! \        V4      WYV4       K  	  K5  	  SW(SV3# )	a¦  Lift each module's parameters then buffers to a flat list, interning by
tensor identity so a tied weight becomes a single entry (one optimizer step,
accumulated gradient -- not one per name).

Returns ``(pb_flat, param_names, buffer_names, alias_entries, num_params)``,
where ``alias_entries`` maps each ``(module_index, name)`` to its index in
``pb_flat`` (used to reparametrize during capture). This same params-then-
buffers, intern-by-identity order is reproduced at runtime against the
user-supplied modules, so the dense list lines up with the compiled graph.

INVARIANT: the all-modules' params then all-modules' buffers, dedup-by-id ordering
here is load-bearing and is reproduced VERBATIM by
``torch._precompile_driver._extract_param_buffers`` (emitted into the inlined/eager
load paths). The cached load path uses this function directly, so both must stay
in sync; ``test_cached_and_inlined_paths_agree`` cross-checks them.
c               ó$   € V ^8„  d   QhRRRRRR/# ©r!   Úmir   Únr2   r$   r   )r%   s   "r   r&   Ú+_intern_param_buffers.<locals>.__annotate__u  s!   € ÷ 	 ñ 	 �lð 	  sð 	 ¨sñ 	 r   c                ó   € R V  RV 2# )Úmr?   r   ©r¼   r½   s   &&r   Ú_nameÚ$_intern_param_buffers.<locals>._nameu  s   € Ø�r�d˜!˜A˜3�<Ðr   c               ó$   € V ^8„  d   QhRRRRRR/# r»   r   )r%   s   "r   r&   r¾   y  s!   € ÷ 	ñ 	�lð 	 sð 	¨sñ 	r   c                ó   € V# rc   r   rÁ   s   &&r   rÂ   rÃ   y  s   € ØˆHr   c          
     ó,   € V ^8„  d   QhRRRRRRRRR	R
/# )r!   r¼   r   r½   r2   r"   r   Ú	names_outr   r$   r^   r   )r%   s   "r   r&   r¾   €  s/   € ÷ ,ñ ,�Lð , Sð ,¨Vð ,À	ð ,Èdñ ,r   c                óì   <€ SP                  \        V4      4      pVfB   \        S4      pVS\        V4      &   SP                  V4       VP                  S! W4      4       SP                  WV34       R # rc   )rp   ÚidÚlenrE   )	r¼   r½   r"   rÇ   ÚuidxrÂ   Úalias_entriesÚ
id_to_uidxÚuniques	   &&&& €€€€r   Ú_internÚ&_intern_param_buffers.<locals>._intern€  sa   ø€ Ø�~‰~œb ›eÓ$ˆØŠ<Ü�v“;ˆDØ $ˆJ”r˜!“uÑØ�M‰M˜!ÔØ×Ñ™U 2›\Ô*Ø×Ñ˜b T˜]Ö+r   F)Úremove_duplicate)rÊ   r—   Únamed_parametersr   Únamed_buffers)r¸   rÏ   Úparam_namesr¼   rÀ   r½   ÚpÚ
num_paramsÚbuffer_namesÚbrÂ   rÌ   rÍ   rÎ   s   &         @@@@r   Ú_intern_param_buffersrÙ   ^  sÐ   û€ ô* ˆ4ƒy�1„}ö	 õ	ð €FØ!#€JØ9;€M÷,ó ,ð  €KÜ˜4–‰ˆØ×&Ñ&¸Ð&Ö>‰DˆAÙ”L Ó$ a¨KÖ8ó ?ñ !ô �V“€JØ €LÜ˜4–‰ˆØ—O‘O°U�OÖ;‰DˆAÙ”L Ó$ a¨LÖ9ó <ñ !ð �;¨m¸ZÐGÐGr   c               ó(   € V ^8„  d   QhRRRRRRRR/# )	r!   ÚfnúCallable[..., object]rL   rM   Údecompositionsúdict | Noner$   Ú_Capturer   )r%   s   "r   r&   r&   •  s6   € ÷ wñ wØðwà
ðwð  ðwð ñ	wr   c                ót  a aaa$a%a&a'a(a)a*a+a,€ ^ RI o'\        S4      o\        S4       UUu. uF3  w  r4\        V\        P
                  P                  4      '       g   K1  VNK5  	  ppp\        V4      o*S Uu. uF1  p\        V\        P
                  P                  4      '       g   K/  VNK3  	  upo)\        ;QJ d     . V*3R l\        S4       4       F  NK  	  5M! V*3R l\        S4       4       4      p\        S)4      w  rxp	o$o+\        V4      o,VRS+  U
u. uF  p
\        V
P                  4      NK  	  pp
VS+R  U
u. uF  p
\        V
P                  4      NK  	  pp
VRS+  U
u. uF  p
\        V
P                  4      NK  	  pp
VS+R  U
u. uF  p
\        V
P                  4      NK  	  pp
VRS+  U
u. uF  p
\        V
P                  4      NK  	  pp
VS+R  U
u. uF  p
\        V
P                  4      NK  	  pp
\        P                  ! V4      w  po(\!        V4       . VOVOp\#        V4      pV U
u. uF  p
\%        V
4      NK  	  pp
V U
u. uF  p
\'        V
4      NK  	  pp
V U
u. uF  p
\)        V
4      NK  	  pp
\+        V4      p\-        V4      pV Uu. uF1  p\        V\        P.                  4      '       d   VP0                  MRNK3  	  ppV F,  p\        V\        P.                  4      '       g   K%  RVn        K.  	  Rp\3        V4      '       dz   \5        VVV4      w  pp\7        VV4       UUau. uFP  w  poVf   RMC\        ;QJ d     . V3R l\        V4       4       F  NK  	  5M! V3R l\        V4       4       4      NKR  	  pppRo&. o%R V$VV%V&V'V V(V)V*V+V,3R llp^ RIHp Ve   RMRpVe   TMS'P=                  4       p  \        P>                  ! 4       ;_uu_ 4        T ;_uu_ 4         \A        VVVR	7      ! V4      p! RRR4       RRR4       \7        TT4       F/  w  pp#\        T\        P.                  4      '       g   K(  T#Tn        K1  	  \G        X!4       \I        T!4       \K        T!4       \M        R / RT!bRTbRTbR\        S4      bRTbRT	bRTbRTbRTbRTbRTbRTbRS(bR\O        RS&4      bRS%bRTbRTbRTbRTbRTb # u uppi u upi u up
i u up
i u up
i u up
i u up
i u up
i u up
i u up
i u up
i u upi u uppi   T d3   p"\C        R
\        T"4      PE                  4       ^ ,           24      T"hRp"?"ii ; i  + '       g   i     ELP; i  + '       g   i     EL\; i  \7        TT4       F/  w  pp#\        T\        P.                  4      '       g   K(  T#Tn        K1  	  i ; i)!a£  Trace the computation ``fn(*args)`` to an ATen graph.

See Note [precompile programming model] for the contract. ``fn`` is the whole
computation, e.g. ``lambda model, x: model(x)`` or a training step
``lambda model, x, t: loss_fn(model(x), t).backward()``. Among ``args``, the
``nn.Module`` arguments have their parameters/buffers lifted to explicit graph
inputs (via reparametrization, so nothing is baked -- invariant 1); the
remaining arguments are the runtime inputs. Whatever ``fn`` returns becomes the
graph's result outputs, and if ``fn`` ran a backward, the resulting parameter
gradients (read off ``param.grad``) are harvested as additional, trailing graph
outputs. They are kept separate from the result so the driver can scatter them
onto the runtime model's ``.grad`` fields rather than return them (invariant 5).

This is a NON-STRICT trace (invariant 3): make_fx records only the ATen ops
that run for THIS example. Python-level control flow over tensor values, data-
dependent branches, and shapes are specialized to ``args`` and baked. The
interning/order established here for params then buffers is the calling
convention the runtime model must reproduce (invariant 2).
Nc              3  ó>   <"  € T F  w  rVS9  g   K  Vx € K  	  R # 5irc   r   )rT   r¥   ÚaÚmodule_pos_sets   &  €r   rU   Ú_capture.<locals>.<genexpr>³  s   øé € ÐQ¡o™d˜a¸À.Ñ9PŸš£oùs   ƒ“
c              3  ó>   <"  € T F  w  rVS9   d   R MTx € K  	  R # 5irc   r   )rT   r¥   r¦   r|   s   &  €r   rU   rä     s   øé € ÐK¹?±4°1˜q Cœx‘t¨QÔ.»?ùs   ƒc               ó    € V ^8„  d   QhRRRR/# )r!   Úflatr]   r$   r   )r%   s   "r   r&   Ú_capture.<locals>.__annotate__  s   € ÷ ?*ñ ?*�lð ?* |ñ ?*r   c                óš  <€ \        R V RS  4      p\        P                  ! V S R S4      pSP                  4       ;_uu_ 4       p\	        S4       FS  w  rES UUUu/ uF  w  rgq†V8X  g   K  WqV,          bK  	  p	pppVP                  \        P                  ! WYRR7      4       KU  	  . p
^ p\        \        S4      4       FD  pVS9   d   V
P                  SV,          4       K$  V
P                  W+,          4       V^,          pKF  	  S! V
!  pVRS pV Uu. uF  qÿP                  NK  	  pp\        ;QJ d    R VSR  4       F  '       g   K   RM	  RM! R VSR  4       4      '       d   \        R4      h\        ;QJ d    R V S R  4       F  '       g   K   RM	  RM! R V S R  4       4      '       d   \        R4      h RRR4       \        P                  ! X4      w  pp. p. p\	        X4       F.  w  ppVf   K  VP                  V4       VP                  V4       K0  	  VoVo. VOVO# u upppi u upi   + '       g   i     L€; i)	r�   NT)Útie_weightsc              3  ó@   "  € T F  p\        VR R4      RJx € K  	  R# 5i©ÚgradN©rD   )rT   rØ   s   & r   rU   Ú,_capture.<locals>.flat_fn.<locals>.<genexpr>.  s   é € ÐQÁ¸A”7˜1˜f dÓ+°4Õ7Ãùó   ‚Fz¯precompile: a registered buffer received a gradient (it has requires_grad=True), but precompile only harvests gradients for parameters. Register it as an nn.Parameter instead.c              3  ó@   "  € T F  p\        VR R4      RJx € K  	  R# 5irì   rî   rS   s   & r   rU   rï   8  s   é € ÐOÁ¸A”7˜1˜f dÓ+°4Õ7Ãùrð   zÑprecompile: a user input received a gradient; precompile only harvests gradients for parameters, so an input gradient would be silently dropped. Pass the tensor as a module parameter if its gradient is needed.)r   rX   Útree_unflattenÚ	ExitStackr—   Úenter_contextr
   Ú_reparametrize_moduleÚrangerÊ   rE   rí   rW   r   Útree_flatten)!rç   ÚpbÚruntime_inputsÚstackr¼   rÀ   Úemir½   rË   ÚreparamÚfullÚuir¥   ÚresultÚparam_proxiesrÕ   Ú	harvestedÚresult_flatÚresult_specÚ	grad_flatÚgrad_param_indicesÚgrÌ   rL   Úcaptured_grad_param_indicesÚcaptured_out_specÚ
contextlibrÛ   Úin_specr¸   rã   rÖ   Únum_pbs!   &                     €€€€€€€€€€€r   Úflat_fnÚ_capture.<locals>.flat_fn  s'  ø€ ô �. $ w¨ -Ó0ˆÜ×.Ò.¨t°F°G¨}¸gÓFˆØ×!Ñ!×#Ô# uÜ" 4ž‘�Ù;HÕV¹=©<¨3°4ÐSUÉIœ;˜1 �hš;¹=�ÒVØ×#Ñ#Ü×3Ò3°AÈDÔQöñ )ð "$ˆDØˆBÜœ3˜t›9Ö%�Ø˜Ô&Ø—K‘K  Q¥Ö(à—K‘K Õ 2Ô3Ø˜!•G’Bñ &ñ ˜‘YˆFà˜{ 
˜OˆMÙ)6Ó7© AŸœ©ˆIÐ7÷ ‹sÑQÀÀJÀKÁÓQ�s�sŠsÑQÀÀJÀKÁÓQ×QÒQÜ%ðJóð ÷ ‹sÑOÀÀfÀgÁÓO�s�sŠsÑOÀÀfÀgÁÓO×OÒOÜ%ð*óð ð P÷C $ô` $*×#6Ò#6°vÓ#>Ñ ˆ�[Øˆ	ØÐÜ˜iÖ(‰DˆAˆqØŒ}Ø× Ñ  Ô#Ø"×)Ñ)¨!Ö,ñ )ð (ÐØ&8Ð#Ø)�Ð)˜yÐ)Ð)ùôo Wùò" 8÷' $×#úsO   ÁH:ÁH.Á*H.Á7BH:ÄH5Ä)!H:ÅH:Å+H:ÆH:ÆH:Æ6H:È.H:È:I
	)ÚGuardOnDataDependentSymNodeÚsymbolicÚreal)Údecomposition_tableÚtracing_modea  precompile: fn needs to guard on a dim marked with mark_unbacked (it branches on or specializes that size), which is not allowed for an unbacked dynamic dim. Do not mark that dim (capture it static), or restructure fn to avoid the size-dependent operation. Underlying: r:   Ú	flat_argsÚmodule_positionsÚnum_positional_argsrÔ   r×   Úparam_shapesÚbuffer_shapesÚparam_dtypesÚbuffer_dtypesÚparam_devicesÚbuffer_devicesr
  Úout_specúpytree.TreeSpecr  Úuser_input_shapesÚuser_input_dtypesÚuser_input_devicesÚuser_input_boundsrŸ   r   )(r	  r*   r—   r(   r)   ÚnnÚModulero   rÙ   rÊ   r+   r2   r3   r7   rX   r÷   rh   Úlistr-   r4   r8   rw   r‚   r   rí   rW   r«   r–   r”   r  ÚnullcontextÚenable_gradr	   r   Ú
splitlinesr±   r¶   Ú_assert_supportedrß   r   )-rÛ   rL   rÝ   r¥   râ   r  Úuser_inputsrŒ   rÔ   r×   r"   r  r  r  r  r  r  r\   r  Ú	real_flatr  r  r   rq   r!  Úsaved_gradsrŸ   Úbaser|   r  r  r  Ú
capture_cmr:   Úer  rÌ   r  r  r	  r
  r¸   rã   rÖ   r  s-   ff&                         `       @@@@@@@@@r   Ú_capturer/  •  s”  ÿû€ ó0 ä�‹;€DÜ&/°¤oÔX¡o™d˜a¼ÀAÄuÇxÁxÇÁ×9WŸ˜¡oÐÑXÜÐ)Ó*€NÙÓ>‘t�!œz¨!¬U¯X©X¯_©_×=�AˆA‘tÑ>€Dß”%ÔQ¤i°¤oÓQ—%‘%ÔQ¤i°¤oÓQÓQ€Kô 	˜dÓ#ñ B€G˜,¨°zô �‹\€Fð -4°K°ZÑ,@ÓAÑ,@ q”E˜!Ÿ'™'–NÑ,@€LÐAØ-4°Z°[Ñ-AÓBÑ-A¨”U˜1Ÿ7™7–^Ñ-A€MÐBØ*1°+°:Ñ*>Ó?Ñ*> Q”C˜Ÿ™–LÑ*>€LÐ?Ø+2°:°;Ñ+?Ó@Ñ+? a”S˜Ÿ™–\Ñ+?€MÐ@Ø,3°K°ZÑ,@ÓAÑ,@ q”S˜Ÿ™–]Ñ,@€MÐAØ-4°Z°[Ñ-AÓBÑ-A¨”c˜!Ÿ(™(–mÑ-A€NÐBä×,Ò,¨[Ó9Ñ€Iˆwô ˜iÔ(Ø&�'Ð&˜IÐ&€Iô �Y“€Iñ "+ó>Ù!*˜AŒ�QŽ¡ð ð >ñ 3<Ó<±)¨Qœ až±)ÐÐ<Ù4=Ó>±I¨qœ-¨Ö*±IÐÐ>ô ! Ó+€Eô +¨5Ó1Ðñ" MVÓVÉIÀqœZ¨¬5¯<©<×8Ò8�1—6’6¸dÒBÉI€KÐVÛˆÜ�aœŸ™×&Ô&ØˆAŽFñ ð €IÜ
ˆ5‡z‚zÜ5°g¸yÈ%ÓPÑˆ	�9ô
 !Ð!2°EÔ:õ	
ñ ;‘	��cð Š|ñ ç”ÔK¼9ÀT¼?ÓK—‘ÔK¼9ÀT¼?ÓKÓKòLñ ;ð	 	ñ 
ð 15ÐØ-/Ð÷?*÷ ?*ò ?*õJ Rà!*Ò!6‘:¸F€LØ'Ò3‘¸×9OÑ9OÓ9Q€JðÜ×Ò× Õ §*¢*ðÜØØ(6Ø!-õð ó	‘÷ #-× ô( ˜	 ;Ö/‰DˆAˆqÜ˜!œUŸ\™\×*Ô*Ø�–ñ 0ô ˜rÔ"Ü% bÔ)Ü�bÔô ò Ùðáðñ *ðô   œIð	ñ
  ðñ "ðñ "ðñ $ðñ "ðñ $ðñ $ðñ &ðñ ðô Ð'Ð):Ô;ðñ 7ðñ  ,ð!ñ" ,ð#ñ$ .ð%ñ& ,ð'ñ( ð)ð ùóO Yùâ>ùò  BùÚBùÚ?ùÚ@ùÚAùÚBùò*>ùò =ùÚ>ùò< Wùó
øðz /ô ô
 &ð\ô ˜1“v×(Ñ(Ó*¨1Õ-Ð.ð	0óð ðûðú÷ #-§* *ú× × Ð ûô( ˜	 ;Ö/‰DˆAˆqÜ˜!œUŸ\™\×*Ô*Ø�–ò 0ús¿   ª.SÁSÁ5,SÂ&SÄSÄ<SÅ#S$Æ
S)Æ1S.ÇS3È1S8ÉS=É%TÊ7TÌ3TÍ=TÏU6 Ï%U"Ï0U	Ï2TÐU"ÐU6 ÔUÔ-UÕUÕU	ÕUÕ	U"Õ"U3	Õ-	U6 Õ60V7Ö+V7c                  ó&   € ] tR tRtRR R lltRtR# )rß   i�  Nc          *     ól   € V ^8„  d   QhRRRRRRRRR	R
RR
RRRRRR
RR
RR
RR
RRRRRRRRRRRRRRRRR R!/# )"r!   r:   r;   r  r]   r  z	list[int]r  r˜   rÔ   r   r×   r  zlist[tuple[int, ...]]r  r  r  r  r  r
  r  r  r  r  z#list[tuple[int | None, ...] | None]r  zlist[str | None]r   r!  ry   rŸ   zFakeTensorMode | Noner$   r^   r   )r%   s   "r   r&   Ú_Capture.__annotate__�  sÜ   € ÷ ,#ñ ,#à ð,#ð  ð,#ð $ð	,#ð
 !ð,#ð ð,#ð  ð,#ð ,ð,#ð -ð,#ð  ð,#ð !ð,#ð !ð,#ð "ð,#ð !ð,#ð "ð,#ð  &ð!,#ð" ?ð#,#ð$ ,ð%,#ð& -ð',#ð( -ð),#ð* )ð+,#ð, 
ñ-,#r   c                	ó   € Wn         W n        W0n        W@n        WPn        W`n        Wpn        W€n        W�n        W n	        W°n
        WÀn        WÐn        Wàn        Wðn        VV n        VV n        VV n        VV n        VV n        R # rc   )r:   r  r  r  rÔ   r×   r  r  r  r  r  r  r
  r  r  r  r  r   r!  rŸ   )Úselfr:   r  r  r  rÔ   r×   r  r  r  r  r  r  r
  r  r  r  r  r   r!  rŸ   s   &&&&&&&&&&&&&&&&&&&&&r   Ú__init__Ú_Capture.__init__�  sƒ   € ð. ŒØ"ŒØ 0ÔØ#6Ô Ø&ÔØ(ÔØ(ÔØ*ÔØ(ÔØ*ÔØ*ÔØ,ÔØŒØ ŒØ"4ÔØ!2ˆÔØ!2ˆÔØ"4ˆÔØ!2ˆÔð #ˆŽr   )r  r  r×   r  rŸ   r  r:   r  r
  r  r  r  r  r  rÔ   r  r!  r   r  r  rc   )r   r   r   r   r5  r   r   r   r   rß   rß   �  s   † ÷,#ó ,#r   rß   a»  # Generated by torch.compiler.precompile -- do not edit.
#
# This is a SELF-CONTAINED, EXECUTABLE artifact: it runs on its own, needing no
# companion cache. You provide the model(s) at runtime, exactly as the original fn
# took them, e.g.:
#
#     ns = {}
#     exec(open("this_file.py").read(), ns)
#     out = ns["forward"](model, my_input)      # same args as the traced fn
#
# The runtime model must be STRUCTURALLY IDENTICAL to the one precompile traced
# (same parameter/buffer names, order, and weight tying); only the weight VALUES
# may differ (swap in a checkpoint). This artifact was produced by a non-strict
# make_fx trace, so control flow and shapes are specialized to the example inputs,
# and (inductor backend) each input's stride / memory format is baked too: pass
# runtime inputs in the example's layout (.contiguous() to match a contiguous
# example). See Note [precompile programming model] in torch/_precompile.py.
#
# It contains, in order:
#   1. The composed graph module from aot_autograd.compile_to_python: the inlined
#      Inductor kernels (JIT-compiled from the embedded source on first use -- no
#      external cache required) plus AOTAutograd's own codegen'd prelude/epilogue
#      (tensor-subclass wrap/unwrap, input-mutation reflection, output aliasing),
#      exposing ``call(flat_inputs) -> outputs``.
#   2. Calling-convention metadata.
#   3. A small driver that extracts each runtime module's params/buffers (in the
#      same order as capture), passes them with the runtime inputs to ``call``, and
#      scatters any harvested gradients onto the model's .grad fields. No model
#      weights are embedded (you bring the model).
#
# The companion ``cache`` returned by precompile is purely an ACCELERATION used by
# torch.compiler.precompile.load: it primes the inductor kernel caches so exec'ing this
# file loads its kernels from the precompiled binaries (no JIT). This file does not read
# it; running this file alone just JITs.
c               ó    € V ^8„  d   QhRRRR/# )r!   ÚcompiledÚPrecompiledModuler$   r   r   )r%   s   "r   r&   r&   å  s   € ÷ Lñ LÐ&7ð L¸Iñ Lr   c                óZ  € V P                   e   V P                  f   \        R4      h \        P                  ! V P                   4      p \        P                  ! T P                  4      pRRRRRRRT P                  : 2RT P                  : 2R	T P                   2R
T P                  : 2RT P                  : 2RT P                  : 2RT P                  : 2RT P                  : 2RT P                  : 2RT P                   : 2RT P"                  : 2RT P$                  : 2RT: 2RT: 2RT P&                  : 2RT P(                  : 2RT P*                  : 2RT P,                  : 2R.pT#   \
        \        3 d   p\        R4      ThR p?ii ; i  \
        \        3 d    R p EL?i ; i)Nz1internal: cannot build metadata before _compile()a�  precompile cannot serialize the output structure of fn (its pytree TreeSpec is not JSON-serializable). This fires when fn returns an unregistered collections.namedtuple, or a registered pytree node with a non-JSON-dumpable context. Register the namedtuple via torch.utils._pytree._register_namedtuple(...) (or supply a JSON-dumpable to_dumpable_context), or return a plain tuple/list/dict of tensors.z # 2. Calling-convention metadatazimport torch as _torchz%import torch.utils._pytree as _pytreeÚ z
BACKEND = zMODULE_POSITIONS = zNUM_POSITIONAL_ARGS = zPARAM_NAMES = zBUFFER_NAMES = zPARAM_SHAPES = zBUFFER_SHAPES = zPARAM_DTYPES = zBUFFER_DTYPES = zPARAM_DEVICES = zBUFFER_DEVICES = zGRAD_PARAM_INDICES = z
IN_SPEC = zOUT_SPEC = zUSER_INPUT_SHAPES = zUSER_INPUT_DTYPES = zUSER_INPUT_DEVICES = zUSER_INPUT_BOUNDS = úH# ======================================================================)Ú	_out_specÚ_in_specr   rX   Útreespec_dumpsÚNotImplementedErrorÚ	TypeErrorÚ_backendÚ_module_positionsÚ_num_positional_argsÚ_param_namesÚ_buffer_namesÚ_param_shapesÚ_buffer_shapesÚ_param_dtypesÚ_buffer_dtypesÚ_param_devicesÚ_buffer_devicesÚ_grad_param_indicesÚ_user_input_shapesÚ_user_input_dtypesÚ_user_input_devicesÚ_user_input_bounds)r8  Úout_spec_strr.  Úin_spec_strÚpartss   &    r   Ú_build_metadata_sectionrU  å  sÿ  € Ø×ÑÒ! X×%6Ñ%6Ò%>ÜÐQÓRÐRð
Ü×,Ò,¨X×-?Ñ-?Ó@ˆð Ü"(×"7Ò"7¸×8IÑ8IÓ"Jˆð 	Ø*ØØ Ø/Ø
ð �X×&Ñ&Ñ)Ð*Ø
˜h×8Ñ8Ñ;Ð<ð ! ×!>Ñ!>Ð ?Ð@Ø
˜×.Ñ.Ñ1Ð2Ø
˜(×0Ñ0Ñ3Ð4ð ˜(×0Ñ0Ñ3Ð4Ø
˜8×2Ñ2Ñ5Ð6Ø
˜(×0Ñ0Ñ3Ð4Ø
˜8×2Ñ2Ñ5Ð6Ø
˜8×2Ñ2Ñ5Ð6Ø
˜H×4Ñ4Ñ7Ð8ð   × <Ñ <Ñ?Ð@ð �[‘OÐ$Ø
�lÑ%Ð&ð
 ˜x×:Ñ:Ñ=Ð>Ø
˜x×:Ñ:Ñ=Ð>Ø
 × <Ñ <Ñ?Ð@ð ˜x×:Ñ:Ñ=Ð>Ø
ð[.€Eð^ €LøôE  ¤Ð+ô ÜðRó
ð ð	ûðûô"  ¤Ð+ô Ø‹ðús)   © E. Á
 F Å.FÅ?FÆFÆF*Æ)F*c               ó    € V ^8„  d   QhRRRR/# )r!   Úpython_coder2   r$   zdict[str, object]r   )r%   s   "r   r&   r&   4  s   € ÷ @ñ @¨#ð @Ð2Cñ @r   c                ó�  € ^ RI p0 Rmp/ p VP                  V 4      pTP                   FÄ  p\        YaP                  4      '       d   \        TP                  4      ^8w  d   K:  TP                  ^ ,          p\        YqP                  4      '       g   Kj  TP                  T9   d*   TP                  TP                  4      Y7P                  &   K¤  \        P                  RTP                  4       KÆ  	  Y#P                  4       ,
          pT'       d   \        R\!        T4       R24      hT#   \         d   p\        R4      ThRp?ii ; i)a¯  Read the calling-convention constants back out of ``python_code`` WITHOUT
executing it (exec'ing the inlined Inductor output would JIT the kernels, the
very work the cache exists to skip).

python_code is the single source of truth: ``_build_metadata_section`` emits the
constants below as top-level literal assignments, so an AST walk + literal_eval
recovers them safely. The cache then only needs to carry the compiled artifact.
Nz\python_code is not valid Python; it does not look like a torch.compiler.precompile artifact.zlprecompile: ignoring unrecognized top-level assignment %r while parsing artifact calling-convention metadataz3python_code is missing calling-convention metadata z=; it does not look like a torch.compiler.precompile artifact.>   ÚBACKENDÚIN_SPECÚOUT_SPECÚPARAM_NAMESÚBUFFER_NAMESÚPARAM_DTYPESÚPARAM_SHAPESÚBUFFER_DTYPESÚBUFFER_SHAPESÚPARAM_DEVICESÚBUFFER_DEVICESÚMODULE_POSITIONSÚUSER_INPUT_BOUNDSÚUSER_INPUT_DTYPESÚUSER_INPUT_SHAPESÚGRAD_PARAM_INDICESÚUSER_INPUT_DEVICESÚNUM_POSITIONAL_ARGS)ÚastÚparseÚSyntaxErrorr   Úbodyr(   ÚAssignrÊ   ÚtargetsÚNamerÉ   Úliteral_evalÚvalueÚlogÚdebugÚkeysÚsorted)	rW  rk  ÚwantedÚfoundÚtreer.  rG   rB   Úmissings	   &        r   Ú_parse_artifact_metadatar|  4  s#  € ó ò€Fð(  "€EðØ�y‰y˜Ó%ˆð —	”	ˆÜ˜$§
¡
×+Ò+¬s°4·<±<Ó/@ÀAÔ/EÙØ—‘˜a•ˆÜ˜&§(¡(×+Ò+ÙØ�9‰9˜ÔØ"×/Ñ/°·
±
Ó;ˆE—)‘)Óô �I‰Ið?à—	‘	öñ ð& —z‘z“|Õ#€GßÜØAÄ&ÈÃ/ÐARð SJð Jó
ð 	
ð €Løô= ô Üð2ó
ð ð	ûðús   ŒD) Ä)EÄ4E Å Ec               ó$   € V ^8„  d   QhRRRRRR/# )r!   r8  r9  Úgraph_pythonr2   r$   r   )r%   s   "r   r&   r&   w  s&   € ÷ ñ Øðàðð 	ñr   c                ó¬  € \         R .pVP                  R4       VP                  R4       VP                  R4       VP                  V4       VP                  R 4       VP                  \        V 4      4       VP                  R4       VP                  R4       VP                  R4       VP                  \	        R4      4       RP                  V4      # )r;  z># 1. Compiled graph (AOTAutograd + Inductor): exposes ``call``zF# 3. Driver: module params/buffers + grad scatter + calling conventionÚ_inductor_forwardÚ
r<  )Ú_GENERATED_HEADERrE   ÚextendrU  Ú_emit_driver_sourceÚjoin)r8  r~  rT  s   && r   Ú_build_python_sourcer†  w  sª   € ô  Ð#€EØ	‡L�L�Ô!Ø	‡L�LÐQÔRØ	‡L�L�Ô!ð 
‡L�L�ÔØ	‡L�L�ÔØ	‡L�LÔ(¨Ó2Ô3Ø	‡L�L�Ô!Ø	‡L�LØPôð 
‡L�L�Ô!Ø	‡L�LÔ$Ð%8Ó9Ô:Ø�9‰9�UÓÐr   aÆ  # Generated by torch.compiler.precompile (backend="eager") -- do not edit.
#
# Self-contained, executable artifact: the captured ATen graph is inlined below (both
# the human-readable rendering and the executable code) and runs on its own. Provide
# the model(s) at runtime, exactly as the original fn took them:
#
#     ns = {}
#     exec(open("this_file.py").read(), ns)
#     out = ns["forward"](model, my_input)      # same args as the traced fn
#
# The runtime model must be structurally identical to the traced one (only weight
# VALUES may differ), and control flow / shapes are specialized to the example inputs.
# See Note [precompile programming model] in torch/_precompile.py for the full contract.
c               ó    € V ^8„  d   QhRRRR/# )r!   r8  r9  r$   r2   r   )r%   s   "r   r&   r&   Ÿ  s   € ÷ *ñ *Ð):ð *¸sñ *r   c                ó‚  € V P                   pVe   VP                  MR pVe   VP                  MR pVe	   Ve   Vf   \        R4      hTP                  P                  RR^4      p\        P                  ! V4      p\        P                  ! V4      p\        R.pVP                  R4       VP                  R4       VP                  R4       ^ RI
Hp VP                  4        F  p	VP                  V	P                  4       K   	  VP                  V4       VP                  R4       VP                  R4       VP                  RV: R	24       VP                  R
V: R	24       VP                  R4       VP                  R4       VP                  R4       VP                  R4       VP                  R4       VP                  R4       VP                  \        V 4      4       VP                  R4       VP                  R4       VP                  R4       VP                  \!        R4      4       RP#                  V4      # )Nz/internal: eager graph missing before _compile()údef forward(zdef _graph_forward(r;  zC# 1. Captured ATen graph (eager backend) -- executable and readable)Ú_custom_builtinszclass _GraphSelf:z%    _in_spec = pytree.treespec_loads(Ú)z&    _out_spec = pytree.treespec_loads(zdef call(args):z2    out = _graph_forward(_GraphSelf(), list(args))zA    return list(out) if isinstance(out, (list, tuple)) else [out]z3# 3. Driver: run the inlined captured graph eagerlyÚ_eager_forwardr�  r<  )Ú_gmr>  r=  r   ÚcodeÚreplacerX   r?  Ú_EAGER_GENERATED_HEADERrE   Útorch.fx.graphrŠ  rf   Ú
import_strrƒ  rU  r„  r…  )
r8  r:   r
  r  Ú	graph_srcrS  rR  rT  rŠ  Ú_cbs
   &         r   Ú_build_eager_python_sourcer•  Ÿ  sÉ  € Ø	�‰€Bð
  š^ˆb�kŠk°€GØ!š~ˆr�|Š|°4€HØ	‚z�W’_¨Ò(8ÜÐOÓPÐPØ—‘—‘ Ð0EÀqÓI€IÜ×'Ò'¨Ó0€KÜ×(Ò(¨Ó2€LÜ$ bÐ)€EØ	‡L�L�Ô!Ø	‡L�LÐVÔWØ	‡L�L�Ô!õ 0à×&Ñ&Ö(ˆØ�‰�S—^‘^Ö$ñ )à	‡L�L�ÔØ	‡L�L�ÔØ	‡L�LÐ$Ô%Ø	‡L�LÐ8¸¹ÀqÐIÔJØ	‡L�LÐ9¸,Ñ9IÈÐKÔLØ	‡L�L�ÔØ	‡L�L�ÔØ	‡L�LÐ"Ô#Ø	‡L�LÐEÔFØ	‡L�LÐTÔUØ	‡L�L�ÔØ	‡L�LÔ(¨Ó2Ô3Ø	‡L�L�Ô!Ø	‡L�LÐFÔGØ	‡L�L�Ô!Ø	‡L�LÔ$Ð%5Ó6Ô7Ø�9‰9�UÓÐr   zšif __name__ == "__main__":
    print("forward() is ready; call it with the model(s) and inputs the traced")
    print("fn took, e.g. forward(model, x).")
c               ó    € V ^8„  d   QhRRRR/# )r!   Úforward_fn_namer2   r$   r   )r%   s   "r   r&   r&   Ó  s   € ÷ 1ñ 1¨ð 1°ñ 1r   c                ó|  € ^ RI p^ RIHp \        W 4      pVP	                  VP
                  4      VP	                  VP                  4      VP	                  VP                  4      VP	                  V4      P                  RV  R2R^4      .pRP                  R V 4       4      pRV,           R	,           \        ,           # )
a"  Emit the runtime driver as text for inlining into python_code.

The driver lives as real, type-checked code in torch._precompile_driver; here we read
it back with inspect.getsource (LAZILY -- only on this emit path; load() never runs
it, so a stripped-source environment only affects capture, not reload) and rename the
selected forward variant to the public ``forward``. Emitting the TEXT (rather than
importing the module from the artifact) keeps python_code self-contained and
version-frozen (Note [precompile programming model], invariant 7).N)Ú_precompile_driverzdef Ú(r‰  z

c              3  ó@   "  € T F  qP                  4       x € K  	  R # 5irc   )Úrstrip)rT   Úblocks   & r   rU   Ú&_emit_driver_source.<locals>.<genexpr>é  s   é € Ð:±6¨%—|‘|—~�~³6ùrð   r�  z


)Úinspectr)   r™  rD   Ú	getsourceÚ_extract_param_buffersÚ_failÚ_check_structurer�  r…  Ú_DRIVER_MAIN)r—  rŸ  ÚdriverÚ
forward_fnÚblocksrn  s   &     r   r„  r„  Ó  s©   € ó å2ä˜Ó1€Jà×Ñ˜&×7Ñ7Ó8Ø×Ñ˜&Ÿ,™,Ó'Ø×Ñ˜&×1Ñ1Ó2Ø×Ñ˜*Ó%×-Ñ-Ø�?Ð# 1Ð% ~°qó	
ð	€Fð �;‰;Ñ:±6Ó:Ó:€DØ�$�;˜Õ!¤LÕ0Ð0r   c               ó    € V ^8„  d   QhRRRR/# r­   r   )r%   s   "r   r&   r&   í  s   € ÷ Bñ BÐ.ð B°4ñ Br   c                ó6  € ^ RI Hp V P                  P                   Fx  pVP                  R8X  g   K  \        VP                  \        P                  P                  4      '       g   KL  V! VP                  4      f   Kb  \        RVP                   24      h	  R# )að  Enforce invariant 4 of Note [precompile programming model]: reject boundary
effects the AOT backend's standalone composition does not handle. Detected
directly from the captured graph -- no AOTAutograd coupling.

Input mutation (incl. module buffers, e.g. BatchNorm running stats), tensor-
subclass wrap/unwrap, output aliasing, and functionalized RNG are SUPPORTED:
AOTAutograd's codegen'd prelude/epilogue is composed into the artifact (see
torch._functorch.aot_autograd.compile_to_python), so they are not rejected here.

Effectful ops are not supported yet (an implementation gap, not a fundamental
limit), so raise here with a concrete reason rather than let the failure surface
deep in the cache layer. See _unsupported for the mechanical cause.
)Ú_get_effectÚcall_functionNzeffectful op )Útorch._higher_order_ops.effectsrª  r@   Únodesr>   r(   rB   r)   Ú_opsÚ
OpOverloadÚ_unsupported)r:   rª  rG   s   &  r   r(  r(  í  sm   € õ <à—‘—”ˆð �7‰7�oÖ%¬*Ø�K‰KœŸ™×.Ñ.÷+
ô +
ñ ˜4Ÿ;™;Ó'Ô3Ü" ]°4·;±;°-Ð#@ÓAÐAó r   c               ó    € V ^8„  d   QhRRRR/# )r!   Úreasonr2   r$   r   r   )r%   s   "r   r&   r&     s   € ÷ ñ ˜ð  ñ r   c                ó    € \        R V  R24      # )z,precompile cannot compile this computation: z³. The graph contains an effectful op, which is not supported yet: its with_effects HOP is non-cacheable, so the compiled artifact cannot be saved and lowered to standalone source.)r   )r²  s   &r   r°  r°    s    € ÜØ
6°v°hð ?ð 	óð r   c                  ó€   € ] tR tRtRtRRRRRR/R	 R
 llt]R R l4       tR R ltR R lt	R R lt
RR R lltRtR# )r9  i  zBInternal holder for a precompiled computation / a loaded runnable.ÚbackendÚinductorÚtracerr	   rÝ   Nc          
     ó,   € V ^8„  d   QhRRRRRRRRRR	/# )
r!   rÛ   rÜ   rµ  r2   r·  rÝ   rÞ   r$   r^   r   )r%   s   "r   r&   ÚPrecompiledModule.__annotate__  sC   € ÷ 7Bñ 7Bà!ð7Bð ð	7Bð
 ð7Bð $ð7Bð 
ñ7Br   c               	ój  € Wn         W n        W0n        W@n        R V n        . V n        ^ V n        . V n        . V n        . V n	        . V n
        . V n        . V n        . V n        . V n        R V n        R V n        R V n        RV n        R V n        . V n        . V n        . V n        . V n        . V n        R V n        R # )Nr;  )Ú_fnrB  Ú_tracerÚ_decompositionsÚ	_artifactrC  rD  rE  rF  rG  rH  rI  rJ  rK  rL  r>  r=  r�  Ú_graph_pythonÚ_artifact_bytesrM  rN  rO  rP  rQ  Ú_loaded_forward)r4  rÛ   rµ  r·  rÝ   s   &&$$$r   r5  ÚPrecompiledModule.__init__  sÑ   € ð ŒØŒØŒØ-ÔØ!%ˆŒØ,.ˆÔØ)*ˆÔ!ð (*ˆÔØ(*ˆÔØ46ˆÔØ57ˆÔØ(*ˆÔØ)+ˆÔØ)+ˆÔØ*,ˆÔØ04ˆŒØ15ˆŒØ04ˆŒð #%ˆÔØ-1ˆÔð
 /1ˆÔ ð HJˆÔØ46ˆÔØ57ˆÔ ð .0ˆÔà=AˆÖr   c               ó$   € V ^8„  d   QhRRRRRR/# )r!   ÚforwardrÜ   rµ  r2   r$   r9  r   )r%   s   "r   r&   r¹  M  s(   € ÷ ñ à&ðð ð	ð
 
ñr   c               ó&   € V ! RVR7      pWn         V# )aÐ  Build a runnable from load()'s reconstructed forward.

load() does not re-run capture/_compile, so reuse ``__init__`` for all the
defaults (the single definition of this object's state) and override only the
reconstructed forward. All the calling-convention metadata lives in the inlined
driver (``forward``) itself, so the __init__ fields (``_fn``, ``_gm``,
``_module_positions``, ``_out_spec``, ...) stay at their defaults; inspect the
artifact via python_code.
N©rµ  )rÁ  )ÚclsrÄ  rµ  Úobjs   &&$ r   Ú_from_loadedÚPrecompiledModule._from_loadedL  s   € ñ  �$ Ô(ˆØ%ÔØˆ
r   c               ó    € V ^8„  d   QhRRRR/# )r!   rL   rM   r$   r^   r   )r%   s   "r   r&   r¹  `  s   € ÷ dñ dÐ/ð d°Dñ dr   c                	óø  € V P                   R 8w  d   \        RV P                   : R24      hV P                  R8X  d   \        V4      '       d   \        R4      h\	        V P
                  WP                  4      pVP                  V n        VP                  V n
        VP                  V n        VP                  V n        VP                  V n        VP"                  V n        VP&                  V n        VP*                  V n        VP.                  V n        VP2                  V n        VP6                  V n        VP:                  V n        VP>                  V n         VPB                  V n"        VPF                  V n$        VPJ                  V n&        VPN                  V n(        VPR                  V n*        V P                  R8X  d   R# ^ RI+H,u H-p ^ RI.H/p ^ RI0H1p ^ RI2H3p R	R
/pVPh                  e   \k        VR4      '       d   R
VR&    VPm                  VPR                  VPn                  VR7      w  V n8        V n9        R#   T d   p\u        R4      ThRp?iT d#   pR\w        T4      9   d   \u        R4      Thh Rp?ii ; i)r	   zprecompile tracer=z< is not implemented yet; use tracer='make_fx' (the default).Úeagerzxprecompile: mark_unbacked (dynamic shapes) is only supported with backend='inductor'; eager + unbacked is not supported.N)Úaot_autograd)ÚInductorError)ÚNoRunnableInductorModuleErrorÚsize_assertsTÚscalar_asserts)ÚoptionszÌthe inductor backend cannot lower a graph with no compute -- the traced fn returns its inputs or Python constants unchanged, producing no Inductor kernel. Return a computed tensor, or use backend='eager'.zUnexpected output typeszÜthe inductor backend cannot lower a graph whose output mixes a non-tensor Python value (e.g. float / complex / str) with computed tensors (int / bool / None outputs are fine). Return only tensors, or use backend='eager'.)<r¼  r@  rB  rZ   r/  r»  r½  r  rC  r  rD  rÔ   rE  r×   rF  r  rG  r  rH  r  rI  r  rJ  r  rK  r  rL  r  rN  r  rO  r   rP  r!  rQ  r
  r>  r  r=  r  rM  r:   r�  Útorch._inductor.configÚ	_inductorÚconfigÚtorch._functorchrÎ  Útorch._inductor.excrÏ  Ú"torch._inductor.standalone_compilerÐ  rŸ   ÚhasattrÚcompile_to_pythonr  r¿  rÀ  r   r2   )	r4  rL   ÚcaptureÚ_ind_configrÎ  rÏ  rÐ  rÓ  r.  s	   &&       r   Ú_compileÚPrecompiledModule._compile`  sV  € ð �<‰<˜9Ô$Ü%Ø$ T§\¡\Ñ$4ð 52ð 2óð ð �=‰=˜GÔ#Ô(;¸D×(AÒ(AÜ%ðIóð ô ˜4Ÿ8™8 T×+?Ñ+?Ó@ˆØ!(×!9Ñ!9ˆÔØ$+×$?Ñ$?ˆÔ!Ø#×/Ñ/ˆÔØ$×1Ñ1ˆÔØ$×1Ñ1ˆÔØ%×3Ñ3ˆÔØ$×1Ñ1ˆÔØ%×3Ñ3ˆÔØ%×3Ñ3ˆÔØ&×5Ñ5ˆÔØ")×";Ñ";ˆÔØ")×";Ñ";ˆÔØ#*×#=Ñ#=ˆÔ Ø")×";Ñ";ˆÔØŸ™ˆŒØ ×)Ñ)ˆŒØ#*×#=Ñ#=ˆÔ Ø—:‘:ˆŒà�=‰=˜GÔ#ñ
 ÷ 	5Ð4Ý1Ý5ÝTð( $2°4Ð"8ˆØ×ÑÒ(¬W°[ÐBR×-SÒ-SØ(,ˆGÐ$Ñ%ð	Ø7C×7UÑ7UØ—
‘
˜G×-Ñ-°wð 8Vó 8Ñ4ˆDÔ Ö 4øð -ô 
	ô "ðUóð ð	ûð
 ô 	ð
 )¬C°«FÔ2Ü%ð.óð
 ðð ûð	ús*   È5H: È:I9ÉIÉI9ÉI9ÉI4É4I9c               ó    € V ^8„  d   QhRRRR/# )r!   rL   r#   r$   r   )r%   s   "r   r&   r¹  Æ  s   € ÷ +ñ +˜fð +¨ñ +r   c                	óT   € V P                   f   \        R4      hV P                   ! V!  # )Nz_this object is not runnable; build one with torch.compiler.precompile.load(python_code, cache).)rÁ  r   )r4  rL   s   &*r   Ú__call__ÚPrecompiledModule.__call__Æ  s6   € ð ×ÑÒ'Ü!ðFóð ð ×#Ò# TÑ*Ð*r   c               ó   € V ^8„  d   QhRR/# ©r!   r$   r2   r   )r%   s   "r   r&   r¹  Ð  s   € ÷ >ñ > ñ >r   c                ó  € V P                   e   \        R4      hV P                  R8X  d%   V P                  f   \        R4      h\	        V 4      # V P
                  '       g   \        R4      h\        W P
                  4      # )ai  Return the self-contained, executable Python artifact as a string.

It runs on its own, needing no cache (Note [precompile programming model],
"self-contained"). For the inductor backend it embeds the composed graph
module from aot_autograd.compile_to_python (kernels JIT-compile on first
call; AOTAutograd's prelude/epilogue inlined), the calling-convention
metadata, and a ``forward()`` that takes the same args the traced fn took
(the model(s) plus runtime inputs). For the eager backend it embeds the
captured ATen graph (both readable and executable) plus a driver that runs it
eagerly. No weights are embedded.
zÈthis object was produced by torch.compiler.precompile.load(); the python_code you passed in is the source artifact (load() does not re-capture, so there is no python_code to re-emit from this object).rÍ  z-internal: not compiled; call _compile() first)rÁ  r   rB  r�  r•  r¿  r†  ©r4  s   &r   Úto_python_codeÚ PrecompiledModule.to_python_codeÐ  s{   € ð ×ÑÒ+Ü!ðWóð ð
 �=‰=˜GÔ#Ø�x‰xÒÜ%Ð&UÓVÐVÜ-¨dÓ3Ð3Ø×!×!Ð!Ü!Ð"QÓRÐRÜ# D×*<Ñ*<Ó=Ð=r   c               ó    € V ^8„  d   QhRRRR/# )r!   rW  r0   r$   Úbytesr   )r%   s   "r   r&   r¹  ê  s   € ÷ $ñ $¨*ð $Àñ $r   c                ó„  € V P                   e   \        R4      hVf   V P                  4       p\        P                  ! VP                  4       4      P                  4       p\        P                  ! 4       p\        P                  ! R\        R\        RV P                  RVRV P                  /V4       VP                  4       # )a¦  Return the binary cache as bytes -- an ACCELERATION, not required to run.

``python_code`` is the single source of truth for the calling convention, so the
cache holds only the compiled artifact plus the integrity tag and code_hash. For
the inductor backend that artifact is the ``save_cache_artifacts`` bundle (load
primes the kernel caches with it, so a warm reload skips JIT); for the eager
backend it is None. See Note [precompile programming model], invariant 7.

``python_code`` defaults to what ``to_python_code()`` would emit; ``__call__``
threads in the exact string it already built so code_hash matches the bytes
returned to the user and the metadata is not rebuilt.
z¼this object was produced by torch.compiler.precompile.load(); the cache you passed in is the source artifact (load() does not re-capture, so there is no cache to re-emit from this object).r%   Úversionrµ  Ú	code_hashÚartifact)rÁ  r   rè  ÚhashlibÚsha256ÚencodeÚ	hexdigestÚioÚBytesIOr)   ÚsaveÚ_CACHE_FORMATÚ_CACHE_VERSIONrB  rÀ  Úgetvalue)r4  rW  rî  Úbufs   &&  r   Úto_cache_bytesÚ PrecompiledModule.to_cache_bytesê  s«   € ð  ×ÑÒ+Ü!ðBóð ð
 ÒØ×-Ñ-Ó/ˆKÜ—N’N ;×#5Ñ#5Ó#7Ó8×BÑBÓDˆ	Ü�jŠj‹lˆÜ�
Š
àœ-Øœ>Ø˜4Ÿ=™=Ø˜YØ˜D×0Ñ0ðð ô		
ð �|‰|‹~Ðr   )r¾  rÀ  rB  rL  rJ  rF  rH  r½  r»  r�  rM  r¿  r>  rÁ  rC  rD  r=  rK  rI  rE  rG  r¼  rQ  rP  rO  rN  rc   )r   r   r   r   r   r5  ÚclassmethodrÉ  rÞ  râ  rè  rû  r   r   r   r   r9  r9    s\   † ÙLð7Bð "ð	7Bð
  ð7Bð '+÷7Bðr ôó ðõ&dõL+õ>÷4$ó $r   r9  c               ó    € V ^8„  d   QhRRRR/# )r!   rW  r2   r$   rÜ   r   )r%   s   "r   r&   r&     s   € ÷ ?ñ ? sð ?Ð/Dñ ?r   c                óˆ   € \         P                  R4       RR/p\        \        V RR4      V4       \	        RVR,          4      # )a,  Fallback: execute the self-contained python string (JITs kernels).

``python_code`` needs no cache -- the kernels (inductor) or graph (eager) are
inlined, so we just exec it and hand back its ``forward``. The returned
``forward`` takes the same args the traced fn took (model(s) plus runtime
inputs).zòtorch.compiler.precompile.load is about to EXEC python_code, which is untrusted executable input (it runs inlined kernels / graph code). Only exec python_code you produced or otherwise trust (Note [precompile programming model], invariant 7).r   Ú_precompiled_artifactz<precompile>ÚexecrÜ   rÄ  )rt  Úwarningr  Úcompiler   )rW  Ú	module_nss   & r   Ú_make_inlined_forwardr    sH   € ô ‡K�Kð	ôð %/Ð0GÐ#H€IÜŒ�˜n¨fÓ	5°yÔAÜÐ'¨°9Õ)=Ó>Ð>r   c                  ób   € ] tR tRtRtRt]tR R ltR R ltRR	R
RRR/R R lltR R lt	Rt
R# )Ú_PrecompileApii&  aä  Callable namespace implementing ``torch.compiler.precompile`` and ``.load``.

A single instance is exposed as ``torch.compiler.precompile``; calling it precompiles a
computation and ``torch.compiler.precompile.load`` reloads the resulting artifacts. It
is a class (rather than a function with attached attributes) so the call, the
loader, and the error type are explicit members.

The contract for both ``__call__`` and ``load`` is Note [precompile programming
model] in this module.
útorch.compilerc               ó   € V ^8„  d   QhRR/# rå  r   )r%   s   "r   r&   Ú_PrecompileApi.__annotate__9  s   € ÷ ñ ˜Cñ r   c                	ó   € R # )Ú
precompiler   rç  s   &r   Ú
__reduce__Ú_PrecompileApi.__reduce__9  s   € ñ
 r   c               ó   € V ^8„  d   QhRR/# rå  r   )r%   s   "r   r&   r
  @  s   € ÷ +ñ +˜#ñ +r   c                	ó   € R # )r   r   rç  s   &r   Ú__repr__Ú_PrecompileApi.__repr__@  s   € Ù*r   rµ  r¶  r·  r	   rÝ   Nc               ó0   € V ^8„  d   QhRRRRRRRRRR	R
R/# )r!   rÛ   rÜ   Úexample_inputsr#   rµ  r2   r·  rÝ   rÞ   r$   ztuple[str, bytes]r   )r%   s   "r   r&   r
  C  sV   € ÷ IAñ IAà!ðIAð  ðIAð ð	IAð
 ðIAð $ðIAð 
ñIAr   c               ó  € \         P                  P                  R4       VR9  d   \        RV: R24      hVR9  d   \        RV: R24      h\	        WW4R7      pVP                  V4       VP                  4       pWvP                  V4      3# )a™  Ahead-of-time precompile ``fn`` against ``example_inputs``.

.. note::

    ``torch.compiler.precompile`` is NOT
    ``torch._dynamo.config.caching_precompile`` (a ``torch.compile``
    guard-serialization caching mode); it captures ``fn`` ahead of time and
    lowers it to a self-contained Python source artifact.

With the default ``make_fx`` tracer this is a non-strict trace with an explicit
contract; read Note [precompile programming model] before using it. The artifact
faithfully reproduces ``fn`` only for callers that uphold that contract.

THREADING: the inductor lowering step drives process-global compiler state
and is serialized by an internal lock, so concurrent ``backend="inductor"``
calls lower one at a time. The make_fx capture phase and the ``backend="eager"``
path are NOT serialized.

``backend`` selects how the captured graph is realized:

- ``"inductor"`` (default): lower the graph through
  ``torch._functorch.aot_autograd.compile_to_python`` (the full AOTAutograd +
  Inductor pipeline, composed into one self-contained module). ``python_code``
  is the inlined Inductor output with AOTAutograd's prelude/epilogue; the cache
  holds the save_cache_artifacts bundle that primes the inductor cache on load.
- ``"eager"``: do NOT lower -- keep the captured ATen graph and run it as-is
  (analogous to ``torch.compile(backend="eager")``). ``python_code`` inlines
  the readable captured graph (both the inspectable rendering and the
  executable artifact); the eager cache carries no compiled artifact
  (artifact=None) but is still a full integrity-tagged envelope -- with no
  kernels there is nothing to accelerate, so ``load`` runs the inlined graph.
  Useful for
  inspecting/debugging exactly what was traced without an Inductor dependency.

``tracer`` selects the capture front-end:

- ``"make_fx"`` (default): a NON-STRICT make_fx trace -- it records the ATen ops
  that actually run when ``fn`` executes once on the example inputs and does not
  analyze your Python, so control flow and shapes are specialized to the example
  (the source of the programming-model contract). The only tracer implemented
  today.
- ``"dynamo"``: planned (a Dynamo-based front-end that analyzes the Python);
  raises ``NotImplementedError`` for now.

``decompositions`` is an optional decomposition table (a dict mapping each
``OpOverload`` to a decomposition function) forwarded to ``make_fx`` as its
``decomposition_table`` during capture, so you can control how ATen ops are
broken down in the captured graph. Defaults to ``None`` (make_fx's default).

Dynamic shapes are opt-in via ``torch._dynamo.decorators.mark_unbacked``
(inductor backend only), NOT a precompile kwarg: mark dims on the inputs before
calling, e.g. ``mark_unbacked(x, 0); precompile(fn, model, x)`` frees ``x``'s
batch dim. Marked dims are captured as UNBACKED symints, which cannot be guarded
on, so one artifact serves any runtime size of them (invariant 3); a graph that
needs to guard on / specialize a marked dim fails at capture with a
``PrecompileError``. Dims sharing a ``shape_id`` reuse one symbol (equal by
construction); ``min``/``max`` become runtime asserts. Other dims stay static.
Dims that MUST be equal at runtime (e.g. two inputs combined by a broadcast that
requires equal sizes, ``model(a) + model(b)``) MUST be given a SHARED ``shape_id``
so a mismatch is rejected; marking two such dims INDEPENDENTLY currently bakes a
SILENT equal-size assumption and a runtime mismatch does NOT raise the loud failure
eager gives (invariant 3). This is a harvesting gap, not an inherent limit of the
standalone artifact: the capture ShapeEnv DOES record the equality (as a deferred
runtime assert, e.g. ``Eq(u0, u1)``), but precompile does not yet harvest/enforce
those relational asserts in the driver -- only the decorator's declared min/max feed
the runtime bound checks. A shared ``shape_id`` is the way to get the check today.

Returns ``(python_code, cache)`` -- a self-contained, executable Python
source string (the single source of truth for the calling convention) and a
binary cache holding ONLY the backend artifact (NO metadata, NO weights).
Reload a runnable with ``torch.compiler.precompile.load(python_code, cache)``.

``fn`` is the whole computation, e.g.::

    python_code, cache = torch.compiler.precompile(
        lambda model, x: model(x), model, x
    )


    def train_step(model, x, t):
        loss_fn(model(x), t).backward()  # or return autograd.grad(...)


    python_code, cache = torch.compiler.precompile(train_step, model, x, t)

Among ``example_inputs``, the ``nn.Module`` arguments have their params/buffers
lifted to graph inputs (no weights are baked into the artifact -- invariant 1);
the rest are the runtime inputs. The reloaded callable is invoked with the SAME
argument structure -- pass the model(s) again at runtime, e.g.
``f_c(model, x)``, and that runtime model must match the example model's
parameter/buffer structure (invariant 2). Arguments are matched POSITIONALLY:
pass the model(s) and inputs positionally both here and at load time; keyword-
argument calling conventions are not supported (a fn that relies on them would
surface as a raw arity error). If ``fn`` ran a backward, the
resulting parameter gradients are scattered (accumulated) onto that runtime
model's ``parameters()`` ``.grad`` fields, exactly like eager ``.backward()``,
so a ``zero_grad()`` / ``optimizer.step()`` loop works unchanged; the artifact
returns ``fn``'s own result (``None`` for a bare ``.backward()`` step), not the
grads (invariant 5).

Input mutation (incl. module buffers, e.g. BatchNorm running stats in
training mode), tensor subclasses (e.g. DTensor), and outputs aliasing inputs
are supported -- AOTAutograd's prelude/epilogue is composed into the artifact
(invariant 4), as is functionalized RNG. Caller responsibilities NOT checked
here (see the Note): the runtime model must be structurally identical to the
example, and control flow / shapes are specialized to ``example_inputs``
(invariants 2 and 3). Violations that ARE checked raise ``PrecompileError``: a
tensor baked
as a constant (invariant 1), effectful ops (invariant 4), and -- for the
inductor backend -- a runtime input whose stride / memory format differs from
the example's (invariant 6).
r   z6precompile backend must be 'inductor' or 'eager', got r?   z5precompile tracer must be 'make_fx' or 'dynamo', got )rµ  r·  rÝ   )r¶  rÍ  )r	   Údynamo)r)   Ú_CÚ_log_api_usage_onceÚ
ValueErrorr9  rÞ  rè  rû  )r4  rÛ   rµ  r·  rÝ   r  r8  rW  s   &&$$$*  r   râ  Ú_PrecompileApi.__call__C  s¥   € ôp 	�‰×$Ñ$Ð%@ÔAØÐ/Ô/ÜØHÈÉÐSTÐUóð ð Ð.Ô.ÜØGÈÁzÐQRÐSóð ô %Ø¨ô
ˆð 	×Ñ˜.Ô)ð ×-Ñ-Ó/ˆØ×3Ñ3°KÓ@Ð@Ð@r   c               ó$   € V ^8„  d   QhRRRRRR/# )r!   rW  r2   Úcacherë  r$   rÜ   r   )r%   s   "r   r&   r
  Î  s,   € ÷ rHñ rH ð rH¨Eð rHÐ6Kñ rHr   c                ó   € ^ RI p\        V4      p\        \        VR,          4      pRp VP                  ! \
        P                  ! V4      RR7      pVP                  R4      \        8w  g   VP                  R4      \        8w  dB   \        P                  RVP                  R4      VP                  R4      \        \        4       RpVe¶   VP                  R4      V8w  d$   \        R	VP                  R4      : R
V: R24      h\        P                  ! VP                  4       4      P!                  4       pVP                  R4      V8w  d$   \        RVP                  R4      : RV: R24      hVP                  R4      pTe    TP(                  P+                  T4       \-        T4      p
\.        P1                  Y¥R7      #   \         d    h \"         d5   p	\        P                  R\%        T	4      P&                  T	4        Rp	?	L†Rp	?	ii ; i  \"         d5   p	\        P                  R\%        T	4      P&                  T	4        Rp	?	L¨Rp	?	ii ; i)aä  Reconstruct a runnable from ``(python_code, cache)`` from precompile.

The driver runs from ``python_code`` -- the single source of truth for the whole
calling convention. ``load`` reads the cache's ``BACKEND`` (to check the pairing)
and, for the inductor backend, primes the inductor kernel caches from its
``save_cache_artifacts`` bundle (via ``torch.compiler.load_cache_artifacts``) so a
warm reload loads precompiled kernels instead of JIT-compiling; then it exec's
``python_code``. With no usable cache it degrades to JIT'ing from ``python_code``.

Call the result with the SAME argument structure ``fn`` took -- the
model(s) in their original positions plus the runtime inputs. Per invariant
2 of Note [precompile programming model], the runtime model must match the
example model's parameter/buffer structure; precompile re-derives the
param/buffer list from it (same interning/order as capture).

Raises ``PrecompileError`` if ``python_code`` is malformed or is not a
``torch.compiler.precompile`` artifact (it fails to parse, or is missing the
calling-convention metadata), if the cache's ``backend`` tag does not match
``python_code``, or if the cache's ``code_hash`` does not match
``sha256(python_code)`` -- i.e. the cache and python_code came from different
``precompile()`` calls. A cache whose ``format``/``version`` does not match (a
foreign or different-build envelope) is NOT fatal: the cache is acceleration
only, so ``load`` degrades to JIT'ing from ``python_code`` rather than crashing.
NrY  T)Úweights_onlyr%   rí  z¨torch.compiler.precompile.load got a cache with format=%r version=%r, expected %r / %r; it is likely from a different torch build. Falling back to JIT from python_code.rµ  zcache backend z( does not match the python_code backend zC; the cache and python_code came from different precompile() calls.rî  z0cache does not match python_code (its code_hash z != sha256(python_code) zŠ); the cache and python_code came from different precompile() calls. Pair each cache with the python_code from the same precompile() call.rï  z­torch.compiler.precompile.load could not read the cache envelope (%s: %s); the cache is likely corrupt or from a different torch build. Falling back to JIT from python_code.zµtorch.compiler.precompile.load could not prime the cache from the artifact bundle (%s: %s); it is likely stale or from a different torch build. Falling back to JIT from python_code.rÆ  )Útorch._dynamor|  r   r2   Úloadrô  rõ  rp   r÷  rø  rt  r  r   rð  rñ  rò  ró  Ú	ExceptionÚtyper   ÚcompilerÚload_cache_artifactsr  r9  rÉ  )r4  rW  r  r)   Úmetarµ  rï  ÚblobÚexpected_code_hashr.  rÄ  s   &&&        r   r   Ú_PrecompileApi.loadÎ  s+  € ó8 	ô (¨Ó4ˆÜ”s˜D �OÓ,ˆð ˆð+	Ø—:’:œbŸjšj¨Ó/¸dÔCˆDØ�x‰x˜Ó!¤]Ô2°d·h±h¸yÓ6IÜô7ô —‘ðCð —H‘H˜XÓ&Ø—H‘H˜YÓ'Ü!Ü"ôð �ØÒØ—8‘8˜IÓ&¨'Ô1Ü)Ø(¨¯©°)Ó)<Ñ(?ð @/Ø/6©kð :BðBóð ô &-§^¢^°K×4FÑ4FÓ4HÓ%I×%SÑ%SÓ%UÐ"Ø—8‘8˜KÓ(Ð,>Ô>Ü)ØJØŸ8™8 KÓ0Ñ3Ð3KØ-Ñ0ð 1GðGóð ð  Ÿ8™8 JÓ/�ð Òð	Ø—‘×3Ñ3°HÔ=ô (¨Ó4ˆä ×-Ñ-¨gÐ-ÓGÐGøôG ô 	ØÜô 	Ü�K‰Kð+ô �Q“× Ñ Ø÷ñ ûð	ûô$ ô Ü—‘ðIô ˜“G×$Ñ$Ø÷ñ ûðús6   ªEG ÆH ÇHÇHÇ*HÈHÈIÈ*IÉIr   )r   r   r   r   r   r   r  r  râ  r   r   r   r   r   r  r  &  sY   † ñ	ð "€Jð &€Oõõ+ðIAð "ð	IAð
  ðIAð '+÷IA÷VrHñ rHr   r  r  r  zprecompile.PrecompileErrorzprecompile.loadrc   )QÚ__conditional_annotations__r   Ú
__future__r   rð  rô  ÚloggingÚtypesr   Útypingr   r   r   r   r)   Útorch.utils._pytreeÚutilsÚ_pytreerX   r   Ú"torch.fx.experimental.proxy_tensorr	   Útorch.nn.utilsr
   Útorch.utils._python_dispatchr   Ú	getLoggerr   rt  Úcollections.abcr   r   r“   r   r   Ú__annotations__r÷  rø  r˜   r   r*   r#   Ú	_MarkSpecÚdictÚ_LeafBoundsr   ÚRuntimeErrorr   r-   r4   r8   rJ   rZ   rh   rw   r‚   rŠ   r«   r±   r¶   rÙ   r/  rß   r‚  rU  r|  r†  r�  r•  r¤  r„  r(  r°  r9  r  r  r  r   râ  r   r   )r)  s   @r   Ú<module>r;     sû  øðôõX #ã Û 	Û Ý "ß 4Ó 4ã ß $Ð $Ý Ý 6Ý $Ý Fð ×Ò˜Ó!€÷ ß1å<ð €ˆÓ ð ,€Ø€ñ
 �~ sÓ+€ð �&˜# �* c¨D¥j°#¸µ*Ð<Õ=€	ð �3˜˜c D�j¨#°­*Ð4Õ5Ð5Õ6¸Õ=€ñ  0°Ó3€	ÐÓ 3ô�lô õ	õ
õ	õõ0
õ,õ^%õPõ*õ.C-õL
õ:
õ,4H÷nw÷t-#ñ -#ð`#Ð õLLõ^@õFð.Ð õ"*ðZ€õ1õ4Bõ4÷~ñ ~õB?÷*ZHñ ZHñz Ó€
ð #€
Ô Ø&€
Ô Ø#×,Ñ,×4Ñ4€
Ô ð .€Ô Ø;€Ô Ø!1€× Ñ Ô Ø#4€× Ñ Ö  r   