import{s as En,o as Pn,n as Qn}from"../chunks/scheduler.8c3d61f6.js";import{S as Hn,i as Fn,g as s,s as n,r as c,A as Jn,h as r,f as i,c as o,j as v,u,x as h,k as y,y as t,a as b,v as f,d as m,t as p,w as g}from"../chunks/index.da70eac4.js";import{T as Vn}from"../chunks/Tip.1d9b8c37.js";import{D as w}from"../chunks/Docstring.6b390b9a.js";import{C as jn}from"../chunks/CodeBlock.00a903b3.js";import{E as Nn}from"../chunks/ExampleCodeBlock.db12be95.js";import{H as $t,E as Zn}from"../chunks/EditOnGithub.1e64e623.js";function Un(we){let _,D='Learn how to quantize models in the <a href="../quantization/overview">Quantization</a> guide.';return{c(){_=s("p"),_.innerHTML=D},l(q){_=r(q,"P",{"data-svelte-h":!0}),h(_)!=="svelte-1dd515k"&&(_.innerHTML=D)},m(q,T){b(q,_,T)},p:Qn,d(q){q&&i(_)}}}function Rn(we){let _,D="Example:",q,T,C;return T=new jn({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMEZsdXhUcmFuc2Zvcm1lcjJETW9kZWwlMkMlMjBUb3JjaEFvQ29uZmlnJTBBJTBBcXVhbnRpemF0aW9uX2NvbmZpZyUyMCUzRCUyMFRvcmNoQW9Db25maWcoJTIyaW50OHdvJTIyKSUwQXRyYW5zZm9ybWVyJTIwJTNEJTIwRmx1eFRyYW5zZm9ybWVyMkRNb2RlbC5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIyYmxhY2stZm9yZXN0LWxhYnMlMkZGbHV4LjEtRGV2JTIyJTJDJTBBJTIwJTIwJTIwJTIwc3ViZm9sZGVyJTNEJTIydHJhbnNmb3JtZXIlMjIlMkMlMEElMjAlMjAlMjAlMjBxdWFudGl6YXRpb25fY29uZmlnJTNEcXVhbnRpemF0aW9uX2NvbmZpZyUyQyUwQSUyMCUyMCUyMCUyMHRvcmNoX2R0eXBlJTNEdG9yY2guYmZsb2F0MTYlMkMlMEEp",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> FluxTransformer2DModel, TorchAoConfig

quantization_config = TorchAoConfig(<span class="hljs-string">&quot;int8wo&quot;</span>)
transformer = FluxTransformer2DModel.from_pretrained(
    <span class="hljs-string">&quot;black-forest-labs/Flux.1-Dev&quot;</span>,
    subfolder=<span class="hljs-string">&quot;transformer&quot;</span>,
    quantization_config=quantization_config,
    torch_dtype=torch.bfloat16,
)`,wrap:!1}}),{c(){_=s("p"),_.textContent=D,q=n(),c(T.$$.fragment)},l(x){_=r(x,"P",{"data-svelte-h":!0}),h(_)!=="svelte-11lpom8"&&(_.textContent=D),q=o(x),u(T.$$.fragment,x)},m(x,M){b(x,_,M),b(x,q,M),f(T,x,M),C=!0},p:Qn,i(x){C||(m(T.$$.fragment,x),C=!0)},o(x){p(T.$$.fragment,x),C=!1},d(x){x&&(i(_),i(q)),g(T,x)}}}function Xn(we){let _,D,q,T,C,x,M,cn='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. Diffusers supports 8-bit and 4-bit quantization with <a href="https://huggingface.co/docs/bitsandbytes/en/index" rel="nofollow">bitsandbytes</a>.',We,Y,un='Quantization techniques that aren’t supported in Transformers can be added with the <a href="/docs/diffusers/pr_10009/en/api/quantization#diffusers.DiffusersQuantizer">DiffusersQuantizer</a> class.',Se,L,Ye,G,Ge,$,O,wt,xe,fn=`This is a wrapper class about all possible attributes and features that you can play with a model that has been
loaded using <code>bitsandbytes</code>.`,xt,ze,mn="This replaces <code>load_in_8bit</code> or <code>load_in_4bit</code>therefore both options are mutually exclusive.",zt,qe,pn=`Currently only supports <code>LLM.int8()</code>, <code>FP4</code>, and <code>NF4</code> quantization. If more methods are added to <code>bitsandbytes</code>,
then more arguments will be added to this class.`,qt,B,K,Tt,Te,gn="Returns <code>True</code> if the model is quantizable, <code>False</code> otherwise.",Ct,A,ee,Mt,Ce,hn="Safety checker that arguments are correct - also replaces some NoneType arguments with their default values.",kt,I,te,Dt,Me,_n=`This method returns the quantization method used for the model. If the model is not quantizable, it returns
<code>None</code>.`,Lt,Q,ne,Bt,ke,bn=`Removes all attributes from config which correspond to the default config attributes for better readability and
serializes to a Python dictionary.`,Oe,oe,Ke,k,se,At,De,vn="This is a config class for torchao quantization/sparsity techniques.",It,E,et,re,tt,a,ie,Qt,Le,yn=`Abstract class of the HuggingFace quantizer. Supports for now quantizing HF diffusers models for inference and/or
quantization. This class is used only for diffusers.models.modeling_utils.ModelMixin.from_pretrained and cannot be
easily used outside the scope of that method yet.`,Et,Be,$n=`Attributes
quantization_config (<code>diffusers.quantizers.quantization_config.QuantizationConfigMixin</code>):
The quantization config that defines the quantization parameters of your model that you want to quantize.
modules_to_not_convert (<code>List[str]</code>, <em>optional</em>):
The list of module names to not convert when quantizing the model.
required_packages (<code>List[str]</code>, <em>optional</em>):
The list of required pip packages to install prior to using the quantizer
requires_calibration (<code>bool</code>):
Whether the quantization method requires to calibrate the model before using it.`,Pt,P,ae,Ht,Ae,wn="adjust max_memory argument for infer_auto_device_map() if extra memory is needed for quantization",Ft,H,de,Jt,Ie,xn=`Override this method if you want to adjust the <code>target_dtype</code> variable used in <code>from_pretrained</code> to compute the
device_map in case the device_map is a <code>str</code>. E.g. for bitsandbytes we force-set <code>target_dtype</code> to <code>torch.int8</code>
and for 4-bit we pass a custom enum <code>accelerate.CustomDtype.int4</code>.`,Vt,F,le,jt,Qe,zn=`checks if a loaded state_dict component is part of quantized param + some validation; only defined for
quantization methods that require to create a new parameters for quantization.`,Nt,J,ce,Zt,Ee,qn="checks if the quantized param has expected shape.",Ut,V,ue,Rt,Pe,Tn="takes needed components from state_dict and creates quantized param.",Xt,j,fe,Wt,He,Cn=`Potentially dequantize the model to retrive the original model, with some loss in accuracy / performance. Note
not all quantization schemes support this.`,St,N,me,Yt,Fe,Mn=`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 <code>modules_to_not_convert</code> that is modified in
<code>_process_model_before_weight_loading</code>. <code>diffusers</code> models don’t have any <code>modules_to_not_convert</code> attributes
yet but this can change soon in the future.`,Gt,Z,pe,Ot,Je,kn=`Post-process the model post weights loading. Make sure to override the abstract method
<code>_process_model_after_weight_loading</code>.`,Kt,U,ge,en,Ve,Dn=`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 <code>_process_model_before_weight_loading</code>.`,tn,R,he,nn,je,Ln=`Override this method if you want to pass a override the existing device map with a new one. E.g. for
bitsandbytes, since <code>accelerate</code> is a hard requirement, if no device_map is passed, the device_map is set to
\`“auto”“`,on,X,_e,sn,Ne,Bn="Override this method if you want to adjust the <code>missing_keys</code>.",rn,W,be,an,Ze,An=`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`,dn,S,ve,ln,Ue,In=`This method is used to potentially check for potential conflicts with arguments that are passed in
<code>from_pretrained</code>. You need to define it for all future quantizers that are integrated with diffusers. If no
explicit check are needed, simply return nothing.`,nt,ye,ot,Xe,st;return C=new $t({props:{title:"Quantization",local:"quantization",headingTag:"h1"}}),L=new Vn({props:{$$slots:{default:[Un]},$$scope:{ctx:we}}}),G=new $t({props:{title:"BitsAndBytesConfig",local:"diffusers.BitsAndBytesConfig",headingTag:"h2"}}),O=new w({props:{name:"class diffusers.BitsAndBytesConfig",anchor:"diffusers.BitsAndBytesConfig",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:""}],parametersDescription:[{anchor:"diffusers.BitsAndBytesConfig.load_in_8bit",description:`<strong>load_in_8bit</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
This flag is used to enable 8-bit quantization with LLM.int8().`,name:"load_in_8bit"},{anchor:"diffusers.BitsAndBytesConfig.load_in_4bit",description:`<strong>load_in_4bit</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
This flag is used to enable 4-bit quantization by replacing the Linear layers with FP4/NF4 layers from
<code>bitsandbytes</code>.`,name:"load_in_4bit"},{anchor:"diffusers.BitsAndBytesConfig.llm_int8_threshold",description:`<strong>llm_int8_threshold</strong> (<code>float</code>, <em>optional</em>, defaults to 6.0) &#x2014;
This corresponds to the outlier threshold for outlier detection as described in <code>LLM.int8() : 8-bit Matrix Multiplication for Transformers at Scale</code> paper: <a href="https://arxiv.org/abs/2208.07339" rel="nofollow">https://arxiv.org/abs/2208.07339</a> 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).`,name:"llm_int8_threshold"},{anchor:"diffusers.BitsAndBytesConfig.llm_int8_skip_modules",description:`<strong>llm_int8_skip_modules</strong> (<code>List[str]</code>, <em>optional</em>) &#x2014;
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 <code>CausalLM</code> models, the last <code>lm_head</code> is typically kept in its original <code>dtype</code>.`,name:"llm_int8_skip_modules"},{anchor:"diffusers.BitsAndBytesConfig.llm_int8_enable_fp32_cpu_offload",description:`<strong>llm_int8_enable_fp32_cpu_offload</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
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 <code>google/flan-t5-xxl</code>. Note that the int8
operations will not be run on CPU.`,name:"llm_int8_enable_fp32_cpu_offload"},{anchor:"diffusers.BitsAndBytesConfig.llm_int8_has_fp16_weight",description:`<strong>llm_int8_has_fp16_weight</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
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.`,name:"llm_int8_has_fp16_weight"},{anchor:"diffusers.BitsAndBytesConfig.bnb_4bit_compute_dtype",description:`<strong>bnb_4bit_compute_dtype</strong> (<code>torch.dtype</code> or str, <em>optional</em>, defaults to <code>torch.float32</code>) &#x2014;
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.`,name:"bnb_4bit_compute_dtype"},{anchor:"diffusers.BitsAndBytesConfig.bnb_4bit_quant_type",description:`<strong>bnb_4bit_quant_type</strong> (<code>str</code>,  <em>optional</em>, defaults to <code>&quot;fp4&quot;</code>) &#x2014;
This sets the quantization data type in the bnb.nn.Linear4Bit layers. Options are FP4 and NF4 data types
which are specified by <code>fp4</code> or <code>nf4</code>.`,name:"bnb_4bit_quant_type"},{anchor:"diffusers.BitsAndBytesConfig.bnb_4bit_use_double_quant",description:`<strong>bnb_4bit_use_double_quant</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
This flag is used for nested quantization where the quantization constants from the first quantization are
quantized again.`,name:"bnb_4bit_use_double_quant"},{anchor:"diffusers.BitsAndBytesConfig.bnb_4bit_quant_storage",description:`<strong>bnb_4bit_quant_storage</strong> (<code>torch.dtype</code> or str, <em>optional</em>, defaults to <code>torch.uint8</code>) &#x2014;
This sets the storage type to pack the quanitzed 4-bit prarams.`,name:"bnb_4bit_quant_storage"},{anchor:"diffusers.BitsAndBytesConfig.kwargs",description:`<strong>kwargs</strong> (<code>Dict[str, Any]</code>, <em>optional</em>) &#x2014;
Additional parameters from which to initialize the configuration object.`,name:"kwargs"}],source:"https://github.com/huggingface/diffusers/blob/vr_10009/src/diffusers/quantizers/quantization_config.py#L164"}}),K=new w({props:{name:"is_quantizable",anchor:"diffusers.BitsAndBytesConfig.is_quantizable",parameters:[],source:"https://github.com/huggingface/diffusers/blob/vr_10009/src/diffusers/quantizers/quantization_config.py#L337"}}),ee=new w({props:{name:"post_init",anchor:"diffusers.BitsAndBytesConfig.post_init",parameters:[],source:"https://github.com/huggingface/diffusers/blob/vr_10009/src/diffusers/quantizers/quantization_config.py#L300"}}),te=new w({props:{name:"quantization_method",anchor:"diffusers.BitsAndBytesConfig.quantization_method",parameters:[],source:"https://github.com/huggingface/diffusers/blob/vr_10009/src/diffusers/quantizers/quantization_config.py#L343"}}),ne=new w({props:{name:"to_diff_dict",anchor:"diffusers.BitsAndBytesConfig.to_diff_dict",parameters:[],source:"https://github.com/huggingface/diffusers/blob/vr_10009/src/diffusers/quantizers/quantization_config.py#L374",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>Dictionary of all the attributes that make up this configuration instance,</p>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>


<p><code>Dict[str, Any]</code></p>
`}}),oe=new $t({props:{title:"TorchAoConfig",local:"diffusers.TorchAoConfig",headingTag:"h2"}}),se=new w({props:{name:"class diffusers.TorchAoConfig",anchor:"diffusers.TorchAoConfig",parameters:[{name:"quant_type",val:": str"},{name:"modules_to_not_convert",val:": typing.Optional[typing.List[str]] = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"diffusers.TorchAoConfig.quant_type",description:`<strong>quant_type</strong> (<code>str</code>) &#x2014;
The type of quantization we want to use, currently supporting:</p>
<ul>
<li>
<p><strong>Integer quantization:</strong></p>
<ul>
<li>Full function names: <code>int4_weight_only</code>, <code>int8_dynamic_activation_int4_weight</code>,
<code>int8_weight_only</code>, <code>int8_dynamic_activation_int8_weight</code></li>
<li>Shorthands: <code>int4wo</code>, <code>int4dq</code>, <code>int8wo</code>, <code>int8dq</code></li>
</ul>
</li>
<li>
<p><strong>Floating point 8-bit quantization:</strong></p>
<ul>
<li>Full function names: <code>float8_weight_only</code>, <code>float8_dynamic_activation_float8_weight</code>,
<code>float8_static_activation_float8_weight</code></li>
<li>Shorthands: <code>float8wo</code>, <code>float8wo_e5m2</code>, <code>float8wo_e4m3</code>, <code>float8dq</code>, <code>float8dq_e4m3</code>,
<code>float8_e4m3_tensor</code>, <code>float8_e4m3_row</code>,</li>
</ul>
</li>
<li>
<p><strong>Floating point X-bit quantization:</strong></p>
<ul>
<li>Full function names: <code>fpx_weight_only</code></li>
<li>Shorthands: <code>fpX_eAwB</code>, where <code>X</code> is the number of bits (between <code>1</code> to <code>7</code>), <code>A</code> is the number
of exponent bits and <code>B</code> is the number of mantissa bits. The constraint of <code>X == A + B + 1</code> must
be satisfied for a given shorthand notation.</li>
</ul>
</li>
<li>
<p><strong>Unsigned Integer quantization:</strong></p>
<ul>
<li>Full function names: <code>uintx_weight_only</code></li>
<li>Shorthands: <code>uint1wo</code>, <code>uint2wo</code>, <code>uint3wo</code>, <code>uint4wo</code>, <code>uint5wo</code>, <code>uint6wo</code>, <code>uint7wo</code></li>
</ul>
</li>
</ul>`,name:"quant_type"},{anchor:"diffusers.TorchAoConfig.modules_to_not_convert",description:`<strong>modules_to_not_convert</strong> (<code>List[str]</code>, <em>optional</em>, default to <code>None</code>) &#x2014;
The list of modules to not quantize, useful for quantizing models that explicitly require to have some
modules left in their original precision.`,name:"modules_to_not_convert"},{anchor:"diffusers.TorchAoConfig.kwargs",description:`<strong>kwargs</strong> (<code>Dict[str, Any]</code>, <em>optional</em>) &#x2014;
The keyword arguments for the chosen type of quantization, for example, int4_weight_only quantization
supports two keyword arguments <code>group_size</code> and <code>inner_k_tiles</code> currently. More API examples and
documentation of arguments can be found in
<a href="https://github.com/pytorch/ao/tree/main/torchao/quantization#other-available-quantization-techniques" rel="nofollow">https://github.com/pytorch/ao/tree/main/torchao/quantization#other-available-quantization-techniques</a>`,name:"kwargs"}],source:"https://github.com/huggingface/diffusers/blob/vr_10009/src/diffusers/quantizers/quantization_config.py#L397"}}),E=new Nn({props:{anchor:"diffusers.TorchAoConfig.example",$$slots:{default:[Rn]},$$scope:{ctx:we}}}),re=new $t({props:{title:"DiffusersQuantizer",local:"diffusers.DiffusersQuantizer",headingTag:"h2"}}),ie=new w({props:{name:"class diffusers.DiffusersQuantizer",anchor:"diffusers.DiffusersQuantizer",parameters:[{name:"quantization_config",val:": QuantizationConfigMixin"},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/diffusers/blob/vr_10009/src/diffusers/quantizers/base.py#L34"}}),ae=new w({props:{name:"adjust_max_memory",anchor:"diffusers.DiffusersQuantizer.adjust_max_memory",parameters:[{name:"max_memory",val:": typing.Dict[str, typing.Union[int, str]]"}],source:"https://github.com/huggingface/diffusers/blob/vr_10009/src/diffusers/quantizers/base.py#L133"}}),de=new w({props:{name:"adjust_target_dtype",anchor:"diffusers.DiffusersQuantizer.adjust_target_dtype",parameters:[{name:"torch_dtype",val:": torch.dtype"}],parametersDescription:[{anchor:"diffusers.DiffusersQuantizer.adjust_target_dtype.torch_dtype",description:`<strong>torch_dtype</strong> (<code>torch.dtype</code>, <em>optional</em>) &#x2014;
The torch_dtype that is used to compute the device_map.`,name:"torch_dtype"}],source:"https://github.com/huggingface/diffusers/blob/vr_10009/src/diffusers/quantizers/base.py#L91"}}),le=new w({props:{name:"check_if_quantized_param",anchor:"diffusers.DiffusersQuantizer.check_if_quantized_param",parameters:[{name:"model",val:": ModelMixin"},{name:"param_value",val:": torch.Tensor"},{name:"param_name",val:": str"},{name:"state_dict",val:": typing.Dict[str, typing.Any]"},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/diffusers/blob/vr_10009/src/diffusers/quantizers/base.py#L137"}}),ce=new w({props:{name:"check_quantized_param_shape",anchor:"diffusers.DiffusersQuantizer.check_quantized_param_shape",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/diffusers/blob/vr_10009/src/diffusers/quantizers/base.py#L157"}}),ue=new w({props:{name:"create_quantized_param",anchor:"diffusers.DiffusersQuantizer.create_quantized_param",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/diffusers/blob/vr_10009/src/diffusers/quantizers/base.py#L151"}}),fe=new w({props:{name:"dequantize",anchor:"diffusers.DiffusersQuantizer.dequantize",parameters:[{name:"model",val:""}],source:"https://github.com/huggingface/diffusers/blob/vr_10009/src/diffusers/quantizers/base.py#L200"}}),me=new w({props:{name:"get_special_dtypes_update",anchor:"diffusers.DiffusersQuantizer.get_special_dtypes_update",parameters:[{name:"model",val:""},{name:"torch_dtype",val:": torch.dtype"}],parametersDescription:[{anchor:"diffusers.DiffusersQuantizer.get_special_dtypes_update.model",description:`<strong>model</strong> (<code>~diffusers.models.modeling_utils.ModelMixin</code>) &#x2014;
The model to quantize`,name:"model"},{anchor:"diffusers.DiffusersQuantizer.get_special_dtypes_update.torch_dtype",description:`<strong>torch_dtype</strong> (<code>torch.dtype</code>) &#x2014;
The dtype passed in <code>from_pretrained</code> method.`,name:"torch_dtype"}],source:"https://github.com/huggingface/diffusers/blob/vr_10009/src/diffusers/quantizers/base.py#L113"}}),pe=new w({props:{name:"postprocess_model",anchor:"diffusers.DiffusersQuantizer.postprocess_model",parameters:[{name:"model",val:": ModelMixin"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"diffusers.DiffusersQuantizer.postprocess_model.model",description:`<strong>model</strong> (<code>~diffusers.models.modeling_utils.ModelMixin</code>) &#x2014;
The model to quantize`,name:"model"},{anchor:"diffusers.DiffusersQuantizer.postprocess_model.kwargs",description:`<strong>kwargs</strong> (<code>dict</code>, <em>optional</em>) &#x2014;
The keyword arguments that are passed along <code>_process_model_after_weight_loading</code>.`,name:"kwargs"}],source:"https://github.com/huggingface/diffusers/blob/vr_10009/src/diffusers/quantizers/base.py#L187"}}),ge=new w({props:{name:"preprocess_model",anchor:"diffusers.DiffusersQuantizer.preprocess_model",parameters:[{name:"model",val:": ModelMixin"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"diffusers.DiffusersQuantizer.preprocess_model.model",description:`<strong>model</strong> (<code>~diffusers.models.modeling_utils.ModelMixin</code>) &#x2014;
The model to quantize`,name:"model"},{anchor:"diffusers.DiffusersQuantizer.preprocess_model.kwargs",description:`<strong>kwargs</strong> (<code>dict</code>, <em>optional</em>) &#x2014;
The keyword arguments that are passed along <code>_process_model_before_weight_loading</code>.`,name:"kwargs"}],source:"https://github.com/huggingface/diffusers/blob/vr_10009/src/diffusers/quantizers/base.py#L171"}}),he=new w({props:{name:"update_device_map",anchor:"diffusers.DiffusersQuantizer.update_device_map",parameters:[{name:"device_map",val:": typing.Optional[typing.Dict[str, typing.Any]]"}],parametersDescription:[{anchor:"diffusers.DiffusersQuantizer.update_device_map.device_map",description:`<strong>device_map</strong> (<code>Union[dict, str]</code>, <em>optional</em>) &#x2014;
The device_map that is passed through the <code>from_pretrained</code> method.`,name:"device_map"}],source:"https://github.com/huggingface/diffusers/blob/vr_10009/src/diffusers/quantizers/base.py#L79"}}),_e=new w({props:{name:"update_missing_keys",anchor:"diffusers.DiffusersQuantizer.update_missing_keys",parameters:[{name:"model",val:""},{name:"missing_keys",val:": typing.List[str]"},{name:"prefix",val:": str"}],parametersDescription:[{anchor:"diffusers.DiffusersQuantizer.update_missing_keys.missing_keys",description:`<strong>missing_keys</strong> (<code>List[str]</code>, <em>optional</em>) &#x2014;
The list of missing keys in the checkpoint compared to the state dict of the model`,name:"missing_keys"}],source:"https://github.com/huggingface/diffusers/blob/vr_10009/src/diffusers/quantizers/base.py#L103"}}),be=new w({props:{name:"update_torch_dtype",anchor:"diffusers.DiffusersQuantizer.update_torch_dtype",parameters:[{name:"torch_dtype",val:": torch.dtype"}],parametersDescription:[{anchor:"diffusers.DiffusersQuantizer.update_torch_dtype.torch_dtype",description:`<strong>torch_dtype</strong> (<code>torch.dtype</code>) &#x2014;
The input dtype that is passed in <code>from_pretrained</code>`,name:"torch_dtype"}],source:"https://github.com/huggingface/diffusers/blob/vr_10009/src/diffusers/quantizers/base.py#L68"}}),ve=new w({props:{name:"validate_environment",anchor:"diffusers.DiffusersQuantizer.validate_environment",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/diffusers/blob/vr_10009/src/diffusers/quantizers/base.py#L163"}}),ye=new Zn({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/quantization.md"}}),{c(){_=s("meta"),D=n(),q=s("p"),T=n(),c(C.$$.fragment),x=n(),M=s("p"),M.innerHTML=cn,We=n(),Y=s("p"),Y.innerHTML=un,Se=n(),c(L.$$.fragment),Ye=n(),c(G.$$.fragment),Ge=n(),$=s("div"),c(O.$$.fragment),wt=n(),xe=s("p"),xe.innerHTML=fn,xt=n(),ze=s("p"),ze.innerHTML=mn,zt=n(),qe=s("p"),qe.innerHTML=pn,qt=n(),B=s("div"),c(K.$$.fragment),Tt=n(),Te=s("p"),Te.innerHTML=gn,Ct=n(),A=s("div"),c(ee.$$.fragment),Mt=n(),Ce=s("p"),Ce.textContent=hn,kt=n(),I=s("div"),c(te.$$.fragment),Dt=n(),Me=s("p"),Me.innerHTML=_n,Lt=n(),Q=s("div"),c(ne.$$.fragment),Bt=n(),ke=s("p"),ke.textContent=bn,Oe=n(),c(oe.$$.fragment),Ke=n(),k=s("div"),c(se.$$.fragment),At=n(),De=s("p"),De.textContent=vn,It=n(),c(E.$$.fragment),et=n(),c(re.$$.fragment),tt=n(),a=s("div"),c(ie.$$.fragment),Qt=n(),Le=s("p"),Le.textContent=yn,Et=n(),Be=s("p"),Be.innerHTML=$n,Pt=n(),P=s("div"),c(ae.$$.fragment),Ht=n(),Ae=s("p"),Ae.textContent=wn,Ft=n(),H=s("div"),c(de.$$.fragment),Jt=n(),Ie=s("p"),Ie.innerHTML=xn,Vt=n(),F=s("div"),c(le.$$.fragment),jt=n(),Qe=s("p"),Qe.textContent=zn,Nt=n(),J=s("div"),c(ce.$$.fragment),Zt=n(),Ee=s("p"),Ee.textContent=qn,Ut=n(),V=s("div"),c(ue.$$.fragment),Rt=n(),Pe=s("p"),Pe.textContent=Tn,Xt=n(),j=s("div"),c(fe.$$.fragment),Wt=n(),He=s("p"),He.textContent=Cn,St=n(),N=s("div"),c(me.$$.fragment),Yt=n(),Fe=s("p"),Fe.innerHTML=Mn,Gt=n(),Z=s("div"),c(pe.$$.fragment),Ot=n(),Je=s("p"),Je.innerHTML=kn,Kt=n(),U=s("div"),c(ge.$$.fragment),en=n(),Ve=s("p"),Ve.innerHTML=Dn,tn=n(),R=s("div"),c(he.$$.fragment),nn=n(),je=s("p"),je.innerHTML=Ln,on=n(),X=s("div"),c(_e.$$.fragment),sn=n(),Ne=s("p"),Ne.innerHTML=Bn,rn=n(),W=s("div"),c(be.$$.fragment),an=n(),Ze=s("p"),Ze.textContent=An,dn=n(),S=s("div"),c(ve.$$.fragment),ln=n(),Ue=s("p"),Ue.innerHTML=In,nt=n(),c(ye.$$.fragment),ot=n(),Xe=s("p"),this.h()},l(e){const d=Jn("svelte-u9bgzb",document.head);_=r(d,"META",{name:!0,content:!0}),d.forEach(i),D=o(e),q=r(e,"P",{}),v(q).forEach(i),T=o(e),u(C.$$.fragment,e),x=o(e),M=r(e,"P",{"data-svelte-h":!0}),h(M)!=="svelte-gx66go"&&(M.innerHTML=cn),We=o(e),Y=r(e,"P",{"data-svelte-h":!0}),h(Y)!=="svelte-pnzeyd"&&(Y.innerHTML=un),Se=o(e),u(L.$$.fragment,e),Ye=o(e),u(G.$$.fragment,e),Ge=o(e),$=r(e,"DIV",{class:!0});var z=v($);u(O.$$.fragment,z),wt=o(z),xe=r(z,"P",{"data-svelte-h":!0}),h(xe)!=="svelte-woamwr"&&(xe.innerHTML=fn),xt=o(z),ze=r(z,"P",{"data-svelte-h":!0}),h(ze)!=="svelte-ki5gis"&&(ze.innerHTML=mn),zt=o(z),qe=r(z,"P",{"data-svelte-h":!0}),h(qe)!=="svelte-8qsk2q"&&(qe.innerHTML=pn),qt=o(z),B=r(z,"DIV",{class:!0});var $e=v(B);u(K.$$.fragment,$e),Tt=o($e),Te=r($e,"P",{"data-svelte-h":!0}),h(Te)!=="svelte-10tvzyv"&&(Te.innerHTML=gn),$e.forEach(i),Ct=o(z),A=r(z,"DIV",{class:!0});var rt=v(A);u(ee.$$.fragment,rt),Mt=o(rt),Ce=r(rt,"P",{"data-svelte-h":!0}),h(Ce)!=="svelte-gy26u4"&&(Ce.textContent=hn),rt.forEach(i),kt=o(z),I=r(z,"DIV",{class:!0});var it=v(I);u(te.$$.fragment,it),Dt=o(it),Me=r(it,"P",{"data-svelte-h":!0}),h(Me)!=="svelte-19bn0da"&&(Me.innerHTML=_n),it.forEach(i),Lt=o(z),Q=r(z,"DIV",{class:!0});var at=v(Q);u(ne.$$.fragment,at),Bt=o(at),ke=r(at,"P",{"data-svelte-h":!0}),h(ke)!=="svelte-1p6bdas"&&(ke.textContent=bn),at.forEach(i),z.forEach(i),Oe=o(e),u(oe.$$.fragment,e),Ke=o(e),k=r(e,"DIV",{class:!0});var Re=v(k);u(se.$$.fragment,Re),At=o(Re),De=r(Re,"P",{"data-svelte-h":!0}),h(De)!=="svelte-1pwo8e0"&&(De.textContent=vn),It=o(Re),u(E.$$.fragment,Re),Re.forEach(i),et=o(e),u(re.$$.fragment,e),tt=o(e),a=r(e,"DIV",{class:!0});var l=v(a);u(ie.$$.fragment,l),Qt=o(l),Le=r(l,"P",{"data-svelte-h":!0}),h(Le)!=="svelte-n1gm3c"&&(Le.textContent=yn),Et=o(l),Be=r(l,"P",{"data-svelte-h":!0}),h(Be)!=="svelte-1fnduym"&&(Be.innerHTML=$n),Pt=o(l),P=r(l,"DIV",{class:!0});var dt=v(P);u(ae.$$.fragment,dt),Ht=o(dt),Ae=r(dt,"P",{"data-svelte-h":!0}),h(Ae)!=="svelte-1d4i4z7"&&(Ae.textContent=wn),dt.forEach(i),Ft=o(l),H=r(l,"DIV",{class:!0});var lt=v(H);u(de.$$.fragment,lt),Jt=o(lt),Ie=r(lt,"P",{"data-svelte-h":!0}),h(Ie)!=="svelte-eyxa3y"&&(Ie.innerHTML=xn),lt.forEach(i),Vt=o(l),F=r(l,"DIV",{class:!0});var ct=v(F);u(le.$$.fragment,ct),jt=o(ct),Qe=r(ct,"P",{"data-svelte-h":!0}),h(Qe)!=="svelte-y0lxmf"&&(Qe.textContent=zn),ct.forEach(i),Nt=o(l),J=r(l,"DIV",{class:!0});var ut=v(J);u(ce.$$.fragment,ut),Zt=o(ut),Ee=r(ut,"P",{"data-svelte-h":!0}),h(Ee)!=="svelte-1170ss6"&&(Ee.textContent=qn),ut.forEach(i),Ut=o(l),V=r(l,"DIV",{class:!0});var ft=v(V);u(ue.$$.fragment,ft),Rt=o(ft),Pe=r(ft,"P",{"data-svelte-h":!0}),h(Pe)!=="svelte-odkanz"&&(Pe.textContent=Tn),ft.forEach(i),Xt=o(l),j=r(l,"DIV",{class:!0});var mt=v(j);u(fe.$$.fragment,mt),Wt=o(mt),He=r(mt,"P",{"data-svelte-h":!0}),h(He)!=="svelte-1wzx7fq"&&(He.textContent=Cn),mt.forEach(i),St=o(l),N=r(l,"DIV",{class:!0});var pt=v(N);u(me.$$.fragment,pt),Yt=o(pt),Fe=r(pt,"P",{"data-svelte-h":!0}),h(Fe)!=="svelte-1cb2fzf"&&(Fe.innerHTML=Mn),pt.forEach(i),Gt=o(l),Z=r(l,"DIV",{class:!0});var gt=v(Z);u(pe.$$.fragment,gt),Ot=o(gt),Je=r(gt,"P",{"data-svelte-h":!0}),h(Je)!=="svelte-6rgq61"&&(Je.innerHTML=kn),gt.forEach(i),Kt=o(l),U=r(l,"DIV",{class:!0});var ht=v(U);u(ge.$$.fragment,ht),en=o(ht),Ve=r(ht,"P",{"data-svelte-h":!0}),h(Ve)!=="svelte-wiwxpv"&&(Ve.innerHTML=Dn),ht.forEach(i),tn=o(l),R=r(l,"DIV",{class:!0});var _t=v(R);u(he.$$.fragment,_t),nn=o(_t),je=r(_t,"P",{"data-svelte-h":!0}),h(je)!=="svelte-5g503h"&&(je.innerHTML=Ln),_t.forEach(i),on=o(l),X=r(l,"DIV",{class:!0});var bt=v(X);u(_e.$$.fragment,bt),sn=o(bt),Ne=r(bt,"P",{"data-svelte-h":!0}),h(Ne)!=="svelte-13hqoy0"&&(Ne.innerHTML=Bn),bt.forEach(i),rn=o(l),W=r(l,"DIV",{class:!0});var vt=v(W);u(be.$$.fragment,vt),an=o(vt),Ze=r(vt,"P",{"data-svelte-h":!0}),h(Ze)!=="svelte-udr2k7"&&(Ze.textContent=An),vt.forEach(i),dn=o(l),S=r(l,"DIV",{class:!0});var yt=v(S);u(ve.$$.fragment,yt),ln=o(yt),Ue=r(yt,"P",{"data-svelte-h":!0}),h(Ue)!=="svelte-1ra2q1u"&&(Ue.innerHTML=In),yt.forEach(i),l.forEach(i),nt=o(e),u(ye.$$.fragment,e),ot=o(e),Xe=r(e,"P",{}),v(Xe).forEach(i),this.h()},h(){y(_,"name","hf:doc:metadata"),y(_,"content",Wn),y(B,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),y(A,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),y(I,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),y(Q,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),y($,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),y(k,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),y(P,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),y(H,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),y(F,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),y(J,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),y(V,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),y(j,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),y(N,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),y(Z,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),y(U,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),y(R,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),y(X,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),y(W,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),y(S,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),y(a,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(e,d){t(document.head,_),b(e,D,d),b(e,q,d),b(e,T,d),f(C,e,d),b(e,x,d),b(e,M,d),b(e,We,d),b(e,Y,d),b(e,Se,d),f(L,e,d),b(e,Ye,d),f(G,e,d),b(e,Ge,d),b(e,$,d),f(O,$,null),t($,wt),t($,xe),t($,xt),t($,ze),t($,zt),t($,qe),t($,qt),t($,B),f(K,B,null),t(B,Tt),t(B,Te),t($,Ct),t($,A),f(ee,A,null),t(A,Mt),t(A,Ce),t($,kt),t($,I),f(te,I,null),t(I,Dt),t(I,Me),t($,Lt),t($,Q),f(ne,Q,null),t(Q,Bt),t(Q,ke),b(e,Oe,d),f(oe,e,d),b(e,Ke,d),b(e,k,d),f(se,k,null),t(k,At),t(k,De),t(k,It),f(E,k,null),b(e,et,d),f(re,e,d),b(e,tt,d),b(e,a,d),f(ie,a,null),t(a,Qt),t(a,Le),t(a,Et),t(a,Be),t(a,Pt),t(a,P),f(ae,P,null),t(P,Ht),t(P,Ae),t(a,Ft),t(a,H),f(de,H,null),t(H,Jt),t(H,Ie),t(a,Vt),t(a,F),f(le,F,null),t(F,jt),t(F,Qe),t(a,Nt),t(a,J),f(ce,J,null),t(J,Zt),t(J,Ee),t(a,Ut),t(a,V),f(ue,V,null),t(V,Rt),t(V,Pe),t(a,Xt),t(a,j),f(fe,j,null),t(j,Wt),t(j,He),t(a,St),t(a,N),f(me,N,null),t(N,Yt),t(N,Fe),t(a,Gt),t(a,Z),f(pe,Z,null),t(Z,Ot),t(Z,Je),t(a,Kt),t(a,U),f(ge,U,null),t(U,en),t(U,Ve),t(a,tn),t(a,R),f(he,R,null),t(R,nn),t(R,je),t(a,on),t(a,X),f(_e,X,null),t(X,sn),t(X,Ne),t(a,rn),t(a,W),f(be,W,null),t(W,an),t(W,Ze),t(a,dn),t(a,S),f(ve,S,null),t(S,ln),t(S,Ue),b(e,nt,d),f(ye,e,d),b(e,ot,d),b(e,Xe,d),st=!0},p(e,[d]){const z={};d&2&&(z.$$scope={dirty:d,ctx:e}),L.$set(z);const $e={};d&2&&($e.$$scope={dirty:d,ctx:e}),E.$set($e)},i(e){st||(m(C.$$.fragment,e),m(L.$$.fragment,e),m(G.$$.fragment,e),m(O.$$.fragment,e),m(K.$$.fragment,e),m(ee.$$.fragment,e),m(te.$$.fragment,e),m(ne.$$.fragment,e),m(oe.$$.fragment,e),m(se.$$.fragment,e),m(E.$$.fragment,e),m(re.$$.fragment,e),m(ie.$$.fragment,e),m(ae.$$.fragment,e),m(de.$$.fragment,e),m(le.$$.fragment,e),m(ce.$$.fragment,e),m(ue.$$.fragment,e),m(fe.$$.fragment,e),m(me.$$.fragment,e),m(pe.$$.fragment,e),m(ge.$$.fragment,e),m(he.$$.fragment,e),m(_e.$$.fragment,e),m(be.$$.fragment,e),m(ve.$$.fragment,e),m(ye.$$.fragment,e),st=!0)},o(e){p(C.$$.fragment,e),p(L.$$.fragment,e),p(G.$$.fragment,e),p(O.$$.fragment,e),p(K.$$.fragment,e),p(ee.$$.fragment,e),p(te.$$.fragment,e),p(ne.$$.fragment,e),p(oe.$$.fragment,e),p(se.$$.fragment,e),p(E.$$.fragment,e),p(re.$$.fragment,e),p(ie.$$.fragment,e),p(ae.$$.fragment,e),p(de.$$.fragment,e),p(le.$$.fragment,e),p(ce.$$.fragment,e),p(ue.$$.fragment,e),p(fe.$$.fragment,e),p(me.$$.fragment,e),p(pe.$$.fragment,e),p(ge.$$.fragment,e),p(he.$$.fragment,e),p(_e.$$.fragment,e),p(be.$$.fragment,e),p(ve.$$.fragment,e),p(ye.$$.fragment,e),st=!1},d(e){e&&(i(D),i(q),i(T),i(x),i(M),i(We),i(Y),i(Se),i(Ye),i(Ge),i($),i(Oe),i(Ke),i(k),i(et),i(tt),i(a),i(nt),i(ot),i(Xe)),i(_),g(C,e),g(L,e),g(G,e),g(O),g(K),g(ee),g(te),g(ne),g(oe,e),g(se),g(E),g(re,e),g(ie),g(ae),g(de),g(le),g(ce),g(ue),g(fe),g(me),g(pe),g(ge),g(he),g(_e),g(be),g(ve),g(ye,e)}}}const Wn='{"title":"Quantization","local":"quantization","sections":[{"title":"BitsAndBytesConfig","local":"diffusers.BitsAndBytesConfig","sections":[],"depth":2},{"title":"TorchAoConfig","local":"diffusers.TorchAoConfig","sections":[],"depth":2},{"title":"DiffusersQuantizer","local":"diffusers.DiffusersQuantizer","sections":[],"depth":2}],"depth":1}';function Sn(we){return Pn(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class oo extends Hn{constructor(_){super(),Fn(this,_,Sn,Xn,En,{})}}export{oo as component};
