o
    i                     @   sn   d dl Z d dlZd dlmZ d dlmZmZmZ d dlm	Z	 ed Z
ed Zee
ef Ze	G dd dZdS )	    N)field)AnyLiteralget_args)configec_producerec_consumerc                   @   s.  e Zd ZU dZdZedB ed< 	 dZedB ed< 	 dZedB ed< 	 dZ	e
ed< 	 dZedB ed	< 	 dZedB ed
< 	 dZeed< 	 dZeed< 	 dZeed< 	 eedZeeef ed< 	 dZedB ed< 	 defddZd!ddZedefddZedefddZedefddZdefdd ZdS )"ECTransferConfigz0Configuration for distributed EC cache transfer.Nec_connector	engine_idcudaec_buffer_deviceg    eAec_buffer_sizeec_roleec_rank   ec_parallel_sizez	127.0.0.1ec_ipi8  ec_port)default_factoryec_connector_extra_configec_connector_module_pathreturnc                 C   s"   g }t jt| dd }|S )a  
        WARNING: Whenever a new field is added to this config,
        ensure that it is included in the factors list if
        it affects the computation graph.

        Provide a hash that uniquely identifies all the configs
        that affect the structure of the computation
        graph from input ids/embeddings to the final hidden states,
        excluding anything before input ids/embeddings and after
        the final hidden states.
        F)usedforsecurity)hashlibmd5strencode	hexdigest)selffactorshash_str r"   M/home/ubuntu/vllm_env/lib/python3.10/site-packages/vllm/config/ec_transfer.pycompute_hash<   s   zECTransferConfig.compute_hashc                 C   sx   | j d u rtt | _ | jd ur%| jttvr%td| j dtt | jd ur8| jd u r:tdtt d S d S )NzUnsupported ec_role: z. Supported roles are zEPlease specify ec_role when ec_connector is set, supported roles are )	r   r   uuiduuid4r   r   ECRole
ValueErrorr
   r   r"   r"   r#   __post_init__N   s   

zECTransferConfig.__post_init__c                 C      | j d uo| jttv S N)r
   r   r   r'   r)   r"   r"   r#   is_ec_transfer_instance^      z(ECTransferConfig.is_ec_transfer_instancec                 C   r+   r,   )r
   r   r   
ECProducerr)   r"   r"   r#   is_ec_producerb   r.   zECTransferConfig.is_ec_producerc                 C   r+   r,   )r
   r   r   
ECConsumerr)   r"   r"   r#   is_ec_consumerf   r.   zECTransferConfig.is_ec_consumerc                 C   s   | j ||S r,   )r   get)r   keydefaultr"   r"   r#   get_from_extra_configj   s   z&ECTransferConfig.get_from_extra_config)r   N)__name__
__module____qualname____doc__r
   r   __annotations__r   r   r   floatr   r'   r   intr   r   r   r   dictr   r   r   r$   r*   propertyboolr-   r0   r2   r6   r"   r"   r"   r#   r	      sB   
 
r	   )r   r%   dataclassesr   typingr   r   r   vllm.config.utilsr   r/   r1   r'   r	   r"   r"   r"   r#   <module>   s   