� 2��gP���ddlmZddlmZddlmZdZeefdejfd���Zeefdejfd���Z eefdejfd ���Z eefdejfd ���Z ed ���Z eefdejfd ���Z eefdejfd ���Zed���Zeefdejfd���Zeefdejfd���ZdS)�)�jit�)�core)�math� �n_roundsc�|�|jtjkr d}d}d} d} n0tj|jtjkd��d}d}d} d } tj|��D]T} | } | } ||}}t j| |��|z |z }t j| |��|z |z }| |z}| |z}||z}||z}�U||||fS) zV Run `n_rounds` rounds of Philox for state (c0, c1, c2, c3) and key (k0, k1). l�yn<l�.�vlS�$lW =z"dtype not supported in philox_impll|�~�f�q l;'� :=[ l�l�B;: lW$*� �R )�dtype�tl�uint32� static_assert�uint64� static_ranger�umulhi)�c0�c1�c2�c3�k0�k1r� PHILOX_KEY_A� PHILOX_KEY_B�PHILOX_ROUND_A�PHILOX_ROUND_B�_�A�B�_c0�_c2s �f/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/triton/language/random.py� philox_implr! s���  �x�2�9���%/� �%/� �'1��'1��� ����R�Y�.�0T�U�U�U�%7� �%7� �'9��'9�� �_�X� &� &� � �� �� ���r�S�� �[��C� � �2� %�� *�� �[��C� � �2� %�� *�� ��W�� ��W�� �,� �� �,� ��� �r�2�r�>��c ��tj|��}tj|��}tj|��}tj|��}tj|��}|�tj��}tj|jj��dkrTtj}|dz dz�tj��}|dz�tj��}nZtjtj|jj��dkd��tj}tj dd|���}|}|�|d� ��}|�|d� ��}|�|d� ��}|�|d� ��}t|||||||��S) N� l���@z bitwidth not supported in philox)r�)r T��bitcast) r � to_tensor�tor� constexprr �primitive_bitwidthr r �fullr!) �seedrrrrr� int_dtype�seed_hi�seed_los r �philoxr2-ss�� �<�� � �D� ��b� � �B� ��b� � �B� ��b� � �B� ��b� � �B� �7�7�2�9� � �D� �|�B�H�/�0�0�B�6�6��I� ��B�J�*�,�0�0���;�;���*�$�(�(���3�3��� ����b�h�&A�B�B�b�H�Jl�m�m�m��I� ��'�%��)�4�4�4���� ���y�$�� '� '�B� ���y�$�� '� '�B� ���y�$�� '� '�B� ���y�$�� '� '�B� �r�2�r�2�w��� B� B�Br"c�2�t|||��\}}}}|S)aq 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)r.�offsetr�retrs r �randintr7Es"���T�6�8�4�4�L�C��A�q� �Jr"c�4�|dz}t||||||��S)aU 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&)r2)r.r5r�_0s r r4r4Us%�� �!��B� �$���B��H� 5� 5�5r"c�2�tj|jtjk��s'tj|jtjk��r$|�tjd���}d}n�tjtj|jtjk��p&tj|jtjk����|�tjd���}d}tj |dk| dz |��}||zS)zo 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_floatr@ss��� �|�A�G�r�y�(�)�)�'�R�\�!�'�R�X�:M�-N�-N�'� �D�D���4�D� (� (�� ��� ����a�g���&:�;�;�`�r�|�A�G�WY�W_�L_�?`�?`�a�a�a� �D�D���4�D� (� (��&�� ���Q����Q���"�"�A� �u�9�r"c�B�t|||��}t|��S)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. )r7r@)r.r5r�sources r �randrC�s#���T�6�8� ,� ,�F� �� (� (�(r"c��t|||��\}}}}t|��}t|��}t|��} t|��} ||| | fS)a 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. )r4r@) r.�offsetsr�i1�i2�i3�i4�u1�u2�u3�u4s r �rand4xrN�s_���t�W�h�7�7�N�B��B�� �r� "� "�B� �r� "� "�B� �r� "� "�B� �r� "� "�B� �r�2�r�>�r"c���tjd|��}d|z}tjdtj|��z��}|tj|��z|tj|��zfS)zBox-Muller transformgH�����z>g-DT�!@g�)r �maximumr�sqrt�log�cos�sin)rJrK�th�rs r �pair_uniform_to_normalrW�s`�� ��F�B� � �B� �R� �B� � �$���"���%�&�&�A� �t�x��|�|� �Q���"���-� -�-r"c��t|||��\}}}}t|��}t|��}t||��\}}|S)a 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. )r4r@rW) r.r5rrFrGrrJrK�n1s r �randnrZ�sO���T�6�8�4�4�L�B��A�q� �r� "� "�B� �r� "� "�B� "�2�r� *� *�E�B�� �Ir"c��t|||��\}}}}t||��\}}t||��\} } ||| | fS)a  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. )rNrW) r.r5rrJrKrLrMrY�n2�n3�n4s r �randn4xr_�sQ���D�&�(�3�3�N�B��B�� #�B�� +� +�F�B�� #�B�� +� +�F�B�� �r�2�r�>�r"N)� runtime.jitr�rr r�N_ROUNDS_DEFAULTr+r!r2r7r4r@rCrNrWrZr_�r"r �<module>rds�����������������������AQ���"�,�������@�:J�C�C�2�<�C�C�C���C�.�3C� � �B�L� � � ��� ��5E� 6� 6�b�l� 6� 6� 6��� 6�:������&�0@� )� )��� )� )� )��� )��3C� � �B�L� � � ��� �*�.�.���.��1A� � �"�,� � � ��� ��3C� � �B�L� � � ��� � � r"
Memory