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

+15 -10
View File
@@ -25,9 +25,7 @@ from pathlib import Path
import numpy as np
_HERE = Path(__file__).resolve()
_PROTOCOL = (
_HERE.parents[4] / "vllm_omni" / "edge" / "local" / "external" / "protocol.py"
)
_PROTOCOL = _HERE.parents[4] / "vllm_omni" / "edge" / "local" / "external" / "protocol.py"
spec = importlib.util.spec_from_file_location("_fake_protocol", _PROTOCOL)
proto = importlib.util.module_from_spec(spec)
@@ -78,13 +76,15 @@ def main() -> int:
"session_create_s": 0.01,
"warmup_s": 0.001,
"rss_bytes": 111 * 2**20,
"inputs": [{"name": n, "type": "tensor(float)", "shape": list(t.shape)}
for n, t in tensors.items()],
"inputs": [{"name": n, "type": "tensor(float)", "shape": list(t.shape)} for n, t in tensors.items()],
"outputs": [{"name": "y", "type": "tensor(float)", "shape": []}],
}
reply.update(config.get("load", {}))
proto.send_message(sock, proto.OP_OK, reply)
elif op == proto.OP_RUN:
import time
time.sleep(float(config.get("run", {}).get("sleep_s", 0)))
scale = float(config.get("run", {}).get("scale", 2.0))
proto.send_message(
sock,
@@ -94,16 +94,21 @@ def main() -> int:
)
elif op == proto.OP_STATS:
proto.send_message(
sock, proto.OP_OK,
{"runs": 1, "total_run_s": 0.001, "rss_bytes": 111 * 2**20,
"peak_rss_bytes": 122 * 2**20, "report": {}},
sock,
proto.OP_OK,
{
"runs": 1,
"total_run_s": 0.001,
"rss_bytes": 111 * 2**20,
"peak_rss_bytes": 122 * 2**20,
"report": {},
},
)
elif op == proto.OP_CLOSE:
proto.send_message(sock, proto.OP_OK, {})
return 0
else:
proto.send_message(sock, proto.OP_ERR,
{"message": f"unknown op {op}", "code": "ValueError"})
proto.send_message(sock, proto.OP_ERR, {"message": f"unknown op {op}", "code": "ValueError"})
if __name__ == "__main__":
+29 -5
View File
@@ -16,9 +16,7 @@ from vllm_omni.edge.local.external import protocol
def _round_trip(op, body=None, tensors=None):
near, far = socket.socketpair()
try:
threading.Thread(
target=lambda: protocol.send_message(near, op, body, tensors), daemon=True
).start()
threading.Thread(target=lambda: protocol.send_message(near, op, body, tensors), daemon=True).start()
return protocol.recv_message(far)
finally:
near.close()
@@ -66,8 +64,7 @@ def test_empty_message_and_no_tensors():
def test_error_reply_raises_with_remote_detail():
with pytest.raises(protocol.WorkerError) as excinfo:
_round_trip(protocol.OP_ERR, {"message": "boom", "code": "ValueError",
"traceback": "far side traceback"})
_round_trip(protocol.OP_ERR, {"message": "boom", "code": "ValueError", "traceback": "far side traceback"})
assert excinfo.value.code == "ValueError"
assert "far side traceback" in excinfo.value.remote_traceback
@@ -92,3 +89,30 @@ def test_oversized_header_is_refused_before_allocation():
finally:
near.close()
far.close()
@pytest.mark.parametrize(
"override",
[
{"version": 2},
{"version": True},
{"required_features": ["unknown-required-feature"]},
{"tensors": [{"name": "x", "dtype": "<f4", "shape": [2], "nbytes": 1}]},
{"tensors": [{"name": "x", "dtype": "|O", "shape": [1], "nbytes": 8}]},
{"tensors": [{"name": "x", "dtype": "<f4", "shape": [-1], "nbytes": -4}]},
],
)
def test_invalid_frame_refused_without_reading_payload(override):
import json
import struct
near, far = socket.socketpair()
far.settimeout(0.2)
try:
header = json.dumps({"version": 1, "op": "run", "body": {}, "tensors": [], **override}).encode()
near.sendall(struct.pack(">I", len(header)) + header)
with pytest.raises(protocol.ProtocolError):
protocol.recv_message(far)
finally:
near.close()
far.close()