[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>
This commit is contained in:
summerandAlicia authored and GitHub committed 2026-09-07 15:56:51 +08:00
1 parent b78c31eda6
commit 4b81f692d1
4 files changed
+23 -3

No files matched your search

@@ -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)
@@ -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"
+5
View File
@@ -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"):
@@ -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; "