[Diffusion] Add paged KV cache support for HunyuanImage3 DiT on NPU and GPU (#6563)

Signed-off-by: Acerak01-fy <wfy2003324@163.com>
Signed-off-by: zwhzzz0821 <zwhzzz0821@users.noreply.github.com>
Signed-off-by: zwhzzz0821 <2831474076@qq.com>
Co-authored-by: zwhzzz0821 <zwhzzz0821@users.noreply.github.com>
Co-authored-by: zwhzzz0821 <2831474076@qq.com>
This commit is contained in:
authored and GitHub committed 2026-08-31 10:15:46 +00:00
1 parent 6f16f9546d
commit fe4a2a7477
28 files changed
+1789 -205

No files matched your search

+40 -6
View File
@@ -1,5 +1,5 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project
from contextlib import nullcontext
from enum import Enum
@@ -150,6 +150,12 @@ class OmniPlatform(Platform):
)
backend_cls.validate_available()
@classmethod
def supports_diffusion_dense_flash_attention(cls) -> bool:
"""Whether the platform's dense ``FLASH_ATTN`` dependencies exist."""
return True
@classmethod
def supports_torch_inductor(cls) -> bool:
"""Check if the platform supports torch.compile with inductor backend."""
@@ -195,17 +201,36 @@ class OmniPlatform(Platform):
def build_diffusion_kv_attn_metadata(cls, **kwargs: Any) -> dict[str, Any]:
"""Build native attention metadata for the diffusion paged path.
The common CUDA/ROCm/XPU path uses vLLM's builder. Platforms with a
backend-specific metadata contract can override this hook without
making the diffusion adapter import their optional runtime package.
``seq_lens_cpu`` is an adapter-only convenience value and is removed
before calling the upstream builder.
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.
"""
from vllm.v1.worker.gpu.attn_utils import build_attn_metadata
kwargs.pop("seq_lens_cpu", None)
return build_attn_metadata(**kwargs)
@classmethod
def get_diffusion_paged_kv_attn_backend(cls, attn_backend: type, *, ulysses_degree: int) -> type:
"""Specialize a native paged backend for diffusion execution."""
del ulysses_degree
return attn_backend
@classmethod
def requires_diffusion_paged_kv_prewrite(cls) -> 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.
"""
return False
@classmethod
def init_diffusion_worker_vllm_config(
cls,
@@ -214,6 +239,15 @@ class OmniPlatform(Platform):
"""Initialize platform-specific state for diffusion worker VllmConfig."""
return None
@classmethod
def configure_diffusion_vllm_config(
cls,
vllm_config: Any,
od_config: Any,
) -> None:
"""Apply platform-specific native cache geometry for diffusion."""
return None
@classmethod
def init_diffusion_model_runner_runtime(
cls,