# 양자화[[quantization]]

양자화 기법은 가중치와 활성화를 8비트 정수(int8)와 같은 더 낮은 정밀도의 데이터 타입으로 표현함으로써 메모리와 계산 비용을 줄입니다. 이를 통해 일반적으로는 메모리에 올릴 수 없는 더 큰 모델을 로드할 수 있고, 추론 속도를 높일 수 있습니다. Transformers는 AWQ와 GPTQ 양자화 알고리즘을 지원하며, bitsandbytes를 통해 8비트와 4비트 양자화를 지원합니다.
Transformers에서 지원되지 않는 양자화 기법들은 `HfQuantizer` 클래스를 통해 추가될 수 있습니다.

모델을 양자화하는 방법은 이 [양자화](../quantization) 가이드를 통해 배울 수 있습니다.

## QuantoConfig[[transformers.QuantoConfig]][[transformers.QuantoConfig]]

#### transformers.QuantoConfig[[transformers.QuantoConfig]]

[Source](https://github.com/huggingface/transformers/blob/v4.57.1/src/transformers/utils/quantization_config.py#L1211)

This is a wrapper class about all possible attributes and features that you can play with a model that has been
loaded using `quanto`.

post_inittransformers.QuantoConfig.post_inithttps://github.com/huggingface/transformers/blob/v4.57.1/src/transformers/utils/quantization_config.py#L1239[]

Safety checker that arguments are correct

**Parameters:**

weights (`str`, *optional*, defaults to `"int8"`) : The target dtype for the weights after quantization. Supported values are ("float8","int8","int4","int2")

activations (`str`, *optional*) : The target dtype for the activations after quantization. Supported values are (None,"int8","float8")

modules_to_not_convert (`list`, *optional*, default to `None`) : The list of modules to not quantize, useful for quantizing models that explicitly require to have some modules left in their original precision (e.g. Whisper encoder, Llava encoder, Mixtral gate layers).

## AqlmConfig[[transformers.AqlmConfig]][[transformers.AqlmConfig]]

#### transformers.AqlmConfig[[transformers.AqlmConfig]]

[Source](https://github.com/huggingface/transformers/blob/v4.57.1/src/transformers/utils/quantization_config.py#L1055)

This is a wrapper class about `aqlm` parameters.

post_inittransformers.AqlmConfig.post_inithttps://github.com/huggingface/transformers/blob/v4.57.1/src/transformers/utils/quantization_config.py#L1092[]

Safety checker that arguments are correct - also replaces some NoneType arguments with their default values.

**Parameters:**

in_group_size (`int`, *optional*, defaults to 8) : The group size along the input dimension.

out_group_size (`int`, *optional*, defaults to 1) : The group size along the output dimension. It's recommended to always use 1.

num_codebooks (`int`, *optional*, defaults to 1) : Number of codebooks for the Additive Quantization procedure.

nbits_per_codebook (`int`, *optional*, defaults to 16) : Number of bits encoding a single codebook vector. Codebooks size is 2**nbits_per_codebook.

linear_weights_not_to_quantize (`Optional[list[str]]`, *optional*) : List of full paths of `nn.Linear` weight parameters that shall not be quantized.

kwargs (`dict[str, Any]`, *optional*) : Additional parameters from which to initialize the configuration object.

## VptqConfig[[transformers.VptqConfig]][[transformers.VptqConfig]]

#### transformers.VptqConfig[[transformers.VptqConfig]]

[Source](https://github.com/huggingface/transformers/blob/v4.57.1/src/transformers/utils/quantization_config.py#L1170)

This is a wrapper class about `vptq` parameters.

post_inittransformers.VptqConfig.post_inithttps://github.com/huggingface/transformers/blob/v4.57.1/src/transformers/utils/quantization_config.py#L1200[]

Safety checker that arguments are correct

**Parameters:**

enable_proxy_error (`bool`, *optional*, defaults to `False`) : calculate proxy error for each layer

config_for_layers (`Dict`, *optional*, defaults to `{}`) : quantization params for each layer

shared_layer_config (`Dict`, *optional*, defaults to `{}`) : shared quantization params among layers

modules_to_not_convert (`list`, *optional*, default to `None`) : The list of modules to not quantize, useful for quantizing models that explicitly require to have some modules left in their original precision (e.g. Whisper encoder, Llava encoder, Mixtral gate layers).

kwargs (`dict[str, Any]`, *optional*) : Additional parameters from which to initialize the configuration object.

## AwqConfig[[transformers.AwqConfig]][[transformers.AwqConfig]]

#### transformers.AwqConfig[[transformers.AwqConfig]]

[Source](https://github.com/huggingface/transformers/blob/v4.57.1/src/transformers/utils/quantization_config.py#L878)

This is a wrapper class about all possible attributes and features that you can play with a model that has been
loaded using `auto-awq` library awq quantization relying on auto_awq backend.

post_inittransformers.AwqConfig.post_inithttps://github.com/huggingface/transformers/blob/v4.57.1/src/transformers/utils/quantization_config.py#L946[]

Safety checker that arguments are correct

**Parameters:**

bits (`int`, *optional*, defaults to 4) : The number of bits to quantize to.

group_size (`int`, *optional*, defaults to 128) : The group size to use for quantization. Recommended value is 128 and -1 uses per-column quantization.

zero_point (`bool`, *optional*, defaults to `True`) : Whether to use zero point quantization.

version (`AWQLinearVersion`, *optional*, defaults to `AWQLinearVersion.GEMM`) : The version of the quantization algorithm to use. GEMM is better for big batch_size (e.g. >= 8) otherwise, GEMV is better (e.g.  1.

use_exllama (`bool`, *optional*) : Whether to use exllama backend. Defaults to `True` if unset. Only works with `bits` = 4.

max_input_length (`int`, *optional*) : The maximum input length. This is needed to initialize a buffer that depends on the maximum expected input length. It is specific to the exllama backend with act-order.

exllama_config (`dict[str, Any]`, *optional*) : The exllama config. You can specify the version of the exllama kernel through the `version` key. Defaults to `{"version": 1}` if unset.

cache_block_outputs (`bool`, *optional*, defaults to `True`) : Whether to cache block outputs to reuse as inputs for the succeeding block.

modules_in_block_to_quantize (`list[list[str]]`, *optional*) : List of list of module names to quantize in the specified block. This argument is useful to exclude certain linear modules from being quantized. The block to quantize can be specified by setting `block_name_to_quantize`. We will quantize each list sequentially. If not set, we will quantize all linear layers. Example: `modules_in_block_to_quantize =[["self_attn.k_proj", "self_attn.v_proj", "self_attn.q_proj"], ["self_attn.o_proj"]]`. In this example, we will first quantize the q,k,v layers simultaneously since they are independent. Then, we will quantize `self_attn.o_proj` layer with the q,k,v layers quantized. This way, we will get better results since it reflects the real input `self_attn.o_proj` will get when the model is quantized.
#### post_init[[transformers.GPTQConfig.post_init]]

[Source](https://github.com/huggingface/transformers/blob/v4.57.1/src/transformers/utils/quantization_config.py#L773)

Safety checker that arguments are correct
#### to_dict_optimum[[transformers.GPTQConfig.to_dict_optimum]]

[Source](https://github.com/huggingface/transformers/blob/v4.57.1/src/transformers/utils/quantization_config.py#L853)

Get compatible dict for optimum gptq config

## BitsAndBytesConfig[[#transformers.BitsAndBytesConfig]][[transformers.BitsAndBytesConfig]]

#### transformers.BitsAndBytesConfig[[transformers.BitsAndBytesConfig]]

[Source](https://github.com/huggingface/transformers/blob/v4.57.1/src/transformers/utils/quantization_config.py#L405)

This is a wrapper class about all possible attributes and features that you can play with a model that has been
loaded using `bitsandbytes`.

This replaces `load_in_8bit` or `load_in_4bit`therefore both options are mutually exclusive.

Currently only supports `LLM.int8()`, `FP4`, and `NF4` quantization. If more methods are added to `bitsandbytes`,
then more arguments will be added to this class.

is_quantizabletransformers.BitsAndBytesConfig.is_quantizablehttps://github.com/huggingface/transformers/blob/v4.57.1/src/transformers/utils/quantization_config.py#L575[]

Returns `True` if the model is quantizable, `False` otherwise.

**Parameters:**

load_in_8bit (`bool`, *optional*, defaults to `False`) : This flag is used to enable 8-bit quantization with LLM.int8().

load_in_4bit (`bool`, *optional*, defaults to `False`) : This flag is used to enable 4-bit quantization by replacing the Linear layers with FP4/NF4 layers from `bitsandbytes`.

llm_int8_threshold (`float`, *optional*, defaults to 6.0) : This corresponds to the outlier threshold for outlier detection as described in `LLM.int8() : 8-bit Matrix Multiplication for Transformers at Scale` paper: https://huggingface.co/papers/2208.07339 Any hidden states value that is above this threshold will be considered an outlier and the operation on those values will be done in fp16. Values are usually normally distributed, that is, most values are in the range [-3.5, 3.5], but there are some exceptional systematic outliers that are very differently distributed for large models. These outliers are often in the interval [-60, -6] or [6, 60]. Int8 quantization works well for values of magnitude ~5, but beyond that, there is a significant performance penalty. A good default threshold is 6, but a lower threshold might be needed for more unstable models (small models, fine-tuning).

llm_int8_skip_modules (`list[str]`, *optional*) : An explicit list of the modules that we do not want to convert in 8-bit. This is useful for models such as Jukebox that has several heads in different places and not necessarily at the last position. For example for `CausalLM` models, the last `lm_head` is kept in its original `dtype`.

llm_int8_enable_fp32_cpu_offload (`bool`, *optional*, defaults to `False`) : This flag is used for advanced use cases and users that are aware of this feature. If you want to split your model in different parts and run some parts in int8 on GPU and some parts in fp32 on CPU, you can use this flag. This is useful for offloading large models such as `google/flan-t5-xxl`. Note that the int8 operations will not be run on CPU.

llm_int8_has_fp16_weight (`bool`, *optional*, defaults to `False`) : This flag runs LLM.int8() with 16-bit main weights. This is useful for fine-tuning as the weights do not have to be converted back and forth for the backward pass.

bnb_4bit_compute_dtype (`torch.dtype` or str, *optional*, defaults to `torch.float32`) : This sets the computational type which might be different than the input type. For example, inputs might be fp32, but computation can be set to bf16 for speedups.

bnb_4bit_quant_type (`str`,  *optional*, defaults to `"fp4"`) : This sets the quantization data type in the bnb.nn.Linear4Bit layers. Options are FP4 and NF4 data types which are specified by `fp4` or `nf4`.

bnb_4bit_use_double_quant (`bool`, *optional*, defaults to `False`) : This flag is used for nested quantization where the quantization constants from the first quantization are quantized again.

bnb_4bit_quant_storage (`torch.dtype` or str, *optional*, defaults to `torch.uint8`) : This sets the storage type to pack the quantized 4-bit params.

kwargs (`dict[str, Any]`, *optional*) : Additional parameters from which to initialize the configuration object.
#### post_init[[transformers.BitsAndBytesConfig.post_init]]

[Source](https://github.com/huggingface/transformers/blob/v4.57.1/src/transformers/utils/quantization_config.py#L538)

Safety checker that arguments are correct - also replaces some NoneType arguments with their default values.
#### quantization_method[[transformers.BitsAndBytesConfig.quantization_method]]

[Source](https://github.com/huggingface/transformers/blob/v4.57.1/src/transformers/utils/quantization_config.py#L581)

This method returns the quantization method used for the model. If the model is not quantizable, it returns
`None`.
#### to_diff_dict[[transformers.BitsAndBytesConfig.to_diff_dict]]

[Source](https://github.com/huggingface/transformers/blob/v4.57.1/src/transformers/utils/quantization_config.py#L612)

Removes all attributes from config which correspond to the default config attributes for better readability and
serializes to a Python dictionary.

**Returns:**

``dict[str, Any]``

Dictionary of all the attributes that make up this configuration instance,

## HfQuantizer[[transformers.quantizers.HfQuantizer]][[transformers.quantizers.HfQuantizer]]

#### transformers.quantizers.HfQuantizer[[transformers.quantizers.HfQuantizer]]

[Source](https://github.com/huggingface/transformers/blob/v4.57.1/src/transformers/quantizers/base.py#L34)

Abstract class of the HuggingFace quantizer. Supports for now quantizing HF transformers models for inference and/or quantization.
This class is used only for transformers.PreTrainedModel.from_pretrained and cannot be easily used outside the scope of that method
yet.

Attributes
quantization_config (`transformers.utils.quantization_config.QuantizationConfigMixin`):
The quantization config that defines the quantization parameters of your model that you want to quantize.
modules_to_not_convert (`list[str]`, *optional*):
The list of module names to not convert when quantizing the model.
required_packages (`list[str]`, *optional*):
The list of required pip packages to install prior to using the quantizer
requires_calibration (`bool`):
Whether the quantization method requires to calibrate the model before using it.
requires_parameters_quantization (`bool`):
Whether the quantization method requires to create a new Parameter. For example, for bitsandbytes, it is
required to create a new xxxParameter in order to properly quantize the model.

adjust_max_memorytransformers.quantizers.HfQuantizer.adjust_max_memoryhttps://github.com/huggingface/transformers/blob/v4.57.1/src/transformers/quantizers/base.py#L163[{"name": "max_memory", "val": ": dict"}]
adjust max_memory argument for infer_auto_device_map() if extra memory is needed for quantization
#### adjust_target_dtype[[transformers.quantizers.HfQuantizer.adjust_target_dtype]]

[Source](https://github.com/huggingface/transformers/blob/v4.57.1/src/transformers/quantizers/base.py#L109)

Override this method if you want to adjust the `target_dtype` variable used in `from_pretrained`
to compute the device_map in case the device_map is a `str`. E.g. for bitsandbytes we force-set `target_dtype`
to `torch.int8` and for 4-bit we pass a custom enum `accelerate.CustomDtype.int4`.

**Parameters:**

dtype (`torch.dtype`, *optional*) : The dtype that is used to compute the device_map.
#### check_quantized_param[[transformers.quantizers.HfQuantizer.check_quantized_param]]

[Source](https://github.com/huggingface/transformers/blob/v4.57.1/src/transformers/quantizers/base.py#L167)

DEPRECATED -> remove in v5
#### create_quantized_param[[transformers.quantizers.HfQuantizer.create_quantized_param]]

[Source](https://github.com/huggingface/transformers/blob/v4.57.1/src/transformers/quantizers/base.py#L181)

Take needed components from state_dict (those from which `param_needs_quantization` is True) and create
quantized param.
It usually also load the new param directly in the `model`.
Note: only applicable if requires_parameters_quantization == True.
#### dequantize[[transformers.quantizers.HfQuantizer.dequantize]]

[Source](https://github.com/huggingface/transformers/blob/v4.57.1/src/transformers/quantizers/base.py#L254)

Potentially dequantize the model to retrieve the original model, with some loss in accuracy / performance.
Note not all quantization schemes support this.
#### get_accelerator_warm_up_factor[[transformers.quantizers.HfQuantizer.get_accelerator_warm_up_factor]]

[Source](https://github.com/huggingface/transformers/blob/v4.57.1/src/transformers/quantizers/base.py#L270)

The factor to be used in `caching_allocator_warmup` to get the number of bytes to pre-allocate to warm up accelerator.
A factor of 2 means we allocate all bytes in the empty model (since we allocate in fp16), a factor of 4 means
we allocate half the memory of the weights residing in the empty model, etc...
#### get_param_name[[transformers.quantizers.HfQuantizer.get_param_name]]

[Source](https://github.com/huggingface/transformers/blob/v4.57.1/src/transformers/quantizers/base.py#L286)

Override this method if you want to adjust the `param_name`.
#### get_special_dtypes_update[[transformers.quantizers.HfQuantizer.get_special_dtypes_update]]

[Source](https://github.com/huggingface/transformers/blob/v4.57.1/src/transformers/quantizers/base.py#L146)

returns dtypes for modules that are not quantized - used for the computation of the device_map in case
one passes a str as a device_map. The method will use the `modules_to_not_convert` that is modified
in `_process_model_before_weight_loading`.

**Parameters:**

model (`~transformers.PreTrainedModel`) : The model to quantize

dtype (`torch.dtype`) : The dtype passed in `from_pretrained` method.
#### get_state_dict_and_metadata[[transformers.quantizers.HfQuantizer.get_state_dict_and_metadata]]

[Source](https://github.com/huggingface/transformers/blob/v4.57.1/src/transformers/quantizers/base.py#L324)

Get state dict and metadata. Useful when we need to modify a bit the state dict due to quantization
#### param_needs_quantization[[transformers.quantizers.HfQuantizer.param_needs_quantization]]

[Source](https://github.com/huggingface/transformers/blob/v4.57.1/src/transformers/quantizers/base.py#L175)

Check whether a given param needs quantization as defined by `create_quantized_param`.
#### postprocess_model[[transformers.quantizers.HfQuantizer.postprocess_model]]

[Source](https://github.com/huggingface/transformers/blob/v4.57.1/src/transformers/quantizers/base.py#L227)

Post-process the model post weights loading.
Make sure to override the abstract method `_process_model_after_weight_loading`.

**Parameters:**

model (`~transformers.PreTrainedModel`) : The model to quantize

kwargs (`dict`, *optional*) : The keyword arguments that are passed along `_process_model_after_weight_loading`.
#### preprocess_model[[transformers.quantizers.HfQuantizer.preprocess_model]]

[Source](https://github.com/huggingface/transformers/blob/v4.57.1/src/transformers/quantizers/base.py#L209)

Setting model attributes and/or converting model before weights loading. At this point
the model should be initialized on the meta device so you can freely manipulate the skeleton
of the model in order to replace modules in-place. Make sure to override the abstract method `_process_model_before_weight_loading`.

**Parameters:**

model (`~transformers.PreTrainedModel`) : The model to quantize

kwargs (`dict`, *optional*) : The keyword arguments that are passed along `_process_model_before_weight_loading`.
#### remove_quantization_config[[transformers.quantizers.HfQuantizer.remove_quantization_config]]

[Source](https://github.com/huggingface/transformers/blob/v4.57.1/src/transformers/quantizers/base.py#L240)

Remove the quantization config from the model.
#### update_device_map[[transformers.quantizers.HfQuantizer.update_device_map]]

[Source](https://github.com/huggingface/transformers/blob/v4.57.1/src/transformers/quantizers/base.py#L97)

Override this method if you want to pass a override the existing device map with a new
one. E.g. for bitsandbytes, since `accelerate` is a hard requirement, if no device_map is
passed, the device_map is set to `"auto"``

**Parameters:**

device_map (`Union[dict, str]`, *optional*) : The device_map that is passed through the `from_pretrained` method.
#### update_dtype[[transformers.quantizers.HfQuantizer.update_dtype]]

[Source](https://github.com/huggingface/transformers/blob/v4.57.1/src/transformers/quantizers/base.py#L85)

Some quantization methods require to explicitly set the dtype of the model to a
target dtype. You need to override this method in case you want to make sure that behavior is
preserved

**Parameters:**

dtype (`torch.dtype`) : The input dtype that is passed in `from_pretrained`
#### update_ep_plan[[transformers.quantizers.HfQuantizer.update_ep_plan]]

[Source](https://github.com/huggingface/transformers/blob/v4.57.1/src/transformers/quantizers/base.py#L205)

updates the tp plan for the scales
#### update_expected_keys[[transformers.quantizers.HfQuantizer.update_expected_keys]]

[Source](https://github.com/huggingface/transformers/blob/v4.57.1/src/transformers/quantizers/base.py#L131)

Override this method if you want to adjust the `update_expected_keys`.

**Parameters:**

expected_keys (`list[str]`, *optional*) : The list of the expected keys in the initialized model.

loaded_keys (`list[str]`, *optional*) : The list of the loaded keys in the checkpoint.
#### update_missing_keys[[transformers.quantizers.HfQuantizer.update_missing_keys]]

[Source](https://github.com/huggingface/transformers/blob/v4.57.1/src/transformers/quantizers/base.py#L121)

Override this method if you want to adjust the `missing_keys`.

**Parameters:**

missing_keys (`list[str]`, *optional*) : The list of missing keys in the checkpoint compared to the state dict of the model
#### update_state_dict_with_metadata[[transformers.quantizers.HfQuantizer.update_state_dict_with_metadata]]

[Source](https://github.com/huggingface/transformers/blob/v4.57.1/src/transformers/quantizers/base.py#L328)

Update state dict with metadata. Default behaviour returns state_dict
#### update_torch_dtype[[transformers.quantizers.HfQuantizer.update_torch_dtype]]

[Source](https://github.com/huggingface/transformers/blob/v4.57.1/src/transformers/quantizers/base.py#L72)

Deprecared in favor of `update_dtype`!

**Parameters:**

dtype (`torch.dtype`) : The input dtype that is passed in `from_pretrained`
#### update_tp_plan[[transformers.quantizers.HfQuantizer.update_tp_plan]]

[Source](https://github.com/huggingface/transformers/blob/v4.57.1/src/transformers/quantizers/base.py#L201)

updates the tp plan for the scales
#### validate_environment[[transformers.quantizers.HfQuantizer.validate_environment]]

[Source](https://github.com/huggingface/transformers/blob/v4.57.1/src/transformers/quantizers/base.py#L193)

This method is used to potentially check for potential conflicts with arguments that are
passed in `from_pretrained`. You need to define it for all future quantizers that are integrated with transformers.
If no explicit check are needed, simply return nothing.

## HqqConfig[[transformers.HqqConfig]][[transformers.HqqConfig]]

#### transformers.HqqConfig[[transformers.HqqConfig]]

[Source](https://github.com/huggingface/transformers/blob/v4.57.1/src/transformers/utils/quantization_config.py#L280)

This is wrapper around hqq's BaseQuantizeConfig.

from_dicttransformers.HqqConfig.from_dicthttps://github.com/huggingface/transformers/blob/v4.57.1/src/transformers/utils/quantization_config.py#L357[{"name": "config", "val": ": dict"}]

Override from_dict, used in AutoQuantizationConfig.from_dict in quantizers/auto.py

**Parameters:**

nbits (`int`, *optional*, defaults to 4) : Number of bits. Supported values are (8, 4, 3, 2, 1).

group_size (`int`, *optional*, defaults to 64) : Group-size value. Supported values are any value that is divisible by weight.shape[axis]).

view_as_float (`bool`, *optional*, defaults to `False`) : View the quantized weight as float (used in distributed training) if set to `True`.

axis (`Optional[int]`, *optional*) : Axis along which grouping is performed. Supported values are 0 or 1.

dynamic_config (dict, *optional*) : Parameters for dynamic configuration. The key is the name tag of the layer and the value is a quantization config. If set, each layer specified by its id will use its dedicated quantization configuration.

skip_modules (`list[str]`, *optional*, defaults to `['lm_head']`) : List of `nn.Linear` layers to skip.

kwargs (`dict[str, Any]`, *optional*) : Additional parameters from which to initialize the configuration object.
#### post_init[[transformers.HqqConfig.post_init]]

[Source](https://github.com/huggingface/transformers/blob/v4.57.1/src/transformers/utils/quantization_config.py#L351)

Safety checker that arguments are correct - also replaces some NoneType arguments with their default values.
#### to_diff_dict[[transformers.HqqConfig.to_diff_dict]]

[Source](https://github.com/huggingface/transformers/blob/v4.57.1/src/transformers/utils/quantization_config.py#L382)

Removes all attributes from config which correspond to the default config attributes for better readability and
serializes to a Python dictionary.

**Returns:**

``dict[str, Any]``

Dictionary of all the attributes that make up this configuration instance,

## FbgemmFp8Config[[transformers.FbgemmFp8Config]][[transformers.FbgemmFp8Config]]

#### transformers.FbgemmFp8Config[[transformers.FbgemmFp8Config]]

[Source](https://github.com/huggingface/transformers/blob/v4.57.1/src/transformers/utils/quantization_config.py#L1468)

This is a wrapper class about all possible attributes and features that you can play with a model that has been
loaded using fbgemm fp8 quantization.

**Parameters:**

activation_scale_ub (`float`, *optional*, defaults to 1200.0) : The activation scale upper bound. This is used when quantizing the input activation.

modules_to_not_convert (`list`, *optional*, default to `None`) : The list of modules to not quantize, useful for quantizing models that explicitly require to have some modules left in their original precision.

## CompressedTensorsConfig[[transformers.CompressedTensorsConfig]][[transformers.CompressedTensorsConfig]]

#### transformers.CompressedTensorsConfig[[transformers.CompressedTensorsConfig]]

[Source](https://github.com/huggingface/transformers/blob/v4.57.1/src/transformers/utils/quantization_config.py#L1285)

This is a wrapper class that handles compressed-tensors quantization config options.
It is a wrapper around `compressed_tensors.QuantizationConfig`

from_dicttransformers.CompressedTensorsConfig.from_dicthttps://github.com/huggingface/transformers/blob/v4.57.1/src/transformers/utils/quantization_config.py#L1372[{"name": "config_dict", "val": ""}, {"name": "return_unused_kwargs", "val": " = False"}, {"name": "**kwargs", "val": ""}]- **config_dict** (`dict[str, Any]`) --
  Dictionary that will be used to instantiate the configuration object.
- **return_unused_kwargs** (`bool`,*optional*, defaults to `False`) --
  Whether or not to return a list of unused keyword arguments. Used for `from_pretrained` method in
  `PreTrainedModel`.
- **kwargs** (`dict[str, Any]`) --
  Additional parameters from which to initialize the configuration object.0`QuantizationConfigMixin`The configuration object instantiated from those parameters.

Instantiates a [CompressedTensorsConfig](/docs/transformers/v4.57.1/ko/main_classes/quantization#transformers.CompressedTensorsConfig) from a Python dictionary of parameters.
Optionally unwraps any args from the nested quantization_config

**Parameters:**

config_groups (`typing.dict[str, typing.Union[ForwardRef('QuantizationScheme'), typing.list[str]]]`, *optional*) : dictionary mapping group name to a quantization scheme definition

format (`str`, *optional*, defaults to `"dense"`) : format the model is represented as. Set `run_compressed` True to execute model as the compressed format if not `dense`

quantization_status (`QuantizationStatus`, *optional*, defaults to `"initialized"`) : status of model in the quantization lifecycle, ie 'initialized', 'calibration', 'frozen'

kv_cache_scheme (`typing.Union[QuantizationArgs, NoneType]`, *optional*) : specifies quantization of the kv cache. If None, kv cache is not quantized.

global_compression_ratio (`typing.Union[float, NoneType]`, *optional*) : 0-1 float percentage of model compression

ignore (`typing.Union[typing.list[str], NoneType]`, *optional*) : layer names or types to not quantize, supports regex prefixed by 're:'

sparsity_config (`typing.dict[str, typing.Any]`, *optional*) : configuration for sparsity compression

quant_method (`str`, *optional*, defaults to `"compressed-tensors"`) : do not override, should be compressed-tensors

run_compressed (`bool`, *optional*, defaults to `True`) : alter submodules (usually linear) in order to emulate compressed model execution if True, otherwise use default submodule

**Returns:**

``QuantizationConfigMixin``

The configuration object instantiated from those parameters.
#### to_dict[[transformers.CompressedTensorsConfig.to_dict]]

[Source](https://github.com/huggingface/transformers/blob/v4.57.1/src/transformers/utils/quantization_config.py#L1400)

Quantization config to be added to config.json

Serializes this instance to a Python dictionary. Returns:
`dict[str, Any]`: Dictionary of all the attributes that make up this configuration instance.
#### to_diff_dict[[transformers.CompressedTensorsConfig.to_diff_dict]]

[Source](https://github.com/huggingface/transformers/blob/v4.57.1/src/transformers/utils/quantization_config.py#L1420)

Removes all attributes from config which correspond to the default config attributes for better readability and
serializes to a Python dictionary.

**Returns:**

``dict[str, Any]``

Dictionary of all the attributes that make up this configuration instance,

## TorchAoConfig[[transformers.TorchAoConfig]][[transformers.TorchAoConfig]]

#### transformers.TorchAoConfig[[transformers.TorchAoConfig]]

[Source](https://github.com/huggingface/transformers/blob/v4.57.1/src/transformers/utils/quantization_config.py#L1640)

from_dicttransformers.TorchAoConfig.from_dicthttps://github.com/huggingface/transformers/blob/v4.57.1/src/transformers/utils/quantization_config.py#L1852[{"name": "config_dict", "val": ""}, {"name": "return_unused_kwargs", "val": " = False"}, {"name": "**kwargs", "val": ""}]
Create configuration from a dictionary.
#### get_apply_tensor_subclass[[transformers.TorchAoConfig.get_apply_tensor_subclass]]

[Source](https://github.com/huggingface/transformers/blob/v4.57.1/src/transformers/utils/quantization_config.py#L1790)

Create the appropriate quantization method based on configuration.
#### post_init[[transformers.TorchAoConfig.post_init]]

[Source](https://github.com/huggingface/transformers/blob/v4.57.1/src/transformers/utils/quantization_config.py#L1728)

Validate configuration and set defaults.
#### to_dict[[transformers.TorchAoConfig.to_dict]]

[Source](https://github.com/huggingface/transformers/blob/v4.57.1/src/transformers/utils/quantization_config.py#L1824)

Convert configuration to a dictionary.

