Buckets:
| # Quantization | |
| Quantization techniques reduce memory and computational costs by representing weights and activations with lower-precision data types like 8-bit integers (int8). This enables loading larger models you normally wouldn't be able to fit into memory, and speeding up inference. Transformers supports the AWQ and GPTQ quantization algorithms and it supports 8-bit and 4-bit quantization with bitsandbytes. | |
| Quantization techniques that aren't supported in Transformers can be added with the `HfQuantizer` class. | |
| <Tip> | |
| Learn how to quantize models in the [Quantization](../quantization) guide. | |
| </Tip> | |
| ## QuantoConfig[[transformers.QuantoConfig]] | |
| <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"> | |
| <docstring><name>class transformers.QuantoConfig</name><anchor>transformers.QuantoConfig</anchor><source>https://github.com/huggingface/transformers/blob/vr_33892/src/transformers/utils/quantization_config.py#L1191</source><parameters>[{"name": "weights", "val": " = 'int8'"}, {"name": "activations", "val": " = None"}, {"name": "modules_to_not_convert", "val": ": list | None = None"}, {"name": "**kwargs", "val": ""}]</parameters><paramsdesc>- **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).</paramsdesc><paramgroups>0</paramgroups></docstring> | |
| This is a wrapper class about all possible attributes and features that you can play with a model that has been | |
| loaded using `quanto`. | |
| <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"> | |
| <docstring><name>post_init</name><anchor>transformers.QuantoConfig.post_init</anchor><source>https://github.com/huggingface/transformers/blob/vr_33892/src/transformers/utils/quantization_config.py#L1219</source><parameters>[]</parameters></docstring> | |
| Safety checker that arguments are correct | |
| </div></div> | |
| ## AqlmConfig[[transformers.AqlmConfig]] | |
| <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"> | |
| <docstring><name>class transformers.AqlmConfig</name><anchor>transformers.AqlmConfig</anchor><source>https://github.com/huggingface/transformers/blob/vr_33892/src/transformers/utils/quantization_config.py#L1035</source><parameters>[{"name": "in_group_size", "val": ": int = 8"}, {"name": "out_group_size", "val": ": int = 1"}, {"name": "num_codebooks", "val": ": int = 1"}, {"name": "nbits_per_codebook", "val": ": int = 16"}, {"name": "linear_weights_not_to_quantize", "val": ": list[str] | None = None"}, {"name": "**kwargs", "val": ""}]</parameters><paramsdesc>- **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.</paramsdesc><paramgroups>0</paramgroups></docstring> | |
| This is a wrapper class about `aqlm` parameters. | |
| <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"> | |
| <docstring><name>post_init</name><anchor>transformers.AqlmConfig.post_init</anchor><source>https://github.com/huggingface/transformers/blob/vr_33892/src/transformers/utils/quantization_config.py#L1072</source><parameters>[]</parameters></docstring> | |
| Safety checker that arguments are correct - also replaces some NoneType arguments with their default values. | |
| </div></div> | |
| ## VptqConfig[[transformers.VptqConfig]] | |
| <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"> | |
| <docstring><name>class transformers.VptqConfig</name><anchor>transformers.VptqConfig</anchor><source>https://github.com/huggingface/transformers/blob/vr_33892/src/transformers/utils/quantization_config.py#L1150</source><parameters>[{"name": "enable_proxy_error", "val": ": bool = False"}, {"name": "config_for_layers", "val": ": dict = {}"}, {"name": "shared_layer_config", "val": ": dict = {}"}, {"name": "modules_to_not_convert", "val": ": list | None = None"}, {"name": "**kwargs", "val": ""}]</parameters><paramsdesc>- **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.</paramsdesc><paramgroups>0</paramgroups></docstring> | |
| This is a wrapper class about `vptq` parameters. | |
| <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"> | |
| <docstring><name>post_init</name><anchor>transformers.VptqConfig.post_init</anchor><source>https://github.com/huggingface/transformers/blob/vr_33892/src/transformers/utils/quantization_config.py#L1180</source><parameters>[]</parameters></docstring> | |
| Safety checker that arguments are correct | |
| </div></div> | |
| ## AwqConfig[[transformers.AwqConfig]] | |
| <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"> | |
| <docstring><name>class transformers.AwqConfig</name><anchor>transformers.AwqConfig</anchor><source>https://github.com/huggingface/transformers/blob/vr_33892/src/transformers/utils/quantization_config.py#L858</source><parameters>[{"name": "bits", "val": ": int = 4"}, {"name": "group_size", "val": ": int = 128"}, {"name": "zero_point", "val": ": bool = True"}, {"name": "version", "val": ": AWQLinearVersion = <AWQLinearVersion.GEMM: 'gemm'>"}, {"name": "backend", "val": ": AwqBackendPackingMethod = <AwqBackendPackingMethod.AUTOAWQ: 'autoawq'>"}, {"name": "do_fuse", "val": ": bool | None = None"}, {"name": "fuse_max_seq_len", "val": ": int | None = None"}, {"name": "modules_to_fuse", "val": ": dict | None = None"}, {"name": "modules_to_not_convert", "val": ": list | None = None"}, {"name": "exllama_config", "val": ": dict[str, int] | None = None"}, {"name": "**kwargs", "val": ""}]</parameters><paramsdesc>- **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. < 8 ). GEMM models are compatible with Exllama kernels. | |
| - **backend** (`AwqBackendPackingMethod`, *optional*, defaults to `AwqBackendPackingMethod.AUTOAWQ`) -- | |
| The quantization backend. Some models might be quantized using `llm-awq` backend. This is useful for users | |
| that quantize their own models using `llm-awq` library. | |
| - **do_fuse** (`bool`, *optional*, defaults to `False`) -- | |
| Whether to fuse attention and mlp layers together for faster inference | |
| - **fuse_max_seq_len** (`int`, *optional*) -- | |
| The Maximum sequence length to generate when using fusing. | |
| - **modules_to_fuse** (`dict`, *optional*, default to `None`) -- | |
| Overwrite the natively supported fusing scheme with the one specified by the users. | |
| - **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). | |
| Note you cannot quantize directly with transformers, please refer to `AutoAWQ` documentation for quantizing HF models. | |
| - **exllama_config** (`dict[str, Any]`, *optional*) -- | |
| You can specify the version of the exllama kernel through the `version` key, the maximum sequence | |
| length through the `max_input_len` key, and the maximum batch size through the `max_batch_size` key. | |
| Defaults to `{"version": 2, "max_input_len": 2048, "max_batch_size": 8}` if unset.</paramsdesc><paramgroups>0</paramgroups></docstring> | |
| 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. | |
| <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"> | |
| <docstring><name>post_init</name><anchor>transformers.AwqConfig.post_init</anchor><source>https://github.com/huggingface/transformers/blob/vr_33892/src/transformers/utils/quantization_config.py#L926</source><parameters>[]</parameters></docstring> | |
| Safety checker that arguments are correct | |
| </div></div> | |
| ## EetqConfig[[transformers.EetqConfig]] | |
| <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"> | |
| <docstring><name>class transformers.EetqConfig</name><anchor>transformers.EetqConfig</anchor><source>https://github.com/huggingface/transformers/blob/vr_33892/src/transformers/utils/quantization_config.py#L1232</source><parameters>[{"name": "weights", "val": ": str = 'int8'"}, {"name": "modules_to_not_convert", "val": ": list | None = None"}, {"name": "**kwargs", "val": ""}]</parameters><paramsdesc>- **weights** (`str`, *optional*, defaults to `"int8"`) -- | |
| The target dtype for the weights. Supported value is only "int8" | |
| - **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.</paramsdesc><paramgroups>0</paramgroups></docstring> | |
| This is a wrapper class about all possible attributes and features that you can play with a model that has been | |
| loaded using `eetq`. | |
| <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"> | |
| <docstring><name>post_init</name><anchor>transformers.EetqConfig.post_init</anchor><source>https://github.com/huggingface/transformers/blob/vr_33892/src/transformers/utils/quantization_config.py#L1256</source><parameters>[]</parameters></docstring> | |
| Safety checker that arguments are correct | |
| </div></div> | |
| ## GPTQConfig[[transformers.GPTQConfig]] | |
| <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"> | |
| <docstring><name>class transformers.GPTQConfig</name><anchor>transformers.GPTQConfig</anchor><source>https://github.com/huggingface/transformers/blob/vr_33892/src/transformers/utils/quantization_config.py#L626</source><parameters>[{"name": "bits", "val": ": int"}, {"name": "tokenizer", "val": ": typing.Any = None"}, {"name": "dataset", "val": ": list[str] | str | None = None"}, {"name": "group_size", "val": ": int = 128"}, {"name": "damp_percent", "val": ": float = 0.1"}, {"name": "desc_act", "val": ": bool = False"}, {"name": "sym", "val": ": bool = True"}, {"name": "true_sequential", "val": ": bool = True"}, {"name": "checkpoint_format", "val": ": str = 'gptq'"}, {"name": "meta", "val": ": dict[str, typing.Any] | None = None"}, {"name": "backend", "val": ": str | None = None"}, {"name": "use_cuda_fp16", "val": ": bool = False"}, {"name": "model_seqlen", "val": ": int | None = None"}, {"name": "block_name_to_quantize", "val": ": str | None = None"}, {"name": "module_name_preceding_first_block", "val": ": list[str] | None = None"}, {"name": "batch_size", "val": ": int = 1"}, {"name": "pad_token_id", "val": ": int | None = None"}, {"name": "use_exllama", "val": ": bool | None = None"}, {"name": "max_input_length", "val": ": int | None = None"}, {"name": "exllama_config", "val": ": dict[str, typing.Any] | None = None"}, {"name": "cache_block_outputs", "val": ": bool = True"}, {"name": "modules_in_block_to_quantize", "val": ": list[list[str]] | None = None"}, {"name": "**kwargs", "val": ""}]</parameters><paramsdesc>- **bits** (`int`) -- | |
| The number of bits to quantize to, supported numbers are (2, 3, 4, 8). | |
| - **tokenizer** (`str` or `PreTrainedTokenizerBase`, *optional*) -- | |
| The tokenizer used to process the dataset. You can pass either: | |
| - A custom tokenizer object. | |
| - A string, the *model id* of a predefined tokenizer hosted inside a model repo on huggingface.co. | |
| - A path to a *directory* containing vocabulary files required by the tokenizer, for instance saved | |
| using the [save_pretrained()](/docs/transformers/pr_33892/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.save_pretrained) method, e.g., `./my_model_directory/`. | |
| - **dataset** (`Union[list[str]]`, *optional*) -- | |
| The dataset used for quantization. You can provide your own dataset in a list of string or just use the | |
| original datasets used in GPTQ paper ['wikitext2','c4','c4-new'] | |
| - **group_size** (`int`, *optional*, defaults to 128) -- | |
| The group size to use for quantization. Recommended value is 128 and -1 uses per-column quantization. | |
| - **damp_percent** (`float`, *optional*, defaults to 0.1) -- | |
| The percent of the average Hessian diagonal to use for dampening. Recommended value is 0.1. | |
| - **desc_act** (`bool`, *optional*, defaults to `False`) -- | |
| Whether to quantize columns in order of decreasing activation size. Setting it to False can significantly | |
| speed up inference but the perplexity may become slightly worse. Also known as act-order. | |
| - **sym** (`bool`, *optional*, defaults to `True`) -- | |
| Whether to use symmetric quantization. | |
| - **true_sequential** (`bool`, *optional*, defaults to `True`) -- | |
| Whether to perform sequential quantization even within a single Transformer block. Instead of quantizing | |
| the entire block at once, we perform layer-wise quantization. As a result, each layer undergoes | |
| quantization using inputs that have passed through the previously quantized layers. | |
| - **checkpoint_format** (`str`, *optional*, defaults to `"gptq"`) -- | |
| GPTQ weight format. `gptq`(v1) is supported by both gptqmodel and auto-gptq. `gptq_v2` is gptqmodel only. | |
| - **meta** (`dict[str, any]`, *optional*) -- | |
| Properties, such as tooling:version, that do not directly contributes to quantization or quant inference are stored in meta. | |
| i.e. `meta.quantizer`: ["optimum:_version_", "gptqmodel:_version_"] | |
| - **backend** (`str`, *optional*) -- | |
| Controls which gptq kernel to be used. Valid values for gptqmodel are `auto`, `auto_trainable` and more. For auto-gptq, only | |
| valid value is None and `auto_trainable`. Ref gptqmodel backends: https://github.com/ModelCloud/GPTQModel/blob/main/gptqmodel/utils/backend.py | |
| - **use_cuda_fp16** (`bool`, *optional*, defaults to `False`) -- | |
| Whether or not to use optimized cuda kernel for fp16 model. Need to have model in fp16. Auto-gptq only. | |
| - **model_seqlen** (`int`, *optional*) -- | |
| The maximum sequence length that the model can take. | |
| - **block_name_to_quantize** (`str`, *optional*) -- | |
| The transformers block name to quantize. If None, we will infer the block name using common patterns (e.g. model.layers) | |
| - **module_name_preceding_first_block** (`list[str]`, *optional*) -- | |
| The layers that are preceding the first Transformer block. | |
| - **batch_size** (`int`, *optional*, defaults to 1) -- | |
| The batch size used when processing the dataset | |
| - **pad_token_id** (`int`, *optional*) -- | |
| The pad token id. Needed to prepare the dataset when `batch_size` > 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.</paramsdesc><paramgroups>0</paramgroups></docstring> | |
| This is a wrapper class about all possible attributes and features that you can play with a model that has been | |
| loaded using `optimum` api for gptq quantization relying on auto_gptq backend. | |
| <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"> | |
| <docstring><name>from_dict_optimum</name><anchor>transformers.GPTQConfig.from_dict_optimum</anchor><source>https://github.com/huggingface/transformers/blob/vr_33892/src/transformers/utils/quantization_config.py#L842</source><parameters>[{"name": "config_dict", "val": ""}]</parameters></docstring> | |
| Get compatible class with optimum gptq config dict | |
| </div> | |
| <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"> | |
| <docstring><name>post_init</name><anchor>transformers.GPTQConfig.post_init</anchor><source>https://github.com/huggingface/transformers/blob/vr_33892/src/transformers/utils/quantization_config.py#L758</source><parameters>[]</parameters></docstring> | |
| Safety checker that arguments are correct | |
| </div> | |
| <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"> | |
| <docstring><name>to_dict_optimum</name><anchor>transformers.GPTQConfig.to_dict_optimum</anchor><source>https://github.com/huggingface/transformers/blob/vr_33892/src/transformers/utils/quantization_config.py#L833</source><parameters>[]</parameters></docstring> | |
| Get compatible dict for optimum gptq config | |
| </div></div> | |
| ## BitsAndBytesConfig[[transformers.BitsAndBytesConfig]] | |
| <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"> | |
| <docstring><name>class transformers.BitsAndBytesConfig</name><anchor>transformers.BitsAndBytesConfig</anchor><source>https://github.com/huggingface/transformers/blob/vr_33892/src/transformers/utils/quantization_config.py#L399</source><parameters>[{"name": "load_in_8bit", "val": " = False"}, {"name": "load_in_4bit", "val": " = False"}, {"name": "llm_int8_threshold", "val": " = 6.0"}, {"name": "llm_int8_skip_modules", "val": " = None"}, {"name": "llm_int8_enable_fp32_cpu_offload", "val": " = False"}, {"name": "llm_int8_has_fp16_weight", "val": " = False"}, {"name": "bnb_4bit_compute_dtype", "val": " = None"}, {"name": "bnb_4bit_quant_type", "val": " = 'fp4'"}, {"name": "bnb_4bit_use_double_quant", "val": " = False"}, {"name": "bnb_4bit_quant_storage", "val": " = None"}, {"name": "**kwargs", "val": ""}]</parameters><paramsdesc>- **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.</paramsdesc><paramgroups>0</paramgroups></docstring> | |
| This is a wrapper class about all possible attributes and features that you can play with a model that has been | |
| loaded using `bitsandbytes`. | |
| 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. | |
| <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"> | |
| <docstring><name>is_quantizable</name><anchor>transformers.BitsAndBytesConfig.is_quantizable</anchor><source>https://github.com/huggingface/transformers/blob/vr_33892/src/transformers/utils/quantization_config.py#L560</source><parameters>[]</parameters></docstring> | |
| Returns `True` if the model is quantizable, `False` otherwise. | |
| </div> | |
| <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"> | |
| <docstring><name>post_init</name><anchor>transformers.BitsAndBytesConfig.post_init</anchor><source>https://github.com/huggingface/transformers/blob/vr_33892/src/transformers/utils/quantization_config.py#L530</source><parameters>[]</parameters></docstring> | |
| Safety checker that arguments are correct - also replaces some NoneType arguments with their default values. | |
| </div> | |
| <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"> | |
| <docstring><name>quantization_method</name><anchor>transformers.BitsAndBytesConfig.quantization_method</anchor><source>https://github.com/huggingface/transformers/blob/vr_33892/src/transformers/utils/quantization_config.py#L566</source><parameters>[]</parameters></docstring> | |
| This method returns the quantization method used for the model. If the model is not quantizable, it returns | |
| `None`. | |
| </div> | |
| <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"> | |
| <docstring><name>to_diff_dict</name><anchor>transformers.BitsAndBytesConfig.to_diff_dict</anchor><source>https://github.com/huggingface/transformers/blob/vr_33892/src/transformers/utils/quantization_config.py#L597</source><parameters>[]</parameters><rettype>`dict[str, Any]`</rettype><retdesc>Dictionary of all the attributes that make up this configuration instance,</retdesc></docstring> | |
| Removes all attributes from config which correspond to the default config attributes for better readability and | |
| serializes to a Python dictionary. | |
| </div></div> | |
| ## HfQuantizer[[transformers.quantizers.HfQuantizer]] | |
| <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"> | |
| <docstring><name>class transformers.quantizers.HfQuantizer</name><anchor>transformers.quantizers.HfQuantizer</anchor><source>https://github.com/huggingface/transformers/blob/vr_33892/src/transformers/quantizers/base.py#L44</source><parameters>[{"name": "quantization_config", "val": ": QuantizationConfigMixin"}, {"name": "**kwargs", "val": ""}]</parameters></docstring> | |
| 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. | |
| <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"> | |
| <docstring><name>adjust_max_memory</name><anchor>transformers.quantizers.HfQuantizer.adjust_max_memory</anchor><source>https://github.com/huggingface/transformers/blob/vr_33892/src/transformers/quantizers/base.py#L176</source><parameters>[{"name": "max_memory", "val": ": dict"}]</parameters></docstring> | |
| adjust max_memory argument for infer_auto_device_map() if extra memory is needed for quantization | |
| </div> | |
| <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"> | |
| <docstring><name>adjust_target_dtype</name><anchor>transformers.quantizers.HfQuantizer.adjust_target_dtype</anchor><source>https://github.com/huggingface/transformers/blob/vr_33892/src/transformers/quantizers/base.py#L106</source><parameters>[{"name": "dtype", "val": ": torch.dtype"}]</parameters><paramsdesc>- **dtype** (`torch.dtype`, *optional*) -- | |
| The dtype that is used to compute the device_map.</paramsdesc><paramgroups>0</paramgroups></docstring> | |
| 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`. | |
| </div> | |
| <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"> | |
| <docstring><name>create_quantized_param</name><anchor>transformers.quantizers.HfQuantizer.create_quantized_param</anchor><source>https://github.com/huggingface/transformers/blob/vr_33892/src/transformers/quantizers/base.py#L186</source><parameters>[{"name": "*args", "val": ""}, {"name": "**kwargs", "val": ""}]</parameters></docstring> | |
| 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. | |
| </div> | |
| <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"> | |
| <docstring><name>dequantize</name><anchor>transformers.quantizers.HfQuantizer.dequantize</anchor><source>https://github.com/huggingface/transformers/blob/vr_33892/src/transformers/quantizers/base.py#L273</source><parameters>[{"name": "model", "val": ""}]</parameters></docstring> | |
| Potentially dequantize the model to retrieve the original model, with some loss in accuracy / performance. | |
| Note not all quantization schemes support this. | |
| </div> | |
| <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"> | |
| <docstring><name>get_accelerator_warm_up_factor</name><anchor>transformers.quantizers.HfQuantizer.get_accelerator_warm_up_factor</anchor><source>https://github.com/huggingface/transformers/blob/vr_33892/src/transformers/quantizers/base.py#L289</source><parameters>[]</parameters></docstring> | |
| 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... | |
| </div> | |
| <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"> | |
| <docstring><name>get_param_name</name><anchor>transformers.quantizers.HfQuantizer.get_param_name</anchor><source>https://github.com/huggingface/transformers/blob/vr_33892/src/transformers/quantizers/base.py#L305</source><parameters>[{"name": "param_name", "val": ": str"}]</parameters></docstring> | |
| Override this method if you want to adjust the `param_name`. | |
| </div> | |
| <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"> | |
| <docstring><name>get_special_dtypes_update</name><anchor>transformers.quantizers.HfQuantizer.get_special_dtypes_update</anchor><source>https://github.com/huggingface/transformers/blob/vr_33892/src/transformers/quantizers/base.py#L159</source><parameters>[{"name": "model", "val": ""}, {"name": "dtype", "val": ": torch.dtype"}]</parameters><paramsdesc>- **model** (`~transformers.PreTrainedModel`) -- | |
| The model to quantize | |
| - **dtype** (`torch.dtype`) -- | |
| The dtype passed in `from_pretrained` method.</paramsdesc><paramgroups>0</paramgroups></docstring> | |
| 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`. | |
| </div> | |
| <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"> | |
| <docstring><name>get_state_dict_and_metadata</name><anchor>transformers.quantizers.HfQuantizer.get_state_dict_and_metadata</anchor><source>https://github.com/huggingface/transformers/blob/vr_33892/src/transformers/quantizers/base.py#L343</source><parameters>[{"name": "model", "val": ""}, {"name": "safe_serialization", "val": " = False"}]</parameters></docstring> | |
| Get state dict and metadata. Useful when we need to modify a bit the state dict due to quantization | |
| </div> | |
| <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"> | |
| <docstring><name>param_element_size</name><anchor>transformers.quantizers.HfQuantizer.param_element_size</anchor><source>https://github.com/huggingface/transformers/blob/vr_33892/src/transformers/quantizers/base.py#L118</source><parameters>[{"name": "model", "val": ": PreTrainedModel"}, {"name": "param_name", "val": ": str"}]</parameters></docstring> | |
| Return the element size (in bytes) for `param_name`. | |
| </div> | |
| <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"> | |
| <docstring><name>param_needs_quantization</name><anchor>transformers.quantizers.HfQuantizer.param_needs_quantization</anchor><source>https://github.com/huggingface/transformers/blob/vr_33892/src/transformers/quantizers/base.py#L180</source><parameters>[{"name": "model", "val": ": PreTrainedModel"}, {"name": "param_name", "val": ": str"}, {"name": "**kwargs", "val": ""}]</parameters></docstring> | |
| Check whether a given param needs quantization as defined by `create_quantized_param`. | |
| </div> | |
| <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"> | |
| <docstring><name>postprocess_model</name><anchor>transformers.quantizers.HfQuantizer.postprocess_model</anchor><source>https://github.com/huggingface/transformers/blob/vr_33892/src/transformers/quantizers/base.py#L246</source><parameters>[{"name": "model", "val": ": PreTrainedModel"}, {"name": "**kwargs", "val": ""}]</parameters><paramsdesc>- **model** (`~transformers.PreTrainedModel`) -- | |
| The model to quantize | |
| - **kwargs** (`dict`, *optional*) -- | |
| The keyword arguments that are passed along `_process_model_after_weight_loading`.</paramsdesc><paramgroups>0</paramgroups></docstring> | |
| Post-process the model post weights loading. | |
| Make sure to override the abstract method `_process_model_after_weight_loading`. | |
| </div> | |
| <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"> | |
| <docstring><name>preprocess_model</name><anchor>transformers.quantizers.HfQuantizer.preprocess_model</anchor><source>https://github.com/huggingface/transformers/blob/vr_33892/src/transformers/quantizers/base.py#L217</source><parameters>[{"name": "model", "val": ": PreTrainedModel"}, {"name": "config", "val": ""}, {"name": "dtype", "val": " = None"}, {"name": "checkpoint_files", "val": " = None"}, {"name": "**kwargs", "val": ""}]</parameters><paramsdesc>- **model** (`~transformers.PreTrainedModel`) -- | |
| The model to quantize | |
| - **kwargs** (`dict`, *optional*) -- | |
| The keyword arguments that are passed along `_process_model_before_weight_loading`.</paramsdesc><paramgroups>0</paramgroups></docstring> | |
| 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`. | |
| </div> | |
| <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"> | |
| <docstring><name>remove_quantization_config</name><anchor>transformers.quantizers.HfQuantizer.remove_quantization_config</anchor><source>https://github.com/huggingface/transformers/blob/vr_33892/src/transformers/quantizers/base.py#L259</source><parameters>[{"name": "model", "val": ""}]</parameters></docstring> | |
| Remove the quantization config from the model. | |
| </div> | |
| <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"> | |
| <docstring><name>update_device_map</name><anchor>transformers.quantizers.HfQuantizer.update_device_map</anchor><source>https://github.com/huggingface/transformers/blob/vr_33892/src/transformers/quantizers/base.py#L94</source><parameters>[{"name": "device_map", "val": ": typing.Optional[dict[str, typing.Any]]"}]</parameters><paramsdesc>- **device_map** (`Union[dict, str]`, *optional*) -- | |
| The device_map that is passed through the `from_pretrained` method.</paramsdesc><paramgroups>0</paramgroups></docstring> | |
| 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"`` | |
| </div> | |
| <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"> | |
| <docstring><name>update_dtype</name><anchor>transformers.quantizers.HfQuantizer.update_dtype</anchor><source>https://github.com/huggingface/transformers/blob/vr_33892/src/transformers/quantizers/base.py#L82</source><parameters>[{"name": "dtype", "val": ": torch.dtype"}]</parameters><paramsdesc>- **dtype** (`torch.dtype`) -- | |
| The input dtype that is passed in `from_pretrained`</paramsdesc><paramgroups>0</paramgroups></docstring> | |
| 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 | |
| </div> | |
| <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"> | |
| <docstring><name>update_ep_plan</name><anchor>transformers.quantizers.HfQuantizer.update_ep_plan</anchor><source>https://github.com/huggingface/transformers/blob/vr_33892/src/transformers/quantizers/base.py#L210</source><parameters>[{"name": "config", "val": ""}]</parameters></docstring> | |
| updates the tp plan for the scales | |
| </div> | |
| <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"> | |
| <docstring><name>update_expected_keys</name><anchor>transformers.quantizers.HfQuantizer.update_expected_keys</anchor><source>https://github.com/huggingface/transformers/blob/vr_33892/src/transformers/quantizers/base.py#L144</source><parameters>[{"name": "model", "val": ""}, {"name": "expected_keys", "val": ": list"}, {"name": "loaded_keys", "val": ": list"}]</parameters><paramsdesc>- **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.</paramsdesc><paramgroups>0</paramgroups></docstring> | |
| Override this method if you want to adjust the `update_expected_keys`. | |
| </div> | |
| <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"> | |
| <docstring><name>update_missing_keys</name><anchor>transformers.quantizers.HfQuantizer.update_missing_keys</anchor><source>https://github.com/huggingface/transformers/blob/vr_33892/src/transformers/quantizers/base.py#L134</source><parameters>[{"name": "model", "val": ""}, {"name": "missing_keys", "val": ": list"}, {"name": "prefix", "val": ": str"}]</parameters><paramsdesc>- **missing_keys** (`list[str]`, *optional*) -- | |
| The list of missing keys in the checkpoint compared to the state dict of the model</paramsdesc><paramgroups>0</paramgroups></docstring> | |
| Override this method if you want to adjust the `missing_keys`. | |
| </div> | |
| <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"> | |
| <docstring><name>update_state_dict_with_metadata</name><anchor>transformers.quantizers.HfQuantizer.update_state_dict_with_metadata</anchor><source>https://github.com/huggingface/transformers/blob/vr_33892/src/transformers/quantizers/base.py#L347</source><parameters>[{"name": "state_dict", "val": ""}, {"name": "metadata", "val": ""}]</parameters></docstring> | |
| Update state dict with metadata. Default behaviour returns state_dict | |
| </div> | |
| <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"> | |
| <docstring><name>update_tp_plan</name><anchor>transformers.quantizers.HfQuantizer.update_tp_plan</anchor><source>https://github.com/huggingface/transformers/blob/vr_33892/src/transformers/quantizers/base.py#L206</source><parameters>[{"name": "config", "val": ""}]</parameters></docstring> | |
| updates the tp plan for the scales | |
| </div> | |
| <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"> | |
| <docstring><name>validate_environment</name><anchor>transformers.quantizers.HfQuantizer.validate_environment</anchor><source>https://github.com/huggingface/transformers/blob/vr_33892/src/transformers/quantizers/base.py#L198</source><parameters>[{"name": "*args", "val": ""}, {"name": "**kwargs", "val": ""}]</parameters></docstring> | |
| 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. | |
| </div></div> | |
| ## HiggsConfig[[transformers.HiggsConfig]] | |
| <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"> | |
| <docstring><name>class transformers.HiggsConfig</name><anchor>transformers.HiggsConfig</anchor><source>https://github.com/huggingface/transformers/blob/vr_33892/src/transformers/utils/quantization_config.py#L1479</source><parameters>[{"name": "bits", "val": ": int = 4"}, {"name": "p", "val": ": int = 2"}, {"name": "modules_to_not_convert", "val": ": list[str] | None = None"}, {"name": "hadamard_size", "val": ": int = 512"}, {"name": "group_size", "val": ": int = 256"}, {"name": "tune_metadata", "val": ": dict[str, typing.Any] | None = None"}, {"name": "**kwargs", "val": ""}]</parameters><paramsdesc>- **bits** (int, *optional*, defaults to 4) -- | |
| Number of bits to use for quantization. Can be 2, 3 or 4. Default is 4. | |
| - **p** (int, *optional*, defaults to 2) -- | |
| Quantization grid dimension. 1 and 2 are supported. 2 is always better in practice. Default is 2. | |
| - **modules_to_not_convert** (`list`, *optional*, default to ["lm_head"]) -- | |
| List of linear layers that should not be quantized. | |
| - **hadamard_size** (int, *optional*, defaults to 512) -- | |
| Hadamard size for the HIGGS method. Default is 512. Input dimension of matrices is padded to this value. Decreasing this below 512 will reduce the quality of the quantization. | |
| - **group_size** (int, *optional*, defaults to 256) -- | |
| Group size for the HIGGS method. Can be 64, 128 or 256. Decreasing it barely affects the performance. Default is 256. Must be a divisor of hadamard_size. | |
| - **tune_metadata** ('dict', *optional*, defaults to {}) -- | |
| Module-wise metadata (gemm block shapes, GPU metadata, etc.) for saving the kernel tuning results. Default is an empty dictionary. Is set automatically during tuning.</paramsdesc><paramgroups>0</paramgroups></docstring> | |
| HiggsConfig is a configuration class for quantization using the HIGGS method. | |
| <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"> | |
| <docstring><name>post_init</name><anchor>transformers.HiggsConfig.post_init</anchor><source>https://github.com/huggingface/transformers/blob/vr_33892/src/transformers/utils/quantization_config.py#L1520</source><parameters>[]</parameters></docstring> | |
| Safety checker that arguments are correct - also replaces some NoneType arguments with their default values. | |
| </div></div> | |
| ## HqqConfig[[transformers.HqqConfig]] | |
| <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"> | |
| <docstring><name>class transformers.HqqConfig</name><anchor>transformers.HqqConfig</anchor><source>https://github.com/huggingface/transformers/blob/vr_33892/src/transformers/utils/quantization_config.py#L280</source><parameters>[{"name": "nbits", "val": ": int = 4"}, {"name": "group_size", "val": ": int = 64"}, {"name": "view_as_float", "val": ": bool = False"}, {"name": "axis", "val": ": int | None = None"}, {"name": "dynamic_config", "val": ": dict | None = None"}, {"name": "skip_modules", "val": ": list = ['lm_head']"}, {"name": "**kwargs", "val": ""}]</parameters><paramsdesc>- **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.</paramsdesc><paramgroups>0</paramgroups></docstring> | |
| This is wrapper around hqq's BaseQuantizeConfig. | |
| <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"> | |
| <docstring><name>from_dict</name><anchor>transformers.HqqConfig.from_dict</anchor><source>https://github.com/huggingface/transformers/blob/vr_33892/src/transformers/utils/quantization_config.py#L351</source><parameters>[{"name": "config", "val": ": dict"}]</parameters></docstring> | |
| Override from_dict, used in AutoQuantizationConfig.from_dict in quantizers/auto.py | |
| </div> | |
| <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"> | |
| <docstring><name>post_init</name><anchor>transformers.HqqConfig.post_init</anchor><source>https://github.com/huggingface/transformers/blob/vr_33892/src/transformers/utils/quantization_config.py#L345</source><parameters>[]</parameters></docstring> | |
| Safety checker that arguments are correct - also replaces some NoneType arguments with their default values. | |
| </div> | |
| <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"> | |
| <docstring><name>to_diff_dict</name><anchor>transformers.HqqConfig.to_diff_dict</anchor><source>https://github.com/huggingface/transformers/blob/vr_33892/src/transformers/utils/quantization_config.py#L376</source><parameters>[]</parameters><rettype>`dict[str, Any]`</rettype><retdesc>Dictionary of all the attributes that make up this configuration instance,</retdesc></docstring> | |
| Removes all attributes from config which correspond to the default config attributes for better readability and | |
| serializes to a Python dictionary. | |
| </div></div> | |
| ## Mxfp4Config[[transformers.Mxfp4Config]] | |
| <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"> | |
| <docstring><name>class transformers.Mxfp4Config</name><anchor>transformers.Mxfp4Config</anchor><source>https://github.com/huggingface/transformers/blob/vr_33892/src/transformers/utils/quantization_config.py#L2059</source><parameters>[{"name": "modules_to_not_convert", "val": ": list | None = None"}, {"name": "dequantize", "val": ": bool = False"}, {"name": "**kwargs", "val": ""}]</parameters><paramsdesc>- **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. | |
| - **dequantize** (`bool`, *optional*, default to `False`) -- | |
| Whether we dequantize the model to bf16 precision or not</paramsdesc><paramgroups>0</paramgroups></docstring> | |
| This is a wrapper class about all possible attributes and features that you can play with a model that has been | |
| loaded using mxfp4 quantization. | |
| </div> | |
| ## FbgemmFp8Config[[transformers.FbgemmFp8Config]] | |
| <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"> | |
| <docstring><name>class transformers.FbgemmFp8Config</name><anchor>transformers.FbgemmFp8Config</anchor><source>https://github.com/huggingface/transformers/blob/vr_33892/src/transformers/utils/quantization_config.py#L1448</source><parameters>[{"name": "activation_scale_ub", "val": ": float = 1200.0"}, {"name": "modules_to_not_convert", "val": ": list | None = None"}, {"name": "**kwargs", "val": ""}]</parameters><paramsdesc>- **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.</paramsdesc><paramgroups>0</paramgroups></docstring> | |
| 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. | |
| </div> | |
| ## CompressedTensorsConfig[[transformers.CompressedTensorsConfig]] | |
| <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"> | |
| <docstring><name>class transformers.CompressedTensorsConfig</name><anchor>transformers.CompressedTensorsConfig</anchor><source>https://github.com/huggingface/transformers/blob/vr_33892/src/transformers/utils/quantization_config.py#L1265</source><parameters>[{"name": "config_groups", "val": ": dict[str, typing.Union[ForwardRef('QuantizationScheme'), list[str]]] | None = None"}, {"name": "format", "val": ": str = 'dense'"}, {"name": "quantization_status", "val": ": QuantizationStatus = 'initialized'"}, {"name": "kv_cache_scheme", "val": ": typing.Optional[ForwardRef('QuantizationArgs')] = None"}, {"name": "global_compression_ratio", "val": ": float | None = None"}, {"name": "ignore", "val": ": list[str] | None = None"}, {"name": "sparsity_config", "val": ": dict[str, typing.Any] | None = None"}, {"name": "quant_method", "val": ": str = 'compressed-tensors'"}, {"name": "run_compressed", "val": ": bool = True"}, {"name": "**kwargs", "val": ""}]</parameters><paramsdesc>- **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</paramsdesc><paramgroups>0</paramgroups></docstring> | |
| This is a wrapper class that handles compressed-tensors quantization config options. | |
| It is a wrapper around `compressed_tensors.QuantizationConfig` | |
| <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"> | |
| <docstring><name>from_dict</name><anchor>transformers.CompressedTensorsConfig.from_dict</anchor><source>https://github.com/huggingface/transformers/blob/vr_33892/src/transformers/utils/quantization_config.py#L1352</source><parameters>[{"name": "config_dict", "val": ""}, {"name": "return_unused_kwargs", "val": " = False"}, {"name": "**kwargs", "val": ""}]</parameters><paramsdesc>- **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.</paramsdesc><paramgroups>0</paramgroups><rettype>`QuantizationConfigMixin`</rettype><retdesc>The configuration object instantiated from those parameters.</retdesc></docstring> | |
| Instantiates a [CompressedTensorsConfig](/docs/transformers/pr_33892/en/main_classes/quantization#transformers.CompressedTensorsConfig) from a Python dictionary of parameters. | |
| Optionally unwraps any args from the nested quantization_config | |
| </div> | |
| <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"> | |
| <docstring><name>to_dict</name><anchor>transformers.CompressedTensorsConfig.to_dict</anchor><source>https://github.com/huggingface/transformers/blob/vr_33892/src/transformers/utils/quantization_config.py#L1380</source><parameters>[]</parameters></docstring> | |
| 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. | |
| </div> | |
| <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"> | |
| <docstring><name>to_diff_dict</name><anchor>transformers.CompressedTensorsConfig.to_diff_dict</anchor><source>https://github.com/huggingface/transformers/blob/vr_33892/src/transformers/utils/quantization_config.py#L1400</source><parameters>[]</parameters><rettype>`dict[str, Any]`</rettype><retdesc>Dictionary of all the attributes that make up this configuration instance,</retdesc></docstring> | |
| Removes all attributes from config which correspond to the default config attributes for better readability and | |
| serializes to a Python dictionary. | |
| </div></div> | |
| ## TorchAoConfig[[transformers.TorchAoConfig]] | |
| <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"> | |
| <docstring><name>class transformers.TorchAoConfig</name><anchor>transformers.TorchAoConfig</anchor><source>https://github.com/huggingface/transformers/blob/vr_33892/src/transformers/utils/quantization_config.py#L1620</source><parameters>[{"name": "quant_type", "val": ": typing.Union[str, ForwardRef('AOBaseConfig')]"}, {"name": "modules_to_not_convert", "val": ": list | None = None"}, {"name": "include_input_output_embeddings", "val": ": bool = False"}, {"name": "untie_embedding_weights", "val": ": bool = False"}, {"name": "**kwargs", "val": ""}]</parameters></docstring> | |
| <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"> | |
| <docstring><name>from_dict</name><anchor>transformers.TorchAoConfig.from_dict</anchor><source>https://github.com/huggingface/transformers/blob/vr_33892/src/transformers/utils/quantization_config.py#L1832</source><parameters>[{"name": "config_dict", "val": ""}, {"name": "return_unused_kwargs", "val": " = False"}, {"name": "**kwargs", "val": ""}]</parameters></docstring> | |
| Create configuration from a dictionary. | |
| </div> | |
| <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"> | |
| <docstring><name>get_apply_tensor_subclass</name><anchor>transformers.TorchAoConfig.get_apply_tensor_subclass</anchor><source>https://github.com/huggingface/transformers/blob/vr_33892/src/transformers/utils/quantization_config.py#L1770</source><parameters>[]</parameters></docstring> | |
| Create the appropriate quantization method based on configuration. | |
| </div> | |
| <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"> | |
| <docstring><name>post_init</name><anchor>transformers.TorchAoConfig.post_init</anchor><source>https://github.com/huggingface/transformers/blob/vr_33892/src/transformers/utils/quantization_config.py#L1708</source><parameters>[]</parameters></docstring> | |
| Validate configuration and set defaults. | |
| </div> | |
| <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"> | |
| <docstring><name>to_dict</name><anchor>transformers.TorchAoConfig.to_dict</anchor><source>https://github.com/huggingface/transformers/blob/vr_33892/src/transformers/utils/quantization_config.py#L1804</source><parameters>[]</parameters></docstring> | |
| Convert configuration to a dictionary. | |
| </div></div> | |
| ## BitNetQuantConfig[[transformers.BitNetQuantConfig]] | |
| <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"> | |
| <docstring><name>class transformers.BitNetQuantConfig</name><anchor>transformers.BitNetQuantConfig</anchor><source>https://github.com/huggingface/transformers/blob/vr_33892/src/transformers/utils/quantization_config.py#L1858</source><parameters>[{"name": "modules_to_not_convert", "val": ": list | None = None"}, {"name": "linear_class", "val": ": str = 'bitlinear'"}, {"name": "quantization_mode", "val": ": str = 'offline'"}, {"name": "use_rms_norm", "val": ": bool = False"}, {"name": "rms_norm_eps", "val": ": float | None = 1e-06"}, {"name": "**kwargs", "val": ""}]</parameters><paramsdesc>- **modules_to_not_convert** (`Optional[List]`, *optional*) -- | |
| Optionally, provides a list of full paths of `nn.Linear` weight parameters | |
| that shall not be quantized. Defaults to None. | |
| - **linear_class** (`str`, *optional*, defaults to `"bitlinear"`) -- | |
| The type of linear class to use. Can be either `bitlinear` or `autobitlinear`. | |
| - **quantization_mode** (`str`, *optional*, defaults to `"offline"`) -- | |
| The quantization mode to use. Can be either `online` or `offline`. | |
| In `online` mode, the weight quantization parameters are calculated dynamically | |
| during each forward pass (e.g., based on the current weight values). This can | |
| adapt to weight changes during training (Quantization-Aware Training - QAT). | |
| In `offline` mode, quantization parameters are pre-calculated *before* inference. | |
| These parameters are then fixed and loaded into the quantized model. This | |
| generally results in lower runtime overhead compared to online quantization. | |
| - **use_rms_norm** (`bool`, *optional*, defaults to `False`) -- | |
| Whether to apply RMSNorm on the activations before quantization. This matches the original BitNet paper's approach | |
| of normalizing activations before quantization/packing. | |
| - **rms_norm_eps** (`float`, *optional*, defaults to 1e-06) -- | |
| The epsilon value used in the RMSNorm layer for numerical stability. | |
| - **kwargs** (`dict[str, Any]`, *optional*) -- | |
| Additional keyword arguments that may be used by specific quantization | |
| backends or future versions.</paramsdesc><paramgroups>0</paramgroups></docstring> | |
| Configuration class for applying BitNet quantization. | |
| <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"> | |
| <docstring><name>post_init</name><anchor>transformers.BitNetQuantConfig.post_init</anchor><source>https://github.com/huggingface/transformers/blob/vr_33892/src/transformers/utils/quantization_config.py#L1907</source><parameters>[]</parameters></docstring> | |
| Safety checker that arguments are correct | |
| </div></div> | |
| ## SpQRConfig[[transformers.SpQRConfig]] | |
| <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"> | |
| <docstring><name>class transformers.SpQRConfig</name><anchor>transformers.SpQRConfig</anchor><source>https://github.com/huggingface/transformers/blob/vr_33892/src/transformers/utils/quantization_config.py#L1915</source><parameters>[{"name": "bits", "val": ": int = 3"}, {"name": "beta1", "val": ": int = 16"}, {"name": "beta2", "val": ": int = 16"}, {"name": "shapes", "val": ": dict[str, int] | None = None"}, {"name": "modules_to_not_convert", "val": ": list[str] | None = None"}, {"name": "**kwargs", "val": ""}]</parameters><paramsdesc>- **bits** (`int`, *optional*, defaults to 3) -- | |
| Specifies the bit count for the weights and first order zero-points and scales. | |
| Currently only bits = 3 is supported. | |
| - **beta1** (`int`, *optional*, defaults to 16) -- | |
| SpQR tile width. Currently only beta1 = 16 is supported. | |
| - **beta2** (`int`, *optional*, defaults to 16) -- | |
| SpQR tile height. Currently only beta2 = 16 is supported. | |
| - **shapes** (`Optional`, *optional*) -- | |
| A dictionary holding the shape of each object. We need this because it's impossible | |
| to deduce the exact size of the parameters just from bits, beta1, beta2. | |
| - **modules_to_not_convert** (`Optional[list[str]]`, *optional*) -- | |
| Optionally, provides a list of full paths of `nn.Linear` weight parameters that shall not be quantized. | |
| Defaults to None. | |
| - **kwargs** (`dict[str, Any]`, *optional*) -- | |
| Additional parameters from which to initialize the configuration object.</paramsdesc><paramgroups>0</paramgroups></docstring> | |
| This is a wrapper class about `spqr` parameters. Refer to the original publication for more details. | |
| <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"> | |
| <docstring><name>post_init</name><anchor>transformers.SpQRConfig.post_init</anchor><source>https://github.com/huggingface/transformers/blob/vr_33892/src/transformers/utils/quantization_config.py#L1956</source><parameters>[]</parameters></docstring> | |
| Safety checker that arguments are correct - also replaces some NoneType arguments with their default values. | |
| </div></div> | |
| ## FineGrainedFP8Config[[transformers.FineGrainedFP8Config]] | |
| <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"> | |
| <docstring><name>class transformers.FineGrainedFP8Config</name><anchor>transformers.FineGrainedFP8Config</anchor><source>https://github.com/huggingface/transformers/blob/vr_33892/src/transformers/utils/quantization_config.py#L1978</source><parameters>[{"name": "activation_scheme", "val": ": str = 'dynamic'"}, {"name": "weight_block_size", "val": ": tuple = (128, 128)"}, {"name": "modules_to_not_convert", "val": ": list | None = None"}, {"name": "**kwargs", "val": ""}]</parameters><paramsdesc>- **activation_scheme** (`str`, *optional*, defaults to `"dynamic"`) -- | |
| The scheme used for activation, the defaults and only support scheme for now is "dynamic". | |
| - **weight_block_size** (`typing.tuple[int, int]`, *optional*, defaults to `(128, 128)`) -- | |
| The size of the weight blocks for quantization, default is (128, 128). | |
| - **modules_to_not_convert** (`list`, *optional*) -- | |
| A list of module names that should not be converted during quantization.</paramsdesc><paramgroups>0</paramgroups></docstring> | |
| FineGrainedFP8Config is a configuration class for fine-grained FP8 quantization used mainly for deepseek models. | |
| <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"> | |
| <docstring><name>post_init</name><anchor>transformers.FineGrainedFP8Config.post_init</anchor><source>https://github.com/huggingface/transformers/blob/vr_33892/src/transformers/utils/quantization_config.py#L2004</source><parameters>[]</parameters></docstring> | |
| Safety checker that arguments are correct | |
| </div></div> | |
| ## QuarkConfig[[transformers.QuarkConfig]] | |
| <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"> | |
| <docstring><name>class transformers.QuarkConfig</name><anchor>transformers.QuarkConfig</anchor><source>https://github.com/huggingface/transformers/blob/vr_33892/src/transformers/utils/quantization_config.py#L2017</source><parameters>[{"name": "**kwargs", "val": ""}]</parameters></docstring> | |
| </div> | |
| ## FPQuantConfig[[transformers.FPQuantConfig]] | |
| <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"> | |
| <docstring><name>class transformers.FPQuantConfig</name><anchor>transformers.FPQuantConfig</anchor><source>https://github.com/huggingface/transformers/blob/vr_33892/src/transformers/utils/quantization_config.py#L1535</source><parameters>[{"name": "forward_dtype", "val": ": str = 'nvfp4'"}, {"name": "forward_method", "val": ": str = 'abs_max'"}, {"name": "backward_dtype", "val": ": str = 'bf16'"}, {"name": "store_master_weights", "val": ": bool = False"}, {"name": "hadamard_group_size", "val": ": int | None = None"}, {"name": "pseudoquantization", "val": ": bool = False"}, {"name": "transform_init", "val": ": str = 'hadamard'"}, {"name": "modules_to_not_convert", "val": ": list[str] | None = None"}, {"name": "**kwargs", "val": ""}]</parameters><paramsdesc>- **forward_dtype** (`str`, *optional*, defaults to `"nvfp4"`) -- | |
| The dtype to use for the forward pass. | |
| - **forward_method** (`str`, *optional*, defaults to `"abs_max"`) -- | |
| The scaling to use for the forward pass. Can be `"abs_max"` or `"quest"`. `"abs_max"` is better for PTQ, `"quest"` is better for QAT. | |
| - **backward_dtype** (`str`, *optional*, defaults to `"bf16"`) -- | |
| The dtype to use for the backward pass. | |
| - **store_master_weights** (`bool`, *optional*, defaults to `False`) -- | |
| Whether to store the master weights. Needed for QAT over layer weights. | |
| - **hadamard_group_size** (`int`, *optional*) -- | |
| The group size for the hadamard transform before quantization for `"quest"` it matches the MXFP4 group size (32). If `None`, it will be set to 16 for `"nvfp4"` and 32 for `"mxfp4"`. | |
| - **pseudoquantization** (`bool`, *optional*, defaults to `False`) -- | |
| Whether to use Triton-based pseudo-quantization. Is mandatory for non-Blackwell GPUs. Doesn't provide any speedup. For debugging purposes. | |
| - **transform_init** (`str`, *optional*, defaults to `"hadamard"`) -- a method to initialize the pre-processing matrix with. Can be `"hadamard"`, `"identity"` or `"gsr"`. | |
| - **modules_to_not_convert** (`list`, *optional*) -- | |
| The list of modules to not quantize, useful for quantizing models that explicitly require to have | |
| some modules left in their original precision.</paramsdesc><paramgroups>0</paramgroups></docstring> | |
| FPQuantConfig is a configuration class for quantization using the FPQuant method. | |
| <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"> | |
| <docstring><name>post_init</name><anchor>transformers.FPQuantConfig.post_init</anchor><source>https://github.com/huggingface/transformers/blob/vr_33892/src/transformers/utils/quantization_config.py#L1582</source><parameters>[]</parameters></docstring> | |
| Safety checker that arguments are correct - also replaces some NoneType arguments with their default values. | |
| </div></div> | |
| ## AutoRoundConfig[[transformers.AutoRoundConfig]] | |
| <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"> | |
| <docstring><name>class transformers.AutoRoundConfig</name><anchor>transformers.AutoRoundConfig</anchor><source>https://github.com/huggingface/transformers/blob/vr_33892/src/transformers/utils/quantization_config.py#L211</source><parameters>[{"name": "bits", "val": ": int = 4"}, {"name": "group_size", "val": ": int = 128"}, {"name": "sym", "val": ": bool = True"}, {"name": "backend", "val": ": str = 'auto'"}, {"name": "**kwargs", "val": ""}]</parameters><paramsdesc>- **bits** (`int`, *optional*, defaults to 4) -- | |
| The number of bits to quantize to, supported numbers are (2, 3, 4, 8). | |
| - **group_size** (`int`, *optional*, defaults to 128) -- Group-size value | |
| - **sym** (`bool`, *optional*, defaults to `True`) -- Symmetric quantization or not | |
| - **backend** (`str`, *optional*, defaults to `"auto"`) -- The kernel to use, e.g., ipex,marlin, exllamav2, triton, etc. Ref. https://github.com/intel/auto-round?tab=readme-ov-file#specify-backend</paramsdesc><paramgroups>0</paramgroups></docstring> | |
| This is a wrapper class about all possible attributes and features that you can play with a model that has been | |
| loaded AutoRound quantization. | |
| <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"> | |
| <docstring><name>post_init</name><anchor>transformers.AutoRoundConfig.post_init</anchor><source>https://github.com/huggingface/transformers/blob/vr_33892/src/transformers/utils/quantization_config.py#L242</source><parameters>[]</parameters></docstring> | |
| Safety checker that arguments are correct. | |
| </div></div> | |
| <EditOnGithub source="https://github.com/huggingface/transformers/blob/main/docs/source/en/main_classes/quantization.md" /> |
Xet Storage Details
- Size:
- 70 kB
- Xet hash:
- 222ece629741b6cf0c612d8dfcdb6347f143eb6e70de2eef1845da601ad6b8e7
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.