o
    áÙ·ic  ã                   @   sT   d dl mZ d dlZd dlmZ G dd„ deƒZG dd„ deƒZG dd	„ d	eƒZdS )
é    )ÚEnumN)ÚPlatformc                   @   s$   e Zd ZdZdZdZdZdZdZdS )ÚOmniPlatformEnumz"Enum for supported Omni platforms.ÚcudaÚrocmÚnpuÚxpuÚunspecifiedN)	Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚCUDAÚROCMÚNPUÚXPUÚUNSPECIFIED© r   r   úQ/home/ubuntu/.local/lib/python3.10/site-packages/vllm_omni/platforms/interface.pyr   
   s    r   c                   @   s<  e Zd ZU dZeed< defdd„Zdefdd„Zdefdd	„Z	defd
d„Z
edefdd„ƒZedefdd„ƒZedefdd„ƒZededB dedefdd„ƒZedefdd„ƒZed'dedB dejfdd„ƒZedefdd„ƒZededB fdd„ƒZed(d d!„ƒZed'd"ejdB defd#d$„ƒZedefd%d&„ƒZdS ))ÚOmniPlatformzÖ
    Abstract base class for vllm-omni Platform.

    Inherits from vLLM's Platform and adds Omni-specific interfaces.
    This gives OmniPlatform all vLLM Platform capabilities plus
    Omni-specific methods.
    Ú
_omni_enumÚreturnc                 C   ó   | j tjkS ©N)r   r   r   ©Úselfr   r   r   Úis_npu   ó   zOmniPlatform.is_npuc                 C   r   r   )r   r   r   r   r   r   r   Úis_xpu"   r   zOmniPlatform.is_xpuc                 C   r   r   )r   r   r   r   r   r   r   Úis_cuda%   r   zOmniPlatform.is_cudac                 C   r   r   )r   r   r   r   r   r   r   Úis_rocm(   r   zOmniPlatform.is_rocmc                 C   ó   t ‚r   ©ÚNotImplementedError©Úclsr   r   r   Úget_omni_ar_worker_cls+   ó   z#OmniPlatform.get_omni_ar_worker_clsc                 C   r!   r   r"   r$   r   r   r   Úget_omni_generation_worker_cls/   r'   z+OmniPlatform.get_omni_generation_worker_clsc                 C   r!   r   r"   r$   r   r   r   Úget_default_stage_config_path3   r'   z*OmniPlatform.get_default_stage_config_pathÚselected_backendNÚ	head_sizec                 C   r!   )a  Get the diffusion attention backend class path for this platform.

        This method selects the appropriate attention backend for diffusion
        models based on platform capabilities and user preferences.

        Args:
            selected_backend: User-selected backend name (e.g., "FLASH_ATTN",
                "TORCH_SDPA", "SAGE_ATTN"). If None, uses platform default.
            head_size: Attention head size.

        Returns:
            Fully qualified class path of the selected backend.
        r"   )r%   r*   r+   r   r   r   Úget_diffusion_attn_backend_cls7   s   z+OmniPlatform.get_diffusion_attn_backend_clsc                 C   r!   )zCCheck if the platform supports torch.compile with inductor backend.r"   r$   r   r   r   Úsupports_torch_inductorL   s   z$OmniPlatform.supports_torch_inductorÚ
local_rankc                 C   r!   r   r"   )r%   r.   r   r   r   Úget_torch_deviceQ   r'   zOmniPlatform.get_torch_devicec                 C   r!   r   r"   r$   r   r   r   Úget_device_countU   r'   zOmniPlatform.get_device_countc                 C   r!   r   r"   r$   r   r   r   Úget_device_versionY   r'   zOmniPlatform.get_device_versionc                 C   r!   r   r"   r$   r   r   r   Úsynchronize]   r'   zOmniPlatform.synchronizeÚdevicec                 C   r!   r   r"   )r%   r3   r   r   r   Úget_free_memorya   r'   zOmniPlatform.get_free_memoryc                 C   s   dS )NTr   r$   r   r   r   Úsupports_cpu_offloade   r'   z!OmniPlatform.supports_cpu_offloadr   )r   N)r
   r   r   r   r   Ú__annotations__Úboolr   r   r   r    ÚclassmethodÚstrr&   r(   r)   Úintr,   r-   Útorchr3   r/   r0   r1   r2   r4   r5   r   r   r   r   r      sF   
 þýür   c                   @   s   e Zd ZejZdZdS )ÚUnspecifiedOmniPlatformÚ N)r
   r   r   r   r   r   Údevice_typer   r   r   r   r<   j   s    r<   )Úenumr   r;   Úvllm.platformsr   r   r   r<   r   r   r   r   Ú<module>   s   
V