+
    "Ý³jê ã                   óä  € R t ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIHt ^ RIH	t	H
t
 ^ RIHt ^ RIHtHtHtHtHtHt ^ RIHt ^ RIt^ RIHt ^ RIHu Hu Ht ^ RIt^ RIHt ^ RIHt ^ RI H!t! ^ R	I"H#t#H$t$H%t%H&t&H't' ^ R
I(H)t) ^ RI*H+t+ ^ RI,H-t-H.t.H/t/H0t0H1t1H2t2H3t3H4t4H5t5H6t6H7t7H8t8H9t9H:t:H;t;H<t<H=t= ^ RI>H?t?H@t@ ^ RIAHBtBHCtCHDtDHEtE ^ RIFHGtGHHtHHItI ^RIJHKtKHLtLHMtMHNtNHOtO ^RIPHQtQHRtR ^RISHTtT ^RIUHVtVHWtWHXtX ]P²                  ! ]Z4      t[. RcOt\RdR R llt]R t^ReR lt_RfR lt`R taRRRR/R ltb]^R3R R lltc]	 ! R  R!]4      4       tdR"RR#R/R$ R% llte]@! ]d4      R&R'R"RR#R/R( R) ll4       tf]	 ! R* R+]4      4       tgR, th]@! ]g4      R&R'/R- R. ll4       ti]	 ! R/ R0]4      4       tj]@! ]j4      R&R'/R1 R2 ll4       tk]	 ! R3 R4]4      4       tlR5 tm]@! ]l4      R&R'/R6 R7 ll4       tnR8 R9 lto]	 ! R: R;]4      4       tpR< tq]@! ]p4      R&R'/R= R> ll4       tr]	 ! R? R@]4      4       ts]@! ]s4      R&R'/RA RB ll4       tt]	 ! RC RD]4      4       tuRE tv]@! ]u4      R&R'/RF RG ll4       tw]	 ! RH RI]4      4       txRJ tyRK RL ltz]@! ]x4      R&R'/RM RN ll4       t{RO RP lt|]	 ! RQ RR]4      4       t}R"RR#R/RS RT llt~]@! ]}4      R&R'R"RR#R/RU RV ll4       t]	 ! RW RX]4      4       t€]€t�RY RZ lt‚R[ R\ ltƒR] R^ lt„R_ R` lt…Ra Rb lt†R# )gap  
Quantization APIs

Generally these APIs can be applied directly to any model
with Linear modules to obtain quantized linear ops. The intended
usage involves applying torch.compile to the model afterwards
both because primitives were designed based on the fusions that
come along with it and because that is how we access the intended quantized
and mixed GEMM kernels
N)ÚOrderedDict)Ú	dataclassÚfield)Úpartial)ÚAnyÚCallableÚListÚOptionalÚTupleÚUnion)ÚAOBaseConfig)Ú
e4m3_dtype)ÚFloat8Linear)ÚFloat8MMConfigÚFP8GranularityÚ_check_hardware_supportÚ!_granularity_is_a_1_128_w_128_128Ú_normalize_granularity)Ú(Float8StaticActivationFloat8WeightConfig)ÚKernelPreference)ÚFloat8PackingFormatÚ&Float8Sparse2x4_1DData1DMetadataTensorÚ&Float8Sparse2x4_2DData2DMetadataTensorÚFloat8TensorÚInt4ChooseQParamsAlgorithmÚInt4PackingFormatÚInt4PlainInt32TensorÚInt4PreshuffledTensorÚ
Int4TensorÚInt4TilePackedTo4dTensorÚ
Int8TensorÚIntxChooseQParamsAlgorithmÚIntxOpaqueTensorÚIntxPackingFormatÚIntxUnpackedToInt8TensorÚQuantizeTensorToFloat8KwargsÚQuantizeTensorToInt8Kwargs)Ú_QUANTIZE_CONFIG_HANDLERÚ register_quantize_module_handler)Ú_fp8_mm_compatÚ_linear_extra_reprÚ_module_extra_reprÚ_quantization_type)Úis_MI300Úis_MI350Úis_sm_at_least_89)ÚGranularityÚPerAxisÚPerGroupÚPerRowÚ	PerTensor)ÚInt4WeightOnlyQuantizerÚInt8DynActInt4WeightQuantizer)Ú intx_quantization_aware_training)Ú_DTYPE_TO_QVALUE_BOUNDSÚMappingTypeÚquantize_affinec                óX   € V ^8„  d   QhR\         \        \        R3,          ,          RR/# )é   Ú
extra_args.ÚreturnN)r	   r
   r   )Úformats   "Ú_/home/luca/screen-checking/.venv/lib/python3.14/site-packages/torchao/quantization/quant_api.pyÚ__annotate__rA   z   s-   € ÷ +ñ +ô œœs C˜x�Õ)ð+ð 
ñ+ó    c           	     ó<  € V! WRR 4      '       d#   Ve   V P                  VR7       V! V .VO5!  p V # \        V P                  4       4      pV F3  w  rx\        VVVV V R2VV4      p	W˜Jg   K!  V	f   K'  \	        WV	4       K5  	  Ve   V P                  VR7       V # )a÷  
Recursively replaces each child module in `model` with the result of `replacement_fn(child)`
if `filter_fn(child)` returns `True`.

Args:
    model (torch.nn.Module): The model containing modules to be replaced.
    replacement_fn (Callable[[torch.nn.Module], torch.nn.Module]): The function to replace matching modules.
    filter_fn (Callable[[torch.nn.Module], bool]): The filter function to determine which modules to replace.
    cur_fqn (str, optional): The current fully qualified name of the module being processed. Defaults to "".
    device (device, optional): Device to move the model to before applying `filter_fn`. Defaults to None.
    extra_args (Tuple[Any, ...], optional): optional extra args to pass to `replacement_fn`.

Returns:
    None
N©ÚdeviceÚ.éÿÿÿÿ)ÚtoÚlistÚnamed_childrenÚ)_replace_with_custom_fn_if_matches_filterÚsetattr)
ÚmodelÚreplacement_fnÚ	filter_fnÚcur_fqnrE   r=   Únamed_children_listÚnameÚchildÚ	new_childs
   &&&&&&    r@   rK   rK   z   s¶   € ñ. �  ˜×%Ò%ØÒØ�H‰H˜FˆHÔ#Ù˜uÐ2 zÓ2ˆØˆä" 5×#7Ñ#7Ó#9Ó:ÐÛ.‰KˆDÜAØØØØ�)˜D˜6 Ð#ØØóˆIð Õ%¨)Ô*?Ü˜ YÖ/ñ /ð ÒØ�H‰H˜FˆHÔ#ØˆrB   c                 ó:  € ^ RI Hp \        V \        P                  P
                  4      ;'       dk    \        V R4      ;'       dW    \        V P                  V4      '       * ;'       d4    \        V \        P                  P                  P                  4      '       * # )é    )Ú_AffineFakeQuantizedTensorÚweight)Ú5torchao.quantization.qat.affine_fake_quantized_tensorrW   Ú
isinstanceÚtorchÚnnÚLinearÚhasattrrX   ÚmodulesÚlinearÚNonDynamicallyQuantizableLinear)ÚmodÚargsrW   s   &* r@   Ú
_is_linearrd   ¨   s   € õô 	�3œŸ™Ÿ™Ó(÷ 	Sð 	SÜ�C˜Ó"÷	Sð 	Sä˜3Ÿ:™:Ð'AÓBÔB÷	Sð 	Sô ˜3¤§
¡
× 1Ñ 1× QÑ QÓRÔRð	rB   Fc                ól   a aaaa€ SP                  RR4      oSP                  RR4      oV VVVV3R lpV# )aË  
Returns a function which inserts the given subclass into all linear modules
in the model. The inserted module will have its weight set to the result of
`cls(mod.weight, **kwargs)`. If parametrization is enabled then this will be done using
torch.nn.utils.parametrize instead of directly setting the attribute on the module.

Args:
    cls (torch.Tensor): The class to insert as a child module.
    kwargs (Any): Any additional arguments for the constructor.
ÚconstructorÚsubclass_constructorÚmethodÚ
from_floatc                 ó¤  <€ S'       d†   \         P                  P                  SP                  ! V P                  3/ SB R R7      V n        V P                  P                  4       w  r\        P                  ! V R\        SS4      ! V!  4       V # \         P                  P                  \        SS4      ! V P                  3/ SB R R7      V n        V # )F©Úrequires_gradrX   )	r[   r\   Ú	Parameterri   rX   Ú__tensor_flatten__ÚparametrizeÚregister_parametrizationÚgetattr)ÚlinÚ_rc   Úclsrf   Úenable_parametrizationri   Úkwargss   &  €€€€€r@   Úinsert_subclassÚ/_get_subclass_inserter.<locals>.insert_subclassÇ   sµ   ø€ ß!ÜŸ™×+Ñ+Ø—’˜sŸz™zÑ4¨VÑ4ÀEð ,ó ˆCŒJð —j‘j×3Ñ3Ó5‰GˆAÜ×0Ò0Ø�Xœw s¨KÔ8¸$Ñ?ôð ˆ
ô Ÿ™×+Ñ+ä˜˜ZÔ(¨¯©Ñ>°vÑ>Ø#ð ,ó ˆCŒJð
 ˆ
rB   )Úpop)rt   ru   rv   rw   rf   ri   s   ffl @@r@   Ú_get_subclass_inserterrz   ¹   s8   ü€ ð —*‘*˜]Ð,BÓC€KØ—‘˜H lÓ3€J÷ñ ð" ÐrB   c                ó‚   a€  ! R R\         P                  P                  4      oV3R lpVf   R p\        WVR7       R# )za
Changes all conv2d 1x1 modules to equivalent linear modules so that they can then be quantized.
c                   ó8   a a€ ] tR t^àt oV 3R ltR tRtVtV ;t# )Ú2swap_conv2d_1x1_to_linear.<locals>.PermuteSandwichc                ó0   <€ \         SV `  4        Wn        R # ©N)ÚsuperÚ__init__rb   )Úselfrb   Ú	__class__s   &&€r@   r�   Ú;swap_conv2d_1x1_to_linear.<locals>.PermuteSandwich.__init__á   s   ø€ Ü‰GÑÔØŽHrB   c                óz   € V P                  V^ ,          P                  ^ ^^^4      4      P                  ^ ^^^4      # )rV   )rb   Úpermute)r‚   rc   s   &*r@   ÚforwardÚ:swap_conv2d_1x1_to_linear.<locals>.PermuteSandwich.forwardå   s5   € Ø—8‘8˜D �GŸO™O¨A¨q°!°QÓ7Ó8×@Ñ@ÀÀQÈÈ1ÓMÐMrB   )rb   )	Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__r�   r‡   Ú__static_attributes__Ú__classdictcell__Ú__classcell__)rƒ   Ú__classdict__s   @@r@   ÚPermuteSandwichr}   à   s   ù‡ € õ	÷	Nò 	NrB   r‘   c                 ó\  <€ V P                   R8X  g   Q h\        P                  P                  V P                  V P
                  V P                  RJ R7      p\        P                  P                  V P                  P                  RR4      4      Vn        V P                  Vn        S! V4      # )é   N)Úbias©r“   r“   rG   éþÿÿÿ)
Úkernel_sizer[   r\   r]   Úin_channelsÚout_channelsr”   rm   rX   Úsqueeze)Úconvrr   r‘   s   & €r@   Úreplace_conv2d_1x1Ú5swap_conv2d_1x1_to_linear.<locals>.replace_conv2d_1x1è   s‰   ø€ Ø×Ñ 6Ô)Ð)Ð)Ü�h‰h�o‰oØ×Ñ˜d×/Ñ/°t·y±yÀDÐ7Hð ó 
ˆô —X‘X×'Ñ'¨¯©×(;Ñ(;¸BÀÓ(CÓDˆŒ
Ø—9‘9ˆŒÙ˜sÓ#Ð#rB   Nc                 óx   € \        V \        P                  P                  4      ;'       d    V P                  R8H  # )r“   r•   )rZ   r[   r\   ÚConv2dr—   )rb   rc   s   &*r@   Ú<lambda>Ú+swap_conv2d_1x1_to_linear.<locals>.<lambda>ò   s1   € ¤zØ”—‘—‘ó(
÷ ((ð ((à�o‰o Ñ'ð((rB   )rO   )r[   r\   ÚModulerK   )rM   rO   rœ   r‘   s   && @r@   Úswap_conv2d_1x1_to_linearr£   Û   s<   ø€ ô
Nœ%Ÿ(™(Ÿ/™/ô Nõ$ð Òñ(ˆ	ô .Ø¨Y÷rB   c                 óª   € R V P                   P                  ^ ,           RV P                   P                  ^,           R\        V P                   4       2# )znum_embeddings=z, embedding_dim=z	, weight=)rX   Úshaper,   ©r‚   s   &r@   Ú_embedding_extra_reprr§   û   sb   € Ø˜TŸ[™[×.Ñ.¨qÕ1Ð2Ð2BÀ4Ç;Á;×CTÑCTÐUVÕCWÐBXÐXaÔbtÐuy÷  vAñ  vAó  cBð  bCð  Dð  DrB   Úallow_requires_gradÚpropagate_biasc               ó    a aaa€ VV VV3R lpV# )z‚Helper function to apply the constructor that quantizes the weight Tensor (with additional kwargs)
to the weight of linear module
c                 ó"  <€ S;'       d    V P                   P                  pSR 8X  d   V P                  SR&   \        P                  P                  S! V P                   3/ SB VR7      V n         \        P                  ! \        V 4      V n	        V # )Tr”   rk   )
rX   rl   r”   r[   r\   rm   ÚtypesÚ
MethodTyper*   Ú
extra_repr)rr   rl   r¨   rf   rv   r©   s   & €€€€r@   rw   Ú6_get_linear_subclass_inserter.<locals>.insert_subclass  sy   ø€ Ø+×HÐH°·
±
×0HÑ0HˆØ˜TÔ!Ø ŸX™XˆF�6‰NÜ—X‘X×'Ñ'Ù˜Ÿ
™
Ñ- fÑ-¸]ð (ó 
ˆŒ
ô ×)Ò)Ô*<¸cÓBˆŒØˆ
rB   © )rf   r¨   r©   rv   rw   s   fddl r@   Ú_get_linear_subclass_inserterr±   ÿ   s   û€ ÷ð ð ÐrB   c          	      ó  € V ^8„  d   QhR\         P                  P                  R\        R\        \
        \         P                  P                  \        .\        3,          ,          R\        \         P                  P                  ,          /# )r<   rM   ÚconfigrO   rE   )
r[   r\   r¢   r   r	   r   ÚstrÚboolr¬   ÚDevice)r?   s   "r@   rA   rA     si   € ÷ H
ñ H
Ü�8‰8�?‰?ðH
äðH
ô œ¤%§(¡(§/¡/´3Ð!7¼Ð!=Õ>Õ?ðH
ô ”U—[‘[×'Ñ'Õ(ñ	H
rB   c                ó.  € \         P                  P                  R4       \        V\        4      '       Ed   Ve   \        R4      h\        V P                  4       4      pVP                  4        FÌ  w  rV\        WQ4      '       g9   \        WeV4      '       g'   RVP                  9   g   K;  \        V4      '       g   KN  \        WeV4      pVe   VP                  VR7      pWvJg   Kw  VR8w  g   K€  VP                  R4      R
,          pVP!                  V4      P!                  R4      p	WI,          p
\#        W¨V4       KÎ  	  R# \        V\$        4      '       d6   Vf   \        MTp\&        \)        V4      ,          p\+        V VVVV3R7       R# \-        R	4      h)an  Convert the weight of linear modules in the model with `config`, model is modified inplace

Args:
    model (torch.nn.Module): input model
    config (AOBaseConfig): a workflow configuration object.
    filter_fn (Optional[Callable[[torch.nn.Module, str], bool]]): function that takes a nn.Module instance and fully qualified name of the module, returns True if we want to run `config` on
    the weight of the module
    device (device, optional): Device to move module to before applying `filter_fn`. This can be set to `"cuda"` to speed up quantization. The final model will be on the specified `device`.
        Defaults to None (do not change device).

Example::

    import torch
    import torch.nn as nn
    from torchao import quantize_

    # quantize with some predefined `config` method that corresponds to
    # optimized execution paths or kernels (e.g. int4 tinygemm kernel)
    # also customizable with arguments
    # currently options are
    # Int8DynamicActivationInt8WeightConfig (optimized with int8 mm op and torch.compile)
    # Int4WeightOnlyConfig (optimized with int4 tinygemm kernel and torch.compile)
    # Int8WeightOnlyConfig (optimized with int8 mm op and torch.compile
    from torchao.quantization.quant_api import Int4WeightOnlyConfig

    m = nn.Sequential(nn.Linear(32, 1024), nn.Linear(1024, 32))
    quantize_(m, Int4WeightOnlyConfig(group_size=32))

ztorchao.quantization.quantize_NzuCustom filter_fn and FqnToConfig were both specified. Only filter_fn=None is supported when FqnToConfig is specified.Ú_defaultrD   Ú rF   )rE   r=   zåPassing a generic Callable to `quantize_` is no longer recommended and will be deprecated at a later release. Please see https://github.com/pytorch/ao/issues/1690 for instructions on how to pass in workflow configuration instead.rG   )r[   Ú_CÚ_log_api_usage_oncerZ   ÚFqnToConfigÚ
ValueErrorÚdictÚnamed_modulesÚitemsÚfqn_matches_fqn_configÚ _module_param_matches_fqn_configÚfqn_to_configrd   Ú_fqn_to_config_handlerrH   ÚsplitÚremovesuffixrL   r   r'   ÚtyperK   ÚAssertionError)rM   r³   rO   rE   r¿   Ú
module_fqnÚmoduleÚreplacementÚ
child_nameÚ
parent_fqnÚparent_moduleÚhandlers   &&&&        r@   Ú	quantize_rÐ     sb  € ôF 
‡H�H× Ñ Ð!AÔBä�&œ+×&Ó&ØÒ Üð Hóð ô ˜U×0Ñ0Ó2Ó3ˆØ"/×"5Ñ"5Ö"7ÑˆJä& z×:Ò:Ü3°FÈ×OÒOØ &×"6Ñ"6Ö6¼:Àf×;MÔ;Mä4°VÈÓP�ØÒ%Ø"-§.¡.¸ .Ó"?�KàÕ,°¸rÖ1AØ!+×!1Ñ!1°#Ó!6°rÕ!:�JØ!+×!8Ñ!8¸Ó!D×!QÑ!QÐRUÓ!V�JØ$1Õ$=�MÜ˜M°{ÖCó #8ô 
�FœL×	)Ò	)Ø"+Ò"3•J¸ˆ	Ü*¬4°«<Õ8ˆä1ØØØØØ�y÷	
ô ð xó
ð 	
rB   c                   óÆ   a € ] tR tRt o Rt]P                  t]! ^ 4      t	]
P                  tRt]
P                  t]P"                  t]P(                  t^tR tV 3R ltRtV tR# )Ú%Int8DynamicActivationIntxWeightConfigi^  a^  
Configuration for dynamically quantizing activations to torch.int8 and weights to torch.intx, with 1 <= x <= 8.
More specifically, activations are dynamically quantized to 8-bits at a per-token granularity with scales/zeros.
Weights are quantized with scales/zeros in a groupwise or channelwise manner using the number of bits specified by weight_dtype.

args:
    `weight_dtype`: The dtype to use for weight quantization.  Must be torch.intx, where 1 <= x <= 8.
    `weight_granularity`: The granularity to use for weight quantization.  Must be PerGroup or PerAxis(axis=0).
    `weight_mapping_type`: The type of mapping to use for the weight quantization.
        Must be one of MappingType.ASYMMETRIC or MappingType.SYMMETRIC.  MappingType.SYMMETRIC requires ZeroPointDomain.NONE
    `weight_scale_dtype`: The dtype to use for the weight scale.
    `act_mapping_type`: The type of mapping to use for the activation quantization.
        Must be one of MappingType.ASYMMETRIC or MappingType.SYMMETRIC.
    `intx_packing_format`: The format to use for the packed weight tensor (version 2 only).

        - unpacked_to_int8: this format is the default and is intended for export applications like ExecuTorch.
        - opaque_torchao_auto: this format is optimized for CPU performance.

    `intx_choose_qparams_algorithm`: The algorithm to use for choosing the quantization parameters.
    `version`: version of the config to use, only subset of above args are valid based on version, see note for more details.

Example:

.. literalinclude:: ../../examples/inference/int8_dynamic_activation_intx_weight.py
   :language: python
Nc           	     ó>  € \         P                  P                  R 4       V P                  \	        ^^	4       Uu. uF  p\        \         RV 24      NK  	  up9   g   Q RV P                   24       h\        V P                  \        \        34      '       g   Q RV P                   24       h\        V P                  \        4      '       d:   V P                  P                  ^ 8X  g   Q RV P                  P                   24       hV P                  \        P                  \        P                  \        P                  39   g   Q RV P                   24       hV P                   \        P                  \        P                  39   g   Q RV P                    24       hR# u upi )z:torchao.quantization.Int8DynamicActivationIntxWeightConfigÚintú<weight_dtype must be torch.intx, where 1 <= x <= 8, but got z8weight_granularity must be PerAxis or PerGroup, but got zaxis must be 0, but got z~weight_mapping_type must be MappingType.ASYMMETRIC or MappingType.SYMMETRIC or MappingType.SYMMETRIC_NO_CLIPPING_ERR, but got zRact_mapping_type must be MappingType.ASYMMETRIC or MappingType.SYMMETRIC, but got N)r[   rº   r»   Úweight_dtypeÚrangerq   rZ   Úweight_granularityr1   r2   ÚaxisÚweight_mapping_typer9   Ú
ASYMMETRICÚ	SYMMETRICÚSYMMETRIC_NO_CLIPPING_ERRÚact_mapping_type©r‚   Úbs   & r@   Ú__post_init__Ú3Int8DynamicActivationIntxWeightConfig.__post_init__‡  s¥  € Ü�‰×$Ñ$ØHô	
ð × Ñ ÌÈaÐQRÌÓ$TÉÀ1¤W¬U°c¸!¸°IÖ%>ÉÑ$TÔTð 	
ØJÈ4×K\ÑK\ÐJ]Ð^ó	
ÐTô ˜$×1Ñ1´G¼XÐ3F×GÒGð 	
ØFÀt×G^ÑG^ÐF_Ð`ó	
ÐGô �d×-Ñ-¬w×7Ò7Ø×*Ñ*×/Ñ/°1Ô4ð Ø*¨4×+BÑ+B×+GÑ+GÐ*HÐIóÐ4ð ×'Ñ'Ü×"Ñ"Ü×!Ñ!Ü×1Ñ1ð,
ô 
ð 	
ð
 Mð  NR÷  Nfñ  Nfð  Mgð  hó	
ð 
ð ×$Ñ$Ü×"Ñ"Ü×!Ñ!ð)
ô 
ð 	
ð aÐae×avÑavÐ`wÐxó		
ò 
ùò# %Us   ¹Fc                ó²   <€ V ^8„  d   Qh/ S[ P                  ;R&   S[;R&   S[;R&   S[S[ P                  ,          ;R&   S[;R&   S[;R&   S[;R&   S[;R&   # )	r<   rÖ   rØ   rÚ   Úweight_scale_dtyperÞ   Úintx_packing_formatÚintx_choose_qparams_algorithmÚversion©r[   Údtyper0   r9   r	   r#   r!   rÔ   )r?   r�   s   "€r@   rA   Ú2Int8DynamicActivationIntxWeightConfig.__annotate__^  s†   ø‡ ‚ ñ: —+‘+Ñ*ñ; ñ< $Ñ2ñ= ñ> %Ñ<ñ? ñ@ !¡§¡Õ-Ñ4ñA ñB "Ñ:ñC ñD +ÑOñE ñF $>ñ ñG ñN ÑòO rB   r°   )r‰   rŠ   r‹   rŒ   Ú__doc__r[   Úint8rÖ   r2   rØ   r9   rÜ   rÚ   rä   rÛ   rÞ   r#   ÚUNPACKED_TO_INT8rå   r!   ÚAFFINEræ   rç   rá   Ú__annotate_func__r�   rŽ   ©r�   s   @r@   rÒ   rÒ   ^  sk   ø‡ € ñð6 !&§
¡
€LÙ&.¨r£lÐØ'2×'<Ñ'<ÐØ04ÐØ$/×$:Ñ$:ÐØ->×-OÑ-OÐà"×)Ñ)ð "ð €Gò
÷S ƒ rB   rÒ   Úcustom_scaleÚcustom_zero_pointc                ó„   € V ^8„  d   QhR\         \        P                  ,          R\         \        P                  ,          /# ©r<   rñ   rò   ©r	   r[   ÚTensor)r?   s   "r@   rA   rA   ¤  s6   € ÷ G ñ G ô
 œ5Ÿ<™<Õ(ðG ô  ¤§¡Õ-ñG rB   c                ót  € VP                   pVP                  pVP                  pVP                  pVP                  p	VP
                  p
VP                  pV P                  4       ^8X  g   Q RV P                  4        24       h\        V\        4      '       d   VP                  pM]\        V\        4      '       d:   VP                  ^ 8X  g   Q RVP                   24       hV P                  R	,          pM\        RV 24      h^V3pVP                  ^8X  g   Q hV	\         P"                  8X  g   Q h\$        P&                  \$        P(                  \$        P*                  \$        P,                  .pV
\$        P.                  8X  g   W®9   g   Q RV
 24       hVe?   VP0                  \2        P4                  8X  d    VP7                  \2        P8                  4      p\:        P<                  ! V VVVRVVVR7      pVe   W€P0                  8w  d   \?        WðV4       TpW®9   d   \@        PB                  ! VVV
R7      pRpVV3# )
r<   zFInt8DynamicActivationIntxWeightConfig only works for 2-d Tensor, got: ú%axis must be 0 with PerAxis, but got z4weight_granularity must be PerGroup or PerAxis, got úUnsupported packing format: NÚint8_asym_per_token)Úmapping_typeÚactivation_quantizationræ   rñ   rò   )r”   rå   rG   )"rÖ   rØ   rÚ   rä   rÞ   rå   ræ   ÚdimrZ   r2   Ú
group_sizer1   rÙ   r¥   r½   rç   r9   rÛ   r#   ÚOPAQUE_ATEN_KLEIDIAIÚOPAQUE_TORCHAO_AUTOÚOPAQUE_TORCHAO_KLEIDIAIÚOPAQUE_TORCHAO_LOWBITrí   ré   r[   Úint32rH   rì   r$   Úfrom_hpÚ+_adjust_scale_dtype_in_intx_unpacked_tensorr"   Ú!from_intx_unpacked_to_int8_tensor)rX   r”   r³   rñ   rò   rÖ   rØ   rÚ   rä   rÞ   rå   ræ   rþ   Ú
block_sizeÚopaque_formatsÚ
new_weightÚnew_biass   &&&$$            r@   Ú4_int8_dynamic_activation_intx_weight_quantize_tensorr  ¤  sF  € ð ×&Ñ&€LØ×2Ñ2ÐØ ×4Ñ4ÐØ×2Ñ2ÐØ×.Ñ.ÐØ ×4Ñ4ÐØ$*×$HÑ$HÐ!à�:‰:‹<˜1Ôð Ø
PÐQW×Q[ÑQ[ÓQ]ÐP^Ð_óÐô Ð$¤h×/Ò/Ø'×2Ñ2‰
Ü	Ð&¬×	0Ò	0Ø!×&Ñ&¨!Ô+ð 	
Ø3Ð4F×4KÑ4KÐ3LÐMó	
Ð+ð —\‘\ "Õ%‰
äØBÐCUÐBVÐWó
ð 	
ð �Z�€Jà�>‰>˜QÔÐÐØœ{×5Ñ5Ô5Ð5Ð5ä×.Ñ.Ü×-Ñ-Ü×1Ñ1Ü×/Ñ/ð	€Nð 	Ô0×AÑAÔAØÔ0ð<ð 
&Ð&9Ð%:Ð;ó<ð	1ð Ò$Ð):×)@Ñ)@ÄEÇKÁKÔ)OØ-×0Ñ0´·±Ó<ÐÜ)×1Ò1ØØØØ(Ø 5Ø&CØ!Ø+ô	€Jð Ò%Ð*<ÇÁÔ*LÜ3ØÐ 2ô	
ð €Hð Ô,Ü%×GÒGØ˜XÐ;Nô
ˆ
ð ˆà�xÐÐrB   Úparameter_namerX   c                ó  € V ^8„  d   QhR\         P                  P                  R\        R\        R\
        \         P                  ,          R\
        \         P                  ,          R\         P                  P                  /# ©r<   rÊ   r³   r  rñ   rò   r>   )r[   r\   r¢   rÒ   r´   r	   rö   )r?   s   "r@   rA   rA   ï  sf   € ÷ ñ Ü�H‰H�O‰Oðä1ðô ð	ô
 œ5Ÿ<™<Õ(ðô  ¤§¡Õ-ðô ‡X�X‡_�_ñrB   c          	      ó*  € \        \        W4      V P                  VVVR 7      w  rV\        V V\        P
                  P                  VRR7      4       Vf   RV n        \        P                  ! \        \        V P                  VR7      V 4      V n        V # )©rñ   rò   Frk   N©Úoriginal_extra_reprr  )r  rq   r”   rL   r[   r\   rm   r¬   r­   r   r+   r®   )rÊ   r³   r  rñ   rò   r	  r
  s   &&$$$  r@   Ú._int8_dynamic_activation_intx_weight_transformr  î  s–   € ô PÜ�Ó'Ø�‰ØØ!Ø+ôÑ€Jô ØØÜ�‰×Ñ˜:°UÐÓ;ôð
 ÒØˆŒÜ×(Ò(ÜÜØ &× 1Ñ 1Ø)ô	
ð
 	ó€FÔð €MrB   c                   óv   a € ] tR tRt o Rt^€tRt]P                  t	]
P                  t^t^tR tV 3R ltRtV tR# )ÚInt4WeightOnlyConfigi  a  
Configuration for int4 weight only quantization, only groupwise quantization is supported.

Args:
    `group_size`: parameter for quantization, controls the granularity of quantization, smaller
     size is more fine grained, choices are [256, 128, 64, 32]
    `int4_packing_format`: the packing format for int4 tensor
    `int4_choose_qparams_algorithm`: variants of choose qparams algorithm to use for int4,
     currently support TINYGEMM ("tinygemm") and HQQ ("hqq")
    `set_inductor_config`: if True, adjusts `torchinductor` settings to recommended values.
    `int4_tile_packed_ntile`: ntile size for TILED_PACKED_TO_4D format, default is 8 for CUDA platform, 16 for ROCm platform

Example:

.. literalinclude:: ../../examples/inference/int4_weight_only.py
   :language: python
Tc                ót   € V P                   R9   g   Q R4       h\        P                  P                  R4       R# )é   z-int4_tile_packed_ntile must be either 8 or 16z)torchao.quantization.Int4WeightOnlyConfigN)r  é   )Úint4_tile_packed_ntiler[   rº   r»   r¦   s   &r@   rá   Ú"Int4WeightOnlyConfig.__post_init__-  s5   € Ø×*Ñ*¨gÔ5ð 	
Ø;ó	
Ð5ô 	�‰×$Ñ$Ð%PÖQrB   c                ób   <€ V ^8„  d   Qh/ S[ ;R&   S[;R&   S[;R&   S[;R&   S[ ;R&   S[ ;R&   # )r<   rþ   Úset_inductor_configÚint4_packing_formatÚint4_choose_qparams_algorithmr  rç   )rÔ   rµ   r   r   )r?   r�   s   "€r@   rA   Ú!Int4WeightOnlyConfig.__annotate__  sU   ø‡ ‚ ñ( Ññ) ñ* Ñ$ñ+ ñ, +ÑDñ- ñ. $>ñ ñ/ ñ4  Ñ#ñ5 ñ6 Ñò7 rB   r°   N)r‰   rŠ   r‹   rŒ   rë   rþ   r  r   ÚPLAINr  r   ÚTINYGEMMr  r  rç   rá   rï   r�   rŽ   rð   s   @r@   r  r    sK   ø‡ € ñð$ €JØ $ÐØ->×-DÑ-DÐà"×+Ñ+ð "ð #$ÐØ€GòR÷; ƒ rB   r  c                 óÊ  € VP                   pVP                  pVP                  pVP                  pV P                  R,          V,          ^ 8w  d(   \
        P                  RV P                   RV 24       V # \        \        V P                  ^,
          4       Uu. uF  p^NK  	  upV.,           4      pVP                  ^8X  g   Q h\        V4      pV\        P                  8X  d!   V\        P                  8X  g   Q RV R24       hV\        P                   8X  d*   \"        P$                  ! V V\&        P(                  R7      pV# V\        P*                  8X  d   \,        P$                  ! V V4      pV# V\        P.                  8X  d   \0        P$                  ! V V4      pV# V\        P                  8X  d   \2        P$                  ! V VVVR7      pV# \5        RV 24      hu upi )	r“   zZSkipping quantizing weight with int4 weight only quantization because the shape of weight z# is not compatible with group_size zBInt4ChooseQParamsAlgorithm.HQQ is not supported by packing format zF, it's only supported by Int4PackingFormat.TILE_PACKED_TO_4D currently©Úactivation_dtype)r  Ú
ntile_sizez!Unsupported int4 packing format: rG   )rþ   r  r  r  r¥   ÚloggerÚinfoÚtupler×   Úndimrç   rI   r   ÚHQQr   ÚTILE_PACKED_TO_4DÚPRESHUFFLEDr   r  r[   Úbfloat16r   r   ÚPLAIN_INT32r   r   r½   )	rX   r³   rþ   r  r  r  rs   r  r	  s	   &&       r@   Ú!_int4_weight_only_quantize_tensorr/  4  sð  € ð ×"Ñ"€JØ$*×$HÑ$HÐ!Ø ×4Ñ4ÐØ#×:Ñ:Ðà‡|�|�BÕ˜*Õ$¨Ô)Ü�‰ØhÐio×iuÑiuÐhvð  wZð  [eð  Zfð  gô	
ð ˆä¤5¨¯©°q­Ô#9Ó:Ñ#9˜a›Ñ#9Ñ:¸j¸\ÕIÓJ€Jà�>‰>˜QÔÐÐÜ�jÓ!€Jà$Ô(B×(FÑ(FÔFØ"Ô&7×&IÑ&IÔIð 	
ØPÐQdÐPeð fSð Tó	
ÐIð
 Ô/×;Ñ;Ô;Ü*×2Ò2ØØÜ"Ÿ^™^ô
ˆ
ð
 ÐØ	Ô 1× 7Ñ 7Ô	7Ü×'Ò'ØØó
ˆ
ð ÐØ	Ô 1× =Ñ =Ô	=Ü)×1Ò1ØØó
ˆ
ð ÐØ	Ô 1× CÑ CÔ	CÜ-×5Ò5ØØØ*GØ-ô	
ˆ
ð ÐäÐ<Ð=PÐ<QÐRÓSÐSùòO ;s   ÂG c                ó˜   € V ^8„  d   QhR\         P                  P                  R\        R\        R\         P                  P                  /# ©r<   rÊ   r³   r  r>   )r[   r\   r¢   r  r´   )r?   s   "r@   rA   rA   p  s@   € ÷ ñ Ü�H‰H�O‰Oðä ðô ð	ô
 ‡X�X‡_�_ñrB   c          	      ó¶  € VP                   '       d)   \        P                  P                  P	                  4        \        W4      '       g   Q R V R2RV  R2,           4       h\        \        W4      V4      p\        V V\        P                  P                  VRR7      4       \        P                  ! \        \        V P                   VR7      V 4      V n        V # )z8applying int4 weight only quant requires module to have ú
 attributeú but ú does not have oneFrk   r  )r  ÚtorchaoÚquantizationÚutilsÚ"recommended_inductor_config_setterr^   r/  rq   rL   r[   r\   rm   r¬   r­   r   r+   r®   ©rÊ   r³   r  r	  s   &&$ r@   Ú_int4_weight_only_transformr;  o  sÕ   € ð ×!×!Ð!Ü×Ñ×"Ñ"×EÑEÔGä�6×*Ò*ð Ø
BÀ>ÐBRÐR\Ð]Ø�&�Ð+Ð
,õ	-óÐ*ô 3Ü�Ó'¨ó€Jô ØØÜ�‰×Ñ˜:°UÐÓ;ôô
 ×(Ò(ÜÜØ &× 1Ñ 1Ø)ô	
ð
 	ó€FÔð €MrB   c                   ó4   a € ] tR tRt o RtRtV 3R ltRtV tR# )Ú'Float8DynamicActivationInt4WeightConfigi�  aØ  Configuration for apply float8 dynamic per row quantization and int4
per group weight quantization to linear
(only group_size 128 is supported right now since underlying kernel used only supports 128
and above and no benefits of making it bigger)

Args:
    `int4_packing_format`: how the weight is packed, supported values are "preshuffled" and "plain"

Example:

.. literalinclude:: ../../examples/inference/float8_dynamic_activation_int4_weight.py
   :language: python
Úpreshuffledc                ó&   <€ V ^8„  d   Qh/ S[ ;R&   # )r<   r  )r   )r?   r�   s   "€r@   rA   Ú4Float8DynamicActivationInt4WeightConfig.__annotate__�  s   ø‡ ‚ ñ  +Ñ:ò! rB   r°   N)	r‰   rŠ   r‹   rŒ   rë   r  rï   r�   rŽ   rð   s   @r@   r=  r=  �  s   ø‡ € ñð .;Ð÷! ƒ rB   r=  c                ó˜   € V ^8„  d   QhR\         P                  P                  R\        R\        R\         P                  P                  /# r1  )r[   r\   r¢   r=  r´   )r?   s   "r@   rA   rA   ¤  s@   € ÷ 1ñ 1Ü�H‰H�O‰Oð1ä3ð1ô ð	1ô
 ‡X�X‡_�_ñ1rB   c          	      óÄ  € \        W4      '       g   Q R V R2RV  R2,           4       hVP                  pVR
9   g   Q RV 24       h\        W4      p^€p\        \	        VP
                  ^,
          4       Uu. uF  p^NK  	  upV.,           4      pVR8X  d3   \        P                  ! V P                  V\        P                  R7      pM1\        P                  ! V P                  V\        P                  R7      p\        V V\        P                  P                  VRR7      4       \        P                   ! \#        \$        V P&                  VR	7      V 4      V n        V # u upi )zMapplying float8 dynamic activation int4 weight quant requires module to have r3  r4  r5  r>  zIonly preshuffled and plain int4_packing_format supported right now, got: r#  Frk   r  )r>  Úplain)r^   r  rq   rI   r×   r)  r   r  rX   r[   Úfloat8_e4m3fnr   rL   r\   rm   r¬   r­   r   r+   r®   )	rÊ   r³   r  r  rX   rþ   rs   r  r	  s	   &&$      r@   Ú0_float8_dynamic_activation_int4_weight_transformrE  £  sj  € ô �6×*Ò*ð Ø
WÐXfÐWgÐgqÐrØ�&�Ð+Ð
,õ	-óÐ*ð !×4Ñ4Ðàð #ô ð ð TÐTgÐShÐió	ð ô �VÓ,€FØ€JÜ¤%¨¯©°a­Ô"8Ó9Ñ"8˜Q“qÑ"8Ñ9¸Z¸LÕHÓI€Jà˜mÔ+Ü*×2Ò2Ø�M‰MØÜ"×0Ñ0ô
‰
ô  ×'Ò'Ø�M‰MØÜ"×0Ñ0ô
ˆ
ô ØØÜ�‰×Ñ˜:°UÐÓ;ôô
 ×(Ò(ÜÜØ &× 1Ñ 1Ø)ô	
ð
 	ó€FÔð €Mùò; :s   Á5Ec                   óP   a € ] tR tRt o RtRt]! 4       tRt^t	R t
V 3R ltRtV tR# )ÚInt8WeightOnlyConfigiØ  a÷  
Configuration for applying int8 weight-only symmetric per-channel quantization to linear layers.

Args:
    group_size (version 1) - Controls the granularity of quantization.
    If None, applies per-channel quantization. Otherwise, applies per-group quantization with the specified group size.
    granularity (version 2) - Quantization granularity.
        PerRow() for per-channel quantization, PerTensor() for per-tensor quantization,
        PerGroup(group_size) for per-group quantization.
    set_inductor_config: bool = True - If True, adjusts `torchinductor` settings to recommended values
        for better performance with this quantization scheme.

Example:

.. literalinclude:: ../../examples/inference/int8_weight_only.py
   :language: python
NTc                óZ  € \         P                  P                  R 4       V P                  ^8X  d   \	        R4      hV P
                  e#   Q RV P
                   RV P
                   R24       h\        V P                  \        \        \        34      '       g   Q RV P                   24       hR# )z)torchao.quantization.Int8WeightOnlyConfigzˆversion 1 of Int8WeightOnlyConfig has been removed, please use version 2, see https://github.com/pytorch/ao/issues/2752 for more detailsNz1Only support version 2 with group_size=None, got z. Use granularity=PerGroup(z
) instead.z<granularity must be PerTensor, PerRow, or PerGroup, but got )r[   rº   r»   rç   r½   rþ   rZ   Úgranularityr4   r3   r2   r¦   s   &r@   rá   Ú"Int8WeightOnlyConfig.__post_init__ñ  s«   € Ü�‰×$Ñ$Ð%PÔQØ�<‰<˜1ÔÜðQóð ð �‰Ò&ð 	
Ø?ÀÇÁÐ?Pð Q(Ø(,¯©Ð'8¸
ðDó	
Ð&ô ˜$×*Ñ*¬Y¼ÄÐ,I×JÒJð 	
ØJÈ4×K[ÑK[ÐJ\Ð]ó	
ÒJrB   c                ój   <€ V ^8„  d   Qh/ S[ S[,          ;R&   S[ S[,          ;R&   S[;R&   S[;R&   # )r<   rþ   rI  r  rç   )r	   rÔ   r0   rµ   )r?   r�   s   "€r@   rA   Ú!Int8WeightOnlyConfig.__annotate__Ø  sB   ø‡ ‚ ñ( ™•Ñ$ñ) ñ* ™+Õ&Ñ1ñ+ ñ, Ñ$ñ- ñ. Ñò/ rB   r°   )r‰   rŠ   r‹   rŒ   rë   rþ   r3   rI  r  rç   rá   rï   r�   rŽ   rð   s   @r@   rG  rG  Ø  s/   ø‡ € ñð$ !%€JÙ)/«€KØ $ÐØ€Gò
÷3 ƒ rB   rG  c                 ó’   € VP                   ^8X  g   Q RVP                    24       h\        P                  ! WP                  R7      pV# )r<   úUnexpected version: ©rI  )rç   r    r  rI  )rX   r³   r	  s   && r@   Ú!_int8_weight_only_quantize_tensorrP    sB   € Ø�>‰>˜QÔÐGÐ"6°v·~±~Ð6FÐ GÓGÐÜ×#Ò# F×8JÑ8JÔK€JØÐrB   c                ód   € V ^8„  d   QhR\         P                  P                  R\        R\        /# ©r<   rÊ   r³   r  )r[   r\   r¢   rG  r´   )r?   s   "r@   rA   rA     s.   € ÷ ñ Ü�H‰H�O‰Oðä ðô ñ	rB   c          	      ó˜  € VP                   '       d)   \        P                  P                  P	                  4        \        W4      '       g   Q R4       h\        \        W4      V4      p\        V V\        P                  P                  VRR7      4       \        P                  ! \        \        V P                   VR7      V 4      V n        V # )zRapplying int8 weight only quant requires module to have {parameter_name} attributeFrk   r  zqapplying int8 weight only quant requires module to have {parameter_name} attribute but {module} does not have one)r  r6  r7  r8  r9  r^   rP  rq   rL   r[   r\   rm   r¬   r­   r   r+   r®   ©rÊ   r³   r  Úquantized_tensors   &&$ r@   Ú_int8_weight_only_transformrV    s¼   € ð ×!×!Ð!Ü×Ñ×"Ñ"×EÑEÔGä�6×*Ò*ð ð	,óÐ*ô 9Ü�Ó'¨óÐô ØØÜ�‰×ÑÐ+¸5ÐÓAôô
 ×(Ò(ÜÜØ &× 1Ñ 1Ø)ô	
ð
 	ó€FÔð €MrB   c                ó4   € V ^8„  d   QhR\         R\         RR/# )r<   Úact_granularityrØ   r>   N)r0   )r?   s   "r@   rA   rA   (  s&   € ÷ 
ñ 
Ü ð
ä#ð
ð 
ñ
rB   c                 óB  € \         \        3p\        W4      '       g   \        R \	        V 4       R24      h\        V \        4      '       d+   V P
                  R8w  d   \        RV P
                   R24      h\        W4      '       g   \        R\	        V4       R24      hR# )z)Unsupported activation granularity type: z*. Only PerTensor and PerRow are supported.zMOnly PerRow(dim=-1) is supported for activation quantization, got PerRow(dim=zS). Per-feature activation quantization is not supported due to slicing limitations.z%Unsupported weight granularity type: NrG   )r4   r3   rZ   r½   rÇ   rý   )rX  rØ   Ú	supporteds   && r@   Ú_validate_granularity_int8r[  (  s½   € ô œFÐ#€IÜ�o×1Ò1ÜØ7¼¸_Ó8MÐ7Nð O7ð 8ó
ð 	
ô �/¤6×*Ò*¨×/BÑ/BÀbÔ/HÜðØ-×1Ñ1Ð2ð 3_ð`ó
ð 	
ô Ð(×4Ò4ÜØ3´DÐ9KÓ4LÐ3Mð N7ð 8ó
ð 	
ñ 5rB   c                   ól   a € ] tR tRt o Rt]P                  tRt]	! 4       t
Rt^tRtR tV 3R ltRtV tR# )	Ú%Int8DynamicActivationInt8WeightConfigiB  a¥  
Configuration for applying int8 dynamic per-token activation and int8 per-channel weight
quantization to linear layers.

Args:
    granularity: Optional[Union[Granularity, List[Granularity]]] = PerRow()
        The granularity for quantization. Can be either a single granularity (applied to both
        activations and weights) or a list of two granularities (first for activations, second for weights).
        If None, defaults to PerRow for both. Only PerTensor and PerRow are supported.
    act_mapping_type: Optional[MappingType] = MappingType.SYMMETRIC - Mapping type for activation quantization.
        SYMMETRIC and ASYMMETRIC are supported.
    set_inductor_config: bool = True - If True, adjusts `torchinductor` settings to recommended values
        for better performance with this quantization scheme.
    version (int): the version of the config
    reduce_range (Optional[bool] = False): If True, use reduced activation and weight quantization ranges
        to avoid overflow on CPU without VNNI. Users can call should_reduce_range() to help determine.

Example:

.. literalinclude:: ../../examples/inference/int8_dynamic_activation_int8_weight.py
   :language: python
FTc                óB  € \         P                  P                  R 4       V P                  ^8X  d   \	        R4      h\
        P                  ! V P                  4      w  r\        W4       V P                  \        P                  \        P                  39   g   Q R4       hR# )z:torchao.quantization.Int8DynamicActivationInt8WeightConfigz™version 1 of Int8DynamicActivationInt8WeightConfig has been removed, please use version 2, see https://github.com/pytorch/ao/issues/2752 for more detailsz·Int8DynamicActivationInt8WeightConfig requires `act_mapping_type` in (MappingType.SYMMETRIC, MappingType.ASYMMETRIC). Please set it to MappingType.SYMMETRIC or MappingType.ASYMMETRIC.N)r[   rº   r»   rç   r½   r    r   rI  r[  rÞ   r9   rÜ   rÛ   ©r‚   rX  rØ   s   &  r@   rá   Ú3Int8DynamicActivationInt8WeightConfig.__post_init__b  s™   € Ü�‰×$Ñ$ØHô	
ð �<‰<˜1ÔÜðQóð ô /9×.OÒ.OØ×Ñó/
Ñ+ˆô 	# ?ÔGØ×$Ñ$Ü×!Ñ!Ü×"Ñ"ð)
ô 
ð 		
ð&ó			
ò 
rB   c                ó¸   <€ V ^8„  d   Qh/ S[ S[,          ;R&   S[;R&   S[ S[S[S[S[,          3,          ,          ;R&   S[;R&   S[;R&   S[ S[,          ;R&   # )r<   rÞ   Úweight_only_decoderI  r  rç   Úreduce_range)r	   r9   rµ   r   r0   rI   rÔ   )r?   r�   s   "€r@   rA   Ú2Int8DynamicActivationInt8WeightConfig.__annotate__B  sp   ø‡ ‚ ñ2 ™{Õ+ÑCñ3 ñ4 Ñ$ñ5 ñ6 ™%¡©T±+Õ->Ð >Õ?Õ@ÑKñ7 ñ8 Ñ$ñ9 ñ: Ññ; ñ< ™4•.Ñ(ò= rB   r°   N)r‰   rŠ   r‹   rŒ   rë   r9   rÜ   rÞ   rb  r3   rI  r  rç   rc  rá   rï   r�   rŽ   rð   s   @r@   r]  r]  B  sB   ø‡ € ñð. /:×.CÑ.CÐØ$ÐÙCIÃ8€KØ $ÐØ€GØ#(€Lò
÷A ƒ rB   r]  c           
      ó  € VP                   ^8X  g   Q RVP                    24       h\        P                  ! VP                  4      w  r#\        P                  ! V V\        VVP                  VP                  R7      VP                  R7      pV# )r<   rN  ©rI  rû   rc  )rI  Úact_quant_kwargsrc  )rç   r    r   rI  r  r&   rÞ   rc  )rX   r³   rX  rØ   Úquantized_weights   &&   r@   Ú4_int8_dynamic_activation_int8_weight_quantize_tensorri  {  s‹   € Ø�>‰>˜QÔÐGÐ"6°v·~±~Ð6FÐ GÓGÐÜ*4×*KÒ*KØ×Ñó+Ñ'€Oô "×)Ò)ØØ&Ü3Ø'Ø×0Ñ0Ø×,Ñ,ô
ð
 ×(Ñ(ô	Ðð ÐrB   c                óŒ   € V ^8„  d   QhR\         P                  P                  R\        R\         P                  P                  /# )r<   rÊ   r³   r>   )r[   r\   r¢   r]  )r?   s   "r@   rA   rA   �  s6   € ÷ ñ Ü�H‰H�O‰Oðä1ðô
 ‡X�X‡_�_ñrB   c          	      ó¶  € VP                   '       d)   \        P                  P                  P	                  4        \        W4      '       g   Q R V R2RV  R2,           4       h\        \        W4      V4      p\        V V\        P                  P                  VRR7      4       \        P                  ! \        \        V P                   VR7      V 4      V n        V # )zKapplying int8 dynamic activation int8 weight quant requires module to have r3  r4  r5  Frk   r  )r  r6  r7  r8  r9  r^   ri  rq   rL   r[   r\   rm   r¬   r­   r   r+   r®   r:  s   &&$ r@   Ú._int8_dynamic_activation_int8_weight_transformrl  �  s×   € ð ×!×!Ð!Ü×Ñ×"Ñ"×EÑEÔGä�6×*Ò*ð Ø
UÐVdÐUeÐeoÐpØ�&�Ð+Ð
,õ	-óÐ*ô FÜ�Ó'¨ó€Jô ØØÜ�‰×Ñ˜:°UÐÓ;ôô
 ×(Ò(ÜÜØ &× 1Ñ 1Ø)ô	
ð
 	ó€FÔð €MrB   c                   ó‚   a € ] tR tRt o RtRtRt]! 4       t]	P                  tRt^tRtR tV 3R lR ltV 3R	 ltR
tV tR# )Ú$Int8StaticActivationInt8WeightConfigi°  ac  
Configuration for applying int8 static quantization to both activation and weight

Args:
    act_quant_scale (torch.Tensor): The scale tensor for activation quantization.
    act_quant_zero_point (torch.Tensor): The zero_point tensor for activation quantization (asymmetric only).
    granularity (Optional[Union[Granularity, List[Granularity]]] = PerRow()):
        The granularity for quantization. Can be either a single granularity (applied to both
        activations and weights) or a list of two granularities (first for activations, second for weights).
        If None, defaults to PerRow for both. Only PerTensor and PerRow are supported.
    act_mapping_type (MappingType): The mapping type for activation quantization. SYMMETRIC and ASYMMETRIC are supported.
    set_inductor_config (bool): if True, adjusts `torchinductor` settings to recommended values.
    version (int): the version of the config
    reduce_range (Optional[bool] = False): If True, use reduced activation and weight quantization ranges
        to avoid overflow on CPU without VNNI. Users can call should_reduce_range() to help determine.
NTFc                ó
  € \         P                  P                  R 4       \        P                  ! V P
                  4      w  r\        W4       V P                  \        P                  \        P                  39   g   Q R4       hR# )z9torchao.quantization.Int8StaticActivationInt8WeightConfigz¶Int8StaticActivationInt8WeightConfig requires `act_mapping_type` in (MappingType.SYMMETRIC, MappingType.ASYMMETRIC). Please set it to MappingType.SYMMETRIC or MappingType.ASYMMETRIC.N)r[   rº   r»   r    r   rI  r[  rÞ   r9   rÜ   rÛ   r_  s   &  r@   rá   Ú2Int8StaticActivationInt8WeightConfig.__post_init__Ë  sx   € Ü�‰×$Ñ$ØGô	
ô /9×.OÒ.OØ×Ñó/
Ñ+ˆô 	# ?ÔGØ×$Ñ$Ü×!Ñ!Ü×"Ñ"ð)
ô 
ð 		
ð&ó			
ò 
rB   c                ó    <€ V ^8„  d   QhRS[ /# )r<   r>   )r&   )r?   r�   s   "€r@   rA   Ú1Int8StaticActivationInt8WeightConfig.__annotate__Þ  s   ø€ ÷ 
ñ 
Ñ&@ñ 
rB   c                óŠ   € \         P                  ! V P                  4      w  r\        VV P                  V P
                  R7      # )z›Get the activation quantization kwargs for static quantization.

Returns:
    QuantizeTensorToInt8Kwargs with the configured granularity and mapping type.
rf  )r    r   rI  r&   rÞ   rc  r_  s   &  r@   Úget_act_quant_kwargsÚ9Int8StaticActivationInt8WeightConfig.get_act_quant_kwargsÞ  sD   € ô /9×.OÒ.OØ×Ñó/
Ñ+ˆô *Ø'Ø×.Ñ.Ø×*Ñ*ô
ð 	
rB   c                ó  <€ V ^8„  d   Qh/ S[ S[P                  ,          ;R&   S[ S[P                  ,          ;R&   S[ S[S[S[S[,          3,          ,          ;R&   S[ S[,          ;R&   S[;R&   S[;R&   S[ S[,          ;R&   # )r<   Úact_quant_scaleÚact_quant_zero_pointrI  rÞ   r  rç   rc  )	r	   r[   rö   r   r0   rI   r9   rµ   rÔ   )r?   r�   s   "€r@   rA   rr  °  s�   ø‡ ‚ ñ& ™eŸl™lÕ+Ñ2ñ' ñ( #¡5§<¡<Õ0Ñ7ñ) ñ* ™%¡©T±+Õ->Ð >Õ?Õ@ÑKñ+ ñ, ™{Õ+ÑCñ- ñ. Ñ$ñ/ ñ0 Ññ1 ñ2 ™4•.Ñ(ò3 rB   r°   )r‰   rŠ   r‹   rŒ   rë   rw  rx  r3   rI  r9   rÜ   rÞ   r  rç   rc  rá   rt  rï   r�   rŽ   rð   s   @r@   rn  rn  °  sQ   ø‡ € ñð" /3€OØ37ÐÙCIÃ8€KØ.9×.CÑ.CÐØ $ÐØ€GØ#(€Lò
÷&
ð 
÷] ƒ rB   rn  c                óX   € V ^8„  d   QhR\         P                  P                  R\        /# )r<   rÊ   r³   )r[   r\   r¢   rn  )r?   s   "r@   rA   rA   ð  s$   € ÷ .ñ .Ü�H‰H�O‰Oð.ä0ñ.rB   c          
      óÜ  € \         P                  ! VP                  4      w  r4\        W4      '       g   Q R V R24       hVP                  '       d)   \
        P                  P                  P                  4        RpVP                  e   VP                  P                  4       p\         P                  ! \        W4      V\        VVP                  VP                  R7      VP                   P                  4       VVP                  R7      p\#        V V\$        P&                  P)                  VRR7      4       \*        P,                  ! \/        \0        V P2                  VR7      V 4      V n        V # )z#Expected module to have attribute `z` but not foundNrf  )rI  rg  rw  rx  rc  Frk   r  )r    r   rI  r^   r  r6  r7  r8  r9  rx  Údetachr  rq   r&   rÞ   rc  rw  rL   r[   r\   rm   r¬   r­   r   r+   r®   )rÊ   r³   r  Úactivation_granularityrØ   rx  rU  s   &&$    r@   Ú-_int8_static_activation_int8_weight_transformr}  ï  sN  € ô 2<×1RÒ1RØ×Ñó2Ñ.Ðô �6×*Ò*ð Ø
-¨nÐ-=¸_ÐMóÐ*ð ×!×!Ð!Ü×Ñ×"Ñ"×EÑEÔGàÐØ×"Ñ"Ò.Ø%×:Ñ:×AÑAÓCÐä!×)Ò)Ü�Ó'Ø&Ü3Ø.Ø×0Ñ0Ø×,Ñ,ô
ð
 ×.Ñ.×5Ñ5Ó7Ø1Ø×(Ñ(ôÐô ØØÜ�‰×ÑÐ+¸5ÐÓAôô
 ×(Ò(ÜÜØ &× 1Ñ 1Ø)ô	
ð
 	ó€FÔð €MrB   c                   óF   a € ] tR tRt o Rt]tRt^tRt	R t
V 3R ltRtV tR# )ÚFloat8WeightOnlyConfigi!  aÇ  
Configuration for applying float8 weight-only symmetric quantization to linear layers.

Args:
    weight_dtype (torch.dtype): The target data type for weight quantization. Default is torch.float8_e4m3fn.
    set_inductor_config (bool): if True, adjusts `torchinductor` settings to recommended values.
    version (int): the version of the config, version 1 is deprecated, version 2 is using Float8Tensor (default)
    granularity (Granularity): quantization granularity. Supported: PerTensor, PerRow (default), PerGroup.

Note:
    The actual matmul will be computed in original precision of the weight tensor.

Example:

.. literalinclude:: ../../examples/inference/float8_weight_only.py
   :language: python
TNc                ó  € V P                   f   \        4       V n         \        V P                   \        \        \        34      '       g   Q R\        V P                   4       24       h\        P                  P                  R4       R # )Nz8granularity must be PerTensor, PerRow, or PerGroup, got z+torchao.quantization.Float8WeightOnlyConfig)	rI  r3   rZ   r4   r2   rÇ   r[   rº   r»   r¦   s   &r@   rá   Ú$Float8WeightOnlyConfig.__post_init__:  sj   € Ø×ÑÒ#Ü%›xˆDÔÜ˜$×*Ñ*¬Y¼ÄÐ,I×JÒJð 	
ØFÄtÈD×L\ÑL\ÓG]ÐF^Ð_ó	
ÐJô 	�‰×$Ñ$Ð%RÖSrB   c                ó^   <€ V ^8„  d   Qh/ S[ P                  ;R&   S[;R&   S[;R&   S[;R&   # )r<   rÖ   r  rç   rI  )r[   ré   rµ   rÔ   r0   )r?   r�   s   "€r@   rA   Ú#Float8WeightOnlyConfig.__annotate__!  s=   ø‡ ‚ ñ( —+‘+Ñ*ñ) ñ* Ñ$ñ+ ñ, Ññ- ñ. Ñ#ò/ rB   rO  )r‰   rŠ   r‹   rŒ   rë   r   rÖ   r  rç   rI  rá   rï   r�   rŽ   rð   s   @r@   r  r  !  s.   ø‡ € ñð$ !+€LØ $ÐØ€GØ#€KòT÷3 ƒ rB   r  c                 ó¬   € VP                   ^8X  g   Q RVP                    24       hVP                  p\        P                  ! WVP                  R7      pV# )r<   rN  )Úfloat8_dtyperI  )rç   rÖ   r   r  rI  )rX   r³   rÖ   r	  s   &&  r@   Ú _float8_weight_only_quant_tensorr†  C  sT   € Ø�>‰>˜QÔÐGÐ"6°v·~±~Ð6FÐ GÓGÐØ×&Ñ&€LÜ×%Ò%Ø°v×7IÑ7Iô€Jð ÐrB   c                ó˜   € V ^8„  d   QhR\         P                  P                  R\        R\        R\         P                  P                  /# r1  )r[   r\   r¢   r  r´   )r?   s   "r@   rA   rA   M  s@   € ÷ "ñ "Ü�H‰H�O‰Oð"ä"ð"ô ð	"ô
 ‡X�X‡_�_ñ"rB   c          	      óÚ  € VP                   '       d)   \        P                  P                  P	                  4        \        W4      '       g   Q R4       h\        V \        4      '       d   \        V 4      p \        \        W4      V4      p\        V V\        P                  P                  VRR7      4       \        P                   ! \#        \$        V P&                  VR7      V 4      V n        V # )zTapplying float8 weight only quant requires module to have {parameter_name} attributeFrk   r  zsapplying float8 weight only quant requires module to have {parameter_name} attribute but {module} does not have one)r  r6  r7  r8  r9  r^   rZ   r   Ú_unwrap_float8_linearr†  rq   rL   r[   r\   rm   r¬   r­   r   r+   r®   rT  s   &&$ r@   Ú_float8_weight_only_transformrŠ  L  sÓ   € ð ×!×!Ð!Ü×Ñ×"Ñ"×EÑEÔGä�6×*Ò*ð ð	,óÐ*ô
 �&œ,×'Ò'Ü& vÓ.ˆä7Ü�Ó'¨óÐô ØØÜ�‰×ÑÐ+¸5ÐÓAôô
 ×(Ò(ÜÜØ &× 1Ñ 1Ø)ô	
ð
 	ó€FÔð €MrB   c                   óŠ   a € ] tR tRt o Rt]t]tRt]	P                  tRtRtRt]P                   tRt^t^ tR tV 3R ltRtV tR# )Ú)Float8DynamicActivationFloat8WeightConfigir  a~  
Configuration for applying float8 dynamic symmetric quantization to both activations and weights of linear layers.

Args:
    activation_dtype (torch.dtype): The target data type for activation quantization. Default is torch.float8_e4m3fn.
    weight_dtype (torch.dtype): The target data type for weight quantization. Default is torch.float8_e4m3fn.
    granularity (Optional[Union[FP8Granularity, List[FP8Granularity]]]):
        The granularity for quantization. Can be either a single granularity (applied to both
        activations and weights) or a tuple of two granularities (one for activations, one for weights).
        If None, defaults to PerTensor for both. Currently both quantizations need to be the same type. And
        only PerTensor and PerRow are supported.
    mm_config (Float8MMConfig): Configuration for the matrix multiplication. Default uses fast accumulation.
    activation_value_lb (Optional[float]): the lower bound for activation value for calculating scale
    activation_value_ub (Optional[float]): the upper bound for activation value for calculating scale
    kernel_preference (KernelPreference): kernel preference for ops like matmul, grouped matmul etc. by defalut (KernelPreference.AUTO) it will be chosen for user based on hardware or other information, this only needs to be set in weight
    set_inductor_config (bool): if True, adjusts `torchinductor` settings to recommended values.
    version (int): the version of the config, version 1 is deprecated, version 2 is using Float8Tensor (default)

Example:

.. literalinclude:: ../../examples/inference/float8_dynamic_activation_float8_weight.py
   :language: python
NTc                óê  € \         P                  P                  R 4       \        V P                  4      w  rW.V n        Rp\        V P                  4      '       dQ   V P                  \        P                  \        P                  39   g   Q R4       hV P                  ^8¼  g   Q R4       hRp\         P                  P                  4       '       d   RpV P                  f   \        VR7      V n        R# R# )z>torchao.quantization.Float8DynamicActivationFloat8WeightConfigTÚunimplementedFN)Úuse_fast_accum)r[   rº   r»   r   rI  r   Úkernel_preferencer   ÚAUTOÚTORCHrç   ÚxpuÚis_availableÚ	mm_configr   )r‚   r|  rØ   Údefault_use_fast_accums   &   r@   rá   Ú7Float8DynamicActivationFloat8WeightConfig.__post_init__˜  sâ   € Ü�‰×$Ñ$ØLô	
ô 6LØ×Ñó6
Ñ2Ðð 3ÐGˆÔà!%ÐÜ,¨T×-=Ñ-=×>Ò>Ø×)Ñ)Ü ×%Ñ%Ü ×&Ñ&ð.ô ð ð óð ð —<‘< 1Ô$Ð5 oÓ5Ð$Ø%*Ð"Ü�9‰9×!Ñ!×#Ò#à%*Ð"à�>‰>Ò!Ü+Ð;QÔRˆDŽNñ "rB   c                ó<  <€ V ^8„  d   Qh/ S[ P                  ;R&   S[ P                  ;R&   S[S[S[S[S[,          3,          ,          ;R&   S[S[,          ;R&   S[S[,          ;R&   S[S[,          ;R&   S[S[,          ;R&   S[	;R&   S[
;R	&   S[;R
&   S[;R&   # )r<   r$  rÖ   rI  Úpacking_formatr•  Úactivation_value_lbÚactivation_value_ubr�  r  rç   Úalg_id)r[   ré   r	   r   r   r   r   r   Úfloatr   rµ   rÔ   )r?   r�   s   "€r@   rA   Ú6Float8DynamicActivationFloat8WeightConfig.__annotate__r  sÌ   ø‡ ‚ ñ4 —k‘kÑ.ñ5 ñ6 —+‘+Ñ*ñ7 ñ8 ™%¡±±^Õ0DÐ DÕEÕFÑMñ9 ñ: Ñ0Õ1ÑMñ; ñ< ™Õ'Ñ.ñ= ñ> "¡%�Ñ/ñ? ñ@ "¡%�Ñ/ñA ñB (Ñ?ñC ñD Ñ$ñE ñF ÑñG ñH �OòI rB   )rI  r•  )r‰   rŠ   r‹   rŒ   rë   r   r$  rÖ   rI  r   r   r™  r•  rš  r›  r   r‘  r�  r  rç   rœ  rá   rï   r�   rŽ   rð   s   @r@   rŒ  rŒ  r  sb   ø‡ € ñð0 %/ÐØ *€LØIM€KØ4G×4MÑ4M€NØ*.€IØ+/ÐØ+/ÐØ*:×*?Ñ*?ÐØ $ÐØ€GØ€FòS÷M ƒ rB   rŒ  c           	      óÜ  € VP                   pVP                  pVP                  pVP                  pVP                  pVP
                  pVP                  pVP                  p	\        V4       Vw  r«V P                  4       R9   du   \        V
\        4      '       d   \        V\        4      '       g   Q R4       hV P                  ^ ,          ^,          ^ 8w  g    V P                  ^,          ^,          ^ 8w  d   V # M\        V 4      '       g   V # VP                  ^8X  g   Q RVP                   24       hV	\        P                   8X  d=   \        V\"        4      '       d'   V P$                  \&        P(                  8X  g   Q R4       h\+        VV
VVVR7      pV	\        P                   8X  d   \,        P.                  ! V VVVVVR7      pV# V	\        P0                  8X  d:   \        V\"        4      '       g   Q R4       h\2        P.                  ! V VVVR7      pV# V	\        P4                  8X  dE   \        V\        4      '       g   Q R4       h\6        P.                  ! V VVVVP8                  R	7      pV# R
# )é   zH4D/5D tensor only supports per tensor activation and weight quantizationrN  zBPerRow quantization only works for bfloat16 precision input weight)Úhp_value_lbÚhp_value_ubr�  )r…  rI  r•  r�  rg  z8Sparse packing format only supports per-row quantization)r…  rI  rg  zOSparse 1D data 1D metadata packing format only supports per-tensor quantization)r…  rI  rg  rœ  N)r   é   )r$  rÖ   rI  r•  rš  r›  r�  r™  r   rý   rZ   r4   r¥   r)   rç   r   r   r3   ré   r[   r-  r%   r   r  ÚSPARSE_2D_DATA_2D_METADATAr   ÚSPARSE_1D_DATA_1D_METADATAr   rœ  )rX   r³   r$  rÖ   rI  r•  rš  r›  r�  r™  r|  rØ   rg  rh  s   &&            r@   Ú8_float8_dynamic_activation_float8_weight_quantize_tensorr¦  ±  ss  € Ø×.Ñ.ÐØ×&Ñ&€LØ×$Ñ$€KØ× Ñ €IØ ×4Ñ4ÐØ ×4Ñ4ÐØ×0Ñ0ÐØ×*Ñ*€Nô ˜KÔ(Ø1<Ñ.Ðð ‡z�zƒ|�vÔäÐ0´)×<Ò<ÄØ¤	÷B
ò B
ð 	VàUó	Vð 
ð �<‰<˜�?˜RÕ 1Ô$¨¯©°Q­¸"Õ(<ÀÔ(AØˆMð )Bä˜F×#Ò#ð ˆØ�>‰>˜QÔÐGÐ"6°v·~±~Ð6FÐ GÓGÐØÔ,×2Ñ2Ô2´zØœF÷8ò 8ð �|‰|œuŸ~™~Ô-ð 	
ØPó	
Ð-ô 4ØØØ'Ø'Ø+ôÐð Ô,×2Ñ2Ô2Ü'×/Ò/ØØ%Ø*ØØ/Ø-ô
Ðð  ÐØ	Ô.×IÑIÔ	IÜÐ,¬f×5Ò5ð 	
ØFó	
Ð5ô B×IÒIØØ%Ø*Ø-ô	
Ðð  ÐØ	Ô.×IÑIÔ	IÜÐ,¬i×8Ò8ð 	
Ø]ó	
Ð8ô B×IÒIØØ%Ø*Ø-Ø—=‘=ô
Ðð  Ðñ 
JrB   c                ó(   € V ^8„  d   QhR\         RR/# )r<   r³   r>   N)rŒ  )r?   s   "r@   rA   rA     s   € ÷ %ñ %Ü5ð%à	ñ%rB   c                 óR  € \         P                  P                  4       '       g   R # \         P                  P                  e0   \         P                  P                  P	                  R4      '       g   R # \
        ;QJ d&    R V P                   4       F  '       g   K   RM	  RM! R V P                   4       4      '       g   R # V P                  \        P                  8X  d   R # V P                  e   V P                  P                  '       g   R # \        P                  ! R4       R # )Nz12.9c              3   óB   "  € T F  p\        V\        4      x € K  	  R # 5ir   )rZ   r3   )Ú.0Úgs   & r@   Ú	<genexpr>Ú4_maybe_warn_rowwise_fp8_cuda_12_9.<locals>.<genexpr>  s   é € ÐAÑ.@¨Œz˜!œV×$Ð$Ó.@ùs   ‚TFa  Rowwise fp8 (Float8DynamicActivationFloat8WeightConfig with PerRow()) on CUDA 12.9 can crash with CUBLAS_STATUS_NOT_SUPPORTED for some large-K + small-M/N GEMM shapes, due to a cuBLASLt regression specific to CUDA 12.9 (not present in 12.6, fixed in 13.0). We can't reliably predict which shapes fail, so we warn rather than guard. If you hit this, work around it with any of:
  (1) upgrade to CUDA 13.0 (or downgrade to 12.6), where the regression is not present; or
on the affected layers (e.g. via FqnToConfig):
  (2) the mslk kernel, which uses CUTLASS instead of cuBLASLt and is unaffected: Float8DynamicActivationFloat8WeightConfig(granularity=PerRow(), kernel_preference=KernelPreference.MSLK). This requires the mslk package to be installed (see https://github.com/pytorch/MSLK); or
  (3) disabling fast accumulation, which avoids the failing cuBLASLt path: Float8DynamicActivationFloat8WeightConfig(granularity=PerRow(), mm_config=Float8MMConfig(use_fast_accum=False)).
See https://github.com/pytorch/ao/issues/4582.)r[   Úcudar”  rç   Ú
startswithÚanyrI  r�  r   ÚMSLKr•  r�  ÚwarningsÚwarn)r³   s   &r@   Ú!_maybe_warn_rowwise_fp8_cuda_12_9r´    sÄ   € ô �:‰:×"Ñ"×$Ò$Ùô ‡}�}×ÑÒ!¬¯©×);Ñ);×)FÑ)FÀv×)NÒ)NÙç‹3ÑA¨f×.@Ò.@ÓA�3�3Š3ÑA¨f×.@Ò.@ÓA×AÒAÙà×ÑÔ#3×#8Ñ#8Ô8Ùð ×ÑÒ#¨F×,<Ñ,<×,K×,KÐ,KÙÜ‡M‚Mð	9örB   c                ód   € V ^8„  d   QhR\         P                  P                  R\        R\        /# rR  )r[   r\   r¢   rŒ  r´   )r?   s   "r@   rA   rA   .  s.   € ÷ $ñ $Ü�H‰H�O‰Oð$ä5ð$ô ñ	$rB   c          	      óÄ  € \        V4       \        P                  P                  4       '       d8   \	        4       '       g(   \        4       '       g   \        4       '       g   Q R 4       hVP                  '       d)   \        P                  P                  P                  4        \        W4      '       g   Q RV R2RV  R2,           4       h\        V \        4      '       d   \        V 4      p \!        \#        W4      V4      p\%        V V\        P&                  P)                  VRR7      4       \*        P,                  ! \/        \0        V P2                  VR7      V 4      V n        V # )zPFloat8 dynamic activation quantization is only supported on CUDA>=8.9 and MI300+zKapplying float8 dynamic activation quant requires module to have parameter r3  r4  r5  Frk   r  )r´  r[   r®  r”  r/   r-   r.   r  r6  r7  r8  r9  r^   rZ   r   r‰  r¦  rq   rL   r\   rm   r¬   r­   r   r+   r®   rT  s   &&$ r@   Ú2_float8_dynamic_activation_float8_weight_transformr·  -  s1  € ô & fÔ-Ü‡z�z×Ñ× Ò Ü ×"Ò"¤h§j¢j´H·J²Jð 	
Ø^ó	
Ð>ð ×!×!Ð!Ü×Ñ×"Ñ"×EÑEÔGä�6×*Ò*ð Ø
UÐVdÐUeÐeoÐpØ�&�Ð+Ð
,õ	-óÐ*ô �&œ,×'Ò'Ü& vÓ.ˆÜOÜ�Ó'¨óÐô ØØÜ�‰×ÑÐ+¸5ÐÓAôô
 ×(Ò(ÜÜØ &× 1Ñ 1Ø)ô	
ð
 	ó€FÔð €MrB   c                óh   € V ^8„  d   QhR\         R\        P                  R\        P                  RR/# )r<   Úintx_unpacked_tensorÚ	hp_tensorÚscale_dtyper>   N)r$   r[   rö   ré   )r?   s   "r@   rA   rA   U  s8   € ÷ ñ Ü2ðä�|‰|ðô —‘ðð 
ñ	rB   c           
     ó.  € \        V \        4      '       g   Q hV P                  P                  V4      V n        \        V P
                  ,          w  r4\        VV P                  V P                  V P                  \        P                  VVR7      V n        R# )aP  
Adjusts the scale_dtype on IntxUnpackedToInt8Tensor.
Updating the scale dtype requires updating the qdata because qdata is calculated after the scale.
This is used in IntxWeightOnlyConfig and Int8DynamicActivationIntxWeightConfig to make
version=2 and version=1 numerically equivalent when the scale_dtype differs from the input dtype
)Úoutput_dtypeÚ	quant_minÚ	quant_maxN)rZ   r$   ÚscalerH   r8   Útarget_dtyper:   r  Ú
zero_pointr[   rì   Úqdata)r¹  rº  r»  ÚqminÚqmaxs   &&&  r@   r  r  U  s   € ô Ð*Ô,D×EÒEÐEÐEØ!5×!;Ñ!;×!>Ñ!>¸{Ó!KÐÔÜ(Ð)=×)JÑ)JÕK�J€DÜ!0ØØ×'Ñ'Ø×"Ñ"Ø×'Ñ'Ü—Z‘ZØØô"ÐÖrB   c                   ó®   a € ] tR tRt o Rt]P                  t]! ^ 4      t	]
P                  tRt]P                  t]P$                  t^tR tV 3R ltRtV tR# )ÚIntxWeightOnlyConfigin  a  
Configuration for quantizing weights to torch.intx, with 1 <= x <= 8.
Weights are quantized with scales/zeros in a groupwise or channelwise
manner using the number of bits specified by weight_dtype.
args:
    `weight_dtype`: The dtype to use for weight quantization.  Must be torch.intx, where 1 <= x <= 8.
    `granularity`: The granularity to use for weight quantization.  Must be PerGroup or PerAxis(0).
    `mapping_type`: The type of mapping to use for the weight quantization.
        Must be one of MappingType.ASYMMETRIC or MappingType.SYMMETRIC.
    `scale_dtype`: The dtype to use for the weight scale.
    `intx_packing_format`: The format to use for the packed weight tensor (version 2 only).
    `intx_choose_qparams_algorithm`: The algorithm to use for choosing the quantization parameters.
    `version`: version of the config to use, only subset of above args are valid based on version, see note for more details.

Example:

.. literalinclude:: ../../examples/inference/intx_weight_only.py
   :language: python
Nc           	     ó¸  € \         P                  P                  R 4       V P                  \	        ^^	4       Uu. uF  p\        \         RV 24      NK  	  up9   g   Q RV P                   24       h\        V P                  \        \        34      '       g   Q RV P                   24       h\        V P                  \        4      '       d:   V P                  P                  ^ 8X  g   Q RV P                  P                   24       hV P                  \        P                  \        P                  \        P                  39   g   Q RV P                   24       hR# u upi )z)torchao.quantization.IntxWeightOnlyConfigrÔ   rÕ   z1granularity must be PerAxis or PerGroup, but got rø   zvmapping_type must be MappingType.ASYMMETRIC, MappingType.SYMMETRIC, or MappingType.SYMMETRIC_NO_CLIPPING_ERR, but got N)r[   rº   r»   rÖ   r×   rq   rZ   rI  r1   r2   rÙ   rû   r9   rÛ   rÜ   rÝ   rß   s   & r@   rá   Ú"IntxWeightOnlyConfig.__post_init__Ž  sV  € Ü�‰×$Ñ$Ð%PÔQØ× Ñ ÌÈaÐQRÌÓ$TÉÀ1¤W¬U°c¸!¸°IÖ%>ÉÑ$TÔTð 	
ØJÈ4×K\ÑK\ÐJ]Ð^ó	
ÐTô ˜$×*Ñ*¬W´hÐ,?×@Ò@ð 	
Ø?À×@PÑ@PÐ?QÐRó	
Ð@ô �d×&Ñ&¬×0Ò0Ø×#Ñ#×(Ñ(¨AÔ-ð Ø7¸×8HÑ8H×8MÑ8MÐ7NÐOóÐ-ð × Ñ Ü×"Ñ"Ü×!Ñ!Ü×1Ñ1ð%
ô 
ð 	
ð
 Eð  FJ÷  FWñ  FWð  EXð  Yó	
ò 
ùò %Us   ¹Ec                ó¦   <€ V ^8„  d   Qh/ S[ P                  ;R&   S[;R&   S[;R&   S[S[ P                  ,          ;R&   S[;R&   S[;R&   S[;R&   # )r<   rÖ   rI  rû   r»  rå   ræ   rç   rè   )r?   r�   s   "€r@   rA   Ú!IntxWeightOnlyConfig.__annotate__n  so   ø‡ ‚ ñ, —+‘+Ñ*ñ- ñ. Ñ)ñ/ ñ0 Ñ5ñ1 ñ2 ™%Ÿ+™+Õ&Ñ-ñ3 ñ4 +ÑOñ5 ñ6 $>ñ ñ7 ñ< Ñò= rB   r°   )r‰   rŠ   r‹   rŒ   rë   r[   rì   rÖ   r1   rI  r9   rÜ   rû   r»  r#   rí   rå   r!   rî   ræ   rç   rá   rï   r�   rŽ   rð   s   @r@   rÇ  rÇ  n  s\   ø‡ € ñð( !&§
¡
€LÙ& q›z€KØ +× 5Ñ 5€LØ)-€KØ->×-OÑ-OÐà"×)Ñ)ð "ð €Gò
÷A ƒ rB   rÇ  c                ó„   € V ^8„  d   QhR\         \        P                  ,          R\         \        P                  ,          /# rô   rõ   )r?   s   "r@   rA   rA   £  s6   € ÷ ;Oñ ;Oô œ5Ÿ<™<Õ(ð	;Oô
  ¤§¡Õ-ñ;OrB   c          
      ó  € VP                   pVP                  pVP                  pVP                  pVP                  pVP
                  p	V P                  4       ^8X  d   Rp
M4V P                  4       ^8X  d   ^p
M\        RV P                  4        24      h\        V\        4      '       d   VP                  pM]\        V\        4      '       d:   VP                  ^ 8X  g   Q RVP                   24       hV P                  V
,          pM\        RV 24      hV P                  4       ^8X  d   ^V3pMV P                  4       ^8X  g   Q h^V^^3pVP                  ^8X  g   Q hVP                  \        P                   8X  d‚   Ve?   VP"                  \$        P&                  8X  d    VP)                  \$        P*                  4      p\,        P.                  ! V VVVVVV	R7      pVe   WpP"                  8w  d   \1        WÐV4       V# \        RV 24      h)r<   z>IntxWeightOnlyConfig only works for 2-d and 4-d Tensors, got: rø   z-granularity must be PerGroup or PerAxis, got )rû   rñ   rò   ræ   rù   rG   )rÖ   rI  rû   r»  rå   ræ   rý   r½   rZ   r2   rþ   r1   rÙ   r¥   rç   r#   rí   ré   r[   r  rH   rì   r$   r  r  )rX   r³   rñ   rò   rÖ   rI  rû   r»  rå   ræ   Ú	input_dimrþ   r  r	  s   &&$$          r@   Ú!_intx_weight_only_quantize_tensorrÏ  £  së  € ð ×&Ñ&€LØ×$Ñ$€KØ×&Ñ&€LØ×$Ñ$€KØ ×4Ñ4ÐØ$*×$HÑ$HÐ!à‡z�zƒ|�qÔØ‰	Ø	�‰‹˜Ô	à‰	äØLÈVÏZÉZË\ÈNÐ[ó
ð 	
ô �+œx×(Ò(Ø ×+Ñ+‰
Ü	�K¤×	)Ò	)Ø×Ñ 1Ô$ð 	
Ø3°K×4DÑ4DÐ3EÐFó	
Ð$ð —\‘\ )Õ,‰
äÐHÈÈÐVÓWÐWà‡z�zƒ|�qÔØ˜�_‰
ð �z‰z‹|˜qÔ Ð Ð Ø˜ Q¨Ð*ˆ
à�>‰>˜QÔÐÐØ×!Ñ!Ô%6×%GÑ%GÔGØÒ(Ð->×-DÑ-DÌÏÉÔ-SØ 1× 4Ñ 4´U·Z±ZÓ @ÐÜ-×5Ò5ØØØØ%Ø%Ø/Ø*Gô
ˆ
ð Ò" {·l±lÔ'BÜ7¸
ÈKÔXàÐäÐ7Ð8KÐ7LÐMÓNÐNrB   c                ó  € V ^8„  d   QhR\         P                  P                  R\        R\        R\
        \         P                  ,          R\
        \         P                  ,          R\         P                  P                  /# r  )r[   r\   r¢   rÇ  r´   r	   rö   )r?   s   "r@   rA   rA   â  sf   € ÷ ñ Ü�H‰H�O‰Oðä ðô ð	ô
 œ5Ÿ<™<Õ(ðô  ¤§¡Õ-ðô ‡X�X‡_�_ñrB   c          	      óH  € \        W4      '       g   Q R V R2RV  R2,           4       h\        \        W4      VVVR7      p\        V V\        P
                  P                  VRR7      4       \        P                  ! \        \        V P                  VR7      V 4      V n        V # )z8applying intx weight only quant requires module to have r3  r4  r5  r  Frk   r  )r^   rÏ  rq   rL   r[   r\   rm   r¬   r­   r   r+   r®   )rÊ   r³   r  rñ   rò   r	  s   &&$$$ r@   Ú_intx_weight_only_transformrÒ  á  s¸   € ô �6×*Ò*ð Ø
BÀ>ÐBRÐR\Ð]Ø�&�Ð+Ð
,õ	-óÐ*ô 3Ü�Ó'ØØ!Ø+ô	€Jô ØØÜ�‰×Ñ˜:°UÐÓ;ôô
 ×(Ò(ÜÜØ &× 1Ñ 1Ø)ô	
ð
 	ó€FÔð €MrB   c                   ód   a € ] tR tRt o Rt]! ]R7      t]! ]R7      t^t	R t
R tV 3R ltRtV tR# )	r¼   i  aÃ  Configuration class for applying different quantization configs to modules or parameters based on their fully qualified names (FQNs).

Args:
    `fqn_to_config`: typing.OrderedDict[str, Optional[AOBaseConfig]]: an
        ordered dictionary from a key to the config that we want to apply
        to the module/param (or None). A key is one of:

        1. fully qualified name (fqn) of module or parameter
        2. regex of fully qualified name (in python `re` module regex format), should
           start with prefix "re:" or
        3. "_default"

        Config key ordered by precedence:

        * fully qualified parameter name, e.g. `language.layers.0.q_proj.weight`
        * fully qualified module name, e.g. `language.layers.0.q_proj`
        * regex for parameter names, must start with `re:`, e.g. `re:language\.layers\..+\.q_proj.weight`.
          The first regex that matches will be applied.
        * regex for module names, must start with `re:`, e.g. `re:language\.layers\..+\.q_proj`,
          whichever regex fully matches the module fqn first will be applied
          (order of keys for dictionary are kept consistent since we are using OrderedDict)
        * "_default", fallback if no match for all previous keys
          (Note, when using `_default`, the config is applied to all modules, to apply
          it to only a subset of modules, e.g. with some types, it's better to filter
          the modules that we don't want to quantize before hand and configure them to
          None, e.g. `{"re:.+norm.+": None, "_default": linear_config}`) "_default" is not supported when filter_fn is not specified.
    `module_fqn_to_config`: typing.OrderedDict[str, Optional[AOBaseConfig]]: To maintain BC with ModuleFqnToConfig, to be deprecated later
    `version`: int: Version of config to use.

Note:
    - The order of patterns in the OrderedDict may matter as only the first matching pattern is applied
    - "_default" is ignored for parameter replacement.
)Údefault_factoryc                ó^  € \         P                  P                  R 4       \        V P                  4      ^ 8”  dA   \        V P
                  4      ^ 8”  d'   V P                  V P
                  8w  d   \        R4      h\        V P
                  4      ^ 8”  d,   \        V P                  4      ^ 8X  d   V P
                  V n        \        V P                  4      ^ 8”  d,   \        V P
                  4      ^ 8X  d   V P                  V n        RV P                  9   d   \        P                  ! R4       R# R# )z torchao.quantization.FqnToConfigzP`fqn_to_config` and `module_fqn_to_config` are both specified and are not equal!r¸   z¦Config Deprecation: _default is deprecated and will no longer be supported in a future release. Please see https://github.com/pytorch/ao/issues/3229 for more details.N)	r[   rº   r»   ÚlenrÃ   Úmodule_fqn_to_configr½   r²  r³  r¦   s   &r@   rá   ÚFqnToConfig.__post_init__1  sð   € Ü�‰×$Ñ$Ð%GÔHô �×"Ñ"Ó# aÔ'Ü�D×-Ñ-Ó.°Ô2Ø×"Ñ" d×&?Ñ&?Ô?äØbóð ô
 ˆt×(Ñ(Ó)¨AÔ-´#°d×6HÑ6HÓ2IÈQÔ2NØ!%×!:Ñ!:ˆDÔäˆt×!Ñ!Ó" QÔ&¬3¨t×/HÑ/HÓ+IÈQÔ+NØ(,×(:Ñ(:ˆDÔ%ð ˜×+Ñ+Ô+Ü�MŠMð yöñ ,rB   c                ól   € R P                  R.R V P                  P                  4        4       ORN4      # )Ú
zFqnToConfig({c              3   ó8   "  € T F  w  rR V RV R2x € K  	  R# 5i)z  'z':
    Ú,Nr°   )rª  ÚkeyÚvalues   &  r@   r¬  Ú&FqnToConfig.__str__.<locals>.<genexpr>N  s(   é € ð á&@™
˜ð ˜#˜˜h u g¨QÕ/Û&@ùs   ‚z}))ÚjoinrÃ   rÀ   r¦   s   &r@   Ú__str__ÚFqnToConfig.__str__J  sF   € Ø�y‰yàðñà&*×&8Ñ&8×&>Ñ&>Ô&@óðð ðó	
ð 		
rB   c                óŠ   <€ V ^8„  d   Qh/ S[ S[S[S[,          3,          ;R&   S[ S[S[S[,          3,          ;R&   S[;R&   # )r<   rÃ   r×  rç   )ÚOrderedDictTyper´   r	   r   rÔ   )r?   r�   s   "€r@   rA   ÚFqnToConfig.__annotate__  sT   ø‡ ‚ ñH #¡3©±Õ(>Ð#>Õ?ñ ñI ñP *©#©x¹Õ/EÐ*EÕFñ ñQ ñV ÑòW rB   )rÃ   r×  N)r‰   rŠ   r‹   rŒ   rë   r   r   rÃ   r×  rç   rá   rá  rï   r�   rŽ   rð   s   @r@   r¼   r¼     sI   ø‡ € ñ ñD CHØ#ôC€Mñ JOØ#ôJÐð €Gòò2

÷M ƒ rB   r¼   c                ó®   € V ^8„  d   QhR\         \        P                  P                  \        .\        P                  P                  3,          R\
        /# )r<   rÏ   r>   )r   r[   r\   r¢   r   rµ   )r?   s   "r@   rA   rA   [  s?   € ÷ Yñ YÜ”u—x‘x—‘¬Ð5´u·x±x·±ÐFÕGðYä	ñYrB   c                óf   € \         P                  ! V 4      P                  P                  RR4      RJ# )zk
Returns True if the handler function has a "parameter_name" kwarg in its type signature, False otherwise.
r  N)ÚinspectÚ	signatureÚ
parametersÚget)rÏ   s   &r@   Ú"_handler_supports_fqn_quantizationrì  [  s/   € ô ×Ò˜WÓ%×0Ñ0×4Ñ4Ð5EÀtÓLÐTXÐXÐXrB   c                ód   € V ^8„  d   QhR\         P                  P                  R\        R\        /# ©r<   rÊ   Úfqnr³   )r[   r\   r¢   r´   r¼   )r?   s   "r@   rA   rA   d  s3   € ÷ [ñ [Ü�H‰H�O‰Oð[ä	ð[ô ñ[rB   c                óî  € Rp. p\        \        V P                  4       4      4       FF  w  pw  rgV\        V 4      9   g   K  \	        V4      ^ 8”  d   V RV 2MTpVP                  WVWx34       KH  	  \        V4       FŒ  w  rVrxW‚P                  9   g   K  RpVP                  V,          p	V	f   VP                  V4       KD  \        \        V	4      ,          p
\        V
4      '       d   V
! W	VR7      p Kw  \        \        V	4       R24      h	  V'       gH   WP                  9   d8   VP                  V,          p	V	e   \        \        V	4      ,          p
V
! W	4      # V # V F»  w  rVrxVP                   F¥  pVP                  R4      '       g   K  \        P                  ! VR,          V4      '       g   KB  RpVP                  V,          p	V	f   K]  \        \        V	4      ,          p
\        V
4      '       d   V
! W	VR7      p K�  \        \        V	4       R24      h	  K½  	  V'       gŒ   VP                   F{  pVP                  R4      '       g   K  \        P                  ! VR,          V4      '       g   KB  VP                  V,          p	V	e!   \        \        V	4      ,          p
V
! W	4      u # V u # 	  V'       g?   VP                  P                  R	R4      p	V	e   \        \        V	4      ,          p
V
! W	4      # V # )
aO  This function expects a module that either is specified in FqnToConfig or has a parameter that is specified in FqnToConfig.

Args:
    module (torch.nn.Module): The module to be processed.
    fqn (str): The fully qualified name of the module containing the parameters.
    config (FqnToConfig): Configuration object containing regex patterns / fqn mapped
        to quantization configurations.

Returns:
    torch.nn.Module: The modified module with quantized parameters.

Raises:
    NotImplementedError: If the quantization configuration is not yet supported for parameter quantization.
FrF   TN)r  zs does not yet support parameter quantization! Please see https://github.com/pytorch/ao/issues/3252 for more detailsúre:ºé   NNr¸   )Ú	enumeraterI   Únamed_parametersÚdirrÖ  ÚappendrÃ   ry   r'   rÇ   rì  ÚNotImplementedErrorr¯  ÚreÚ	fullmatchrë  )rÊ   rï  r³   Úparameter_config_foundÚtop_level_paramsÚir  ÚparamÚparameter_fqnÚcrÏ   Úpatterns   &&&         r@   rÄ   rÄ   d  s¥  € ð& #ÐØÐÜ&/´°V×5LÑ5LÓ5NÓ0OÖ&PÑ"ˆÑ"ˆNØœS ›[Ö(ä-0°«X¸¬\�3�%�q˜Ð(Ñ)¸~ð ð ×#Ñ# Q¸Ð$MÖNñ 'Qô 48Ð8HÖ3IÑ/ˆ˜5Ø×0Ñ0Ö0Ø%)Ð"Ø×$Ñ$ ]Õ3ˆAàŠyØ ×$Ñ$ QÖ'ä2´4¸³7Õ;�Ü5°g×>Ò>á$ V¸~ÔN’Fä-Ü ›7˜)ð  $Wð  Xóð ñ 4J÷$ " c×-AÑ-AÔ&AØ× Ñ  Õ%ˆØŠ=Ü.¬t°A«wÕ7ˆGÙ˜6Ó%Ð%àˆMó 4DÑ/ˆ˜5Ø×+Ô+ˆGØ×!Ñ! %×(Ô(¬R¯\ª\¸'À"½+À}×-UÔ-UØ)-Ð&Ø×(Ñ(¨Õ1�Ø”=Ü6´t¸A³wÕ?�GÜ9¸'×BÒBá!(¨À>Ô!Ršä1Ü# A›w˜ið  ([ð  \óð ó ,ñ 4D÷  "Ø×+Ô+ˆGà×!Ñ! %×(Ô(¬R¯\ª\¸'À"½+Às×-KÔ-KØ×(Ñ(¨Õ1�Ø’=Ü6´t¸A³wÕ?�GÙ" 6Ó-Ò-à!’Mñ ,÷ "Ø× Ñ ×$Ñ$ Z°Ó6ˆØŠ=Ü.¬t°A«wÕ7ˆGá˜6Ó%Ð%à€MrB   c                ó0   € V ^8„  d   QhR\         R\        /# )r<   rï  r³   )r´   r¼   )r?   s   "r@   rA   rA   Â  s   € ÷ ñ Ü	ðäñrB   c                ó  € WP                   9   d%   V P                  R4      '       d   Q RV  R24       hR# VP                    FC  pVP                  R4      '       g   K  \        P                  ! VR,          V 4      '       g   KB   R# 	  R# )aM  Check if a given fqn matches the exact fqn or regex pattern specified in FqnToConfig.

Args:
    fqn (str): The fully qualified name of the module.
    config (FqnToConfig): Configuration object containing regex patterns or raw FQNs for quantization.

Returns:
    bool: True if the fqn is specified in FqnToConfig. False otherwise.
rñ  zError: Exact match but regex z specified.Trò  F)rÃ   r¯  rù  rú  )rï  r³   Ú!maybe_module_or_param_fqn_patterns   && r@   rÁ   rÁ   Â  s†   € ð ×"Ñ"Ô"Ø—>‘> %×(Ò(ð 	
Ø+¨C¨5°Ð<ó	
Ð(ñ à17×1EÔ1EÐ-Ø0×;Ñ;¸E×BÔBÄrÇ|Â|Ø1°"Õ5°s÷Hô Hò ñ	 2Fñ
 rB   c                óP   € V ^8„  d   QhR\         P                  R\        R\        /# rî  )r\   r¢   r´   r¼   )r?   s   "r@   rA   rA   Ý  s*   € ÷ ñ Ü�I‰Iðä	ðô ñrB   c                ó¶   € V P                  4        FD  w  r4V\        V 4      9   g   K  \        V4      ^ 8”  d   V RV 2MTp\        WR4      '       g   KC   R# 	  R# )aÍ  Check if a given module contains top-level parameters that match the exact fqn or regex pattern specified in FqnToConfig.

Args:
    module (nn.Module): The module to be checked.
    fqn (str): The fully qualified name of the module.
    config (FqnToConfig): Configuration object containing regex patterns or raw FQNs for quantization.

Returns:
    bool: True if the module contains top-level parameters that match the fqn or regex pattern specified in FqnTo
rF   TF)rõ  rö  rÖ  rÁ   )rÊ   rï  r³   rR   rþ  rÿ  s   &&&   r@   rÂ   rÂ   Ý  sS   € ð ×.Ñ.Ö0‰ˆØ”3�v“;ÖÜ/2°3«x¸!¬|˜s˜e 1 T F™OÀˆMÜ% m×<Ô<Úñ	 1ñ rB   c                óD   € V ^8„  d   QhR\         R\        P                  /# )r<   rÊ   r>   )r   r\   r]   )r?   s   "r@   rA   rA   õ  s   € ÷ ñ ¤,ð ´2·9±9ñ rB   c                ó  € \         P                  ! R4      ;_uu_ 4        \        P                  ! V P                  V P
                  4      pRRR4       V P                  Xn        V P                  Vn        V#   + '       g   i     L4; i)aE  
Unwrap a torchao Float8Linear by returning a nn.Linear with the same weights and bias.

Torchao inference quantization techniques are generally only applicable to nn.Linear
layers, so this helper is useful for unwrapping models trained with torchao float8 training,
which replaces nn.Linear layers with Float8Linear layers.
ÚmetaN)r[   rE   r\   r]   Úin_featuresÚout_featuresrX   r”   )rÊ   Ú
new_modules   & r@   r‰  r‰  õ  sZ   € ô 
�Š�f×	Õ	Ü—Y’Y˜v×1Ñ1°6×3FÑ3FÓGˆ
÷ 
àŸ™€JÔØ—k‘k€J„OØÐ÷	 
×	ús   Ÿ,A7Á7B	)r£   r5   rz   rÐ   r7   r6   ÚModuleFqnToConfig)r¹   Nr°   )Fr   )‡rë   rè  Úloggingrù  r¬   r²  Úcollectionsr   Údataclassesr   r   Ú	functoolsr   Útypingr   r   r   r	   r
   r   rä  r[   Útorch.nnr\   Útorch.nn.utils.parametrizer8  ro   r6  Útorchao.core.configr   Útorchao.float8.configr   Útorchao.float8.float8_linearr   Útorchao.float8.inferencer   r   r   r   r   Ú(torchao.prototype.quantization.quant_apir   Ú%torchao.quantization.quantize_.commonr   Ú(torchao.quantization.quantize_.workflowsr   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   Ú%torchao.quantization.transform_moduler'   r(   Útorchao.quantization.utilsr)   r*   r+   r,   Útorchao.utilsr-   r.   r/   rI  r0   r1   r2   r3   r4   Úlinear_quant_modulesr5   r6   Úqatr7   Úquant_primitivesr8   r9   r:   Ú	getLoggerr‰   r&  Ú__all__rK   rd   rz   r£   r§   r±   rÐ   rÒ   r  r  r  r/  r;  r=  rE  rG  rP  rV  r[  r]  ri  rl  rn  r}  r  r†  rŠ  rŒ  r¦  r´  r·  r  rÇ  rÏ  rÒ  r¼   r  rì  rÄ   rÁ   rÂ   r‰  r°   rB   r@   Ú<module>r$     s0  ðñ	ó Û Û 	Û Û Ý #ß (Ý ß >× >Ý 1ã Ý ß 0Ó 0ã Ý ,Ý ,Ý 5÷õ õõ÷÷ ÷ ÷ õ ÷&÷ó ÷ñ ÷õ ÷õ÷ñ ð 
×	Ò	˜8Ó	$€ò€÷+ò\ô"ôDò@DðØ(-ðØ>Côð. CMØ+/÷	H
ðV ôB
¨Ló B
ó ðB
ðJG ð
 ,0ðG ð 15÷G ñT "Ð"GÓHðð #ð	ð
 ,0ðð 15öó IððB ô R˜<ó  Ró ð RòF8Tñv "Ð"6Ó7ðð #ö	ó 8ðð@ ô;¨ló ;ó ð;ñ$ "Ð"IÓJð1ð #ö	1ó Kð1ðh ô%
˜<ó %
ó ð%
òPñ "Ð"6Ó7ðð #ö	ó 8ðõ@
ð4 ô5
¨Ló 5
ó ð5
òpñ( "Ð"GÓHðð ö	ó Iðð@ ô;
¨<ó ;
ó ð;
ñ| "Ð"FÓGð.ð ö	.ó Hð.ðb ôT˜\ó Tó ðTòBñ "Ð"8Ó9ð"ð #ö	"ó :ð"ðJ ô;S°ó ;Só ð;Sò|Q õh%ñP "Ð"KÓLð$ð #ö	$ó Mð$õNð2 ô1
˜<ó 1
ó ð1
ðh;Oð ,0ð	;Oð
 15÷;Oñ| "Ð"6Ó7ðð #ð	ð
 ,0ðð 15öó 8ððD ôO
�,ó O
ó ðO
ðf  Ð õYõ[õ|õ6÷0rB   