ó
    “~iÌ  ã                   óü  • S SK Jr  SSKJr  SSKJr  \R                  " S5      r\\4S\R                  4S jj5       r\\4S\R                  4S jj5       r	\\4S\R                  4S	 jj5       r
\\4S\R                  4S
 jj5       r\S 5       r\\4S\R                  4S jj5       r\\4S\R                  4S jj5       r\S 5       r\\4S\R                  4S jj5       r\\4S\R                  4S jj5       rg)é   )Újité   )Úcore)Úmathé
   Ún_roundsc                 ó*  • U R                   [        R                  :X  a	  SnSnSn	Sn
O:[        R                  " U R                   [        R                  :H  S5        SnSnSn	S	n
[        R
                  " U5       H•  nU	nU
nXpþ[        R                  " Xß5      U-  U-  n [        R                  " XÎ5      U-  U-  n[        R                  " XßS
S9n[        R                  " XÎS
S9n[        R                  " XGS
S9n[        R                  " XXS
S9nM—     XX#4$ )zN
Run `n_rounds` rounds of Philox for state (c0, c1, c2, c3) and key (k0, k1).
l   ¹yn< l   ….Ïv l   S¢$ l   W= z"dtype not supported in philox_impll   |”~åf»q	 l   ;'•	:=[ l   “l˜B;: l   W$*Ž	ÔR F)Úsanitize_overflow)
ÚdtypeÚtlÚuint32Ústatic_assertÚuint64Ústatic_ranger   ÚumulhiÚmulÚadd)Úc0Úc1Úc2Úc3Úk0Úk1r   ÚPHILOX_KEY_AÚPHILOX_KEY_BÚPHILOX_ROUND_AÚPHILOX_ROUND_BÚ_ÚAÚBÚ_c0Ú_c2s                   ÚS/home/mande/repo/quber/.venv/lib/python3.13/site-packages/triton/language/random.pyÚphilox_implr$      sú   € ð
 
‡x�x”2—9‘9ÓØ%/ˆØ%/ˆØ'1ˆØ'1‰ä
×Ò˜Ÿ™¤R§Y¡YÑ.Ð0TÔUØ%7ˆØ%7ˆØ'9ˆØ'9ˆä�_Š_˜XÖ&ˆð ˆØˆØˆSÜ�[Š[˜Ó  2Ñ%¨Ñ*ˆÜ�[Š[˜Ó  2Ñ%¨Ñ*ˆÜ�VŠV�A¨eÑ4ˆÜ�VŠV�A¨eÑ4ˆä�VŠV�B¸Ñ>ˆÜ�VŠV�B¸Ñ>Šñ 'ð �2ˆ>Ðó    c           	      óô  • [         R                  " U 5      n [         R                  " U R                  R	                  5       5        U R                  [         R                  5      n [         R                  " U5      n[         R                  " U5      n[         R                  " U5      n[         R                  " U5      n[         R                  " UR                  R                  5      S:X  aX  [         R                  nU S-	  S-  R                  [         R                  5      nU S-  R                  [         R                  5      nOj[         R                  " [         R                  " UR                  R                  5      S:H  S5        [         R                  n[         R                  " SSUS9nU nUR                  USS	9nUR                  USS	9nUR                  USS	9nUR                  USS	9n[        XX4X‡U5      $ )
Né    l   ÿÿ é@   z bitwidth not supported in philox)r   é    )r   T©Úbitcast)r   Ú	to_tensorr   r   Úis_intÚtor   Ú	constexprÚprimitive_bitwidthr   Úfullr$   )	Úseedr   r   r   r   r   Ú	int_dtypeÚseed_hiÚseed_los	            r#   Úphiloxr6   -   sq  € ä�<Š<˜Ó€DÜ×Ò�T—Z‘Z×&Ñ&Ó(Ô)Ø�7‰7”2—9‘9Ó€DÜ	�Š�bÓ	€BÜ	�Š�bÓ	€BÜ	�Š�bÓ	€BÜ	�Š�bÓ	€Bä	‡|‚|�B—H‘H×/Ñ/Ó0°BÓ6Ü—I‘Iˆ	Ø˜B‘J *Ñ,×0Ñ0´·±Ó;ˆØ˜*Ñ$×(Ñ(¬¯©Ó3‰ä
×ÒœŸš b§h¡h×&AÑ&AÓBÀbÑHÐJlÔmÜ—I‘Iˆ	Ü—'’'˜% ¨)Ñ4ˆØˆà	�‰ˆy $ˆÐ	'€BØ	�‰ˆy $ˆÐ	'€BØ	�‰ˆy $ˆÐ	'€BØ	�‰ˆy $ˆÐ	'€BÜ�r˜r w¸ÓBÐBr%   c                 ó(   • [        XU5      u  n    nU$ )aU  
Given a :code:`seed` scalar and an :code:`offset` block, returns a single
block of random :code:`int32`.

If you need multiple streams of random numbers,
using `randint4x` is likely to be faster than calling `randint` 4 times.

:param seed: The seed for generating random numbers.
:param offset: The offsets to generate random numbers for.
)Ú	randint4x)r2   Úoffsetr   Úretr   s        r#   Úrandintr;   H   s   € ô ˜T¨8Ó4�L€CˆˆAˆqØ€Jr%   c                 ó
  • UR                  [        R                  5      nUS-  n[        R                  " UR                  R
                  5      S:”  a#  US-	  R                  [        R                  5      nOUn[        XXTXB5      $ )a9  
Given a :code:`seed` scalar and an :code:`offset` block, returns four
blocks of random :code:`int32`.

This is the maximally efficient entry point
to Triton's Philox pseudo-random number generator.

:param seed: The seed for generating random numbers.
:param offsets: The offsets to generate random numbers for.
r)   r'   )r.   r   r   r/   r   r0   r6   )r2   r9   r   Ú	offset_loÚ_0Ú	offset_his         r#   r8   r8   X   sf   € ð —	‘	œ"Ÿ)™)Ó$€IØ	�Q‰€Bä	‡|‚|�F—L‘L×3Ñ3Ó4°rÓ9Ø˜r‘\×%Ñ%¤b§i¡iÓ0‰	àˆ	ä�$ 9°"Ó?Ð?r%   c                 óœ  • [         R                  " U R                  [         R                  :H  5      (       d6  [         R                  " U R                  [         R                  :H  5      (       a!  U R                  [         R                  SS9n SnO�[         R                  " [         R                  " U R                  [         R                  :H  5      =(       d1    [         R                  " U R                  [         R                  :H  5      5        U R                  [         R                  SS9n Sn[         R                  " U S:  U * S-
  U 5      n X-  $ )zg
Numerically stable function to convert a random uint into a random float uniformly sampled in [0, 1).
Tr*   gýïÿÿÿ=g   Àÿÿÿ;r)   r   )
r   r/   r   r   Úint32r.   r   r   Úint64Úwhere)ÚxÚscales     r#   Úuint_to_uniform_floatrF   ~   s×   € ô 
‡|‚|�A—G‘GœrŸy™yÑ(×)Ñ)¬R¯\ª\¸!¿'¹'ÄRÇXÁXÑ:M×-NÑ-Nà�D‰D”—‘ 4ˆDÐ(ˆØ ‰ä
×ÒœŸš a§g¡g´·±Ñ&:Ó;×`¼r¿|º|ÈAÏGÉGÔWY×W_ÑW_ÑL_Ó?`ÔaØ�D‰D”—‘ 4ˆDÐ(ˆØ&ˆÜ
�Š��Q‘˜˜˜Q™ Ó"€AØ‰9Ðr%   c                 ó0   • [        XU5      n[        U5      $ )zê
Given a :code:`seed` scalar and an :code:`offset` block,
returns a block of random :code:`float32` in :math:`U(0, 1)`.

:param seed: The seed for generating random numbers.
:param offsets: The offsets to generate random numbers for.
)r;   rF   )r2   r9   r   Úsources       r#   ÚrandrI   ’   s   € ô �T 8Ó,€FÜ  Ó(Ð(r%   c                 ó€   • [        XU5      u  p4pV[        U5      n[        U5      n[        U5      n	[        U5      n
XxXš4$ )zì
Given a :code:`seed` scalar and an :code:`offsets` block,
returns 4 blocks of random :code:`float32` in :math:`U(0, 1)`.

:param seed: The seed for generating random numbers.
:param offsets: The offsets to generate random numbers for.
)r8   rF   )r2   Úoffsetsr   Úi1Úi2Úi3Úi4Úu1Úu2Úu3Úu4s              r#   Úrand4xrT   Ÿ   sF   € ô ˜t¨hÓ7�N€BˆBÜ	˜rÓ	"€BÜ	˜rÓ	"€BÜ	˜rÓ	"€BÜ	˜rÓ	"€BØ�2ˆ>Ðr%   c                 óø   • [         R                  " SU 5      n SU-  n[        R                  " S[        R                  " U 5      -  5      nU[        R
                  " U5      -  U[        R                  " U5      -  4$ )zBox-Muller transformgH¯¼šò×z>g-DTû!@g       À)r   Úmaximumr   ÚsqrtÚlogÚcosÚsin)rP   rQ   ÚthÚrs       r#   Úpair_uniform_to_normalr]   µ   s^   € ô 
�Š�F˜BÓ	€BØ	˜RÑ	€BÜ�	Š	�$œŸš "›Ñ%Ó&€AØŒt�xŠx˜‹|Ñ˜Q¤§¢¨"£Ñ-Ð-Ð-r%   c                 ól   • [        XU5      u  p4  n[        U5      n[        U5      n[        Xg5      u  p…U$ )zô
Given a :code:`seed` scalar and an :code:`offset` block,
returns a block of random :code:`float32` in :math:`\mathcal{N}(0, 1)`.

:param seed: The seed for generating random numbers.
:param offsets: The offsets to generate random numbers for.
)r8   rF   r]   )	r2   r9   r   rL   rM   r   rP   rQ   Ún1s	            r#   Úrandnr`   ¾   s;   € ô ˜T¨8Ó4�L€BˆAˆqÜ	˜rÓ	"€BÜ	˜rÓ	"€BÜ" 2Ó*�E€BØ€Ir%   c                 ó\   • [        XU5      u  p4pV[        X45      u  px[        XV5      u  pšXxXš4$ )zõ
Given a :code:`seed` scalar and an :code:`offset` block,
returns 4 blocks of random :code:`float32` in :math:`\mathcal{N}(0, 1)`.

:param seed: The seed for generating random numbers.
:param offsets: The offsets to generate random numbers for.
)rT   r]   )r2   r9   r   rP   rQ   rR   rS   r_   Ún2Ún3Ún4s              r#   Úrandn4xre   Î   s6   € ô ˜D¨(Ó3�N€BˆBÜ# BÓ+�F€BÜ# BÓ+�F€BØ�2ˆ>Ðr%   N)Úruntime.jitr   Ú r   r   r   r/   ÚN_ROUNDS_DEFAULTr$   r6   r;   r8   rF   rI   rT   r]   r`   re   © r%   r#   Ú<module>rj      s]  ðÝ Ý Ý à—<’< Ó#Ð ð ØAQñ °"·,±,ô ó ðð@ Ø:Jñ C¨2¯<©<ô Có ðCð4 Ø3Cñ  B§L¡Lô ó ðð Ø5Eñ @ b§l¡lô @ó ð@ðJ ñó ðð& Ø0@ñ 	) §¡ô 	)ó ð	)ð Ø3Cñ  B§L¡Lô ó ðð* ñ.ó ð.ð Ø1Añ  "§,¡,ô ó ðð Ø3Cñ  B§L¡Lô ó ñr%   