vllm_omni.platforms ¶
Modules:
| Name | Description |
|---|---|
cuda | |
interface | |
musa | |
npu | |
rocm | |
xpu | |
builtin_omni_platform_plugins module-attribute ¶
builtin_omni_platform_plugins = {
"cuda": cuda_omni_platform_plugin,
"rocm": rocm_omni_platform_plugin,
"npu": npu_omni_platform_plugin,
"xpu": xpu_omni_platform_plugin,
"musa": musa_omni_platform_plugin,
}
OmniPlatform ¶
Bases: Platform
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.
build_diffusion_kv_attn_metadata classmethod ¶
Build native attention metadata for the diffusion paged path.
This default is the GPU/common path and uses vLLM's builder. NPU overrides it to build Ascend attention metadata without making the shared diffusion adapter import vllm_ascend. seq_lens_cpu is an adapter-only convenience value and is removed before calling the upstream builder.
configure_diffusion_vllm_config classmethod ¶
Apply platform-specific native cache geometry for diffusion.
create_autocast_context classmethod ¶
get_device_memory classmethod ¶
get_diffusion_attn_backend_cls classmethod ¶
get_diffusion_attn_backend_cls(
selected_backend: str | None,
head_size: int,
allow_trtllm_default: bool = False,
) -> str
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.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
selected_backend | str | None | User-selected backend name (e.g., "FLASH_ATTN", "TORCH_SDPA", "SAGE_ATTN"). If None, uses platform default. | required |
head_size | int | Attention head size. | required |
allow_trtllm_default | bool | Whether TRTLLM may be chosen as the default. | False |
Returns:
| Type | Description |
|---|---|
str | Fully qualified class path of the selected backend. |
get_diffusion_kv_block_tables_cls classmethod ¶
get_diffusion_kv_block_tables_cls() -> type
Return the platform's native paged-KV BlockTables implementation.
get_diffusion_model_runner_cls classmethod ¶
get_diffusion_model_runner_cls() -> str
Get the diffusion model runner class path for this platform.
Returns a fully qualified class path string. The class must be compatible with the DiffusionModelRunner interface.
get_diffusion_packed_modules_mapping classmethod ¶
get_diffusion_paged_kv_attn_backend classmethod ¶
Specialize a native paged backend for diffusion execution.
get_diffusion_worker_cls classmethod ¶
get_diffusion_worker_cls() -> str
Get the diffusion worker class path for this platform.
Returns a fully qualified class path string that will be resolved and instantiated by WorkerWrapperBase. The class must be compatible with the DiffusionWorker interface.
get_graph_wrapper_cls classmethod ¶
get_graph_wrapper_cls() -> type
Return the platform's full-graph wrapper class.
Defaults to vLLM's CUDAGraphWrapper; NPU overrides with ACLGraphWrapper.
has_flash_attn_package classmethod ¶
has_flash_attn_package() -> bool
Check if a Flash Attention package is available and usable on this platform.
init_diffusion_model_runner_runtime classmethod ¶
Initialize platform-specific runtime state for diffusion model runners.
init_diffusion_worker_vllm_config classmethod ¶
init_diffusion_worker_vllm_config(vllm_config: Any) -> None
Initialize platform-specific state for diffusion worker VllmConfig.
memory_reserved classmethod ¶
Bytes reserved by this process's caching allocator on device.
Device-wide get_device_memory counts every process; this is the portable equivalent of torch.cuda.memory_reserved.
prepare_diffusion_op_runtime classmethod ¶
record_device_event classmethod ¶
Record a device event on the default stream to mark tensor readiness.
On platforms where distributed communication (e.g. HCCL) may use internal streams not visible to the default stream, this method should synchronize the default stream before recording the event to ensure the event captures all completed work including cross-device communication results.
Returns None by default so that platforms without a native implementation (ROCm, XPU, MUSA) fall through to a safe no-op. Override in platform subclasses to provide real event support.
register_additional_diffusion_fused_moe_hooks classmethod ¶
register_additional_diffusion_fused_moe_hooks(
moe_runner: Any,
) -> None
requires_diffusion_paged_kv_prewrite classmethod ¶
requires_diffusion_paged_kv_prewrite() -> bool
Whether paged attention must write K/V before native execution.
The default GPU path keeps cache-update ownership in its native attention call. Ascend overrides this because piecewise FIA should write the complete K/V span once, then read it from cache for every segment.
reset_diffusion_fused_moe_forward_context classmethod ¶
set_device_control_env_var classmethod ¶
set_forward_context classmethod ¶
set_forward_context(
attn_metadata: Any,
vllm_config: VllmConfig,
*,
cudagraph_runtime_mode: CUDAGraphMode,
batch_descriptor: BatchDescriptor,
)
Platform-neutral wrapper around the device's set_forward_context.
Defaults to vLLM's set_forward_context; NPU overrides to dispatch to set_ascend_forward_context (renaming cudagraph_runtime_mode to aclgraph_runtime_mode).
supports_diffusion_dense_flash_attention classmethod ¶
supports_diffusion_dense_flash_attention() -> bool
Whether the platform's dense FLASH_ATTN dependencies exist.
supports_talker_mtp_graph_capture classmethod ¶
supports_talker_mtp_graph_capture() -> bool
Whether a model may capture its dedicated talker MTP graph.
supports_torch_inductor classmethod ¶
supports_torch_inductor() -> bool
Check if the platform supports torch.compile with inductor backend.
validate_diffusion_attn_backend classmethod ¶
validate_diffusion_attn_backend(
selected_backend: str,
) -> None
Reject an explicitly selected backend this platform cannot run.
Platforms call this from get_diffusion_attn_backend_cls so that a backend restricted to other hardware, or one whose kernel package is missing, fails during resolution rather than at the first forward.
cuda_omni_platform_plugin ¶
cuda_omni_platform_plugin() -> str | None
Check if CUDA OmniPlatform should be activated.
musa_omni_platform_plugin ¶
musa_omni_platform_plugin() -> str | None
Check if MUSA OmniPlatform should be activated.
npu_omni_platform_plugin ¶
npu_omni_platform_plugin() -> str | None
Check if NPU OmniPlatform should be activated.
resolve_current_omni_platform_cls_qualname ¶
resolve_current_omni_platform_cls_qualname() -> str
Resolve the current OmniPlatform class qualified name.