§
    ‚ŠtjŸ
  ã                   óN   — d Z ddlmZ ddlmZ erddlmZ  G d„ de¦  «        Zd	S )
aH  HfQuantizer implementation for pre-quantized Gemma checkpoints.

Handles loading of checkpoints that contain:
  - Packed integer weights (INT2/4/8) with per-channel scales
  - Static Range Quantization (SRQ) activation scales
  - Audio residual quantization (rqv2_muls)
  - Quantized embeddings
  - KV cache quantization scales
é    )ÚTYPE_CHECKINGé   )ÚHfQuantizeré   )ÚGemmaQuantizationConfigc                   óp   — e Zd ZU dZded<   dZd„ Zed„ ¦   «         Zed„ ¦   «         Z	ede
fd	„¦   «         Zd
S )ÚGemmaQuantizeraN  HfQuantizer for pre-quantized Gemma checkpoints.

    Replaces `nn.Linear` / `nn.Embedding` modules with their quantized
    counterparts during model loading, and loads quantized weights + SRQ
    scales directly from safetensors. Wrappers and unquantized layers are
    skipped via `quantization_config.modules_to_not_convert`.
    r   Úquantization_configTc                 ó  — ddl m} |                      || j        j        |j        ¦  «        | _         ||| j        | j        ¬¦  «        }t          t          |dd ¦  «        pg ¦  «        }|                     ddg¦  «         ||_	        d S )Nr   )Úreplace_with_quant_layers)r
   Úmodules_to_not_convertÚ"_keys_to_ignore_on_load_unexpectedz.*\.k_cache_scale$z.*\.v_cache_scale$)
Úintegrations.gemma_quantr   Úget_modules_to_not_convertr
   r   Ú_keep_in_fp32_modulesÚsetÚgetattrÚupdater   )ÚselfÚmodelÚkwargsr   Úignoreds        úe/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/transformers/quantizers/quantizer_gemma.pyÚ$_process_model_before_weight_loadingz3GemmaQuantizer._process_model_before_weight_loading.   s­   € ØHÐHÐHÐHÐHÐHà&*×&EÒ&EØ�4Ô+ÔBÀEÔD_ñ'
ô '
ˆÔ#ð *Ð)ØØ $Ô 8Ø#'Ô#>ð
ñ 
ô 
ˆõ •g˜eÐ%IÈ4ÑPÔPÐVÐTVÑWÔWˆØ�ŠÐ-Ð/DÐEÑFÔFÐFØ3:ˆÔ0Ð0Ð0ó    c                 ó   — dS ©NT© ©r   s    r   Úis_serializablezGemmaQuantizer.is_serializableA   ó   € àˆtr   c                 ó   — dS )NFr   r   s    r   Úis_trainablezGemmaQuantizer.is_trainableE   s   € àˆur   Úreturnc                 ó   — dS r   r   r   s    r   Úis_compileablezGemmaQuantizer.is_compileableI   r!   r   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú__annotations__Úrequires_calibrationr   Úpropertyr    r#   Úboolr&   r   r   r   r	   r	   "   s    € € € € € € ðð ð 3Ð2Ð2Ñ2ØÐð;ð ;ð ;ð& ðð ñ „Xðð ðð ñ „Xðð ð ð ð ð ñ „Xðð ð r   r	   N)r*   Útypingr   Úbaser   Úutils.quantization_configr   r	   r   r   r   ú<module>r2      s†   ððð ð !Ð  Ð  Ð  Ð  Ð  à Ð Ð Ð Ð Ð ð ð DØCÐCÐCÐCÐCÐCð)ð )ð )ð )ð )�[ñ )ô )ð )ð )ð )r   