
    bi                         d dl mZ d dlZd dlmZ d dlmZ ddlmZ  e       r G d de      Z	d	ej                  j                  d
efdZy)    )OptionalN)is_inc_available)BaseTunerLayer   )Linearc                   z     e Zd Zdej                  j
                  def fdZd
dede	e
e      ddfdZdd	Z xZS )IncLoraLinear
base_layeradapter_namec                 (    t        |   ||fi | y )N)super__init__)selfr
   r   kwargs	__class__s       O/home/cdr/jupyterlab/.venv/lib/python3.12/site-packages/peft/tuners/lora/inc.pyr   zIncLoraLinear.__init__    s     GZ@@    N
safe_mergeadapter_namesreturnc                     t        d      )a  
            Merge the active adapter weights into the base weights

            Args:
                safe_merge (`bool`, *optional*):
                    If True, the merge operation will be performed in a copy of the original weights and check for NaNs
                    before merging the weights. This is useful if you want to check if the merge operation will produce
                    NaNs. Defaults to `False`.
                adapter_names (`list[str]`, *optional*):
                    The list of adapter names that should be merged. If None, all active adapters will be merged.
                    Defaults to `None`.
            z3Merging LoRA with INC layers is not yet implementedNotImplementedError)r   r   r   s      r   mergezIncLoraLinear.merge(   s     &&[\\r   c                     t        d      )z_
            This method unmerges all merged adapter layers from the base weights.
            z5Unmerging LoRA from INC layers is not yet implementedr   )r   s    r   unmergezIncLoraLinear.unmerge7   s     &&]^^r   )FN)r   N)__name__
__module____qualname__torchnnModulestrr   boolr   listr   r   __classcell__)r   s   @r   r	   r	      sS    	A	A 	A	]D 	]$s)AT 	]`d 	]	_r   r	   targetr   c                     d }t        | t              r| j                         }n| }t               rddlm} t        ||      rt        | |fi |}|S )Nr   )PatchedLinear)
isinstancer   get_base_layerr   Ineural_compressor.torch.algorithms.fp8_quant._quant_common.helper_modulesr)   r	   )r'   r   r   
new_moduletarget_base_layerr)   s         r   dispatch_incr/   >   sU    J&.)"113"	
 '7&v|FvFJr   )typingr   r    peft.import_utilsr   peft.tuners.tuners_utilsr   layerr   r	   r!   r"   r#   r/    r   r   <module>r5      sG   &   . 3  _ _>  r   