[Diffusion] Make DLO host weight cache opt-in

Signed-off-by: Hongsheng Liu <liuhongsheng4@huawei.com>
This commit is contained in:
Hongsheng Liu committed 2026-08-19 11:23:36 +08:00
1 parent 75af33a76f
commit 16642dc2e8
12 files changed
+85 -20

No files matched your search

+14 -2
View File
@@ -912,12 +912,24 @@ def test_structured_diffusion_config_rejects_invalid_compile_granularity():
("enable_dlo", "use_allgather"),
[(False, False), (True, True)],
)
def test_structured_diffusion_config_restricts_host_weight_registration_to_no_allgather_dlo(enable_dlo, use_allgather):
@pytest.mark.parametrize(
("field_name", "field_value"),
[
("dlo_use_host_weight_cache", True),
("dlo_host_weight_cache_pin_limit_gib", 1.0),
],
)
def test_structured_diffusion_config_restricts_host_weight_cache_to_no_allgather_dlo(
enable_dlo,
use_allgather,
field_name,
field_value,
):
with pytest.raises(ValueError, match="requires no-AllGather distributed layerwise offload"):
omni_config_module._DiffusionConfigProjection(
enable_distributed_layerwise_offload=enable_dlo,
dlo_use_allgather=use_allgather,
dlo_host_weight_cache_pin_limit_gib=1.0,
**{field_name: field_value},
)
@@ -375,7 +375,7 @@ def test_dlo_plan_loads_component_sources_outside_planned_dit(monkeypatch):
assert loader.take_host_weight_plan() is plan
def test_dlo_plan_fallback_runs_ordinary_loader_then_cache(monkeypatch):
def test_dlo_plan_fallback_retains_ordinary_loader_weights_by_default(monkeypatch):
import vllm_omni.diffusion.model_loader.diffusers_loader as loader_mod
import vllm_omni.diffusion.model_loader.host_weight_cache as cache_mod
@@ -402,14 +402,13 @@ def test_dlo_plan_fallback_runs_ordinary_loader_then_cache(monkeypatch):
lambda *_args, **_kwargs: HostWeightPlanResult(None, "not direct-compatible"),
)
def build_cache(_pipeline, **_kwargs):
calls.append("cache")
return HostWeightPlanResult(None, "unsupported test layout", "unsupported_layout")
def build_cache(*_args, **_kwargs):
pytest.fail("host weight cache must require explicit selection")
monkeypatch.setattr(cache_mod, "build_host_weight_cache_plan", build_cache)
assert loader.load_model(load_device="cpu") is model
assert calls == ["load", "process", "cache"]
assert calls == ["load", "process"]
assert loader.take_host_weight_plan() is None
@@ -434,6 +433,7 @@ def test_dlo_host_weight_cache_is_built_after_final_post_load_mutation(monkeypat
quantization_config=None,
enable_distributed_layerwise_offload=True,
dlo_use_allgather=False,
dlo_use_host_weight_cache=True,
dlo_host_weight_cache_dir=str(tmp_path),
dlo_host_weight_cache_lock_timeout=1.0,
model="unused",
@@ -567,6 +567,7 @@ def test_dlo_host_weight_cache_failure_retains_ordinary_weights(monkeypatch, tmp
quantization_config=None,
enable_distributed_layerwise_offload=True,
dlo_use_allgather=False,
dlo_use_host_weight_cache=True,
dlo_host_weight_cache_dir=str(tmp_path),
model="unused",
)
@@ -328,6 +328,7 @@ def test_serve_cli_forwards_distributed_offload_residency():
"--omni",
"--enable-distributed-layerwise-offload",
"--dlo-no-use-allgather",
"--dlo-use-host-weight-cache",
"--dlo-host-weight-cache-pin-limit-gib",
"80",
"--dlo-resident-layers",
@@ -341,10 +342,12 @@ def test_serve_cli_forwards_distributed_offload_residency():
assert args.enable_distributed_layerwise_offload is True
assert args.dlo_use_allgather is False
assert args.dlo_use_host_weight_cache is True
assert args.dlo_host_weight_cache_pin_limit_gib == 80
assert args.dlo_resident_layers == 20
assert engine_args["enable_distributed_layerwise_offload"] is True
assert engine_args["dlo_use_allgather"] is False
assert engine_args["dlo_use_host_weight_cache"] is True
assert engine_args["dlo_host_weight_cache_dir"] is None
assert engine_args["dlo_host_weight_cache_lock_timeout"] == 600.0
assert engine_args["dlo_host_weight_cache_pin_limit_gib"] == 80