o
    .i                     @   s   d dl Z d dlmZ d dlmZ d dlmZ de jde jde jde jd	e jd
eee	  de jfddZ
d
eee	  de	de jde jfddZdS )    N)apply_penalties)is_pin_memory_available)make_tensor_with_padlogitsprompt_token_idspresence_penaltiesfrequency_penaltiesrepetition_penaltiesoutput_token_idsreturnc           	      C   s:   | j \}}t||| j}||dk| t| |||||S )zM
    Applies presence, frequency and repetition penalties to the logits.
    )shape_convert_to_tensorsdevicemasked_fill_r   )	r   r   r   r   r	   r
   _
vocab_sizeoutput_tokens_t r   Y/home/ubuntu/veenaModal/venv/lib/python3.10/site-packages/vllm/v1/sample/ops/penalties.pyapply_all_penalties   s   
r   r   r   c                 C   s$   t | |dtjt d}|j|ddS )z@
    Convert the different list data structures to tensors.
    cpu)padr   dtype
pin_memoryT)non_blocking)r   torchint64r   to)r
   r   r   output_tokens_tensorr   r   r   r   *   s   	r   )r    vllm.model_executor.layers.utilsr   vllm.utils.platform_utilsr   vllm.utils.torch_utilsr   Tensorlistintr   r   r   r   r   r   r   <module>   s8   


