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

Detect custom model-path arguments with explicit provenance

Scott Hanselmand6e1c4bd0ce5
diff --git a/AGENTS.md b/AGENTS.md
index 41e73ce..af43d0e 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -22,10 +22,13 @@ these rules:
counter is the reference total. On Linux amdgpu (`drm.py`), a process gets bytes only when all its
DRM clients are provably private (one holder, render node, every `drm-shared-*` is 0); never
compute resident minus shared, since the two count by different placements.
-4. **Model evidence has a ladder:** `api` > `mapped` > `cmdline` > `installed`. App settings mean
+4. **Model evidence has a ladder:** `api` > `mapped` > `cmdline` > `path-arg` > `installed`. App settings mean
*selected*. Log events are *timestamped history*, not current residency. Model-store folders only
supply friendly names. Name-based hints (`kind_hint`, the `decision?` category) never change the
- evidence or the KV-cache math.
+ evidence or the KV-cache math. A `path-arg` alone is informational: no process classification,
+ API probing, full GGUF-header reads or weights/KV estimates. It never counts toward *confirmed*;
+ only `api`, `mapped` and `cmdline` can corroborate each other. Keep fallback discovery bounded
+ and exclude the same secret-flag values the inspector redacts.
5. **Markers mean what they say.** `*` means only one explanation fits, or every explanation gives
exactly the same bytes (near-equal is not enough). `?` is a heuristic owner. Caches, such as WSL
foreign-context sizes in `~/.cache/gputaskman/`, only rank candidates and never prove ownership.
diff --git a/README.md b/README.md
index 4329bb1..81449f6 100644
--- a/README.md
+++ b/README.md
@@ -780,6 +780,7 @@ reading is NVML's memory-activity percentage, **not measured bandwidth in GB/s**
| stable-diffusion.cpp (`--diffusion-model`) | Diffusion, text-encoder and VAE files from launch arguments; no LLM memory breakdown |
| Hugging Face cache | `models--org--repo` paths are named `org/repo` |
| Other AI runtimes | DLL detection, plus model files installed with the app (marked *not proven loaded*) |
+| Unknown apps / custom server flags | Validated model-like file paths in launch arguments, marked `path-arg` (*not proven loaded*); no runtime tag required |
| Handy | Reads selected model from settings and bounded load/start/preview/unload events from `handy.log`; selection is not load evidence and log events are historical, not proof of current residency |
| WinML / local helper processes | GPU-backed execution is in scope; generic process counters and runtime detection only. No WinML-specific model/session or client-to-helper attribution yet |
| Windows Studio Effects | Only any observable GPU portion is in scope. NPU inference is out of scope; do not interpret GPU camera/render activity as proof of model execution |
@@ -821,11 +822,13 @@ Every model row shows its **evidence**, strongest first:
|---|---|
| `api` | The runtime's local API reports the model as loaded |
| `mapped` | Windows shows the file memory-mapped into the process right now |
-| `cmdline` | The file was a launch argument (`-m model.gguf`) |
+| `cmdline` | The file was passed under a recognized model flag (`-m model.gguf`) |
+| `path-arg` | A model-like file was passed at launch under another flag or positionally; not proven loaded |
| `installed` | Found in the app's install or data folder; nothing proves it is loaded |
| Handy settings / log | Settings show selection; timestamped log events show what Handy reported, not current residency |
-Two sources including `api` or `mapped` show as **confirmed**. Runtime logs can report model events,
+Two of `api`, `mapped`, and `cmdline`, including `api` or `mapped`, show as **confirmed**.
+`path-arg` does not count as corroboration. Runtime logs can report model events,
but are displayed as timestamped history and do not prove current residency. Model-store folders
only supply a friendly name. The authoritative model *kind* comes from GGUF header keys: `decision.type` marks a
decision model (for example [Laya](https://huggingface.co/ggml-org/Laya-GGUF)), `pooling_type`
@@ -833,6 +836,30 @@ an embedding model or reranker, `stt.*` a speech model, and a causal model with
trained context an LLM. llama-server's `/v1/models` `output_modalities` (`text`, `decisions`)
confirms it. Non-causal encoders such as Laya allocate no KV cache, so none is estimated.
+For an unknown server, both `--native C:\models\model.gguf` and
+`--native=C:\models\model.gguf` can identify a **path argument**, as can a positional model path.
+Existing `--model` handling remains `cmdline` evidence. The automatic fallback considers
+`.gguf`, `.ggml`, `.safetensors`, `.onnx`, `.pt`, `.pth`, `.bin`, `.engine`, `.plan`, `.tflite`
+and `.ckpt` files. It requires a regular file: GGUF must have the four-byte `GGUF` magic;
+`.bin`, `.pt`, `.pth` and `.ckpt` need at least 64 MiB or a recognized model store; the other
+formats need at least 4 MiB. These checks identify plausible files, not proof of model loading.
+
+The fallback examines at most 256 argument tokens after the executable and attempts at most
+16 distinct model-extension paths per scan, including unsuccessful attempts. It does not walk
+directories or expand shell expressions. Relative paths use the target process's current working
+directory, never the monitor's; unavailable cwd means relative paths are skipped. A process may
+have changed cwd since launch, so this is not proof of the original file selection. Special and
+privacy-protected paths are skipped, as are API-key and key-file arguments. Only the GGUF magic
+is read from fallback model files; full headers and weights are not read. Existing cached store
+metadata may supply a friendly name.
+
+A `path-arg`-only match changes neither process classification nor API probing and supplies no
+weights, KV-cache or GPU-placement estimate. JSON preserves it in `model_files[].sources`;
+unobserved file RAM residency is `resident: null`, not zero. Mapped, recognized-flag or exact API
+file-identity evidence can support the existing richer analysis; store-name similarity alone
+cannot upgrade a path argument. Installed-folder discovery still requires a recognized AI runtime.
+This fallback is fixture-tested; the original unknown-server/GPU workload is **not hardware-validated**.
+
When a file lacks specific kind metadata, known local decision-model names (`openjev`, `laya`,
`julia-1`, `lev`, `kev`) supply a **likely decision model (name)** hint. Matching uses delimited
names in the filename, immediate model folder, or resolved store model name, not arbitrary path
@@ -863,8 +890,9 @@ recipe, and a log-format change can break it. The runtime-agnostic answer is to
opened during the load: Windows kernel file-I/O ETW events record which process opened which model
file. Combined with that process's VRAM jump, this identifies the model without app-specific code.
It needs elevation and must already be running when the load happens, so it is planned as an
-opt-in mode. Until then, unknown apps show their runtime DLLs, VRAM, engine activity, and installed
-candidates. Reading model names out of another process's memory is deliberately not done.
+opt-in mode. Until then, unknown apps show their observable runtime DLLs, VRAM, engine activity and
+validated path arguments; recognized AI runtimes can also show installed candidates.
+Reading model names out of another process's memory is deliberately not done.
Identification is designed to stay cheap. Measured on one Windows machine:
@@ -874,6 +902,7 @@ Identification is designed to stay cheap. Measured on one Windows machine:
| Windows adapter discovery (DXGI + exact-LUID PnP identity + PCI location, no telemetry sample) | ~0.86 ms median, 2.60 ms max in 30 warm reads, 26.1 ms first/cold call (Windows 11 build 28000, RTX Spark N1X, driver 32.0.16.2114); same machine without the PnP probe: ~0.36 ms median | Once at startup; TUI rediscovery every 5 s. PnP uses fixed buffers, one interface lookup per adapter and at most two name-property reads, no path/device enumeration or retries. Synchronous OS calls are not a hard latency bound. Other drivers, virtual displays and multi-GPU laptops unmeasured; provider reconstruction has additional driver-dependent cost |
| Windows NVML handle reacquisition (no telemetry sample) | ~8.7 ms median, 9.3 ms max in 30 reads (Windows 11 build 26340, RTX 4080 SUPER, NVIDIA 630.20) | Every 5 s per active collector; retries initialization after NVML session-loss errors. Other drivers unmeasured |
| Memory-map scan (DLLs + mapped files) | 1-50 ms per process | New processes, a 64 MiB / 10% memory change, or every 2 min; at most 150 ms per refresh |
+| Model-path argument fallback | 0.14 ms median / 0.20 ms max for 256 non-model arguments; 5.51 / 6.58 ms for 16 local GGUF paths; 0.18 / 0.62 ms for 16 missing paths (30 warm reads, Windows 11 build 26340, x64, Python 3.13.17; synthetic files, no GPU workload). First 16-file call: 7.74 ms | Same cached scan cadence as memory maps; at most 256 tokens and 16 candidate paths, no directory walk or full GGUF headers. Counts bound work, not synchronous filesystem latency; other platforms and network filesystems unmeasured |
| GGUF header, model-store manifests | ms, cached | Once per file / every 60 s |
| Local API probes | ms, local only | llama-server `/v1/models` only when its model path changes |
| vLLM `/v1/models` | 1.32 ms median, 21.36 ms max in 30 loopback fixture GETs; cached lookup ~0.0004 ms (Windows 11 build 28000, ARM64; no vLLM runtime/GPU workload) | One GET, 0.5 s timeout and 4 MiB response cap; success cached 3 s, misses/401 cached 30 s. No redirects; actual Linux/vLLM latency unmeasured |
diff --git a/src/gputaskman/app.py b/src/gputaskman/app.py
index 361cab9..41521fd 100644
--- a/src/gputaskman/app.py
+++ b/src/gputaskman/app.py
@@ -76,8 +76,10 @@ This display-only choice applies to all GPUs and resets to full when the app res
| Per-texture / per-buffer names | needs a debugger (PIX, Nsight) attached to the app | games, 3D apps |
**Evidence** shows how a model was identified: `api` (the runtime says it is loaded), `mapped`
-(Windows shows the file mapped into the process right now), `cmdline` (a launch argument only).
-Two sources, including `api` or `mapped`, is shown as *confirmed*.
+(Windows shows the file mapped into the process right now), `cmdline` (a recognized model flag),
+`path-arg` (a model-like file passed at launch; not proven loaded), `installed` (an app-folder candidate).
+Two of `api`, `mapped`, and `cmdline`, including `api` or `mapped`, are shown as *confirmed*.
+`path-arg` alone does not identify a runtime or produce weights/KV estimates.
**Local workloads only:** inference, decision models, vision, speech, training, graphics and video.
Cloud-hosted models are outside this monitor's scope. DLLs identify runtimes, not models or tasks.
diff --git a/src/gputaskman/collector.py b/src/gputaskman/collector.py
index c34a025..b751c5d 100644
--- a/src/gputaskman/collector.py
+++ b/src/gputaskman/collector.py
@@ -91,8 +91,10 @@ class ProcRow:
parts.append(f"{self.llm.label(i)} {g.params_label} {g.quant}")
return ", ".join(parts)
if self.detail.models:
- return ", ".join((m.store_name or os.path.basename(m.path)) +
- (f" ({m.kind_label})" if m.kind_hint else "") for m in self.detail.models[:2])
+ models = sorted(self.detail.models, key=lambda m: not m.has_model_evidence)
+ return ", ".join(("" if m.has_model_evidence else "path-arg (unproven): ") +
+ (m.store_name or os.path.basename(m.path)) +
+ (f" ({m.kind_label})" if m.kind_hint else "") for m in models[:2])
if self.detail.candidates:
return "installed (unproven): " + ", ".join(
f"{m.store_name or os.path.basename(m.path)} {gb(m.size)}" +
@@ -191,7 +193,7 @@ def _llm_wanted(row, shared_is_spill: bool) -> bool:
not diffusion, and with measured GPU memory. Where spilled system memory is a counter of its own
(WDDM, discrete DRM cards) both the dedicated and shared counters must be present; on an integrated
GPU system memory is the memory and there is no spill counter, so dedicated alone suffices."""
- if row.detail.is_diffusion or row.kind not in AI_KINDS or not (row.detail.models or row.kind == "LLM"):
+ if row.detail.is_diffusion or row.kind not in AI_KINDS or not (row.detail.has_model_evidence or row.kind == "LLM"):
return False
need = {"dedicated", "shared"} if shared_is_spill else {"dedicated"}
return need <= row.gpu.available
diff --git a/src/gputaskman/llm.py b/src/gputaskman/llm.py
index e14f4d4..866d240 100644
--- a/src/gputaskman/llm.py
+++ b/src/gputaskman/llm.py
@@ -22,7 +22,7 @@ import urllib.request
from dataclasses import dataclass, field
from .gguf import GgufInfo, is_gguf, read_gguf
-from .procinfo import MappedModel, ProcDetail, file_key, make_model
+from .procinfo import SECRET_FLAGS, MappedModel, ProcDetail, file_key, make_model
MiB = 1 << 20
KV_TYPE_BYTES = {"f32": 4, "f16": 2, "bf16": 2, "q8_0": 34 / 32, "q4_0": 18 / 32, "q4_1": 20 / 32,
@@ -128,7 +128,6 @@ _opener = urllib.request.build_opener(urllib.request.ProxyHandler({}))
_keyed_opener = urllib.request.build_opener(urllib.request.ProxyHandler({}), _NoRedirect)
-_SECRET_FLAGS = ("--api-key", "--api-key-file")
UNAUTHORIZED = object() # _get result for HTTP 401: the server wants a key
@@ -160,10 +159,10 @@ def redact_cmdline(cmd: list[str]) -> list[str]:
if hide:
out.append("***")
hide = False
- elif arg in _SECRET_FLAGS:
+ elif arg in SECRET_FLAGS:
out.append(arg)
hide = True
- elif "=" in arg and arg.split("=", 1)[0] in _SECRET_FLAGS:
+ elif "=" in arg and arg.split("=", 1)[0] in SECRET_FLAGS:
out.append(arg.split("=", 1)[0] + "=***")
else:
out.append(arg)
@@ -422,13 +421,15 @@ def _merge_api(files: list[MappedModel], server: ServerInfo | None, host: Server
is_gguf(server.model_path), "api"))
for front in (s for s in (server, host) if s and s.kind == "ollama"):
for f in files:
+ if not f.has_model_evidence:
+ continue
names = set((f.store_name or "").split(", "))
for om in front.models:
if om["name"] in names:
f.add_source("api")
matched.append(om)
lms = host if host and host.kind == "lmstudio" else (server if server and server.kind == "lmstudio" else None)
- primary = [f for f in files if f.kind not in _SIDE_KINDS]
+ primary = [f for f in files if f.has_model_evidence and f.kind not in _SIDE_KINDS]
if lms and len(lms.models) == 1 and len(primary) == 1: # LM Studio keys don't map to paths; only pair 1:1
primary[0].add_source("api")
matched.append(lms.models[0])
@@ -449,6 +450,9 @@ def build_view(d: ProcDetail, vram: float, shared: float, server: ServerInfo | N
files = [dataclasses.replace(m, sources=list(m.sources)) for m in d.models] # cached details stay untouched
matched = _merge_api(files, server, host)
for m in files:
+ if not m.has_model_evidence:
+ v.other_files.append(m)
+ continue
g = read_gguf(m.path) if m.gguf else None
if g is not None and not g.error:
v.models.append(g)
diff --git a/src/gputaskman/procinfo.py b/src/gputaskman/procinfo.py
index 8365cc4..85d2620 100644
--- a/src/gputaskman/procinfo.py
+++ b/src/gputaskman/procinfo.py
@@ -5,6 +5,7 @@ from __future__ import annotations
import fnmatch
import os
import re
+import stat
import sys
import time
from dataclasses import dataclass, field
@@ -42,6 +43,9 @@ AI_RUNTIMES = {"llama.cpp", "whisper.cpp", "ggml", "PyTorch", "MLX", "TensorRT",
_RUNTIME_RX = [(tag, re.compile("|".join(fnmatch.translate(p) for p in pats))) for tag, pats in RUNTIMES]
MODEL_EXTS = {".gguf", ".ggml", ".safetensors", ".onnx", ".pt", ".pth", ".bin", ".engine", ".plan", ".tflite", ".ckpt"}
AMBIGUOUS_EXTS = {".bin", ".pt", ".pth", ".ckpt"} # also used for caches/tiles, so require size or a model store
+SECRET_FLAGS = ("--api-key", "--api-key-file")
+PATH_ARG_TOKENS = 256
+PATH_ARG_CANDIDATES = 16
_NOT_MODELS = {".dll", ".exe", ".sys", ".mui", ".ttf", ".ttc", ".otf", ".dat", ".db", ".nls", ".pak", ".mun"}
BROWSERS = {"msedge.exe", "chrome.exe", "firefox.exe", "msedgewebview2.exe", "brave.exe", "opera.exe", "arc.exe", "vivaldi.exe",
"chrome", "chromium", "chromium-browser", "firefox", "firefox-bin", "brave", "msedge", "opera", "vivaldi-bin",
@@ -80,9 +84,9 @@ _installed: dict[str, tuple[float, list[MappedModel]]] = {}
class MappedModel:
path: str
size: int
- resident: int # bytes of the file currently in this process's RAM working set
+ resident: int | None # bytes of the file in this process's RAM working set; None when unobserved
gguf: bool
- sources: list[str] = field(default_factory=lambda: ["mapped"]) # mapped | cmdline | api | installed
+ sources: list[str] = field(default_factory=lambda: ["mapped"]) # mapped | cmdline | api | path-arg | installed
store_name: str | None = None # e.g. "qwen3:14b" from an Ollama manifest
kind: str = "" # GGUF kind: LLM, decision model, embedding model, ...
kind_hint: str = "" # name-based suggestion only; never changes loading evidence or GGUF math
@@ -95,12 +99,18 @@ class MappedModel:
if source not in self.sources:
self.sources.append(source)
+ @property
+ def has_model_evidence(self) -> bool:
+ return any(s in ("api", "mapped", "cmdline") for s in self.sources)
+
@property
def evidence(self) -> str:
s = set(self.sources)
how = "+".join(x for x in ("api", "mapped", "cmdline") if x in s)
- if len(s) >= 2 and s & {"api", "mapped"}:
+ if len(s & {"api", "mapped", "cmdline"}) >= 2 and s & {"api", "mapped"}:
return f"confirmed ({how})"
+ if not how and "path-arg" in s:
+ return "path-arg (not proven loaded)"
if not how and "installed" in s:
return "installed, not proven loaded"
return {"mapped": "in use (mapped)", "cmdline": "launch arg", "api": "reported (api)"}.get(how, how)
@@ -128,7 +138,11 @@ class ProcDetail:
@property
def is_ai(self) -> bool:
- return bool(self.models) or any(r in AI_RUNTIMES for r in self.runtimes)
+ return self.has_model_evidence or any(r in AI_RUNTIMES for r in self.runtimes)
+
+ @property
+ def has_model_evidence(self) -> bool:
+ return any(m.has_model_evidence for m in self.models)
@property
def is_diffusion(self) -> bool:
@@ -208,11 +222,16 @@ def file_key(path: str) -> tuple[int, int] | str:
return (st.st_dev, st.st_ino) if st.st_ino else os.path.normcase(os.path.abspath(path))
-def _models_from_cmdline(cmd: list[str]) -> list[str]:
- paths = []
+def _model_flags(cmd: list[str]) -> set[str]:
flags = {"-m", "--model", "--mmproj", "-md", "--model-draft", "--lora"}
if _is_diffusion_cmdline(cmd):
flags.update(("--diffusion-model", "--vae", "--llm"))
+ return flags
+
+
+def _models_from_cmdline(cmd: list[str]) -> list[str]:
+ paths = []
+ flags = _model_flags(cmd)
for i, arg in enumerate(cmd):
val = None
key, sep, value = arg.partition("=")
@@ -233,6 +252,76 @@ def _is_model_file(ext: str, size: int, gg: bool, store: str | None) -> bool:
return size >= 4 * MiB
+def _models_from_path_args(d: ProcDetail) -> list[MappedModel]:
+ """Bounded file hints, not model selection: no model contents beyond GGUF magic."""
+ cmd = d.cmdline[1:PATH_ARG_TOKENS + 1]
+ flags = _model_flags(cmd)
+ found: list[MappedModel] = []
+ seen: set[str] = set()
+ cwd, cwd_checked = "", False
+ skip_next, hide_secret, positional = False, False, False
+ for arg in cmd:
+ if hide_secret:
+ hide_secret = False
+ continue
+ key, sep, value = arg.partition("=")
+ if key in SECRET_FLAGS:
+ hide_secret, skip_next = not sep, False
+ continue
+ if skip_next:
+ skip_next = False
+ continue
+ if not positional and arg == "--":
+ positional = True
+ continue
+ if not positional and key in flags:
+ skip_next = not sep
+ continue
+ if not positional and arg.startswith("-"):
+ if not sep:
+ continue
+ path = value
+ else:
+ path = arg
+ ext = os.path.splitext(path)[1].lower()
+ if ext not in MODEL_EXTS or "\0" in path or "://" in path or _skip_path(path):
+ continue
+ spelling = os.path.normcase(path)
+ if spelling in seen:
+ continue
+ if len(seen) >= PATH_ARG_CANDIDATES:
+ break
+ seen.add(spelling)
+ if not os.path.isabs(path):
+ if not cwd_checked:
+ cwd_checked = True
+ try:
+ cwd = psutil.Process(d.pid).cwd()
+ except (psutil.Error, OSError):
+ pass
+ if not cwd or not os.path.isabs(cwd):
+ continue
+ path = os.path.join(cwd, path)
+ if not os.path.isabs(path):
+ continue # e.g. a Windows drive-relative path on another drive
+ # Check normalized exclusions without rewriting symlink/.. traversal before stat/open.
+ if _skip_path(path) or _skip_path(os.path.normpath(path)):
+ continue
+ try:
+ info = os.stat(path)
+ if not stat.S_ISREG(info.st_mode):
+ continue
+ gg = ext == ".gguf" and is_gguf(path)
+ if ext == ".gguf" and not gg:
+ continue
+ store = store_name(path)
+ if _is_model_file(ext, info.st_size, gg, store):
+ found.append(MappedModel(path, info.st_size, None, gg, ["path-arg"], store))
+ except (OSError, ValueError):
+ continue
+ return found
+
+
def make_model(path: str, size: int, resident: int, gg: bool, source: str, store: str | None = None) -> MappedModel:
g = read_gguf(path) if gg else None
kind = g.kind if g is not None and not g.error else ""
@@ -431,7 +520,7 @@ class ProcInspector:
d.access_denied = True
return
dlls: set[str] = set()
- models: dict[str, MappedModel] = {}
+ models: dict[tuple[int, int] | str, MappedModel] = {}
for m in maps:
path = m.path
base = os.path.basename(path).lower()
@@ -463,10 +552,16 @@ class ProcInspector:
models[key].add_source("cmdline")
else:
models[key] = make_model(path, os.path.getsize(path), 0, is_gguf(path), "cmdline")
+ for model in _models_from_path_args(d):
+ key = file_key(model.path)
+ if key in models:
+ models[key].add_source("path-arg")
+ else:
+ models[key] = model
d.runtimes = _match_runtimes(dlls)
- d.models = sorted(models.values(), key=lambda m: -m.size)
+ d.models = sorted(models.values(), key=lambda m: (not m.has_model_evidence, -m.size))
ai = any(r in AI_RUNTIMES for r in d.runtimes)
- d.candidates = installed_models(d.exe) if ai and not d.models else []
+ d.candidates = installed_models(d.exe) if ai and not d.has_model_evidence else []
def prune(self, live_pids: set[int]) -> None:
for pid in list(self._cache):
@@ -491,11 +586,12 @@ def classify(d: ProcDetail, engines: dict[str, float]) -> str:
return "system"
if d.is_diffusion:
return "diffusion"
- kinds = {MODEL_KINDS[m.kind] for m in d.models if m.kind in MODEL_KINDS and not m.kind_hint}
+ kinds = {MODEL_KINDS[m.kind] for m in d.models
+ if m.has_model_evidence and m.kind in MODEL_KINDS and not m.kind_hint}
for k in ("LLM", "decision", "embedding", "speech"):
if k in kinds:
return k
- if any(m.kind_hint == "decision model" for m in d.models):
+ if any(m.has_model_evidence and m.kind_hint == "decision model" for m in d.models):
return "decision?"
if d.vllm_role or "llama.cpp" in d.runtimes or n.startswith(LLM_NAMES):
return "LLM"
diff --git a/src/gputaskman/report.py b/src/gputaskman/report.py
index 8680b20..ebd0142 100644
--- a/src/gputaskman/report.py
+++ b/src/gputaskman/report.py
@@ -254,6 +254,12 @@ def to_text(s: Snapshot, limit: int = 30) -> str:
out.append(f" last Handy event: {p.handy.last_event} {p.handy.last_model or ''} "
f"at {p.handy.last_event_local} (runtime-reported history, not current GPU residency)")
if not p.llm:
+ path_args = [m for m in p.detail.models if "path-arg" in m.sources]
+ if path_args:
+ out.append("")
+ out.append(f"== {p.name} ({p.pid_label}) VRAM {vram_label(p.gpu)}")
+ for m in path_args:
+ out.append(f" file: {m.store_name or m.path} ({gb(m.size)}) evidence: {m.evidence}")
continue
out.append("")
out.append(f"== {p.name} ({p.pid_label}) VRAM {vram_label(p.gpu)}")
diff --git a/tests/test_core.py b/tests/test_core.py
index cd6188a..eaaab03 100644
--- a/tests/test_core.py
+++ b/tests/test_core.py
@@ -7,6 +7,7 @@ import ctypes
import io
import json
import os
+import stat
from types import SimpleNamespace
import tempfile
import threading
@@ -34,8 +35,10 @@ from gputaskman.llm import (LlmView, ServerInfo, ServerProber, _get, api_key, bu
redact_cmdline)
from gputaskman.nvml import NvDevice, Nvml
from gputaskman.pdh import AdapterGpu, GpuCounters, ProcGpu
-from gputaskman.procinfo import (AI_KINDS, MappedModel, ProcDetail, ProcInspector, _is_model_file, _match_runtimes,
- _models_from_cmdline, classify, file_key, installed_models, make_model)
+from gputaskman.procinfo import (AI_KINDS, AMBIGUOUS_EXTS, MODEL_EXTS, PATH_ARG_CANDIDATES, PATH_ARG_TOKENS,
+ MappedModel, ProcDetail, ProcInspector, _is_model_file, _match_runtimes,
+ _models_from_cmdline, _models_from_path_args, classify, file_key, installed_models,
+ make_model)
from gputaskman.report import to_dict, to_text
from gputaskman.stores import ollama_names, store_name
from tools.capture_screenshots import for_publication
@@ -554,6 +557,285 @@ class HandyTests(unittest.TestCase):
self.assertEqual(to_dict(s)["processes"][0]["handy"]["last_event"], "loaded")
+class PathArgumentTests(unittest.TestCase):
+ def setUp(self):
+ directory = tempfile.TemporaryDirectory()
+ self.addCleanup(directory.cleanup)
+ self.root = Path(directory.name)
+ self.path = self.root / "custom model.GGUF"
+ self.path.write_bytes(b"GGUF" + bytes(20))
+
+ def detail(self, *args):
+ return ProcDetail(123, "custom-server", exe=str(self.root / "custom-server"),
+ cmdline=["custom-server", *map(str, args)])
+
+ def scan(self, detail, maps=()):
+ with patch("gputaskman.procinfo._memory_maps", return_value=list(maps)):
+ ProcInspector().scan(detail)
+
+ def test_unknown_flags_assignments_and_positional_paths_are_informational(self):
+ for args in (["--native", self.path], [f"--native={self.path}"], [self.path], ["--", self.path]):
+ with self.subTest(args=args):
+ detail = self.detail(*args)
+ before = classify(detail, {})
+ with patch("gputaskman.procinfo.read_gguf") as header, \
+ patch("gputaskman.procinfo.installed_models") as installed:
+ self.scan(detail)
+ header.assert_not_called()
+ installed.assert_not_called()
+ self.assertEqual(len(detail.models), 1)
+ m = detail.models[0]
+ self.assertEqual((m.path, m.sources, m.gguf), (str(self.path), ["path-arg"], True))
+ self.assertEqual((m.kind, m.kind_hint, m.resident), ("", "", None))
+ self.assertEqual(m.evidence, "path-arg (not proven loaded)")
+ self.assertFalse(detail.is_ai)
+ self.assertEqual(classify(detail, {}), before)
+ self.assertEqual(detail.runtimes, [])
+ for kind in ("app", "compute", "AI"):
+ row = ProcRow(123, detail.name, kind, ProcGpu(dedicated=GiB, shared=0), detail)
+ self.assertFalse(_llm_wanted(row, True))
+ detail.runtimes = ["CUDA"]
+ self.assertEqual(classify(detail, {}), "compute")
+
+ def test_regular_file_and_all_extension_size_boundaries(self):
+ for ext in sorted(MODEL_EXTS - {".gguf"}):
+ threshold = (64 if ext in AMBIGUOUS_EXTS else 4) * MiB
+ for size, accepted in ((threshold - 1, False), (threshold, True)):
+ with self.subTest(ext=ext, size=size), \
+ patch("gputaskman.procinfo.os.stat",
+ return_value=SimpleNamespace(st_mode=stat.S_IFREG, st_size=size)), \
+ patch("gputaskman.procinfo.store_name", return_value=None), \
+ patch("gputaskman.procinfo.is_gguf") as magic:
+ found = _models_from_path_args(self.detail(self.root / ("model" + ext)))
+ self.assertEqual(bool(found), accepted)
+ magic.assert_not_called()
+ for ext in AMBIGUOUS_EXTS:
+ with self.subTest(store_ext=ext), \
+ patch("gputaskman.procinfo.os.stat",
+ return_value=SimpleNamespace(st_mode=stat.S_IFREG, st_size=1)), \
+ patch("gputaskman.procinfo.store_name", return_value="org/model"):
+ found = _models_from_path_args(self.detail(self.root / ("model" + ext)))
+ self.assertEqual(found[0].store_name, "org/model")
+ self.assertEqual(found[0].sources, ["path-arg"])
+
+ def test_invalid_magic_is_rejected_even_above_the_size_gate(self):
+ for contents in (b"", b"G", b"GGU", b"NOPE"):
+ self.path.write_bytes(contents)
+ with self.subTest(contents=contents), open(self.path, "ab") as f:
+ if contents == b"NOPE":
+ f.truncate(4 * MiB)
+ self.assertEqual(_models_from_path_args(self.detail(self.path)), [])
+
+ def test_paths_are_resolved_against_target_cwd_not_monitor_cwd(self):
+ other = self.root / "other.GGUF"
+ other.write_bytes(b"GGUF")
+ with patch("gputaskman.procinfo.psutil.Process") as process:
+ process.return_value.cwd.return_value = str(self.root)
+ found = _models_from_path_args(self.detail(self.path.name, other.name))
+ process.assert_called_once_with(123)
+ process.return_value.cwd.assert_called_once_with()
+ self.assertEqual([m.path for m in found], [str(self.path), str(other)])
+ for cwd in ("", "relative"):
+ with patch("gputaskman.procinfo.psutil.Process") as process:
+ process.return_value.cwd.return_value = cwd
+ self.assertEqual(_models_from_path_args(self.detail(self.path.name)), [])
+ with patch("gputaskman.procinfo.psutil.Process") as process:
+ process.return_value.cwd.side_effect = PermissionError("protected")
+ found = _models_from_path_args(self.detail(self.path.name, other.name, self.path))
+ process.return_value.cwd.assert_called_once_with()
+ self.assertEqual([m.path for m in found], [str(self.path)])
+
+ def test_nonfiles_and_invalid_paths_are_skipped_before_opening(self):
+ folder = self.root / "folder.gguf"
+ folder.mkdir()
+ for path in (folder, self.root / "missing.gguf"):
+ with patch("gputaskman.procinfo.is_gguf") as magic:
+ self.assertEqual(_models_from_path_args(self.detail(path)), [])
+ magic.assert_not_called()
+ for path in ("bad\0.gguf", "https://example.test/model.gguf", "/proc/model.gguf",
+ "/dev/model.gguf", "/sys/model.gguf", "[model.gguf", "settings.json"):
+ with self.subTest(path=path), patch("gputaskman.procinfo.os.stat") as probe:
+ self.assertEqual(_models_from_path_args(self.detail(path)), [])
+ probe.assert_not_called()
+ with patch("gputaskman.procinfo.sys.platform", "darwin"), \
+ patch("gputaskman.procinfo.os.stat") as probe:
+ self.assertEqual(_models_from_path_args(self.detail("/System/model.gguf")), [])
+ self.assertEqual(_models_from_path_args(self.detail("/Users/x/Library/Containers/model.gguf")), [])
+ probe.assert_not_called()
+ for mode in (stat.S_IFIFO, stat.S_IFCHR, stat.S_IFSOCK):
+ with patch("gputaskman.procinfo.os.stat", return_value=SimpleNamespace(st_mode=mode)), \
+ patch("gputaskman.procinfo.is_gguf") as magic:
+ self.assertEqual(_models_from_path_args(self.detail(self.path)), [])
+ magic.assert_not_called()
+ for error in (FileNotFoundError(), PermissionError(), ValueError("invalid path")):
+ with patch("gputaskman.procinfo.os.stat", side_effect=error):
+ self.assertEqual(_models_from_path_args(self.detail(self.path)), [])
+ with patch("gputaskman.gguf.open", side_effect=PermissionError()):
+ self.assertEqual(_models_from_path_args(self.detail(self.path)), [])
+
+ def test_token_and_attempt_limits_include_unsuccessful_candidates(self):
+ self.assertEqual(len(_models_from_path_args(
+ self.detail(*(["noop"] * (PATH_ARG_TOKENS - 1)), self.path))), 1)
+ self.assertEqual(_models_from_path_args(
+ self.detail(*(["noop"] * PATH_ARG_TOKENS), self.path)), [])
+ missing = [self.root / f"{i}.gguf" for i in range(PATH_ARG_CANDIDATES)]
+ with patch("gputaskman.procinfo.os.stat", wraps=os.stat) as probe:
+ self.assertEqual(_models_from_path_args(self.detail(*missing, self.path)), [])
+ self.assertEqual(probe.call_count, PATH_ARG_CANDIDATES)
+ found = _models_from_path_args(self.detail(*missing[:-1], self.path))
+ self.assertEqual([m.path for m in found], [str(self.path)])
+ with patch("gputaskman.procinfo.os.stat", wraps=os.stat) as probe:
+ self.assertEqual(len(_models_from_path_args(self.detail(*([self.path] * PATH_ARG_TOKENS)))), 1)
+ self.assertEqual(probe.call_count, 1)
+
+ def test_known_model_operands_and_secrets_are_not_fallback_candidates(self):
+ for flag in ("-m", "--model", "--mmproj", "-md", "--model-draft", "--lora",
+ "--api-key", "--api-key-file"):
+ for args in ([flag, self.path], [f"{flag}={self.path}"]):
+ with self.subTest(args=args), patch("gputaskman.procinfo.os.stat") as probe:
+ self.assertEqual(_models_from_path_args(self.detail(*args)), [])
+ probe.assert_not_called()
+ with patch("gputaskman.procinfo.os.stat") as probe:
+ self.assertEqual(_models_from_path_args(self.detail("--", "--api-key", self.path)), [])
+ self.assertEqual(_models_from_path_args(self.detail("--model", "--api-key", self.path)), [])
+ self.assertEqual(_models_from_path_args(self.detail("--model", f"--api-key-file={self.path}")), [])
+ self.assertEqual(_models_from_path_args(self.detail("--diffusion-model", self.path,
+ "--vae", self.path, f"--llm={self.path}")), [])
+ probe.assert_not_called()
+ detail = self.detail("--api-key", self.path, f"--api-key-file={self.path}")
+ self.scan(detail)
+ self.assertEqual(detail.models, [])
+ self.assertNotIn(str(self.path), " ".join(redact_cmdline(detail.cmdline)))
+ # argv[0] may itself name a model-like executable; it is not an argument.
+ self.assertEqual(_models_from_path_args(ProcDetail(123, cmdline=[str(self.path)])), [])
+
+ @unittest.skipIf(os.name == "nt", "POSIX resolves .. after following directory symlinks")
+ def test_symlink_parent_traversal_is_not_rewritten_to_another_file(self):
+ base, target = self.root / "base", self.root / "target"
+ base.mkdir()
+ (target / "inner").mkdir(parents=True)
+ (target / "model.gguf").write_bytes(b"GGUF")
+ (base / "model.gguf").write_bytes(b"NOPE")
+ (base / "link").symlink_to(target / "inner", target_is_directory=True)
+ path = base / "link" / ".." / "model.gguf"
+ found = _models_from_path_args(self.detail(path, base / "model.gguf"))
+ self.assertEqual(len(found), 1)
+ self.assertEqual(file_key(found[0].path), file_key(str(target / "model.gguf")))
+
+ def test_aliases_merge_without_fabricating_confirmation(self):
+ alias = self.root / "alias.gguf"
+ try:
+ os.link(self.path, alias)
+ except OSError as error:
+ self.skipTest(f"hard links unavailable: {error}")
+ for args, maps, expected in (
+ (["--native", self.path, alias, self.path], [], ["path-arg"]),
+ (["--native", alias], [SimpleNamespace(path=str(self.path), rss=42)], ["mapped", "path-arg"]),
+ (["--model", self.path, "--native", alias], [], ["cmdline", "path-arg"])):
+ detail = self.detail(*args)
+ self.scan(detail, maps)
+ self.assertEqual(len(detail.models), 1)
+ self.assertEqual(detail.models[0].sources, expected)
+ self.assertNotIn("confirmed", detail.models[0].evidence)
+ if maps:
+ self.assertEqual(detail.models[0].resident, 42)
+ self.assertEqual(MappedModel("m", 1, None, False, ["api", "path-arg"]).evidence, "reported (api)")
+ self.assertEqual(MappedModel("m", 1, 0, False, ["api", "mapped", "path-arg"]).evidence,
+ "confirmed (api+mapped)")
+
+ def test_weak_paths_do_not_suppress_installed_candidates_for_ai_runtimes(self):
+ detail = self.detail("--native", self.path)
+ with patch("gputaskman.procinfo.installed_models", return_value=[]) as installed:
+ self.scan(detail, [SimpleNamespace(path="onnxruntime.dll", rss=0)])
+ installed.assert_called_once_with(detail.exe)
+ self.assertTrue(detail.is_ai)
+ self.assertFalse(_llm_wanted(ProcRow(123, detail.name, "AI", ProcGpu(dedicated=GiB), detail), True))
+
+ def test_collection_adds_the_filename_without_probing_or_changing_memory(self):
+ detail = self.detail("--native", self.path)
+ c = Collector.__new__(Collector)
+ c.adapter = Adapter(1, "GPU", 0x10DE, 16 * GiB, 0, False)
+ c.adapters = [c.adapter]
+ c.gpu_index, c.scan_budget, c.host, c.host_status = 0, None, None, ""
+ c.nvml = Mock(ok=False)
+ c.counters = Mock(outside={})
+ c.counters.sample.return_value = (
+ {1: {123: ProcGpu(dedicated=8 * GiB, shared=0)}},
+ {1: AdapterGpu(dedicated=8 * GiB, shared=0)})
+ c.inspector, c.prober = ProcInspector(), Mock()
+ with patch("gputaskman.collector.BACKEND", "wddm"), \
+ patch.object(c.inspector, "get", return_value=detail), \
+ patch("gputaskman.procinfo._memory_maps", return_value=[]), \
+ patch("gputaskman.procinfo.read_gguf") as header:
+ s = c.sample()
+ c.prober.get.assert_not_called()
+ header.assert_not_called()
+ self.assertEqual((s.attributed, s.vram_used), (8 * GiB, 8 * GiB))
+ self.assertEqual(s.procs[0].kind, "app")
+ self.assertIsNone(s.procs[0].llm)
+ self.assertIn(self.path.name, s.procs[0].inside)
+
+ def test_weak_files_are_excluded_from_header_math_and_name_only_api_pairing(self):
+ weak = MappedModel(str(self.path), GiB, None, True, ["path-arg"], "org/model")
+ detail = self.detail()
+ detail.models = [weak]
+ for server in (None, ServerInfo("ollama", "http://local", models=[{"name": "org/model"}]),
+ ServerInfo("lmstudio", "http://local", models=[{"name": "org/model"}])):
+ with self.subTest(server=server), patch("gputaskman.llm.read_gguf") as header:
+ view = build_view(detail, GiB, 0, server)
+ header.assert_not_called()
+ self.assertEqual(view.models, [])
+ self.assertEqual(view.other_files[0].sources, ["path-arg"])
+ self.assertIsNone(view.kv_per_token)
+ self.assertFalse(any(s.kind in ("weights", "kv") for s in view.segments))
+ weak.kind, weak.kind_hint = "LLM", "decision model"
+ self.assertEqual(classify(detail, {}), "app") # never infer process kind from a weak entry
+
+ def test_exact_api_identity_upgrades_only_the_view_copy(self):
+ detail = self.detail("--native", self.path)
+ self.scan(detail)
+ server = ServerInfo("llama-server", "http://local", model_path=str(self.path), n_ctx=4096)
+ with patch("gputaskman.llm.read_gguf", return_value=gguf("qwen3", block_count=1, context_length=4096)):
+ view = build_view(detail, GiB, 0, server)
+ self.assertEqual(view.files[0].sources, ["path-arg", "api"])
+ self.assertEqual(view.files[0].evidence, "reported (api)")
+ self.assertEqual(detail.models[0].sources, ["path-arg"])
+
+ def test_mixed_files_keep_stronger_selection_and_estimates(self):
+ strong = MappedModel("real.gguf", 1000, 0, True, ["cmdline"], kind="LLM")
+ weak = MappedModel(str(self.path), GiB, None, True, ["path-arg"])
+ detail = self.detail()
+ detail.models = [weak, strong]
+ model = gguf("qwen3", block_count=1, context_length=4096)
+ with patch("gputaskman.llm.read_gguf", return_value=model) as header:
+ view = build_view(detail, GiB, 0, None)
+ header.assert_called_once_with("real.gguf")
+ self.assertEqual(view.files, [strong])
+ self.assertEqual(view.other_files, [weak])
+ self.assertTrue(ProcRow(123, detail.name, "LLM", ProcGpu(), detail).inside.startswith("real.gguf"))
+
+ def test_table_text_json_and_screenshot_redaction_preserve_uncertainty(self):
+ detail = self.detail("--native", self.path)
+ self.scan(detail)
+ s = snapshot()
+ s.procs[0].detail, s.procs[0].llm, s.procs[0].kind = detail, None, "compute"
+ before = to_dict(s)
+ self.assertIn("path-arg (unproven): custom model.GGUF", s.procs[0].inside)
+ self.assertIn("path-arg (not proven loaded)", to_text(s))
+ data = to_dict(s)["processes"][0]
+ self.assertEqual(data["model_files"][0]["sources"], ["path-arg"])
+ self.assertIsNone(data["model_files"][0]["resident"])
+ self.assertNotIn("llm", data)
+ public = for_publication(s)
+ self.assertEqual(public.procs[0].detail.models[0].path, self.path.name)
+ detail.models = []
+ after = to_dict(s)
+ for key in ("attributed", "vram_used", "shared_used"):
+ self.assertEqual(before[key], after[key])
+ for key in ("vram_bytes", "shared_bytes", "committed_bytes", "paged_out_bytes", "engines"):
+ self.assertEqual(before["processes"][0][key], after["processes"][0][key])
+
+
class ModelTests(unittest.TestCase):
def test_diffusion_arguments_do_not_classify_text_encoder_as_llm(self):
with tempfile.TemporaryDirectory() as directory:
@@ -1114,7 +1396,8 @@ class LlmWantedTests(unittest.TestCase):
def _row(self, kind="LLM", models=("m.gguf",), diffusion=False, available=("dedicated", "shared")):
return SimpleNamespace(
kind=kind,
- detail=SimpleNamespace(is_diffusion=diffusion, models=list(models)),
+ detail=ProcDetail(123, cmdline=["--diffusion-model"] if diffusion else [],
+ models=[MappedModel(m, 1, 0, True) for m in models]),
gpu=SimpleNamespace(available=set(available)),
)
@@ -1651,6 +1934,22 @@ class UiTests(unittest.IsolatedAsyncioTestCase):
self.assertIn("likely decision model (name)", text)
self.assertIn("in use (mapped)", text)
+ async def test_path_argument_is_explicit_without_an_llm_view(self):
+ with patch.object(GpuTaskManager, "poll"), patch("gputaskman.app.BACKEND", "wddm"):
+ app = GpuTaskManager()
+ async with app.run_test(size=(220, 50)) as pilot:
+ s = snapshot()
+ detail = ProcDetail(10, "custom-server", models=[
+ MappedModel("custom.gguf", 5 * GiB, None, True, ["path-arg"])])
+ s.procs[0] = ProcRow(10, detail.name, "compute", ProcGpu(dedicated=8 * GiB), detail)
+ app.apply(s)
+ await pilot.pause()
+ self.assertEqual(app.query_one("#procs").get_row("10")[2].plain, "compute")
+ text = " ".join(ET.fromstring(app.export_screenshot()).itertext()).replace("\u00a0", " ")
+ self.assertIn("path-arg (unproven): custom.gguf", text)
+ self.assertIn("path-arg (not proven loaded)", text)
+ self.assertNotIn("on GPU (est)", text)
+
async def test_navigation_sort_pause_and_help(self):
with patch.object(GpuTaskManager, "poll"):
app = GpuTaskManager()
diff --git a/tests/test_diff.py b/tests/test_diff.py
index 286ec91..1c0bf81 100644
--- a/tests/test_diff.py
+++ b/tests/test_diff.py
@@ -116,6 +116,19 @@ class PidReuseTests(unittest.TestCase):
class DiffTests(unittest.TestCase):
+ def test_path_argument_discovery_does_not_change_measured_memory(self):
+ before = snap([proc(1, "custom-server", vram=GiB)], used=GiB, attributed=GiB)
+ after = snap([proc(1, "custom-server", vram=GiB)], used=GiB, attributed=GiB)
+ after["processes"][0]["model_files"] = [
+ {"path": "custom.gguf", "sources": ["path-arg"], "resident": None}]
+ result = diff(before, after)
+ process = result["processes"][0]
+ self.assertEqual(process["model_files"]["added"], [{"path": "custom.gguf", "sources": ["path-arg"]}])
+ self.assertEqual(process["measured"]["vram_bytes"]["delta"], 0)
+ self.assertEqual(result["device"]["vram_used"]["delta"], 0)
+ self.assertIn("[path-arg]", to_text(result))
+ self.assertIn("not what is resident in GPU memory", to_text(result))
+
def test_measured_runtime_and_mapped_evidence_stay_separate(self):
before = snap([proc(1, "dwm.exe", vram=2 * GiB),
proc(2, "llama-server", vram=5 * GiB, ports=[8080], llm=llm(4096, GiB // 2))],
diff --git a/tests/test_linux.py b/tests/test_linux.py
index efe7041..c8aae2c 100644
--- a/tests/test_linux.py
+++ b/tests/test_linux.py
@@ -11,7 +11,7 @@ from gputaskman.nvml import NvDevice
from gputaskman.gguf import GgufInfo
from gputaskman.llm import LlmView, build_view
from gputaskman.pdh import ProcGpu
-from gputaskman.procinfo import ProcDetail, _lib_name, _match_runtimes, classify
+from gputaskman.procinfo import MappedModel, ProcDetail, _lib_name, _match_runtimes, classify
from gputaskman.report import to_dict, to_text
GiB = 1 << 30
@@ -376,10 +376,8 @@ class UnattributedReportTests(unittest.TestCase):
def test_llm_view_does_not_claim_cpu_inference_when_vram_is_unknown(self):
d = ProcDetail(4242, "llama-server", cmdline=["llama-server", "-c", "4096"])
- d.models = [SimpleNamespace(path="/m/x.gguf", gguf=True, sources=["mapped"], store_name=None,
- kind="", kind_hint="", size=GiB)]
- with patch("gputaskman.llm.dataclasses.replace", side_effect=lambda m, **kw: m), \
- patch("gputaskman.llm.read_gguf", return_value=GgufInfo(path="/m/x.gguf", file_size=GiB, version=3)):
+ d.models = [MappedModel("/m/x.gguf", GiB, 0, True)]
+ with patch("gputaskman.llm.read_gguf", return_value=GgufInfo(path="/m/x.gguf", file_size=GiB, version=3)):
known = build_view(d, 0, 0, None)
unknown = build_view(d, 0, 0, None, attributed=False)
self.assertTrue(any("CPU inference" in n for n in known.notes))
diff --git a/tests/test_record.py b/tests/test_record.py
index bf20ad6..91df7e7 100644
--- a/tests/test_record.py
+++ b/tests/test_record.py
@@ -25,7 +25,7 @@ from gputaskman.dxgi import Adapter
from gputaskman.host import HostProc, HostSample
from gputaskman.host import to_dict as host_to_dict
from gputaskman.pdh import ProcGpu
-from gputaskman.procinfo import ProcDetail
+from gputaskman.procinfo import MappedModel, ProcDetail
from gputaskman.report import dump, to_dict, to_json_dict
GiB = 1 << 30
@@ -180,6 +180,18 @@ class RunTests(unittest.TestCase):
class MakeSampleTests(unittest.TestCase):
+ def test_path_argument_provenance_and_unknown_residency_survive_recording(self):
+ s = snapshot()
+ s.procs[0].detail.models = [MappedModel("custom.gguf", GiB, None, True, ["path-arg"])]
+ clock, output = Clock(), io.StringIO()
+ sample = record.make_sample(lambda: s)
+ record.run(sample, output, interval=1, duration=1, clock=clock, sleep=clock.sleep)
+ data = json.loads(output.getvalue())
+ self.assertEqual(data, json.loads(dump(s, True)))
+ self.assertEqual(data["processes"][0]["model_files"][0]["sources"], ["path-arg"])
+ self.assertIsNone(data["processes"][0]["model_files"][0]["resident"])
+ self.assertNotIn("llm", data["processes"][0])
+
def test_a_record_is_the_object_json_prints(self):
sample = record.make_sample(snapshot, host_sample)
self.assertEqual(json.loads(json.dumps(sample(), default=str)),