+
    "Ý³jÁ3  ã                   ó  a € R t0 t ^ RIt^ RIHt ^ RIHt ^ RIHtHtH	t	 ^ RI
t
]! RR7       ! R R4      4       tRs] ^ k ]! 4       tR	 R
 ltR R ltRR R llt^€]
P"                  3R R llt^€]
P"                  3R R lltRR R lltR# )é    N)Ú	dataclass)ÚLock)ÚCallableÚOptionalÚTupleT)Úfrozenc                   ó,   a € ] tR t^t o V 3R ltRtV tR# )Ú_BlockwiseFp8Implsc                ó–   <€ V ^8„  d   Qh/ S[ ;R&   S[S[,          ;R&   S[S[,          ;R&   S[S[,          ;R&   S[S[,          ;R&   # )é   Ú	availableÚgemmÚ	act_quantÚweight_quantÚweight_dequant)Úboolr   r   )ÚformatÚ__classdict__s   "€Úf/home/luca/screen-checking/.venv/lib/python3.14/site-packages/torchao/kernel/blockwise_quantization.pyÚ__annotate__Ú_BlockwiseFp8Impls.__annotate__   sW   ø‡ ‚ á�Oñ ñ ‘8Õ
Ññ ñ ™Õ!Ñ!ñ	 ñ
 ™8Õ$Ñ$ñ ñ ™XÕ&Ñ&ò ó    © N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__annotate_func__Ú__static_attributes__Ú__classdictcell__)r   s   @r   r
   r
      s   ø‡ ‡ „ r   r
   c                ó$   € V ^8„  d   QhR\         /# ©r   Úreturn©r
   )r   s   "r   r   r      s   € ÷ 	ñ 	Ô-ñ 	r   c                  ó    € \         p V f0   \        ;_uu_ 4        \         p V f   \        4       p V s R R R 4       V # V #   + '       g   i     T # ; i)N)Ú_triton_implsÚ_triton_impls_lockÚ_build_triton_impls)Úimplss    r   Ú_get_triton_implsr*      sI   € ä€EØ‚}ßÖÜ!ˆEØŠ}Ü+Ó-�Ø %�÷	  ð
 €Lˆ5€L÷  Öð
 €Lús	   ™<¼A	c                ó$   € V ^8„  d   QhR\         /# r"   r$   )r   s   "r   r   r   (   s   € ÷ Añ AÔ/ñ Ar   c                  ó’  aaa€ ^ RI Hp  V ! 4       '       g   \        RRRRR4      # ^ RIo^ RIHo ^ RIHp R UUUu. uF$  pR F  pR F  pV! RVRV/V^R7      NK  	  K  	  K&  	  ppppSP                  V. ROR7      SP                  V3R	 lV3R
 ll4       4       o\        P                  P                  RRR7      RR VV3R lll4       pVP                  RR l4       pSP                  V3R lV3R ll4       pSP                  V3R lV3R ll4       p	SP                  V3R lV3R ll4       p
\        RVVV	V
R7      # u upppi )r   )Ú
has_tritonFN)ÚConfigÚBLOCK_SIZE_MÚBLOCK_SIZE_N)Ú
num_stagesÚ	num_warps)ÚconfigsÚkeyc                óª   <€ V ^8„  d   QhRSP                   RSP                   RSP                   RSP                   RSP                   RSP                   /# )r   ÚNÚKÚM_BUCKETr/   r0   ÚBLOCK_SIZE_K©Ú	constexpr)r   Útls   "€r   r   Ú)_build_triton_impls.<locals>.__annotate__C   sa   ø€ ÷ *'ñ *'ð �<‰<ð*'ð �<‰<ð*'ð —,‘,ð*'ð —l‘lð*'ð —l‘lð*'ð —l‘lñ*'r   c                 ó‚  <€ SP                  ^ R7      pSP                  ^R7      pSP                  W{4      pWÉ,          SP                  ^ V	4      ,           V,          pWÚ,          SP                  ^ V
4      ,           V,          pSP                  ^ V4      pWR,          V,          ,           VR,          ,           pVVR,          V,          ,           VR,          ,           pW?V,          ,           pVVV,          V,          ,           pSP                  Wš3SP                  R7      p\        V4       FÖ  pSP                  VVR,          VVV,          ,
          8  RR7      pSP                  VVR,          VVV,          ,
          8  RR7      pSP                  V4      pSP                  V4      pVSP                  VV4      VR,          ,          VR,          ,          ,          pVV,          pVV,          pV^,          pV^,          pKØ  	  VP                  VP                  P                  4      pWÉ,          SP                  ^ V	4      ,           pWÚ,          SP                  ^ V
4      ,           pW/R,          V,          ,           VR,          ,           pVR,          V8  VR,          V8  ,          pSP                  VVVR7       R# )	r   ©ÚaxisN©Údtypeg        )ÚmaskÚother©rC   ©ºNNNN©NrG   )Ú
program_idÚcdivÚarangeÚzerosÚfloat32ÚrangeÚloadÚdotÚtorB   Ú
element_tyÚstore) Úa_ptrÚb_ptrÚc_ptrÚa_s_ptrÚb_s_ptrÚMr6   r7   r8   r/   r0   r9   Úpid_mÚpid_nÚkÚoffs_mÚoffs_nÚoffs_kÚa_ptrsÚb_ptrsÚa_s_ptrsÚb_s_ptrsÚaccumulatorÚiÚaÚbÚa_sÚb_sÚcÚc_ptrsrC   r<   s    &&&&&&&&&&&&                   €r   Úblockwise_fp8_gemm_kernelÚ6_build_triton_impls.<locals>.blockwise_fp8_gemm_kernel?   sD  ø€ ð$ —‘ 1�Ó%ˆØ—‘ 1�Ó%ˆØ�G‰G�AÓ$ˆØÕ&¨¯©°1°lÓ)CÕCÀqÕHˆØÕ&¨¯©°1°lÓ)CÕCÀqÕHˆØ—‘˜1˜lÓ+ˆØ �¨1Õ,Õ,¨v°g­Õ>ˆØ˜ �¨1Õ,Õ,¨v°g­Õ>ˆØ a�ZÕ'ˆØ˜f¨Õ4¸Õ9Õ9ˆà—h‘h Ð;À2Ç:Á:�hÓNˆÜ�q–ˆAØ—‘˜ V¨G¥_°q¸1¸|Õ;KÕ7KÑ%KÐSV�ÓWˆAØ—‘˜ V¨G¥_°q¸1¸|Õ;KÕ7KÑ%KÐSV�ÓWˆAØ—'‘'˜(Ó#ˆCØ—'‘'˜(Ó#ˆCØ˜2Ÿ6™6 ! Q›<¨#¨g­,Õ6¸¸W½ÕEÕEˆKØ�lÕ"ˆFØ�lÕ"ˆFØ˜�MˆHØ˜�MŠHñ ð �N‰N˜5Ÿ;™;×1Ñ1Ó2ˆØÕ%¨¯	©	°!°\Ó(BÕBˆØÕ%¨¯	©	°!°\Ó(BÕBˆØ �¨1Õ,Õ,¨v°g­Õ>ˆØ�w• !Ñ#¨¨w­¸!Ñ(;Õ<ˆØ
�‰�˜ ˆÖ&r   zao::blockwise_fp8_gemm)Úmutates_argsc                óÄ   € V ^8„  d   QhR\         P                  R\         P                  R\         P                  R\         P                  R\        R\         P                  /# ©r   rf   rh   rg   ri   Ú
block_sizer#   ©ÚtorchÚTensorÚint)r   s   "r   r   r=   p   sX   € ÷ ñ Ü�<‰<ðä�\‰\ðô �<‰<ðô �\‰\ð	ô
 ðô 
�‰ñr   c                 ó:  <a	a
€ V P                  4       '       g   Q hVP                  4       '       g   Q hVP                  4       '       g   Q hVP                  4       '       g   Q hV P                  R4      pV P                  4       V,          o	VP                  ^ 4      o
\        P                  ! \        P
                  ! S	4      4      pV P                  ! . V P                  4       RR OS
N5R\        P                  / pV	V
V3R lpSV,          ! WWqVS	S
WVVR7
       V# )é   NrB   c                 óh   <€ SP                  SV R ,          4      SP                  SV R,          4      3# )r/   r0   ©rJ   )ÚMETArY   r6   Útritons   &€€€r   Ú<lambda>ÚE_build_triton_impls.<locals>._blockwise_fp8_gemm_op.<locals>.<lambda>€   s.   ø€ Ø�K‰K˜˜4 Õ/Ó0Ø�K‰K˜˜4 Õ/Ó0ñ
r   )r9   éÿÿÿÿ)	Úis_contiguousÚsizeÚnumelÚmathÚceilÚlog2Ú	new_emptyrs   Úbfloat16)rf   rh   rg   ri   rq   r7   r8   rj   ÚgridrY   r6   rl   r{   s   &&&&&    @@€€r   Ú_blockwise_fp8_gemm_opÚ3_build_triton_impls.<locals>._blockwise_fp8_gemm_opo   së   ú€ ð �‰× Ò Ð Ð Ø�‰× Ò Ð Ð Ø× Ñ ×"Ò"Ð"Ð"Ø× Ñ ×"Ò"Ð"Ð"Ø�F‰F�2‹JˆØ�G‰G‹I˜�NˆØ�F‰F�1‹IˆÜ—9’9œTŸYšY q›\Ó*ˆØ�KŠKÐ@˜Ÿ™› # 2˜Ð@¨Ò@´·±Ñ@ˆö
ˆð 	" $Ö'Ø�!˜#˜q ! Q¸zõ	
ð ˆr   c                 ó”   € VP                  ^ 4      pV P                  ! . V P                  4       RR OVN5R\        P                  / pV# )r   NrB   r~   )r€   r…   rs   r†   )rf   rh   rg   ri   rq   r6   rj   s   &&&&&  r   Ú_Ú_build_triton_impls.<locals>._‰   s?   € à�F‰F�1‹IˆØ�KŠKÐ@˜Ÿ™› # 2˜Ð@¨Ò@´·±Ñ@ˆØˆr   c                ó2   <€ V ^8„  d   QhRSP                   /# ©r   Ú
BLOCK_SIZEr:   )r   r<   s   "€r   r   r=   �   s   ø€ ÷ !ñ !Ø)+¯©ñ!r   c                óÒ  <€ S	P                  ^ R7      pWC,          S	P                  ^ V4      ,           pS	P                  W,           4      P                  S	P                  4      pS	P                  S	P                  V4      4      R,          pWg,          pVP                  VP                  P                  4      pS	P                  W,           V4       S	P                  W$,           V4       R# )aÙ  
Quantizes the input tensor `x_ptr` and stores the result in `y_ptr` and the scaling factor in `s_ptr`.

Args:
    x_ptr (triton.Pointer): Pointer to the input tensor.
    y_ptr (triton.Pointer): Pointer to the output tensor where quantized values will be stored.
    s_ptr (triton.Pointer): Pointer to the output tensor where scaling factors will be stored.
    BLOCK_SIZE (tl.constexpr): The size of the block to be processed by each program instance.

Returns:
    None
r?   ç      |@N)
rI   rK   rO   rQ   rM   ÚmaxÚabsrB   rR   rS   )
Úx_ptrÚy_ptrÚs_ptrr�   ÚpidÚoffsÚxÚsÚyr<   s
   &&&&     €r   Ú$_fp8_blockwise_act_quant_kernel_implÚA_build_triton_impls.<locals>._fp8_blockwise_act_quant_kernel_impl�   s¦   ø€ ð  �m‰m ˆmÓ#ˆØÕ "§)¡)¨A¨zÓ":Õ:ˆØ�G‰G�E•LÓ!×$Ñ$ R§Z¡ZÓ0ˆØ�F‰F�2—6‘6˜!“9Ó Õ%ˆØ�EˆØ�D‰D�—‘×'Ñ'Ó(ˆØ
�‰�•˜qÔ!Ø
�‰�•˜aÖ r   c                ó2   <€ V ^8„  d   QhRSP                   /# rŽ   r:   )r   r<   s   "€r   r   r=   ©   s   ø€ ÷ /ñ /Ø/1¯|©|ñ/r   c                óî  <€ SP                  ^ R7      pSP                  ^R7      pSP                  WE4      pWe,          SP                  ^ V4      ,           p	Wu,          SP                  ^ V4      ,           p
V	R,          V,          V
R,          ,           pV	R,          V8  V
R,          V8  ,          pSP                  W,           VR7      P	                  SP
                  4      pSP                  SP                  V4      4      R,          pWÞ,          pVP	                  VP                  P                  4      pSP                  W,           WüR7       SP                  W&V,          ,           V,           V4       R# )a"  
Quantizes the input tensor `x_ptr` and stores the result in `y_ptr` and the scaling factors in `s_ptr`.

Args:
    x_ptr (tl.pointer): Pointer to the input tensor.
    y_ptr (tl.pointer): Pointer to the output tensor where quantized values will be stored.
    s_ptr (tl.pointer): Pointer to the output tensor where scaling factors will be stored.
    M (int): Number of rows in the weight matrix.
    N (int): Number of columns in the weight matrix.
    BLOCK_SIZE (tl.constexpr): The size of the block to be processed by each program instance.
r?   NrE   r‘   rF   rH   )rI   rJ   rK   rO   rQ   rM   r’   r“   rB   rR   rS   )r”   r•   r–   rY   r6   r�   rZ   r[   Únr]   r^   r˜   rC   r™   rš   r›   r<   s   &&&&&&          €r   Ú'_fp8_blockwise_weight_quant_kernel_implÚD_build_triton_impls.<locals>._fp8_blockwise_weight_quant_kernel_impl¨   s  ø€ ð —‘ 1�Ó%ˆØ—‘ 1�Ó%ˆØ�G‰G�AÓ"ˆØÕ# b§i¡i°°:Ó&>Õ>ˆØÕ# b§i¡i°°:Ó&>Õ>ˆØ�g� Õ" V¨G¥_Õ4ˆØ�w• !Ñ#¨¨w­¸!Ñ(;Õ<ˆØ�G‰G�E•L tˆGÓ,×/Ñ/°·
±
Ó;ˆØ�F‰F�2—6‘6˜!“9Ó Õ%ˆØ�EˆØ�D‰D�—‘×'Ñ'Ó(ˆØ
�‰�•˜qˆÔ,Ø
�‰� �Õ" UÕ*¨AÖ.r   c                ó2   <€ V ^8„  d   QhRSP                   /# rŽ   r:   )r   r<   s   "€r   r   r=   Æ   s   ø€ ÷ -ñ -Ø/1¯|©|ñ-r   c                óT  <€ SP                  ^ R7      pSP                  ^R7      pSP                  WE4      pWe,          SP                  ^ V4      ,           p	Wu,          SP                  ^ V4      ,           p
V	R,          V,          V
R,          ,           pV	R,          V8  V
R,          V8  ,          pSP                  W,           VR7      P	                  SP
                  4      pSP                  WV,          ,           V,           4      pWÞ,          pSP                  W+,           WüR7       R# )aÍ  
Dequantizes weights using the provided scaling factors and stores the result.

Args:
    x_ptr (tl.pointer): Pointer to the quantized weights.
    s_ptr (tl.pointer): Pointer to the scaling factors.
    y_ptr (tl.pointer): Pointer to the output buffer for dequantized weights.
    M (int): Number of rows in the weight matrix.
    N (int): Number of columns in the weight matrix.
    BLOCK_SIZE (tl.constexpr): Size of the block for tiling.

Returns:
    None
r?   NrE   rF   rH   )rI   rJ   rK   rO   rQ   rM   rS   )r”   r–   r•   rY   r6   r�   rZ   r[   r    r]   r^   r˜   rC   r™   rš   r›   r<   s   &&&&&&          €r   Ú)_fp8_blockwise_weight_dequant_kernel_implÚF_build_triton_impls.<locals>._fp8_blockwise_weight_dequant_kernel_implÅ   sì   ø€ ð$ —‘ 1�Ó%ˆØ—‘ 1�Ó%ˆØ�G‰G�AÓ"ˆØÕ# b§i¡i°°:Ó&>Õ>ˆØÕ# b§i¡i°°:Ó&>Õ>ˆØ�g� Õ" V¨G¥_Õ4ˆØ�w• !Ñ#¨¨w­¸!Ñ(;Õ<ˆØ�G‰G�E•L tˆGÓ,×/Ñ/°·
±
Ó;ˆØ�G‰G�E A�IÕ%¨Õ-Ó.ˆØ�EˆØ
�‰�•˜qˆÖ,r   T)r   r   r   r   r   )é   é    é@   é€   )r¨   r©   rª   )é   é   é   é   )r6   r7   r8   r9   r   ©rª   )Útorch.utils._tritonr-   r
   r{   Útriton.languageÚlanguager.   ÚautotuneÚjitrs   ÚlibraryÚ	custom_opÚregister_fake)r-   r.   Úblock_mÚblock_nr1   Úfp8_gemm_configsrˆ   r‹   rœ   r¡   r¥   rl   r<   r{   s              @@@r   r(   r(   (   s„  ú€ Ý.á�<Š<Ü! %¨¨t°T¸4Ó@Ð@ãÝ Ýñ )õ	ñ )ˆGÛ$ˆGÛ&ˆJñ 	Ø˜W n°gÐ>Ø!Ø÷	
ñ 'ñ	
ñ %ñ	
ñ
 )ð ò 	ð ‡_�_Ø Ò&Lð ó ð ‡Z�Z÷*'ò *'ó óð*'ôX ‡]�]×ÑÐ5ÀBÐÓG÷ò ó Hðð2 ×)Ñ)óó *ðð
 ‡Z�Z÷!ò !ó ð!ð0 ‡Z�Z÷/ò /ó ð/ð8 ‡Z�Z÷-ò -ó ð-ô: ØØ#Ø6Ø<Ø@ôð ùô_	s   ¼*Ec                óÄ   € V ^8„  d   QhR\         P                  R\         P                  R\         P                  R\         P                  R\        R\         P                  /# rp   rr   )r   s   "r   r   r   ì   sX   € ÷ 
2ñ 
2Ü‡|�|ð
2ä	�‰ð
2ô ‡|�|ð
2ô 
�‰ð	
2ô
 ð
2ô ‡\�\ñ
2r   c                 óv   € \        4       pVP                  '       g   \        R 4      hVP                  WW#V4      # )úunsupported without triton)r*   r   ÚAssertionErrorr   )rf   rh   rg   ri   rq   r)   s   &&&&& r   Úblockwise_fp8_gemmr¿   ì   s4   € ô Ó€EØ�?�?ˆ?ÜÐ9Ó:Ð:Ø�:‰:�a˜a jÓ1Ð1r   c          
      óº   € V ^8„  d   QhR\         P                  R\        R\         P                  R\        \         P                  \         P                  3,          /# )r   r™   rq   rB   r#   )rs   rt   ru   rB   r   )r   s   "r   r   r   ù   sF   € ÷ #ñ #Ü‡|�|ð#Ü!$ð#Ü38·;±;ð#ä
Œ5�<‰<œŸ™Ð%Õ&ñ#r   c                óR  a a€ \        4       pVP                  '       g   \        R4      h^ RIoS P	                  4       '       g   Q R4       hS P                  R4      V,          ^ 8X  g   Q RV R24       hV\        P                  \        P                  39   g   Q R4       h\        P                  ! S VR7      pS P                  ! . S P                  4       RR OS P                  R4      V,          N5R\        P                  / pVV 3R	 lpVP                  V,          ! S WEVR
7       WE3# )a‚  
Quantizes the input tensor `x` using block-wise quantization with block size being BLOCK_SIZEx1.

Args:
    x (torch.Tensor): The input tensor to be quantized. Must be contiguous and its last dimension size must be divisible by `block_size`.
    block_size (int, optional): The size of the blocks to be used for quantization. Default is 128.
    dtype (torch.dtype, optional): The dtype to use for the quantized tensor. Default is `torch.float8_e4m3fn`.


Returns:
    Tuple[torch.Tensor, torch.Tensor]: A tuple containing:
        - The quantized tensor with dtype `dtype`.
        - A tensor of scaling factors with dtype `torch.float32`.
r½   NúInput tensor must be contiguousz@Last dimension size must be divisible by block_size (block_size=Ú)ú6dtype must be torch.float8_e4m3fn or torch.float8_e5m2rA   rB   c                 óT   <€ SP                  SP                  4       V R ,          4      3# ©r�   )rJ   r�   )Úmetar{   r™   s   &€€r   r|   Ú)fp8_blockwise_act_quant.<locals>.<lambda>  s   ø€ ˜Ÿ™ Q§W¡W£Y°°\Õ0BÓCÑEr   rÆ   r~   )r*   r   r¾   r{   r   r€   rs   Úfloat8_e4m3fnÚfloat8_e5m2Ú
empty_liker…   rM   r   )r™   rq   rB   r)   r›   rš   r‡   r{   s   f&&    @r   Úfp8_blockwise_act_quantrÌ   ù   s  ù€ ô" Ó€EØ�?�?ˆ?ÜÐ9Ó:Ð:ãà�?‰?×ÒÐ?Ð?Ó?ÐØ�6‰6�"‹:˜
Õ" aÔ'ð Ø
JÈ:È,ÐVWÐXóÐ'ð Ü×ÑÜ×Ñðô ð @ð @ó@ð ô 	×Ò˜ %Ô(€AØ	�ŠÐR�Q—V‘V“X˜c˜r�]ÐR A§F¡F¨2£J°*Õ$<ÒRÄEÇMÁMÑR€AÝE€DØ	‡O�O�DÖ˜!˜Q¨jÕ9Øˆ4€Kr   c                óš   € V ^8„  d   QhR\         P                  R\        R\        \         P                  \         P                  3,          /# )r   r™   rq   r#   )rs   rt   ru   r   )r   s   "r   r   r     s:   € ÷ 'ñ 'Ü‡|�|ð'Ü!$ð'ä
Œ5�<‰<œŸ™Ð%Õ&ñ'r   c           	     ó¸  aaa	€ \        4       pVP                  '       g   \        R4      h^ RIo	V P	                  4       '       g   Q R4       hV P                  4       ^8X  g   Q R4       hV P                  ^ 4      V,          ^ 8X  d   V P                  ^4      V,          ^ 8X  g   Q RV R24       hV\        P                  \        P                  39   g   Q R4       hV P                  4       w  oo\        P                  ! WR7      pV P                  SV,          SV,          \        P                  R7      pVVV	3R	 lpVP                  V,          ! WVSSVR
7       WE3# )a9  
Quantizes the given weight tensor using block-wise quantization with block size being BLOCK_SIZExBLOCK_SIZE.

Args:
    x (torch.Tensor): The weight tensor to be quantized.
    block_size (int, optional): The block size to use for quantization. Defaults to 128.
    dtype (torch.dtype, optional): The dtype to use for the quantized tensor. Defaults to `torch.float8_e4m3fn`.

Returns:
    Tuple[torch.Tensor, torch.Tensor]: A tuple containing:
        - The quantized weight tensor with dtype `dtype`.
        - A tensor of scaling factors with dtype `torch.float32`.
r½   NrÂ   z#Input tensor must have 2 dimensionszABoth dimensions of x must be divisible by block_size (block_size=rÃ   rÄ   rA   c                 óh   <€ SP                  SV R ,          4      SP                  SV R ,          4      3# rÆ   ry   ©rÇ   rY   r6   r{   s   &€€€r   r|   Ú,fp8_blockwise_weight_quant.<locals>.<lambda>A  ó.   ø€ Ø�‰�A�t˜LÕ)Ó*Ø�‰�A�t˜LÕ)Ó*ñr   rÆ   )r*   r   r¾   r{   r   Údimr€   rs   rÉ   rÊ   rË   r…   rM   r   )
r™   rq   rB   r)   r›   rš   r‡   rY   r6   r{   s
   &&&    @@@r   Úfp8_blockwise_weight_quantrÔ     s=  ú€ ô  Ó€EØ�?�?ˆ?ÜÐ9Ó:Ð:ãà�?‰?×ÒÐ?Ð?Ó?ÐØ�5‰5‹7�aŒ<Ð>Ð>Ó>ˆ<Ø�6‰6�!‹9�zÕ! QÔ&¨1¯6©6°!«9°zÕ+AÀQÔ+Fð Ø
KÈJÈ<ÐWXÐYóÐFð Ü×ÑÜ×Ñðô ð @ð @ó@ð ð �6‰6‹8�D€A€qÜ×Ò˜Ô(€AØ	�‰�A˜•O Q¨*¥_¼E¿M¹MˆÓJ€Aö€Dð 
×Ñ�tÖ˜Q 1 a¨°zÕBØˆ4€Kr   c                ó„   € V ^8„  d   QhR\         P                  R\         P                  R\        R\         P                  /# )r   r™   rš   rq   r#   rr   )r   s   "r   r   r   I  s8   € ÷  ñ  Ü‡|�|ð ÜŸ™ð Ü25ð ä
‡\�\ñ r   c           	     óò  aaa€ \        4       pVP                  '       g   \        R4      h^ RIoV P	                  4       '       d   VP	                  4       '       g   Q R4       hV P                  4       ^8X  d   VP                  4       ^8X  g   Q R4       hV P                  4       w  oo\        P                  ! V \        P                  ! 4       R7      pVVV3R lpVP                  V,          ! WVSSVR7       V# )a×  
Dequantizes the given weight tensor using the provided scale tensor.

Args:
    x (torch.Tensor): The quantized weight tensor of shape (M, N).
    s (torch.Tensor): The scale tensor of shape (M, N).
    block_size (int, optional): The block size to use for dequantization. Defaults to 128.

Returns:
    torch.Tensor: The dequantized weight tensor of the same shape as `x`.

Raises:
    AssertionError: If `x` or `s` are not contiguous or if their dimensions are not 2.
r½   Nz Input tensors must be contiguousz$Input tensors must have 2 dimensionsrA   c                 óh   <€ SP                  SV R ,          4      SP                  SV R ,          4      3# rÆ   ry   rÐ   s   &€€€r   r|   Ú.fp8_blockwise_weight_dequant.<locals>.<lambda>d  rÒ   r   rÆ   )r*   r   r¾   r{   r   rÓ   r€   rs   rË   Úget_default_dtyper   )	r™   rš   rq   r)   r›   r‡   rY   r6   r{   s	   &&&   @@@r   Úfp8_blockwise_weight_dequantrÚ   I  sÂ   ú€ ô" Ó€EØ�?�?ˆ?ÜÐ9Ó:Ð:ãà�?‰?×Ò §¡×!2Ò!2ÐVÐ4VÓVÐ2Ø�5‰5‹7�aŒ<˜AŸE™E›G qœLÐPÐ*PÓPÐ(Ø�6‰6‹8�D€A€qÜ×Ò˜¤%×"9Ò"9Ó";Ô<€Aö€Dð 
×Ñ˜Ö˜q Q¨¨1¸ÕDØ€Hr   c                óV   € V ^8„  d   Qh/ ^ \         9   d   \        \        ,          ;R&   # )r   r&   )Ú__conditional_annotations__r   r
   )r   s   "r   r   r      s   € ‡�÷" 3Ò 2ŒxÔ*Õ+Ñ 2ò# r   r¯   )rÜ   r‚   Údataclassesr   Ú	threadingr   Útypingr   r   r   rs   r
   r&   r'   r*   r(   r¿   rÉ   rÌ   rÔ   rÚ   r   )rÜ   s   @r   Ú<module>rà      s�   øð÷ €Ý !Ý ß ,Ñ ,ã ñ �$Ô÷'ð 'ó ð'ð /3€Ó 2Ù“VÐ õ	õA÷H
2ð (+À×ATÑAT÷#ðN (+°%×2EÑ2E÷'÷T ñ  r   