+
    Lj7                         R t ^ RIt^RIHt ^RIHtHt ^RIHt ^RI	H
t
 ^RIHtHtHtHtHtHtHtHt ^RIHt ^RIHt R	]R
]R]R]R]R]
R]/tR	]R
]R]R]R]R]R]/t ! R R4      tR# )z
Adapted from
https://github.com/huggingface/transformers/blob/c409cd81777fb27aadc043ed3d8339dbc020fb3b/src/transformers/quantizers/auto.py
N)AutoRoundQuantizer)BnB4BitDiffusersQuantizerBnB8BitDiffusersQuantizer)GGUFQuantizer)NVIDIAModelOptQuantizer)AutoRoundConfigBitsAndBytesConfigGGUFQuantizationConfigNVIDIAModelOptConfigQuantizationConfigMixinQuantizationMethodQuantoConfigTorchAoConfig)QuantoQuantizer)TorchAoHfQuantizerbitsandbytes_4bitbitsandbytes_8bitggufquantotorchaomodeloptz
auto-roundc                      a  ] tR t^<t o Rt]V 3R lR l4       t]V 3R lR l4       t]R 4       t]V 3R lR l4       t	R	t
V tR
# )DiffusersAutoQuantizerz
 The auto diffusers quantizer class that takes care of automatically instantiating to the correct
`DiffusersQuantizer` given the `QuantizationConfig`.
c                    < V ^8  d   QhRS[ /# )   quantization_config_dict)dict)format__classdict__s   "E/app/.local/lib/python3.14/site-packages/diffusers/quantizers/auto.py__annotate__#DiffusersAutoQuantizer.__annotate__C   s     > > >    c           	        VP                  R R4      pVP                  RR4      '       g   VP                  RR4      '       d5   VP                  RR4      '       d   RMRp\        P                  V,           pMVf   \        R4      hV\        P                  4       9  d-   \        RV R	\        \        P                  4       4       24      h\        V,          pVP                  V4      # )
quant_methodNload_in_8bitFload_in_4bit_4bit_8bitzThe model's quantization config from the arguments has no `quant_method` attribute. Make sure that the model has been correctly quantizedUnknown quantization type, got  - supported types are: )	getr   BITS_AND_BYTES
ValueError AUTO_QUANTIZATION_CONFIG_MAPPINGkeyslistAUTO_QUANTIZER_MAPPING	from_dict)clsr   r$   suffix
target_clss   &&   r   r2    DiffusersAutoQuantizer.from_dictB   s    /33NDI#''>>BZB^B^_motBuBu 8 < <^U S SWY`F-<<vEL! \  ?DDFF1, @/44678: 
 6lC
##$<==r"   c                0   < V ^8  d   QhRS[ S[,          /# )r   quantization_config)r   r   )r   r   s   "r   r    r!   X   s     9 9.E.L 9r"   c           	        \        V\        4      '       d   V P                  V4      pVP                  pV\        P
                  8X  d&   VP                  '       d   VR ,          pM	VR,          pV\        P                  4       9  d-   \        RV R\        \        P                  4       4       24      h\        V,          pV! V3/ VB # )r(   r'   r)   r*   )
isinstancer   r2   r$   r   r,   r%   r1   r/   r-   r0   )r3   r8   kwargsr$   r5   s   &&,  r   from_config"DiffusersAutoQuantizer.from_configW   s     )400"%--0C"D*77 -<<<"///''5::<<1, @/44678: 
 ,L9
-888r"   c                    V P                   ! V3/ VB p\        VR R4      f   \        RV R24      hVP                  pV P	                  V4      pVP                  V4       V P                  V4      # )r8   Nz)Did not found a `quantization_config` in z2. Make sure that the model is correctly quantized.)load_configgetattrr-   r8   r2   updater<   )r3   pretrained_model_name_or_pathr;   model_configr   r8   s   &&,   r   from_pretrained&DiffusersAutoQuantizer.from_pretrainedp   s    'DOO<!6=E;<Y;Z  [M  N  $0#C#C !mm,DE""6*233r"   c                D   < V ^8  d   QhRS[ S[,          RS[R,          /# )r   r8   quantization_config_from_argsN)r   r   )r   r   s   "r   r    r!      s*     '# '#!$;;'# (?'E'#r"   c                   Ve   RpMRp\        V\        4      '       d   V P                  V4      p\        V\        4      '       d   VP	                  4        Ve   \        V\
        4      '       d|   VP                  P                  4        F]  w  rEVR9   d   K  \        W4      '       g   K!  \        W4      V8w  g   K3  \        P                  ! RV RV: R24       \        WV4       K_  	  VR8w  d   \        P                  ! V4       V# )zt
handles situations where both quantization_config from args and quantization_config from model config are
present.
zYou passed `quantization_config` or equivalent parameters to `from_pretrained` but the model you're loading already has a `quantization_config` attribute. The `quantization_config` from the model will be used. zOverriding `z0` in the model's quantization_config with value z. from the user-provided `quantization_config`.)r$   )r:   r   r2   r
   check_model_patchingr   __dict__itemshasattrr@   warningswarnsetattr)r3   r8   rG   warning_msgkeyvalues   &&&   r   merge_quantization_configs1DiffusersAutoQuantizer.merge_quantization_configs~   s     )4y 
 K)400"%--0C"D)+?@@446(4DWYh9i9i <DDJJL
++.44AT9Z^c9cMM&se+[\a[d eH I /e< M "MM+&""r"    N)__name__
__module____qualname____firstlineno____doc__classmethodr2   r<   rD   rT   __static_attributes____classdictcell__)r   s   @r   r   r   <   sZ     
 > >( 9 90 4 4 '# '#r"   r   )r[   rN   	autoroundr   bitsandbytesr   r   r   r   r   r   r8   r   r   r	   r
   r   r   r   r   r   r   r   r   r1   r.   r   rV   r"   r   <module>ra      s   
  ) N  -	 	 	 $ ' 22
Mo!'$  ++
"l}$/$  j# j#r"   