Integrate portable edge graph backends with Omni runtime

Extract versioned stage contracts, model shared CPU/iGPU/NPU memory constraints, and add explicit graph routes, reservations, output acknowledgements, and worker retirement. Fix native Windows shared-buffer lifetime and host paths. Document qualified hardware paths and remaining rollout gates.
This commit is contained in:
tzhouam committed 2026-09-22 13:12:33 +08:00
1 parent 00510ce38b
commit 723c550209
55 files changed
+2900 -383

No files matched your search

+75
View File
@@ -0,0 +1,75 @@
"""Ownership/framing tests also run on POSIX; native connector tests run on Windows."""
import subprocess
import sys
import uuid
import pytest
from vllm_omni.host.shared_memory import SharedBufferOwner, read_buffer
def test_producer_retains_until_a_different_process_reads():
owner = SharedBufferOwner()
meta = owner.write(b"payload", f"omni-test-{uuid.uuid4().hex}")
try:
assert owner.retained_bytes > 0
code = (
"from vllm_omni.host.shared_memory import read_buffer; assert read_buffer(" + repr(meta) + ") == b'payload'"
)
subprocess.run([sys.executable, "-c", code], check=True, timeout=60)
owner.collect()
assert owner.retained_bytes == 0
finally:
owner.release(meta["name"])
def test_bounds_stale_generation_and_name_collision():
owner = SharedBufferOwner(max_bytes=128, max_buffers=1)
meta = owner.write(b"one", f"omni-test-{uuid.uuid4().hex}")
try:
with pytest.raises(FileExistsError):
SharedBufferOwner().write(b"collision", meta["name"])
with pytest.raises(ValueError, match="stale"):
read_buffer({**meta, "generation": "wrong"})
with pytest.raises(BufferError):
owner.write(b"two")
assert owner.retained_bytes > 0
assert read_buffer(meta) == b"one"
owner.collect()
assert owner.retained_bytes == 0
with pytest.raises(BufferError):
owner.write(b"x" * 129)
finally:
owner.release(meta["name"])
@pytest.mark.skipif(sys.platform != "win32", reason="native Windows path and mapping lifetime")
def test_native_connector_roundtrip_and_cleanup():
from vllm_omni.distributed.omni_connectors.connectors.shm_connector import SharedMemoryConnector
from vllm_omni.host.shared_memory import owner
from vllm_omni.windows.paths import shm_dir
assert not shm_dir().startswith("/dev/shm")
producer, consumer = SharedMemoryConnector({}), SharedMemoryConnector({})
key = f"omni-test-{uuid.uuid4().hex}"
try:
ok, size, _ = producer.put("0", "1", key, {"data": [1, 2, 3]})
assert ok and owner.retained_bytes > 0
assert consumer.get("0", "1", key) == ({"data": [1, 2, 3]}, size)
owner.collect()
assert owner.retained_bytes == 0
assert producer.put("0", "1", key, {"unconsumed": True})[0]
assert owner.retained_bytes > 0
producer.cleanup(key)
assert owner.retained_bytes == 0
assert consumer.get("0", "1", key) is None
for index in range(8):
next_key = f"{key}_{index}"
assert producer.put("0", "1", next_key, {"index": index})[0]
assert len(producer._pending_keys) <= 1
assert consumer.get("0", "1", next_key)[0] == {"index": index}
owner.collect()
finally:
producer.close()
consumer.close()
+17 -2
View File
@@ -7,6 +7,7 @@ that decide whether a vLLM function is replaced or left alone."""
from __future__ import annotations
import asyncio
import errno
import os
import sys
import tempfile
@@ -34,7 +35,7 @@ class FakeLocking:
self.calls.append((fd, mode))
if mode == self.NBLCK:
if fd in self.held:
raise OSError(36, "Resource deadlock avoided")
raise OSError(errno.EACCES, "Lock held")
self.held.add(fd)
elif mode == self.UNLCK:
self.held.discard(fd)
@@ -86,6 +87,20 @@ def test_flock_blocking_waits_until_released(lock_fd):
assert len(sleeps) == 2 and lock_fd in locking.held
@pytest.mark.parametrize("operation", [shims.LOCK_EX, shims.LOCK_EX | shims.LOCK_NB])
def test_flock_permanent_failure_does_not_retry(lock_fd, operation):
sleeps = []
def invalid_lock(*args):
raise OSError(errno.EINVAL, "Unsupported lock path")
shim = shims.FcntlShim(invalid_lock, 2, 0, sleep=sleeps.append)
with pytest.raises(OSError) as failure:
shim.flock(lock_fd, operation)
assert failure.value.errno == errno.EINVAL
assert sleeps == []
def test_shared_lock_is_served_as_exclusive_and_counted(lock_fd):
locking, sleeps = FakeLocking(), []
s = _shim(locking, sleeps)
@@ -237,7 +252,7 @@ def test_shm_dir_exists_and_path_joins():
d = shm_dir()
assert os.path.isdir(d)
assert shm_path("x.lock").startswith(d)
if os.path.isdir("/dev/shm"):
if sys.platform != "win32" and os.path.isdir("/dev/shm"):
assert d == "/dev/shm"