o
    iU	                     @   sh   d dl mZmZmZ d dlmZmZ d dlmZm	Z	 er#d dl
mZ neZdeddfdd	Zd
d ZdS )    )TYPE_CHECKINGAnycast)
VllmConfigget_layers_from_vllm_config)get_dcp_groupget_pcp_group)AttentionLayerBasevllm_configreturnNc                 C   s   | j j}| j j}| j j}|| dkrhttt t}t| |}|	 D ]G}t
|dd }|d u r/q"| jd urE|dkrE|jsEJ d|jj d|dkrV|jsVJ d|jj d|dkrg|jsgJ d|jj dq"d S d S )	N   implz=MTP with cp_kv_cache_interleave_size > 1 is not supported in .zPDCP requires attention impls to return the softmax lse for decode, but the impl z, does not return the softmax lse for decode.z4PCP requires attention impls' support, but the impl z does not support PCP.)parallel_configprefill_context_parallel_sizedecode_context_parallel_sizecp_kv_cache_interleave_sizer   typer   r	   r   valuesgetattrspeculative_config0supports_mtp_with_cp_non_trivial_interleave_size	__class____name__need_to_return_lse_for_decodesupports_pcp)r
   pcp_sizedcp_sizeinterleave_size
layer_typelayerslayer
layer_impl r#   M/home/ubuntu/vllm_env/lib/python3.10/site-packages/vllm/v1/worker/cp_utils.py check_attention_cp_compatibility   s>   
r%   c                  C   sT   zt  j} W n ty   d} Y nw z	t j}W ||  S  ty)   d}Y ||  S w )Nr   )r   
world_sizeAssertionErrorr   )pcp_world_sizedcp_world_sizer#   r#   r$   get_total_cp_world_size.   s   
r*   )typingr   r   r   vllm.configr   r   vllm.distributedr   r   /vllm.model_executor.layers.attention_layer_baser	   objectr%   r*   r#   r#   r#   r$   <module>   s    