Skip to content

A GPU task manager for Windows, Linux, and WSL: per-process VRAM, GPU activity, and LLM model/KV-cache insights (Windows AMD and NVIDIA).

Python

Reject competing vLLM own and parent listeners

Scott Hanselman7724916d0d97
diff --git a/src/gputaskman/collector.py b/src/gputaskman/collector.py
index 9fc6cdf..0e4b624 100644
--- a/src/gputaskman/collector.py
+++ b/src/gputaskman/collector.py
@@ -279,6 +279,8 @@ class Collector:
ports = self.inspector.exclusive_ports(p.pid)
if parent.ports and set(parent.ports) != set(ports):
return [] # a shared listener cannot identify a server
+ if parent.vllm_role == "worker" and ports:
+ return []
if parent.vllm_role == "server":
candidates.extend(ports)
return candidates if len(candidates) == 1 else []
@@ -394,6 +396,8 @@ class Collector:
parent_ports = []
else:
parent_ports = self._parent_ports(row.pid, vllm=vllm)
+ if vllm and ports and parent_ports:
+ ports, parent_ports = [], [] # two possible server processes: do not pick one
parent_origin = ("parent", tuple((pid, self.inspector.get(pid).create_time)
for pid in row.detail.parents or []))
own = self.prober.get(ports, key, kind=kind, origin=own_origin)
diff --git a/tests/test_vllm.py b/tests/test_vllm.py
index 0f55377..4fa075f 100644
--- a/tests/test_vllm.py
+++ b/tests/test_vllm.py
@@ -190,7 +190,8 @@ class VllmTests(unittest.TestCase):
def test_unclear_ancestry_or_listeners_never_probe(self):
for reason in ("two servers", "shared port", "two ports", "unrelated parent",
"newer parent", "reused parent", "reused worker", "unknown start", "cycle",
- "distributed parent", "distributed worker", "protected parent", "no parent"):
+ "distributed parent", "distributed worker", "protected parent", "no parent",
+ "own and parent", "worker listener"):
with self.subTest(reason=reason):
details = {10: ProcDetail(10, "VLLM::Worker_TP0", create_time=3),
20: ProcDetail(20, "python", cmdline=list(LAUNCH), create_time=2),
@@ -214,6 +215,10 @@ class VllmTests(unittest.TestCase):
details[20 if reason.endswith("parent") else 10].cmdline += ["--data-parallel-size", "2"]
elif reason == "no parent":
parents = {}
+ elif reason == "own and parent":
+ ports[10] = [8001]
+ elif reason == "worker listener":
+ details[20].name, details[20].cmdline = "VLLM::EngineCore", []
nodes = chain(details, parents)
if reason in ("reused parent", "reused worker"):
nodes[20 if reason.endswith("parent") else 10].create_time.return_value = 99