o
    
۾i                     @   s   d dl mZmZ d dlmZ d dlmZ d dlmZm	Z	 d dl
mZ d dlZd dlmZ er4d dlmZ G d	d
 d
eZeZeeeee dB ee f Zeeeef ZeddG dd dZG dd deZdS )    )ABCabstractmethod)Sequence)	dataclass)Enumauto)TYPE_CHECKINGN)SamplingParams)
VllmConfigc                   @   s   e Zd Ze Ze ZdS )MoveDirectionalityN)__name__
__module____qualname__r   UNIDIRECTIONALSWAP r   r   ]/home/ubuntu/.local/lib/python3.10/site-packages/vllm/v1/sample/logits_processor/interface.pyr      s    
r   T)frozenc                   @   s>   e Zd ZU dZeed< ee ed< ee ed< ee	 ed< dS )BatchUpdatez2Persistent batch state change info for logitsprocs
batch_sizeremovedaddedmovedN)
r   r   r   __doc__int__annotations__r   RemovedRequestAddedRequestMovedRequestr   r   r   r   r   $   s   
 r   c                	   @   s   e Zd ZedefddZedddejde	dd	fd
dZ
edejdejfddZede	fddZe					dddZd	S )LogitsProcessorsampling_paramsc                 C   s   dS )zhValidate sampling params for this logits processor.

        Raise ValueError for invalid ones.
        Nr   )clsr    r   r   r   validate_params=   s   zLogitsProcessor.validate_paramsvllm_configr
   deviceis_pin_memoryreturnNc                 C      t )NNotImplementedError)selfr#   r$   r%   r   r   r   __init__E   s   zLogitsProcessor.__init__logitsc                 C   r'   )zApply LogitsProcessor to batch logits tensor.

        The updated tensor must be returned but may be
        modified in-place.
        r(   )r*   r,   r   r   r   applyK   s   zLogitsProcessor.applyc                 C   r'   )a  True if logits processor has no impact on the
        argmax computation in greedy sampling.
        NOTE: may or may not have the same value for all
        instances of a given LogitsProcessor subclass,
        depending on subclass implementation.
        r(   )r*   r   r   r   is_argmax_invariantT   s   z#LogitsProcessor.is_argmax_invariantbatch_updateBatchUpdate | Nonec                 C   r'   )zCalled when there are new output tokens, prior
        to each forward pass.

        Args:
            batch_update: Non-None iff there have been changes
                to the batch makeup.
        r(   )r*   r/   r   r   r   update_state^   s   zLogitsProcessor.update_state)r/   r0   r&   N)r   r   r   classmethodr	   r"   r   torchr$   boolr+   Tensorr-   r.   r1   r   r   r   r   r   <   s.    	r   )abcr   r   collections.abcr   dataclassesr   enumr   r   typingr   r3   vllmr	   vllm.configr
   r   r   r   tuplelistr   r   r   r   r   r   r   r   <module>   s    