
    .`i                     f    d dl Z d dlmZ d dlmZ d dlmZ d dlmZ ddl	m
Z
  G d de
          ZdS )	    N)PretrainedConfig)
LoRAConfig)ReplicatedLinear   )BaseLinearLayerWithLoRAc                       e Zd Zdeddf fdZdej        dej        eej        ej        dz  f         z  fdZe		 dde
j        ded	ed
edz  def
d            Zdej        eej        dz           z  dej        eej        dz           z  fdZdej        eej        dz           z  dej        eej        dz           z  fdZ xZS )ReplicatedLinearWithLoRA
base_layerreturnNc                 z    t                                          |           | j        j        | _        d| _        d S )Nr   )super__init__r
   output_sizen_slices)selfr
   	__class__s     v/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/vllm/lora/layers/replicated_linear.pyr   z!ReplicatedLinearWithLoRA.__init__   s<    	
 	
 	
  ?6    input_c                     | j         j        s| j         j        nd}|                     ||          }| j         j        r| j         j        nd}| j         j        s|S ||fS )zForward of ReplicatedLinearWithLoRA

        Args:
            input_: Tensor whose last dimension is `input_size`.

        Returns:
            - output
            - bias
        N)r
   skip_bias_addbiasapplyreturn_bias)r   r   r   outputoutput_biass        r   forwardz ReplicatedLinearWithLoRA.forward   si     ,0?+HRt##d FD)).2o.KUdo**QU* 	M{""r   source_layerlora_configpacked_modules_listmodel_configc                 .    t          |          t          u S N)typer   )clsr   r   r    r!   s        r   can_replace_layerz*ReplicatedLinearWithLoRA.can_replace_layer2   s     L!!%555r   lora_ac                     |S )z1Slice lora a if splitting for tensor parallelism. )r   r'   s     r   slice_lora_az%ReplicatedLinearWithLoRA.slice_lora_a<   	     r   lora_bc                     |S )z2Slice lora b if splitting with tensor parallelism.r)   )r   r,   s     r   slice_lora_bz%ReplicatedLinearWithLoRA.slice_lora_bB   r+   r   r#   )__name__
__module____qualname__r   r   torchTensortupler   classmethodnnModuler   listr   boolr&   r*   r.   __classcell__)r   s   @r   r	   r	      s       #3       #l#	elEL4,??@	@# # # #4  156 6i6  6 "	6
 '-6 
6 6 6 [6lT%,*=%>>	U\D01	1   lT%,*=%>>	U\D01	1       r   r	   )r2   torch.nnr6   transformersr   vllm.config.lorar   !vllm.model_executor.layers.linearr   base_linearr   r	   r)   r   r   <module>r@      s   
        ) ) ) ) ) ) ' ' ' ' ' ' > > > > > > 0 0 0 0 0 07 7 7 7 76 7 7 7 7 7r   