Skip to content

Qwen3.8-Flash-Next on any consumer hardware: one-click install for Windows / Linux. Strata inference engine, OpenAI/Anthropic API on localhost, optional image input.

C++

Monitor: every card of a layer split (issue #112)

Niko12210f44fb492d77
diff --git a/serve/server.py b/serve/server.py
index defdbc799..db112559b 100644
--- a/serve/server.py
+++ b/serve/server.py
@@ -599,7 +599,8 @@ class Service:
if getattr(self, "telemetry", None) is None:
from serve.telemetry import Telemetry
self.telemetry = Telemetry(extra=lambda: {"tok_s": self._tok_s()},
- gpu_index=int(getattr(self, "gpu_index", 0) or 0))
+ gpu_index=int(getattr(self, "gpu_index", 0) or 0),
+ gpu_indices=getattr(self, "gpu_indices", None))
def _tok_s(self):
with self.status_lock:
@@ -1557,6 +1558,7 @@ def main() -> int:
fit_max_tokens=a.fit_max_tokens or cfg.get("fit_max_tokens") is True)
svc.api_key = a.api_key or cfg.get("api_key", "")
svc.gpu_index = (gpu_list(cfg) or [0])[0] # the Monitor reads the card the engine runs on (issue #51)
+ svc.gpu_indices = gpu_list(cfg) # ... or every card of a layer split (issue #112)
if a.config: # the Chat settings shared with other apps, from last time
svc.shared_path = str(Path(a.config).with_suffix("")) + ".shared-settings.json"
try:
diff --git a/serve/telemetry.py b/serve/telemetry.py
index 3e0b233e2..e746b12a6 100644
--- a/serve/telemetry.py
+++ b/serve/telemetry.py
@@ -169,14 +169,19 @@ class _CpuRamFallback:
# ------------------------------------------------------------------------------------------------ the sampler
class Telemetry:
- def __init__(self, extra=None, gpu_index=0):
+ def __init__(self, extra=None, gpu_index=0, gpu_indices=None):
"""`extra()` -> dict of more series to record each second (the server's tok/s). `gpu_index`: the card the
- engine runs on, numbered as nvidia-smi and NVML number them (by PCI bus)."""
+ engine runs on, numbered as nvidia-smi and NVML number them (by PCI bus); `gpu_indices`: all of them when
+ the model is split across several (issue #112) - the gpu_* readings are then their total (memory, power,
+ PCIe traffic), mean (load) or hottest (temperature), and "gpus" has each card's own."""
self.extra = extra
self.lock = threading.Lock()
self.now: dict = {}
self.hist = collections.defaultdict(lambda: collections.deque(maxlen=HISTORY))
- self.gpu = _Nvml(gpu_index)
+ idx = list(gpu_indices) if gpu_indices and len(gpu_indices) > 1 else [gpu_index]
+ self.gpus = [(i, _Nvml(i)) for i in idx]
+ self.gpus = [(i, g) for i, g in self.gpus if g.ok()] or self.gpus[:1]
+ self.gpu = self.gpus[0][1]
try:
import psutil # noqa: F401
self.ps = sys.modules["psutil"]
@@ -184,7 +189,8 @@ class Telemetry:
self.ps = None
self.fallback = _CpuRamFallback()
self.static = {
- "gpu_name": self.gpu.name() if self.gpu.ok() else None,
+ "gpu_name": " + ".join(g.name() or "?" for _, g in self.gpus) if self.gpu.ok() else None,
+ "gpu_count": len(self.gpus),
"cpu_name": _cpu_name(),
"cores": (self.ps.cpu_count(logical=False) if self.ps else None) or None,
"threads": os.cpu_count(),
@@ -210,7 +216,21 @@ class Telemetry:
def sample(self):
s = {}
if self.gpu.ok():
- g = self.gpu.read()
+ reads = [(i, g.read()) for i, g in self.gpus]
+ g = dict(reads[0][1])
+ if len(reads) > 1:
+ def vals(k):
+ return [r[k] for _, r in reads if r.get(k) is not None]
+ for k in ("mem_used", "mem_total", "power", "power_limit", "pcie_rx_mb", "pcie_tx_mb"):
+ v = vals(k)
+ g[k] = sum(v) if v else None
+ u = vals("util")
+ g["util"] = sum(u) / len(u) if u else None
+ t = vals("temp")
+ g["temp"] = max(t) if t else None
+ s["gpus"] = [{"index": i, "util": r.get("util"), "mem_used": r.get("mem_used"),
+ "mem_total": r.get("mem_total"), "temp": r.get("temp"), "power": r.get("power")}
+ for i, r in reads]
s.update({f"gpu_{k}": v for k, v in g.items()})
if self.ps:
try:
diff --git a/serve/web/app.js b/serve/web/app.js
index 51c415ea1..c23cf0d31 100644
--- a/serve/web/app.js
+++ b/serve/web/app.js
@@ -228,12 +228,18 @@ function renderMonitor(live, hw, st, eng, h, last, requests, totals, kept) {
const speed = live.state === "generating" ? live.tok_s : last ? last.decode_tok_s : null;
setMetric("speed", speed == null ? null : fmt(speed, 1), "tok/s", live.state === "generating" ? "now" : last ? "last request" : "");
spark("sp-speed", h.tok_s);
- setMetric("gpu", hw.gpu_util == null ? null : fmt(hw.gpu_util), "%", st.gpu_name || "");
+ // a model split across several cards (issue #112): the cards show their total / mean / hottest, and each card's own
+ const per = (f) => (hw.gpus || []).map((g) => `GPU ${g.index} ${f(g)}`).join(" · ");
+ const multi = (hw.gpus || []).length > 1;
+ setMetric("gpu", hw.gpu_util == null ? null : fmt(hw.gpu_util), "%",
+ multi ? per((g) => (g.util == null ? "–" : `${fmt(g.util)}%`)) : st.gpu_name || "");
spark("sp-gpu", h.gpu_util, 100);
setMetric("vram", hw.gpu_mem_used == null ? null : gb(hw.gpu_mem_used), hw.gpu_mem_total ? `/ ${gb(hw.gpu_mem_total, 0)} GB` : "GB",
- eng.expert_slots ? `${fmt(eng.expert_slots)} experts cached` : "");
+ multi ? per((g) => (g.mem_used == null ? "–" : `${gb(g.mem_used)} GB`))
+ : eng.expert_slots ? `${fmt(eng.expert_slots)} experts cached` : "");
spark("sp-vram", h.gpu_mem_used, hw.gpu_mem_total);
- setMetric("temp", hw.gpu_temp == null ? null : fmt(hw.gpu_temp), "°C", "");
+ setMetric("temp", hw.gpu_temp == null ? null : fmt(hw.gpu_temp), "°C",
+ multi ? per((g) => (g.temp == null ? "–" : `${fmt(g.temp)}°`)) : "");
spark("sp-temp", h.gpu_temp, 90);
setMetric("power", hw.gpu_power == null ? null : fmt(hw.gpu_power), "W", hw.gpu_power_limit ? `of ${fmt(hw.gpu_power_limit)} W limit` : "");
spark("sp-power", h.gpu_power, hw.gpu_power_limit);