From 4b81f692d1efa9b4f2a4f6777e47f471a3b6d383 Mon Sep 17 00:00:00 2001 From: summer <128961079+zhang-keliang@users.noreply.github.com> Date: Mon, 7 Sep 2026 15:56:51 +0800 Subject: [PATCH] [Bugfix][Diffusion] Canonicalize cache_backend=None to "none" (#7041) Signed-off-by: summer <128961079+zhang-keliang@users.noreply.github.com> Co-authored-by: Alicia <115451386+congw729@users.noreply.github.com> --- .../diffusion/models/sana_video/test_cache_offload.py | 7 ++++++- tests/diffusion/test_diffusion_config_propagation.py | 11 ++++++++++- vllm_omni/diffusion/data.py | 5 +++++ .../models/sana_video/pipeline_sana_video.py | 3 ++- 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/tests/diffusion/models/sana_video/test_cache_offload.py b/tests/diffusion/models/sana_video/test_cache_offload.py index 52ced37c8..57417c886 100644 --- a/tests/diffusion/models/sana_video/test_cache_offload.py +++ b/tests/diffusion/models/sana_video/test_cache_offload.py @@ -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 dataclasses import dataclass from types import SimpleNamespace @@ -155,6 +155,11 @@ def test_sana_video_rejects_unvalidated_cache_backends(): _validate_cache_offload_parallelism(OmniDiffusionConfig(cache_backend="tea_cache")) +def test_sana_video_accepts_none_cache_backend(): + """An explicit ``cache_backend=None`` means "no cache", same as ``"none"``.""" + _validate_cache_offload_parallelism(OmniDiffusionConfig(cache_backend=None)) + + def test_sana_video_rejects_cache_dit_with_distributed_layerwise_offload(): config = OmniDiffusionConfig(cache_backend="cache_dit", enable_distributed_layerwise_offload=True) diff --git a/tests/diffusion/test_diffusion_config_propagation.py b/tests/diffusion/test_diffusion_config_propagation.py index 60d0c63b8..164fcfbeb 100644 --- a/tests/diffusion/test_diffusion_config_propagation.py +++ b/tests/diffusion/test_diffusion_config_propagation.py @@ -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 """Tests that parallel_config survives the create_default_diffusion roundtrip. Regression tests for https://github.com/vllm-project/vllm-omni/issues/1862 @@ -137,6 +137,15 @@ class TestCreateDefaultDiffusion: stages = StageConfigFactory.create_default_diffusion({"model": "x"}) assert stages[0]["engine_args"]["cache_backend"] == "none" + def test_explicit_none_cache_backend_canonicalizes_to_none(self): + """Regression for #7032: ``cache_backend=None`` (e.g. an example CLI default) + must reach the pipeline as the canonical ``"none"`` string.""" + od = _roundtrip_diffusion_config(model="x", cache_backend=None) + assert od.cache_backend == "none" + + od = OmniDiffusionConfig.from_kwargs(model="x", cache_backend=None) + assert od.cache_backend == "none" + def test_single_gpu_default_devices(self): stages = StageConfigFactory.create_default_diffusion({"model": "x"}) assert stages[0]["runtime"]["devices"] == "0" diff --git a/vllm_omni/diffusion/data.py b/vllm_omni/diffusion/data.py index 00764ea46..fd6f0237d 100644 --- a/vllm_omni/diffusion/data.py +++ b/vllm_omni/diffusion/data.py @@ -91,6 +91,11 @@ def normalize_omni_diffusion_kwargs(kwargs: Mapping[str, Any]) -> dict[str, Any] if "cache_backend" not in normalized: cache_backend = os.environ.get("DIFFUSION_CACHE_BACKEND") or os.environ.get("DIFFUSION_CACHE_ADAPTER") normalized["cache_backend"] = cache_backend.lower() if cache_backend else "none" + elif normalized["cache_backend"] is None: + # Callers (e.g. example CLIs with `default=None`) pass an explicit + # None for "no cache"; canonicalize it so every consumer sees the + # declared `str` value instead of relying on per-model None handling. + normalized["cache_backend"] = "none" # Convert optional YAML null values to empty containers. for key in ("diffusers_load_kwargs", "diffusers_call_kwargs"): diff --git a/vllm_omni/diffusion/models/sana_video/pipeline_sana_video.py b/vllm_omni/diffusion/models/sana_video/pipeline_sana_video.py index f2d86622a..6c2d740d4 100644 --- a/vllm_omni/diffusion/models/sana_video/pipeline_sana_video.py +++ b/vllm_omni/diffusion/models/sana_video/pipeline_sana_video.py @@ -273,7 +273,8 @@ def retrieve_timesteps( def _validate_cache_offload_parallelism(od_config: OmniDiffusionConfig) -> None: - cache_backend = od_config.cache_backend + # Treat None like "none", matching the other pipelines' cache checks. + cache_backend = od_config.cache_backend or "none" if cache_backend not in ("none", "cache_dit"): raise NotImplementedError( f"Cache backend {cache_backend!r} is not supported by the native SANA-Video pipeline; "