[Diffusion] Address runtime cache review feedback

Signed-off-by: Hongsheng Liu <liuhongsheng4@huawei.com>
This commit is contained in:
Hongsheng Liu committed 2026-08-19 11:21:59 +08:00
1 parent c1196216a3
commit 6751c1f404
11 files changed
+357 -378

No files matched your search

@@ -6,6 +6,7 @@ from __future__ import annotations
from types import SimpleNamespace
import pytest
import torch
import vllm_omni.diffusion.offloader.cuda_host_registration as registration_module
from vllm_omni.diffusion.offloader.cuda_host_registration import (
@@ -15,6 +16,10 @@ from vllm_omni.diffusion.offloader.cuda_host_registration import (
CudaHostRegistrationError,
_coalesce_ranges,
)
from vllm_omni.diffusion.offloader.host_registration import (
HostRegistrationError,
register_host_mappings,
)
pytestmark = [pytest.mark.diffusion, pytest.mark.cpu, pytest.mark.core_model]
@@ -78,6 +83,25 @@ class _FakeRuntime:
return f"error-{error}"
def test_platform_factory_reports_unsupported_registration() -> None:
with pytest.raises(HostRegistrationError, match="not supported on cpu"):
register_host_mappings({}, device=torch.device("cpu"), max_bytes=4096)
def test_platform_factory_dispatches_cuda(monkeypatch: pytest.MonkeyPatch) -> None:
sentinel = object()
sources = {"weights": []}
def create(actual_sources, *, max_bytes):
assert actual_sources is sources
assert max_bytes == 4096
return sentinel
monkeypatch.setattr(CudaHostRegistration, "create", staticmethod(create))
assert register_host_mappings(sources, device=torch.device("cuda"), max_bytes=4096) is sentinel
def test_coalesce_ranges_aligns_and_merges_overlapping_pages() -> None:
assert _coalesce_ranges(
[(0x1003, 4096), (0x2800, 1024), (0x9001, 1)],