+
    ړLjg"                         ^ RI t ^ RIt^ RIt^ RIt^ RIHt ^ RIHt ^ RI	H
t
 ^ RIHt ^ RIt^ RIt] ! R R4      4       tRtR	 tR
 R lt]R8X  d
   ]! 4        R# R# )    N)ArgumentParser)	dataclass)Path)Listc                   T   a  ] tR t^t o RtRtRtRtRtRt	^t
^tRtRtV 3R ltRtV tR# )CompileArgsz8
A class to contain arguments from command-line parser.
 Nc                   < V ^8  d   Qh/ S[ ;R&   S[ ;R&   S[ ;R&   S[ ;R&   S[ R,          ;R&   S[;R&   S[;R&   S[ R,          ;R	&   S[R,          ;R
&   # )   pathkernel_name	signaturegridNtarget	num_warps
num_stagesout_nameout_path)strintr   )format__classdict__s   "@/app/.local/lib/python3.14/site-packages/triton/tools/compile.py__annotate__CompileArgs.__annotate__   s     
 N      N  $J      Dj  Tk       )__name__
__module____qualname____firstlineno____doc__r   r   r   r   r   r   r   r   r   __annotate_func____static_attributes____classdictcell__)r   s   @r   r   r      s@      DKIDFIJH H  r   r   a  
Triton ahead-of-time compiler:

This program compiles the kernel with name `kernel-name` in the file at the
provided `path` into self-contained C source-code that embeds the `cubin`
data along with utilities to load, unload and launch the kernel.

signature is provided as a list of (optionally divisibility-hinted) types
or constexpr values, e.g.

`compile.py --kernel-name kernel --signature "*fp32:16, i32:16, 1024, i32" --out-name kernel /path/to/kernel.py`

will compile triton.JITFunction of name `kernel` inside the file `/path/to/kernel.py`.
Said kernel will be specialized such that argument 0, 1 are assumed to be multiple of 16,
and argument 2 is assumed to be a compile-time constant of value 1024, i.e. it won't be part of the generated prototype.

The resulting entry point will have signature

CUresult kernel_{specialization_suffix}(CUstream stream, unsigned gX, unsigned gY, unsigned gZ, float* arg0, int32_t arg1, int32_t arg2)

Different such specialized entry points can be combined using the `linker.py` script.

NOTE: when resolving the scope of /path/to/kernel.py, the file will be executed from within its parent directory with the python interpreter
used to run this `compile.py` script
c            	      L   \        \        R 7      p V P                  RRR7       V P                  RR\        RRRR	7       V P                  R
R\        RRR7       V P                  RR\        ^RR7       V P                  RR\        ^RR7       V P                  RR\        RRR7       V P                  RR\
        RRR7       V P                  RR\        RRR7       V P                  RR \        R!RR7       V P                  4       p\        R"/ \        V4      B p\        V4       R# )#)descriptionr   zTPath to Python source containing desired kernel in its scope. File will be executed.)helpz--kernel-namez-nr	   zName of the kernel to compileT)typedefaultr(   requiredz--targetz-tNzThe target to compile towards, in format of '<backend>:<arch>:<warp-size>'; e.g., 'cuda:80:32', 'hip:gfx942:64'. Default to None, which means using current machine's GPU target)r)   r*   r(   z--num-warpsz-wz$Number of warps to launch the kernelz--num-stagesz-nsz/Number of stages (meta-parameter of the kernel)z
--out-namez-onz Out name for the compiled kernelz
--out-pathz-ozOut filenamez--signaturez-szSignature of the kernel)r)   r(   r+   z--gridz-gzLaunch grid of the kernelr   )
r   descadd_argumentr   r   r   
parse_argsr   varscompile_kernel)parsercli_argsargss      r   mainr4   9   s4   -F
s  u
CJi!%  '
DsDo  p t#qGmn
CN  P
e#tJlm
dt.Y
t#<U`de
$S7R]ab  "H(h(D4r   c                $    V ^8  d   QhR\         /# )r   r3   )r   )r   s   "r   r   r   P   s     # # #r   c                 t   V P                   '       d   V P                   MV P                  pV P                  '       d   V P                  M
\        V4      p\        V P                  4      p\
        P                  P                  ^ \        VP                  4      4       \        P                  P                  VP                  V4      p\        P                  P                  V4      pVP                  P                  V4       \!        WPP                  4      pV P"                  P%                  R4      p\'        V4      ^8X  g   Q h\)        \+        R V P,                  P%                  R4      4      4      pR R lp	RV P.                   RV P0                   2p
V	! W.,           4      pR p\3        V4       UUu/ uF.  w  rRV9   g   K  V3V! VP%                  R4      ^,          4      bK0  	  pppVP5                  4        UUu/ uF  w  ppVf   K  VVbK  	  ppp\3        V4       UUu/ uF  w  rVP6                  V,          V! V4      bK!  	  pppVP5                  4        UUu/ uF  w  ppVf   K  VVbK  	  pppVP5                  4        F,  w  ppV^8X  g   K  VVVP6                  V^ ,          ,          &   K.  	  \3        V4       UUu/ uF/  w  rVP6                  V,          VP%                  R4      ^ ,          bK1  	  pppV F  pR
VV&   K
  	  RP9                  VP;                  4        Uu. uF  p\        V4      NK  	  up4      pVP5                  4        UUu. uF  w  ppV RV 2NK  	  pppVRV P.                   2RV P0                   2.,          pVP;                  4        F  pVR:9   d   K  Q RV 24       h	  VP5                  4        UUu/ uF  w  ppV^8X  g   K  VR^..bK  	  pppVP=                  4        VP?                  VVVVR7      pV P@                  '       dB   \B        PD                  PF                  PH                  ! V P@                  P%                  R4      !  M1\B        PJ                  PL                  PN                  PQ                  4       p\B        PF                  PS                  V4      pRV P.                  RV P0                  /pVPU                  V4      p\B        PV                  ! VVVPX                  R7      p\!        VPZ                  R^ 4      ^ 8  d   \]        R4      hVPZ                  P^                  ^ 8  d   \]        R4      h. p. p . p!. p"\3        VP6                  4       F  w  pp#V#V9  dU   VPa                  V#4       V Pa                  VV#,          4       V!Pa                  V#4       V"Pa                  VV#,          4       Ka  VPc                  V3R	4      ^8X  g   K{  VPa                  V#4       V Pa                  R4       K  	  Rp$\3        VP;                  4       4       FP  w  pp%VPc                  V3R	4      ^8X  d   V$V R2,          p$VPc                  V3R	4      ^8X  g   KD  V$V R2,          p$KR  	  RP9                  WV$.4      p&VPd                  VPf                  ,          p'\        \h        Pj                  ! V'4      4      ^R; p(\B        PJ                  PL                  PN                  Pl                  p)VPn                  p*/ RV&bRV P                  bR\'        V'4      bR R!P9                  \q        V(R",          V(R#,          4       U+U,u. uF  w  p+p,R$V+ V, 2NK  	  up,p+4      bR%R!P9                  \q        V!V"4       U-U%u. uF  w  p-p%V)! V%4       R&V- 2NK  	  up%p-4      bR'R!P9                  \q        VV 4       U-U%u. uF  w  p-p%V)! V%4       R&V- 2NK  	  up%p-4      bR(R!P9                  V! U.u. uF  p.R)V. 2NK
  	  up.R*.,           R+.,           4      bR,\'        V!4      ^,           bR-VbR.VPZ                  Pr                  bRV P.                  bR/RP9                  VV
.4      bR0V^ ,          bR1V^,          bR2V^,          bR3RbR4VPt                  bR5V*/Cp/. p0\        \v        4      P                  R6,          V*,          p1V1Py                  R74       F  p2V2Pz                  p3VP}                  R8V RV$ V3 24      p4V4P                  R94      ;_uu_ 4       p5V5P                  V2P                  4       P                  ! R</ V/B 4       R	R	R	4       V0Pa                  V44       K  	  V&V03# u uppi u uppi u uppi u uppi u uppi u upi u uppi u uppi u up,p+i u up%p-i u up%p-i u up.i   + '       g   i     Lo; i)=r   ,c                 $    V P                  R 4      # ) )strip)ss   &r   <lambda> compile_kernel.<locals>.<lambda>_   s    1773<r   c                :    V ^8  d   QhR\         \        ,          /# )r   r   )r   r   )r   s   "r   r   $compile_kernel.<locals>.__annotate__a   s     ! !$s) !r   c                     \         P                  ! 4       pVP                  R P                  V 4      P	                  4       4       VP                  4       R,          # )r9   :N   N)hashlibsha256updatejoinencode	hexdigest)r   ms   & r   hash_signature&compile_kernel.<locals>.hash_signaturea   s=    NN	)$++-.{{}R  r   warpsxstagesc                      \        V 4      pV#   \         d     Mi ; i \        T 4      pT#   \         d     R # i ; i)N)r   
ValueErrorfloat)r;   rets   & r   	constexpr!compile_kernel.<locals>.constexpri   sO    	a&CJ 			(CJ 		s    . ==:NrQ   x=z
num_warps=znum_stages=z#Only 1 and 16 are valid hints, got ztt.divisibility)fn
constexprsr   attrsr   r   )r   optionsglobal_scratch_sizezMAOT compiling kernels with global scratch requirements is not yet implementedzNAOT compiling kernels with profile scratch requirements is not yet implementedi32r	   cd_r   triton_kernel_namebin_sizebin_dataz, :NNr   :   Nr   0xr   r9   full_signaturearg_pointers&z&global_scratchz&profile_scratchnum_argskernel_docstringshared	algo_infogridXgridYgridZ_placeholder	warp_sizebackend_nameextraz	compile.*.w)rb      r   )Cr   r   r   r   r   sysinsertr   parent	importlibutilspec_from_file_locationstemmodule_from_specloaderexec_modulegetattrr   splitlenlistmapr   r   r   	enumerateitems	arg_namesrE   valuescreate_binder	ASTSourcer   tritonbackendscompiler	GPUTargetruntimedriveractiveget_current_targetmake_backendparse_optionscompile__dict__metadataRuntimeErrorprofile_scratch_sizeappendgetasm
binary_extbinasciihexlifymap_python_to_cpp_typebackendzipri   ro   __file__globsuffixwith_suffixopenwrite	read_textr   )6r3   r   r   arg_pathspecmodkernelr   r   rI   meta_sigsig_hashrQ   ir;   hintskv	constantskeyvalue	const_sig
doc_stringhrX   srcr   r   kwargsrY   ccinfor   	arg_typesarg_names_not_1arg_types_not_1arg_namer   ty	func_namer   hex_	ty_to_cpprp   rT   ynameargparamsoutput_filestemplate_dirtemplate_pathextoutput_filefps6   &                                                     r   r0   r0   P   s    $t}}43C3CH $t}}4>H DIIHHHOOAs8??+,>>11(--JD
..
)
)$
/CKKC S**+F99??3Dt9>> S/1E1Ec1JKLI!
 t~~&gdoo->?Hi*45H <EY;O\;O41SVZ[S[.aUIaggcl1o..;OE\#kkm=mdaqTQTmE=?H?ST?Stq!!!$il2?SIT"+//"3E"3$!QqA"3IEkkm
UA:27If&&s1v./ $ CLIBVWBV$!!!!$aggcl1o5BVIW$	# )*:*:*<=*<Q#a&*<=>I)2):;):AQCq*):J;Z/0K?P2QRRJ\\^G|FB1#FF| 6;kkmOmdaqBw)Q#R())mEO



fiW\

]C;;; __%%//1B1B31GH"NN1188KKM oo**62G4>><IF##F+G^^C8H8HIFv 5q9A=jkk++a/kllIIOO !1!1289$X&Yx01""8,""9X#67YYud#q(X&U# 3 F9++-.299aUD!Q&1gF99aUD!R'1gF	 /
 (f56I
**W''
(Cx$%a+D%%,,CCI>>Lyd.. 	CH 	DIIs49d4j7QR7Qtq!A3qc{7QRS	
 	TYY#o_nJopJohdB9R=/4& 9Jopq 	$))sS\^gOh$iOh84	"av%>Oh$ij 			"HQse9"HL]K^"^btau"uv 	C(1, 	J 	&//(( 	T^^ 	SXXy(34 	a 	a 	a  	!" 	V%%#$ 	%F( L>((72\AL%**;7""**Qxj&#+GHc""bHH],,.55??@ #K( 8 l""s ]=TE X >;
 P` Sp$i"H$ #"sl   3e!$e!=	e'e'#%e-	e3,e35e9'e?ff

f
ff>f/f"0f''f7__main__)r   rB   importlib.utilry   rv   argparser   dataclassesr   pathlibr   typingr   r   triton.backendsr   r,   r4   r0   r   r   r   r   <module>r      sc       
 # !     ! ! !6.#D zF r   