+
    –°³j!J  ã                  ól  a € 0 t $ R t^ RIHt ^ RIHt ^ RIt^ RIH	u H
t
 ]'       d~   . tR]R&   ^ tR]R&   . tR]R	&   . tR]R
&   . tR]R&   . tR]R&   . tR]R&   . tR]R&   . tR]R&   . tR]R&   . tR]R&   RtR]R&   RtR]R&   . tR]R&   . tR]R&   . tR]R&   . tR]R&   R R  ltR! tR" tR# t R$ t!R% t"R# )&a#  Runtime driver for torch.compiler.precompile artifacts, authored as real code.

Nothing here is imported or run by torch at runtime, and the generated artifacts never
import this module. Instead torch._precompile emits these function bodies VERBATIM (via
inspect.getsource, on the to_python_code / emit path only) into the self-contained
python_code string, after the calling-convention metadata and the compiled/captured
graph. Authoring the driver as real code -- instead of a hand-written string literal --
lets pyrefly / ruff / IDEs type-check and navigate the load-bearing driver logic that
would otherwise be invisible inside a string (and drops the wall of ``# noqa: F821``).

Keeping python_code self-contained and version-frozen (its behavior is hashed via
code_hash, invariant 7) still holds: the artifact carries the driver TEXT, it does not
import it, so there is no torch-version skew. The emit path runs getsource in-process
where torch source is present; load() never touches this module.

The names the emitted bodies read from the artifact's own namespace -- the metadata
constants, the ``_torch`` / ``_pytree`` import aliases, and the graph's ``call`` -- are
declared under TYPE_CHECKING below so the bodies type-check here; at emit time they
resolve against the metadata + graph sections that precede the driver in python_code.

INVARIANT: ``_extract_param_buffers`` reproduces
``torch._precompile._intern_param_buffers``'s params-then-buffers, intern-by-identity
ordering VERBATIM; the two must stay in sync (see Note [precompile programming model]).
)Úannotations)ÚTYPE_CHECKINGNz	list[int]ÚMODULE_POSITIONSÚintÚNUM_POSITIONAL_ARGSz	list[str]ÚPARAM_NAMESÚBUFFER_NAMESzlist[tuple[int, ...]]ÚPARAM_SHAPESÚBUFFER_SHAPESÚPARAM_DTYPESÚBUFFER_DTYPESÚPARAM_DEVICESÚBUFFER_DEVICESÚGRAD_PARAM_INDICESz
str | NoneÚIN_SPECÚ ÚstrÚOUT_SPECz#list[tuple[int | None, ...] | None]ÚUSER_INPUT_SHAPESzlist[str | None]ÚUSER_INPUT_DTYPESÚUSER_INPUT_DEVICESz5list[dict[int, tuple[int | None, int | None]] | None]ÚUSER_INPUT_BOUNDSc               ó    € V ^8„  d   QhRRRR/# )é   Úflat_inputszlist[object]Úreturn© )Úformats   "ÚY/home/luca/screen-checking/.venv/lib/python3.14/site-packages/torch/_precompile_driver.pyÚ__annotate__r   :   s   € ×<Ñ<˜,Ð<¨<Ñ<ó    c                ó   € R # ©Nr   )r   s   &r   Úcallr#   :   s   € ¹r    c                ó<  aaa	a
€ \        V 4      ^8„  o\        4       o
. o	. oVVV	V
3R lp\        V 4       F)  w  r#VP                  RR7       F  w  rEV! W$V4       K  	  K+  	  \        V 4       F)  w  r#VP	                  RR7       F  w  rFV! W$V4       K  	  K+  	  S	S3# )aH  Lift the runtime modules' params then buffers, interning by identity, in the
same order as capture, so the list lines up with the compiled/captured graph. Returns
(pb, names) where names mirrors PARAM_NAMES + BUFFER_NAMES. This ordering AND the
naming must match torch._precompile._intern_param_buffers verbatim (its INVARIANT).c                óÄ   <€ \        V4      S9  dO   SP                  \        V4      4       SP                  V4       SP                  S'       d	   R V  RV 2MT4       R# R# )ÚmÚ.N)ÚidÚaddÚappend)ÚmiÚnÚtÚmultiÚnamesÚpbÚseens   &&&€€€€r   ÚinternÚ&_extract_param_buffers.<locals>.internG   sJ   ø€ Üˆa‹5˜ÔØ�H‰H”R˜“UŒOØ�I‰I�aŒLØ�L‰L¯˜1˜R˜D  ! ™°AÖ6ñ r    F)Úremove_duplicate)ÚlenÚsetÚ	enumerateÚnamed_parametersÚnamed_buffers)Úmodsr2   r+   r&   r,   ÚpÚbr.   r/   r0   r1   s   &      @@@@r   Ú_extract_param_buffersr=   =   s¢   û€ ô
 �‹I˜‰M€EÜ‹5€DØ	€BØ€E÷7ð 7ô ˜4–‰ˆØ×&Ñ&¸Ð&Ö>‰DˆAÙ�2˜!Öó ?ñ !ô ˜4–‰ˆØ—O‘O°U�OÖ;‰DˆAÙ�2˜!Öó <ñ !ð ˆuˆ9Ðr    c                ó   € ^ RI Hp V! V 4      h)é    )ÚPrecompileError)Útorch._precompiler@   )ÚmsgÚ_PrecompileErrors   & r   Ú_failrD   V   s   € õ Fá
˜3Ó
Ðr    c                ó  € \        \        4      \        \        4      ,           pW8w  d   \        R V: RV: R24       \        \        4      \        \
        4      ,           p\        \        4      \        \        4      ,           p\        \        4      \        \        4      ,           p\        WW4V4       FÒ  w  rgr‰p
\        VP                  4      \        V4      8w  d3   \        RV: R\        VP                  4       R\        V4       R24       \        VP                  4      V	8w  d!   \        RV: RVP                   RV	 R24       \        VP                  4      V
8w  g   K²  \        RV: RVP                   RV
 R24       KÔ  	  R# )	z3precompile: the runtime model's param/buffer names z! do not match the traced model's zU; the runtime model must be structurally identical to the traced model (invariant 2).z%precompile: the runtime param/buffer z has shape z but the traced model's was z has dtype z is on device N)Úlistr   r   rD   r	   r
   r   r   r   r   ÚzipÚtupleÚshaper   ÚdtypeÚdevice)r0   r/   ÚexpectedÚexpected_shapesÚexpected_dtypesÚexpected_devicesÚ_nmÚ_tÚ_shpÚ_dtÚ_devs   &&         r   Ú_check_structurerU   ^   so  € ô ”KÓ ¤4¬Ó#5Õ5€HØÔÜØAÀ%Áð K"Ø"*¡ð .;ð<ô	
ô
 œ<Ó(¬4´Ó+>Õ>€OÜœ<Ó(¬4´Ó+>Õ>€OÜœMÓ*¬T´.Ó-AÕAÐÜ$'Ø�?Ð5Eö%Ñ ˆ�˜Dô �—‘‹?œe D›kÔ)ÜØ7¸±w¸kÜ˜Ÿ™“?Ð#Ð#?ÄÀdÃ¸}ð MZð[ôô
 ˆr�x‰x‹=˜CÔÜØ7¸±w¸kÈ"Ï(É(Èð T*Ø*-¨ð /?ð@ôô
 ˆr�y‰y‹>˜TÖ!ÜØ7¸±w¸nÈRÏYÉYÈKð X.Ø.2¨Vð 4LðMöó!%r    c            
     óî  € \        V 4      \        8w  d    \        R\         R\        V 4       R24       . p\         Fu  p\	        W,          \
        P                  P                  4      '       g,   \        RV R\        W,          4      P                   R24       VP                  W,          4       Kw  	  \        V 4       UUu. uF  w  r4V\        \        4      9  g   K  VNK  	  ppp\        P                  ! \        V4      4      w  rg\         e+   V\        P"                  ! \         4      8w  d   \        R4       \        V4      \        \$        4      8w  d   \        R	4       \'        V\$        \(        \*        4       EF<  w  r‰r«V	e!   \	        V\
        P,                  4      '       g   K-  \        VP.                  4      p\        V4      \        V	4      8w  gM   \0        ;QJ d%    R
 \'        WÉ4       4       F  '       g   K   RM	  RM! R
 \'        WÉ4       4       4      '       d   \        RV R\        V	4       R24       V
e7   \3        VP4                  4      V
8w  d   \        RVP4                   RV
 R24       Vf   EK  \3        VP6                  4      V8w  g   EK   \        RVP6                   RV R24       EK?  	  \9        V4      w  rÞ\;        WÞ4       \
        P<                  ! 4       ;_uu_ 4        \?        \A        . VOVO4      4      pRRR4       \B        '       d�   \        \B        4      pX\        V4      V,
          R pVR\        V4      V,
           p\'        \B        V4       FA  w  ppVV,          pVPD                  f
   VVn"        K&  VPD                  PG                  V4       KC  	  \        PH                  ! X\        P"                  ! \J        4      4      # u uppi   + '       g   i     Lß; i)aå  Run the captured ATen graph eagerly. Pass the same args the traced fn took --
the module(s) in the same positions plus the runtime inputs. The module(s) must
be structurally identical to the ones precompile traced (same param/buffer order
and tying); only the weight values may differ.

The eager backend runs the graph as captured: inputs (including tensor
subclasses) are passed through unchanged (no dense flatten/unflatten), and the
graph's flat outputs are reassembled into fn's output structure. If fn ran a
backward, the trailing grad outputs (one per GRAD_PARAM_INDICES entry) are
parameter grads, scattered (accumulated) onto the params that received one like
eager .backward() -- frozen / non-contributing params keep .grad = None.úprecompile: expected ú2 positional args (the same as the traced fn), got ú (invariant 2).ú!precompile: argument at position ú= must be the nn.Module the traced fn took (invariant 2), got r'   Nú‰precompile: runtime inputs have a different structure than the traced example inputs (invariant 3); they must match in nesting and count.ú‘precompile: runtime inputs flattened to a different number of leaves than the traced example (invariant 3); they must match the traced structure.c              3  ó.   "  € T F  w  rW8g  x € K  	  R # 5ir"   r   ©Ú.0ÚaÚes   &  r   Ú	<genexpr>Ú!_eager_forward.<locals>.<genexpr>¸   s   é € Ð(L¹O±D°A¨®»Oùs   ‚TFú&precompile: a runtime input has shape ú( but the artifact was traced with shape zl; the graph is specialized to the static dims (invariant 3). Retrace for this shape, or use backend='eager'.ú&precompile: a runtime input has dtype ú( but the artifact was traced with dtype ún; the graph is specialized to the example dtype (invariant 6). Cast the input to the traced dtype, or retrace.ú)precompile: a runtime input is on device ú' but the artifact was traced on device úp; the graph is specialized to the example device (invariant 6). Move the input to the traced device, or retrace.)&r5   r   rD   r   Ú
isinstanceÚ_torchÚnnÚModuleÚtypeÚ__name__r*   r7   r6   Ú_pytreeÚtree_flattenrH   r   Útreespec_loadsr   rG   r   r   ÚTensorrI   Úanyr   rJ   rK   r=   rU   Úno_gradrF   r#   r   ÚgradÚadd_Útree_unflattenr   )Úargsr:   Ú_iÚira   Úuser_inputsÚ	user_flatÚ_runtime_in_specrQ   rR   rS   rT   Ú_actr0   Ú_namesÚoutr,   ÚgradsÚidxÚgr;   s   *                    r   Ú_eager_forwardrˆ   ‡   s@  € ô ˆ4ƒyÔ'Ô'ÜØ#Ô$7Ð#8ð 9#Ü#& t£9 +¨_ð>ô	
ð €DßˆÜ˜$�(¤F§I¡I×$4Ñ$4×5Ò5ÜØ3°B°4ð 8.Ü.2°4µ8«n×.EÑ.EÐ-FÀaðIôð 	�‰�D•HÖñ ô "+¨4¤ÔS¡™˜°A¼SÔAQÓ=RÑ4R—1�1¡€KÑSÜ")×"6Ò"6´u¸[Ó7IÓ"JÑ€IÜÒÐ/´7×3IÒ3IÌ'Ó3RÔRÜðRô	
ô ˆ9ƒ~œÔ.Ó/Ô/ÜðVô	
ô  #ØÔ$Ô&7Ô9K÷ Ñˆ�#ð Š<œz¨"¬f¯m©m×<Ò<ÙÜ�R—X‘X‹ˆÜˆt‹9œ˜D›	Ô!§S£SÑ(L¼CÀ¼OÓ(L§S§S¢SÑ(L¼CÀ¼OÓ(L×%LÒ%LÜØ8¸¸ð ?%Ü%*¨4£[ Mð 2VðWôð
 Š?œs 2§8¡8›}°Ô3ÜØ8¸¿¹¸
ð C%Ø%( Eð *QðRôð
 Õ¤ B§I¡I£°$× 6ÜØ;¸B¿I¹I¸;ð G(Ø(, vð .YðZ÷ñ' ô0 (¨Ó-�J€BÜ�RÔ Ü	�Š×	Õ	Ü”4Ð)˜"Ð)˜yÐ)Ó*Ó+ˆ÷ 
çÓÜÔ"Ó#ˆØ”C˜“H˜q•L�NÐ#ˆØ�.”C˜“H˜q•LÐ!ˆÜÔ,¨eÖ4‰FˆC�Ø�3•ˆAØ�v‰vŠ~Ø�–à—‘—‘˜A–ñ 5ô ×!Ò! #¤w×'=Ò'=¼hÓ'GÓHÐHùóq T÷X 
×	ús   ÃOÃ OË4O$Ï$O4	c                 ó¸	  € \        V 4      \        8w  d    \        R\         R\        V 4       R24       . p\         Fu  p\	        W,          \
        P                  P                  4      '       g,   \        RV R\        W,          4      P                   R24       VP                  W,          4       Kw  	  \        V 4       UUu. uF  w  r4V\        \        4      9  g   K  VNK  	  ppp\        P                  ! \        V4      4      w  rg\         e+   V\        P"                  ! \         4      8w  d   \        R4       \        V4      \        \$        4      8w  d   \        R	4       \'        V\$        \(        \*        \,        4       EF½  w  r‰r«pV	e!   \	        V\
        P.                  4      '       g   K.  \        VP0                  4      p\        V4      \        V	4      8w  gM   \2        ;QJ d%    R
 \'        WÙ4       4       F  '       g   K   RM	  RM! R
 \'        WÙ4       4       4      '       d   \        RV R\        V	4       R24       V
e7   \5        VP6                  4      V
8w  d   \        RVP6                   RV
 R24       VeB   \5        VP8                  4      V8w  d(   \        R\5        VP8                  4      : RV: R24       Vf   EKI  VP;                  4        F`  w  pw  ppVP0                  V,          pVe   VV8  d   \        RV RV RV R24       Vf   KB  VV8”  g   KK  \        RV RV RV R24       Kb  	  EKÀ  	  \=        V4      w  pp\?        VV4        \A        \C        . VOVO4      4      p\F        '       d�   \        \F        4      pT\        T4      T,
          R pTR\        T4      T,
           p\'        \F        T4       FA  w  ppTT,          pTPH                  f
   TTn$        K&  TPH                  PK                  T4       KC  	  \        PL                  ! T\        P"                  ! \N        4      4      # u uppi   \D         dˆ   p\5        T4      pRT9   d   RT9   g	   RT9   g   h \2        ;QJ d     R \$         4       F  '       g   K   RM	  RM! R \$         4       4      pRpT'       d
   RT9   d   R p\        R!T R"T 24       h Rp?ii ; i)#a  Run the compiled computation. Pass the same args the traced fn took -- the
module(s) in the same positions plus the runtime inputs. The module(s) must be
structurally identical to the ones precompile traced (same param/buffer order
and tying); only the weight values may differ.

Module params/buffers are extracted (no weights are baked into the artifact) and,
together with the runtime inputs, passed to the composed ``call`` -- which is the
AOTAutograd+Inductor graph with its own prelude/epilogue, so it handles tensor-
subclass wrap/unwrap and input mutation (e.g. BatchNorm running stats) internally
and disables grad itself. If fn ran a backward, the trailing grad outputs (one per
GRAD_PARAM_INDICES entry) are parameter grads: they are scattered (accumulated)
onto the params that received one, mirroring eager .backward() (frozen /
non-contributing params keep .grad = None), and the artifact returns fn's own
result. Nothing here reads an external cache: the kernels JIT-compile from the
inlined source on first call. A runtime input whose shape, dtype, or device differs
from the traced example is rejected up front (invariants 3 and 6), and a differing
stride / memory format is rejected via the inlined assert_size_stride (invariant 6);
use backend="eager" for layout-flexible execution.rW   rX   rY   rZ   r[   r'   Nr\   r]   c              3  óF   "  € T F  w  rVR J;'       d    W8g  x € K  	  R # 5ir"   r   r_   s   &  r   rc   Ú$_inductor_forward.<locals>.<genexpr>  s&   é € ð )
Ù1@©¨ˆA�TˆM×$Ð$˜a™fÔ$³ùs   ‚!”!TFre   rf   z¦ (None = a dynamic dim, any size); the graph is specialized to the static dims (invariant 3). Retrace, mark the dim dynamic via mark_unbacked, or use backend='eager'.rg   rh   ri   rj   rk   rl   zprecompile: runtime input dim z
 has size z  but mark_unbacked declared min=z (invariant 3).z  but mark_unbacked declared max=zexpected sizeÚstridezwrong number of dimensionsc              3  ó    "  € T FD  qR J;'       d5    \         ;QJ d    R V 4       F  '       g   K   RM	  RM! R V 4       4      x € KF  	  R # 5i)Nc              3  ó(   "  € T F  qR J x € K
  	  R # 5ir"   r   )r`   Ú_ds   & r   rc   Ú._inductor_forward.<locals>.<genexpr>.<genexpr>O  s   é € Ð";¹°"¨¥:»ùs   ‚TF)rw   )r`   Ú_ss   & r   rc   r‹   N  s<   é € ð 
ÙFWÀ�dˆN×;Ð;Ÿs›sÑ";¹Ó";ŸsŸsšsÑ";¹Ó";Ó;Ô;ÓFWùs   ‚A‘A�A±Ar   z± If two inputs share a mark_unbacked shape_id, their marked dims are bound to one symbol and so MUST have equal sizes at runtime; this can also be a shape_id equality violation.a  precompile: a runtime tensor's shape or memory format differs from the traced example; the inductor backend specializes on input shape and memory format (invariants 3 and 6). The mismatch can be a user INPUT or a model PARAMETER/BUFFER whose layout (memory format) differs from the example weight, since the inductor backend also bakes each param/buffer's layout. Pass the model/inputs in the example's shape and layout (.contiguous() to match a contiguous example, or match the example weight's layout), or use backend='eager'.z Underlying: )(r5   r   rD   r   rm   rn   ro   rp   rq   rr   r*   r7   r6   rs   rt   rH   r   ru   r   rG   r   r   r   rv   rI   rw   r   rJ   rK   Úitemsr=   rU   rF   r#   ÚAssertionErrorr   ry   rz   r{   r   )r|   r:   r}   r~   ra   r   r€   r�   rQ   rR   rS   rT   Ú_bndr‚   r�   Ú_loÚ_hiÚ_szr0   rƒ   r„   Ú_eÚ_mÚ_has_dynamicÚ_shape_id_noter,   r…   r†   r‡   r;   s   *                             r   Ú_inductor_forwardrœ   Û   sˆ  € ô& ˆ4ƒyÔ'Ô'ÜØ#Ô$7Ð#8ð 9#Ü#& t£9 +¨_ð>ô	
ð €DßˆÜ˜$�(¤F§I¡I×$4Ñ$4×5Ò5ÜØ3°B°4ð 8.Ü.2°4µ8«n×.EÑ.EÐ-FÀaðIôð 	�‰�D•HÖñ ô "+¨4¤ÔS¡™˜°A¼SÔAQÓ=RÑ4R—1�1¡€KÑSÜ")×"6Ò"6´u¸[Ó7IÓ"JÑ€IÜÒÐ/´7×3IÒ3IÌ'Ó3RÔRÜðRô	
ô ˆ9ƒ~œÔ.Ó/Ô/ÜðVô	
ô &)ØÜÜÜÜ÷&Ñ!ˆ�#˜Tð Š<œz¨"¬f¯m©m×<Ò<Ùä�R—X‘X‹ˆÜˆt‹9œ˜D›	Ô!§S£Sñ )
Ü14°T´ó)
§S§S¢Sñ )
Ü14°T´ó)
÷ &
ò &
ô Ø8¸¸ð ?%Ü%*¨4£[ Mð 2MðNôð Š?œs 2§8¡8›}°Ô3ÜØ8¸¿¹¸
ð C%Ø%( Eð *QðRôð
 Ò¤ B§I¡I£°$Ô 6ÜØ;¼CÀÇ	Á	»NÑ;Mð N1Ø15±ð 9ðôð ÕØ"&§*¡*¦,‘�‘J�S˜#Ø—h‘h˜r•l�Ø’? s¨S¤yÜØ8¸¸¸JÀsÀeð L6Ø69°U¸/ðKôð ”? s¨S¦yÜØ8¸¸¸JÀsÀeð L6Ø69°U¸/ðKöô #/ñE&ô\ (¨Ó-�J€BˆÜ�R˜Ô ð+Ü”4Ð)˜"Ð)˜yÐ)Ó*Ó+ˆ÷V ÓÜÔ"Ó#ˆØ”C˜“H˜q•L�NÐ#ˆØ�.”C˜“H˜q•LÐ!ˆÜÔ,¨eÖ4‰FˆC�Ø�3•ˆAØ�v‰vŠ~Ø�–à—‘—‘˜A–ñ 5ô ×!Ò! #¤w×'=Ò'=¼hÓ'GÓHÐHùók TøôB ô )ô �‹Wˆà Ô" x°2¤~Ø+¨rÔ1à÷ “sñ 
ÝFWó
—s—s’sñ 
ÝFWó
ó 
ˆð ˆß˜O¨rÔ1ð9ð ô
 	ðð  .Ð.¨m¸B¸4ðAô		
ð 	ûðS)ús6   ÃQÃ QÍ Q ÑSÑ+SÑ>SÒ"SÒ9SÓS)#Ú__conditional_annotations__Ú__doc__Ú
__future__r   Útypingr   Útorchrn   Útorch.utils._pytreeÚutilsrs   r   Ú__annotations__r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r#   r=   rD   rU   rˆ   rœ   )r�   s   @r   Ú<module>r¥      sþ   øðôõ2 #å  ã ß %Ð %÷ ð
 #%Ð�iÓ$Ø Ð˜Ó Ø€K�ÓØ €L�)Ó Ø*,€LÐ'Ó,Ø+-€MÐ(Ó-Ø €L�)Ó Ø!€M�9Ó!Ø!€M�9Ó!Ø "€N�IÓ"Ø$&Ð˜	Ó&Ø€GˆZÓØ€HˆcÓØ=?ÐÐ:Ó?Ø*,ÐÐ'Ó,Ø+-ÐÐ(Ó-ØOQÐÐLÓQõ =òò2 ò&òRQIôhUIr    