CoolFace
Apppublic

Aluode/PerceptionLabPortable

sourceHugging Faceupdated 9mo agoView on Hugging Face
0likes
quantizer_aqlm.cpython-310.pyc20 linesDownload Raw Back to __pycache__
1o

20�Yi�@s�ddlZddlmZddlmZddlmZerddlmZddl	m3Z4dd	lmZm
Z
mZmZdd5lmZe�r=ddlZe�e�ZGdd�de�ZdS)
�N)�
TYPE_CHECKING)�version�)�HfQuantizer�)�PreTrainedModel)�replace_with_aqlm_linear)�is_accelerate_available�is_aqlm_available�is_torch_available�logging)�QuantizationConfigMixincszeZdZdZdZdgZdZdef�fdd�Zdd	�Z	dd
d�Z6		ddd�Zddd�Ze
defdd��Zddd�Z�ZS)�AqlmHfQuantizerzS7    Quantizer of the AQLM method. Enables the loading of prequantized models.8    T�aqlmN�quantization_configcst�j|fi|��||_dS�N)�super�__init__r)�selfr�kwargs��	__class__���E:\DocsHouse\542 percep lab latest\PerceptionLab\PerceptionLab_Portable\python_embed\Lib\site-packages\transformers/quantizers/quantizer_aqlm.pyr-s9zAqlmHfQuantizer.__init__cOs t�std��t�std��dS)NzGUsing `aqlm` quantization requires Accelerate: `pip install accelerate`zDUsing `aqlm` quantization requires AQLM: `pip install aqlm[gpu,cpu]`)r	�ImportErrorr10)r�argsrrrr�validate_environment1s11�z$AqlmHfQuantizer.validate_environment�dtype�torch.dtype�returncCs:|durtj��rtj}t�d�|Stj}t�d�|S)NzCUDA available. Assuming AQLM inference on GPU and loading the model in `torch.float16`. To overwrite it, set `dtype` manually.z�CUDA is unavailable. Assuming AQLM inference on CPU and loading the model in `torch.float32`. To overwrite it, set `dtype` manually.)�torch�cudaZis_availableZfloat16�logger�infoZfloat32)rrrrr�update_dtype8s12���zAqlmHfQuantizer.update_dtype�modelrcKs"t||j|jjd�|j|j_dS)N)r�linear_weights_not_to_quantize)rrr&�config�rr%rrrr�$_process_model_before_weight_loadingFs�z4AqlmHfQuantizer._process_model_before_weight_loadingcKs|Srrr(rrr�#_process_model_after_weight_loadingR�z3AqlmHfQuantizer._process_model_after_weight_loadingcCsBt�tj�d��t�d�k}|rdSt�dtj�d��d��dS)Nrz1.0.2Tz$Currently installed `aqlm` version (zw) doesn't support training. If you wish to train a quantized model, please update `aqlm` with `pip install aqlm>=1.0.2`F)r�parse�	importlib�metadatar"�warning)rZaqlm_supports_trainingrrr�is_trainableUs�zAqlmHfQuantizer.is_trainablecCsdS)NTr)rZsafe_serializationrrr�is_serializable`r+zAqlmHfQuantizer.is_serializable)rrrr)r%rr)�__name__�13__module__�__qualname__�__doc__Zrequires_calibrationZrequired_packagesZoptimum_quantizerr
rrr$r)r*�property�boolr0r1�
__classcell__rrrrr$s14151617r)r-�typingr�	packagingr�baserZmodeling_utilsrZintegrationsr�utilsr	r18rrZutils.quantization_configr
r Z19get_loggerr2r"rrrrr�<module>s
20
Aluode/PerceptionLabPortable · CoolFace