Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package gputaskman for openSUSE:Factory checked in at 2026-11-21 21:47:44 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/gputaskman (Old) and /work/SRC/openSUSE:Factory/.gputaskman.new.1340718 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "gputaskman" Sat Nov 21 21:47:44 2026 rev:5 rq:1399595 version:0.4.4 Changes: -------- --- /work/SRC/openSUSE:Factory/gputaskman/gputaskman.changes 2026-11-17 17:20:44.520481585 +0100 +++ /work/SRC/openSUSE:Factory/.gputaskman.new.1340718/gputaskman.changes 2026-11-21 21:49:46.212654210 +0100 @@ -1,0 +2,9 @@ +Sat Nov 21 07:06:05 UTC 2026 - Martin Pluskal <[email protected]> + +- Update to version 0.4.4: + * Show macOS compressed graphics memory in Paged column. + * Resolve relative model flags against the target process cwd. + * Clarify Apple Foundation Models runs on Neural Engine, not GPU. + * Detect NVIDIA MCDM compute GPUs through NVML on Windows. + +------------------------------------------------------------------- Old: ---- gputaskman-0.4.3.tar.gz New: ---- gputaskman-0.4.4.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ gputaskman.spec ++++++ --- /var/tmp/diff_new_pack.NNldFU/_old 2026-11-21 21:49:46.941685348 +0100 +++ /var/tmp/diff_new_pack.NNldFU/_new 2026-11-21 21:49:46.944685476 +0100 @@ -19,7 +19,7 @@ # Single-flavour application: build against the primary python only, tracking it as it moves. %define pythons %{primary_python} Name: gputaskman -Version: 0.4.3 +Version: 0.4.4 Release: 0 Summary: GPU task manager with per-process VRAM and LLM insights License: MIT ++++++ gputaskman-0.4.3.tar.gz -> gputaskman-0.4.4.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/gputaskman-0.4.3/AGENTS.md new/gputaskman-0.4.4/AGENTS.md --- old/gputaskman-0.4.3/AGENTS.md 2026-11-16 00:27:14.000000000 +0100 +++ new/gputaskman-0.4.4/AGENTS.md 2026-11-17 22:41:52.000000000 +0100 @@ -54,7 +54,7 @@ ├─ adapters dxgi.py (Windows; tcc.py adds NVIDIA TCC GPUs that DXGI omits) / linux.enumerate_adapters / macos.enumerate_adapters ├─ counters pdh.py GpuCounters (Windows PDH) / tcc.py TccCounters (NVML, TCC GPUs on Windows) / │ linux.py LinuxCounters (NVML, + drm.py for amdgpu and Intel) / - │ macos.py MacCounters (IOKit Metal clients + footprint poller) + │ macos.py MacCounters (IOKit Metal clients + footprint poller: dirty and swapped graphics bytes) ├─ device metrics nvml.py; drm.py read_device (AMD and Intel, Linux) (macOS: MacCounters.device from IOKit) ├─ WSL host wslhost.py: HostStream (powershell PDH via interop), ContextTracker ├─ processes procinfo.py: runtime DLLs, mapped files, cmdline, classify() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/gputaskman-0.4.3/README.md new/gputaskman-0.4.4/README.md --- old/gputaskman-0.4.3/README.md 2026-11-16 00:27:14.000000000 +0100 +++ new/gputaskman-0.4.4/README.md 2026-11-17 22:41:52.000000000 +0100 @@ -478,7 +478,8 @@ | GPU memory (header) | IOAccelerator `PerformanceStatistics`: `Alloc system memory` (all GPU allocations) out of physical RAM | device | | GPU% (header) | `Device Utilization %` | device | | GPU% | Each Metal client (`AGXDeviceUserClient`) names its creator PID and keeps a cumulative `accumulatedGPUTime`; the rate between samples, per client (a closed client never hides the others' work) | every process | -| VRAM | `footprint`: the process's memory macOS charges to graphics (the `(graphics)` categories: Metal buffers, textures) | your own processes | +| VRAM | `footprint`: dirty bytes of the categories macOS charges to graphics (the `(graphics)` categories: Metal buffers, textures) | your own processes | +| Paged | `footprint` `swapped` bytes of those same graphics categories (compressed graphics memory) | your own processes | | Runtime, model files | Mapped files from `proc_pidinfo` region walks (psutil has no memory maps on macOS): `libggml*.dylib`, `libllama*.dylib`, `libmlx*.dylib`, `libtorch_cpu.dylib`, the Metal driver bundle | your own processes | Other users' processes (WindowServer, system daemons) show GPU% with memory `n/a`: `footprint` needs @@ -491,14 +492,26 @@ Metal reports one GPU time per process, with no 3D/compute/copy/video split, so those columns show `n/a`; a Metal process above 10% GPU is classified `3D/game` unless something more specific applies -(AI runtime, browser, compositor). Spill, paged, clocks, power, and temperature are not available, so -the chart picker offers only GPU and GPU memory. Handy's log is read from +(AI runtime, browser, compositor). Spill, clocks, power, and temperature are not available, so +the chart picker offers only GPU and GPU memory. Paged is footprint's swapped graphics bytes, including +a measured 0, and is `n/a` when footprint did not report `swapped` or could not read the process. It is +not added to the VRAM column and it is not the Windows commit estimate. Handy's log is read from `~/Library/Logs/com.pais.handy/handy.log`. Live check on an M4 Mac mini (macOS 26.3.1): a PyTorch MPS job with a 2 GiB buffer and a matmul loop showed `Python AI PyTorch+Metal 3.06 GB 99%`, with device utilization at 99% and allocated GPU memory rising by the same amount. +**Apple Foundation Models (Apple Intelligence's on-device model) does not show up, because it is not GPU +work.** An app that calls `FoundationModels` hands the request to `TGOnDeviceInferenceProviderService`, run +by the `_modelmanagerd` user. That process opens Neural Engine clients (`H1xANELoadBalancerDirectPathClient`) +and no Metal clients, so it has no GPU time or graphics memory to show. macOS exposes no per-process or +device-wide Neural Engine utilization without root (`powermetrics`), so gputaskman does not guess one. +Live check on an M5 Pro (macOS 27.2.1, 24 GB): a Swift loop of `LanguageModelSession.respond` calls, +each about 2,000 characters in 10-20 s, alternated three times with idle windows of 10 s. Device +utilization was 0% in all three AFM windows, the per-process Metal GPU time totaled 9-10% in AFM windows +and 6-12% in idle ones, and neither the calling process nor the AFM worker gained a Metal client. + Scans skip other apps' sandbox containers (`~/Library/Containers`, `~/Library/Group Containers`) and system files without opening them: opening a file in a protected container blocks while macOS waits for a privacy consent prompt. @@ -628,7 +641,7 @@ one of these adapters: NVIDIA adapters are listed first, followed by other vendors, with each group ordered by dedicated memory. An out-of-range index is rejected rather than silently selecting another device. Compute-only devices such as an -NPU are not graphics adapters and are not listed; an NVIDIA GPU in TCC mode is the exception +NPU are not graphics adapters and are not listed; NVIDIA GPUs in TCC or MCDM mode are exceptions (below). AMD and NVIDIA hardware coverage is described below; configurations with multiple GPUs and mixed vendors need further hardware validation. `--once` and `--json` still default to GPU 0; use `--gpu N` to collect another device without changing the snapshot format. @@ -639,16 +652,15 @@ An NVIDIA GPU in **TCC** mode (a datacenter card, or a mining card such as the P102-100) has no display driver, so Windows lists no adapter for it and publishes no GPU counters. On Windows, -gputaskman asks NVML, once when it starts, for TCC devices that DXGI did not list and adds them +gputaskman asks NVML, once when it starts, for TCC and MCDM devices that DXGI did not list and adds them **after** the listed adapters, so no existing GPU number moves. `--list-gpus` marks them -`TCC compute-only` with their PCI address (including the PCI domain when nonzero), and `--gpu N` -selects one. Adapter VRAM and each -process's VRAM come from NVML. NVML documents per-process memory as always unavailable under WDDM +`TCC compute-only` or `MCDM compute-only` with their PCI address (including the PCI domain when +nonzero), and `--gpu N` selects one. Adapter VRAM and each process's VRAM come from NVML. NVML documents per-process memory as always unavailable under WDDM (Windows manages it, not the NVIDIA driver), so a TCC GPU is where it should be reported; a process whose memory the driver does not report is `n/a`, never 0. Engine load, shared memory and commit are -`n/a`, and no model breakdown is attempted because it needs the shared memory counter too. A TCC GPU +`n/a`, and no model breakdown is attempted because it needs the shared memory counter too. A TCC/MCDM GPU added or removed while gputaskman runs needs a restart to be noticed. This is covered by mocks, and -`--list-gpus` reports whether NVML found no TCC GPU or could not complete its probe; raw driver +`--list-gpus` reports whether NVML found no TCC/MCDM GPU or could not complete its probe; raw driver exception details are not printed. To validate a real TCC card, run `gputaskman --list-gpus`, then `gputaskman --once --gpu N` for the TCC index and compare device and per-process VRAM with `nvidia-smi` under the same workload. Record the GPU, driver and workload. The same code path was run @@ -657,6 +669,16 @@ `n/a`, as NVML documents for WDDM). It is **not validated on TCC hardware**, so per-process VRAM on a real TCC card is expected, not confirmed. +MCDM adapters use this same NVML path. Device pairing preserves the full PCI domain; +JSON includes `adapter.pci_domain` for TCC/MCDM adapters even when telemetry is unavailable, +so `diff` can distinguish GPUs with the same bus/device/function in different domains. +Per-process memory remains unknown when the driver does not supply it. + +Live check: Windows ARM64, NVIDIA GB300, driver 621.01, MCDM, PCI 00000009:06:00.0, +alongside an RTX PRO 4000. Discovery, device memory, utilization, temperature, power, +and existing compute-process enumeration worked. Per-process VRAM was unavailable. +No controlled workload was launched, and the interactive UI was not visually validated. + On Windows, each exact DXGI LUID is also resolved through `DisplayConfigGetDeviceInfo` to its PnP device interface, including inactive displays, then read through SetupAPI. A `ROOT\DISPLAY` instance uses its PnP friendly name (device description as fallback) and is labelled `ROOT display @@ -884,7 +906,7 @@ | Question | Evidence | Confidence / limitation | |---|---|---| | How full and busy is the card? | WDDM adapter counters and NVML or AMD ADL/SMI | Measured; driver support varies by metric | -| Which process uses GPU memory? | WDDM process counters; NVML on Linux and for TCC GPUs | Measured accounting, not a resource ownership graph | +| Which process uses GPU memory? | WDDM process counters; NVML on Linux and for TCC/MCDM GPUs | Measured accounting, not a resource ownership graph | | Which WSL process uses GPU memory? | Windows host counters for `vmwp.exe`, matched to Linux processes | Exact VM total; per-process owner inferred (`*`) or guessed (`?`) | | Which engines are active? | WDDM engine counters | CUDA can appear on the **3D** engine | | Which runtime is loaded? | Mapped DLL names | Detection, not proof that every library is doing GPU work | @@ -1081,7 +1103,7 @@ | 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 PnP driver-version lookup | 0.016 ms median, 0.019 ms max in 30 reads; first query 0.044 ms (Windows 11 ARM64 build 28000.3231, Snapdragon X2 Elite / Adreno X2-85, driver 32.0.163.2) | Once when a collector is created; reads the selected adapter's exact PnP `Driver` and `DriverVersion` registry values. Missing values stay unknown; other systems unmeasured | | 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 | -| Windows TCC discovery (NVML init, device count, one driver-model read per GPU, shutdown) | First call in 15 fresh processes on the same machine, one WDDM GPU: median 37.6 ms, 27.8-43.8 ms. About 15 ms of that is the first `nvmlInit` (it loads `nvml.dll`), which NVML readings pay anyway; the added cost is one extra init-to-shutdown cycle, median 20.7 ms (13.3-30.3 ms). Later calls are cached (about 3 µs). A TCC GPU adds PCI, name and memory reads, which are unmeasured (no TCC hardware here) | Once per process on Windows, including `--list-gpus`; never repeated while running | +| Windows TCC/MCDM discovery (NVML init, device count, one driver-model read per GPU, shutdown) | First call in 15 fresh processes on the same machine, one WDDM GPU: median 37.6 ms, 27.8-43.8 ms. About 15 ms of that is the first `nvmlInit` (it loads `nvml.dll`), which NVML readings pay anyway; the added cost is one extra init-to-shutdown cycle, median 20.7 ms (13.3-30.3 ms). Later calls are cached (about 3 µs). A TCC GPU adds PCI, name and memory reads, which are unmeasured (no TCC hardware here) | Once per process on Windows, including `--list-gpus`; never repeated while running | | 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 | @@ -1277,7 +1299,7 @@ | `wslhost.py` | WSL: interop check, Windows host counter stream, adapter pairing, context matching | | `macos.py` | macOS backend: IOKit device stats and per-process GPU time, `footprint` GPU memory poller, libproc memory maps | | `nvml.py` | NVIDIA device readings | -| `tcc.py` | NVIDIA TCC-mode GPUs on Windows: finds the ones DXGI does not list, and reads their VRAM and per-process VRAM from NVML | +| `tcc.py` | NVIDIA TCC/MCDM GPUs on Windows: finds the ones DXGI does not list, and reads their VRAM and per-process VRAM from NVML | | `adl.py`, `amdsmi.py` | Optional AMD device readings | | `procinfo.py` | Runtime, mapped-file, and process discovery | | `stores.py` | Friendly names from Ollama, LM Studio, and Hugging Face model stores | @@ -1300,8 +1322,7 @@ the Windows counters would supply for a WDDM GPU. - Intel `xe` device-wide telemetry and controlled-load/shared-buffer validation of its per-process counters; Intel validation beyond the Arc A770 / UHD 730 pair. -- macOS: a portable build, Ollama/llama.cpp/MLX validation, and compressed GPU memory (footprint's - `swapped`) as the paged column. +- macOS: a portable build and Ollama/llama.cpp/MLX validation. - WSL: per-process GPU load for Linux rows, and Ollama's systemd journal as a log source. - Live throughput deltas, LM Studio validation, and per-model context accounting. - Opt-in ETW file-open tracing to name models loaded by read-and-close runtimes (any whisper or ONNX diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/gputaskman-0.4.3/pyproject.toml new/gputaskman-0.4.4/pyproject.toml --- old/gputaskman-0.4.3/pyproject.toml 2026-11-16 00:27:14.000000000 +0100 +++ new/gputaskman-0.4.4/pyproject.toml 2026-11-17 22:41:52.000000000 +0100 @@ -1,6 +1,6 @@ [project] name = "gputaskman" -version = "0.4.3" +version = "0.4.4" description = "An htop for what's inside your GPU: per-process VRAM, engine load, and LLM weights / KV cache breakdown" readme = "README.md" license = "MIT" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/gputaskman-0.4.3/src/gputaskman/app.py new/gputaskman-0.4.4/src/gputaskman/app.py --- old/gputaskman-0.4.3/src/gputaskman/app.py 2026-11-16 00:27:14.000000000 +0100 +++ new/gputaskman-0.4.4/src/gputaskman/app.py 2026-11-17 22:41:52.000000000 +0100 @@ -122,8 +122,10 @@ allocations, not just overflow. Large usage under VRAM pressure can indicate fallback; the counter alone does not prove it. -**PAGED** = max(Total Committed - Local Usage - Non Local Usage, 0). This is an estimate of +**PAGED** on Windows is max(Total Committed - Local Usage - Non Local Usage, 0), an estimate of non-resident committed memory, not a measured eviction count or proof of pagefile activity. +On macOS the same column is footprint's swapped bytes in graphics categories: compressed graphics +memory, measured on its own and kept out of the VRAM column. **Inside** labels are inferred from runtimes and files. Log sizes describe allocated buffers, not necessarily current residency. A game's textures cannot be enumerated here. @@ -215,7 +217,8 @@ Binding("question_mark", "help", "Explain"), ] SORTS = [("VRAM", lambda r: -(r.gpu.shown_vram or 0)), ("GPU%", lambda r: -r.gpu.gpu_pct), - ("Shared", lambda r: -r.gpu.shared), ("paged", lambda r: -r.gpu.paged_out), + ("Shared", lambda r: -r.gpu.shared), + ("paged", lambda r: -(r.gpu.paged_out if r.gpu.graphics_swapped is None else r.gpu.graphics_swapped)), ("name", lambda r: r.name.lower())] SYSTEM_SORTS = [("RAM", lambda r: (r.ram is None, -(r.ram or 0))), # unknown last; a measured 0 is not unknown ("CPU%", lambda r: (r.cpu is None, -(r.cpu or 0)))] @@ -700,7 +703,7 @@ rows = s.procs if not self.show_all: rows = [r for r in rows if not r.gpu.attributed or r.gpu.dedicated >= 32 << 20 or r.gpu.gpu_pct >= 1 or r.gpu.shared >= 64 << 20 - or r.gpu.paged_out >= 128 << 20 or r.llm] + or r.gpu.paged_out >= 128 << 20 or (r.gpu.graphics_swapped or 0) >= 128 << 20 or r.llm] rows = sorted(rows, key=self.sorts[self.sort_idx][1]) vm = next((i for i, r in enumerate(rows) if r.kind == "wsl-vm"), None) if vm is not None and self.sorts[self.sort_idx][0] == "VRAM": @@ -741,6 +744,9 @@ shared = Text("n/a", justify="right", style="grey62") if wddm and not r.gpu.paged_available: paged = Text("n/a", justify="right", style="grey62") + if s.backend == "metal": + paged = Text("n/a" if not r.gpu.attributed or r.gpu.graphics_swapped is None else gb(r.gpu.graphics_swapped), + justify="right", style="grey62") system_cells = [] if self.system: known = r.ram is not None # "…": readable, CPU% needs one more sample; "n/a": the OS wouldn't say @@ -790,10 +796,15 @@ e = r.gpu.engines wddm = has_wddm_counters(s, r) engines = " ".join(f"{k} {v:.0f}%" for k, v in e.items() if v >= 0.5) or "idle" + if s.backend == "metal": + swapped = "n/a" if not r.gpu.attributed or r.gpu.graphics_swapped is None else gb(r.gpu.graphics_swapped) + paged_text = (" compressed ", swapped) + else: + paged_text = (" paged(est) ", gb(r.gpu.paged_out) if wddm and r.gpu.paged_available else "n/a") hdr = Text.assemble(("VRAM ", "bold"), (vram_label(r.gpu), "bold"), " shared(RAM) ", (gb(r.gpu.shared) if has_shared_counters(s, r) else "n/a", "bold red" if r.gpu.shared > 256 << 20 and s.shared_is_spill else ""), - " paged(est) ", gb(r.gpu.paged_out) if wddm and r.gpu.paged_available else "n/a", + paged_text[0], paged_text[1], " engines ", engines if has_engine_counters(s, r) else "n/a") if r.detail.runtimes: hdr.append(" runtime ", style="grey62") @@ -810,8 +821,13 @@ out.append(Text(drm_note(r.gpu), style="grey62")) elif s.backend == "metal": out.append(Text("GPU memory n/a: footprint can't read other users' processes without root " - "(or hasn't measured this one yet). GPU% comes from Metal's per-process GPU time.", + "(or hasn't measured this one yet). GPU% comes from Metal's per-process GPU time. " + "Compressed graphics memory is n/a for the same reason.", style="grey62")) + if s.backend == "metal" and r.gpu.attributed: + out.append(Text("Compressed is footprint's swapped bytes in graphics categories. " + "It is not added to VRAM, and it is not the Windows paged estimate.", + style="grey62")) if s.backend == "drm" and not r.host and (r.gpu.resident_vram is not None or r.gpu.resident_gtt is not None): def size(v): return gb(v) if v is not None else "n/a" out.append(Text(f"Resident VRAM {size(r.gpu.resident_vram)}, GTT {size(r.gpu.resident_gtt)}. " diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/gputaskman-0.4.3/src/gputaskman/cli.py new/gputaskman-0.4.4/src/gputaskman/cli.py --- old/gputaskman-0.4.3/src/gputaskman/cli.py 2026-11-16 00:27:14.000000000 +0100 +++ new/gputaskman-0.4.4/src/gputaskman/cli.py 2026-11-17 22:41:52.000000000 +0100 @@ -167,7 +167,7 @@ if isinstance(adapter, TccAdapter): # its LUID is made up from the PCI identity, so show the address bus, device, function = adapter.pci_address pci = f"{adapter.pci_domain:08x}:" if adapter.pci_domain else "" - print(f"{i}: {adapter.name} ({adapter.vendor}, TCC compute-only, " + print(f"{i}: {adapter.name} ({adapter.vendor}, {adapter.driver_model} compute-only, " f"PCI {pci}{bus:02x}:{device:02x}.{function:x})") else: print(f"{i}: {adapter.name} ({adapter.vendor}, LUID 0x{adapter.luid & 0xffffffffffffffff:016x})") @@ -175,7 +175,7 @@ print(f" {adapter.identity_status}") status = tcc_discovery_status() if status: - print(f"TCC discovery: {status}", file=sys.stderr) + print(f"TCC/MCDM discovery: {status}", file=sys.stderr) if BACKEND == "wsl" and (not adapters or any(a.vendor_id == VENDOR_AMD for a in adapters)): from .amdsmi import amdsmi_status diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/gputaskman-0.4.3/src/gputaskman/collector.py new/gputaskman-0.4.4/src/gputaskman/collector.py --- old/gputaskman-0.4.3/src/gputaskman/collector.py 2026-11-16 00:27:14.000000000 +0100 +++ new/gputaskman-0.4.4/src/gputaskman/collector.py 2026-11-17 22:41:52.000000000 +0100 @@ -10,7 +10,7 @@ import psutil -from .amdsmi import AmdSmi, _bdf, amdsmi_status +from .amdsmi import AmdSmi, amdsmi_status from .adl import Adl from .dxgi import (VENDOR_AMD, VENDOR_NVIDIA, VENDOR_HUAWEI, VENDOR_INTEL, VENDOR_QUALCOMM, Adapter, adapter_driver_version) @@ -20,7 +20,7 @@ from .nvml import Nvml, NvDevice from .pdh import ProcGpu from .procinfo import AI_KINDS, ProcDetail, ProcInspector, classify -from .tcc import TccAdapter, TccCounters, tcc_adapters +from .tcc import TccAdapter, TccCounters, _pci_identity, tcc_adapters from .telemetry import DeviceTelemetry if sys.platform == "win32": @@ -159,9 +159,10 @@ def _is_live(g: ProcGpu) -> bool: + # graphics_swapped is macOS compressed graphics memory and is not added to dedicated. return ( bool(g.engine_reason) or not g.attributed or g.dedicated >= MiB or g.gpu_pct >= 0.5 - or g.shared >= 16 * MiB or g.paged_out >= 16 * MiB + or g.shared >= 16 * MiB or g.paged_out >= 16 * MiB or (g.graphics_swapped or 0) >= 16 * MiB ) @@ -183,6 +184,16 @@ key=lambda a: (isinstance(a, TccAdapter), a.vendor_id != VENDOR_NVIDIA, -a.dedicated_vram, a.luid)) +def _wddm_bdf(pci_bus) -> tuple[int, int, int] | None: + """An NVML PCI address in WDDM's ADAPTERADDRESS form. Windows puts the PCI segment above the 8-bit + bus (segment 15 bus 1 is bus 0xF01), so domain-0 addresses are unchanged.""" + identity = _pci_identity(pci_bus) + if identity is None: + return None + domain, (bus, device, function) = identity + return domain << 8 | bus, device, function + + def select_nv_device(adapter: Adapter | None, devices: list[NvDevice], gpu_index: int, adapters: list[Adapter] | None = None) -> NvDevice | None: if adapter: @@ -193,13 +204,16 @@ matches = [d for d in devices if d.pci_bus and pci_key(d.pci_bus) == adapter.luid] return matches[0] if len(matches) == 1 else None if isinstance(adapter, TccAdapter): - matches = [d for d in devices if adapter.matches_pci(d.pci_bus) and d.driver_model == "TCC"] + matches = [d for d in devices if adapter.matches_pci(d.pci_bus) and d.driver_model == adapter.driver_model] return matches[0] if len(matches) == 1 else None if adapter.pci_address is None: return None - if adapters is not None and sum(a.pci_address == adapter.pci_address for a in adapters) != 1: + # MCDM telemetry is ineligible for a DXGI adapter below, so its known compute-only + # adapter cannot make a WDDM peer at the same BDF in another PCI domain ambiguous. + if adapters is not None and sum(a.pci_address == adapter.pci_address for a in adapters + if not (isinstance(a, TccAdapter) and a.driver_model == "MCDM")) != 1: return None - matches = [d for d in devices if _bdf(d.pci_bus) == adapter.pci_address and d.driver_model != "MCDM"] + matches = [d for d in devices if _wddm_bdf(d.pci_bus) == adapter.pci_address and d.driver_model != "MCDM"] if len(matches) == 1: return matches[0] return None @@ -415,10 +429,10 @@ snap.counter_adapter_matched = luid in per_luid or luid in adapters if isinstance(self.adapter, TccAdapter): snap.counter_status = ( - "TCC compute-only GPU: Windows publishes no GPU counters for it, so VRAM and processes come " + f"{self.adapter.driver_model} compute-only GPU: VRAM and processes come " "from NVML. Per-process engine load, shared memory and commit are n/a, and per-process VRAM " "is n/a when the driver does not report it." if snap.counter_adapter_matched else - "NVML could not read this TCC GPU; VRAM and processes are unavailable.") + f"NVML could not read this {self.adapter.driver_model} GPU; VRAM and processes are unavailable.") elif not snap.counter_adapter_matched: snap.counter_status = ("Windows GPU counters could not be matched to the selected adapter; " "VRAM and processes are unavailable. The adapter may be temporarily " @@ -427,7 +441,7 @@ snap.counter_status = ("Some Windows adapter memory counters are unavailable; " "GPU-PV VMs may not expose them.") if (nv is None and self.adapter.vendor_id == VENDOR_NVIDIA and self.adapter.pci_address - and any(_bdf(b) == self.adapter.pci_address for b in nvml_mod.LOST)): + and any(_wddm_bdf(b) == self.adapter.pci_address for b in nvml_mod.LOST)): snap.nv_lost = True snap.counter_status = " ".join(filter(None, ( snap.counter_status, "NVIDIA telemetry stopped after this GPU was re-enabled; " diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/gputaskman-0.4.3/src/gputaskman/diff.py new/gputaskman-0.4.4/src/gputaskman/diff.py --- old/gputaskman-0.4.3/src/gputaskman/diff.py 2026-11-16 00:27:14.000000000 +0100 +++ new/gputaskman-0.4.4/src/gputaskman/diff.py 2026-11-17 22:41:52.000000000 +0100 @@ -9,6 +9,7 @@ import json import math +import re from .llm import gb @@ -16,7 +17,8 @@ NOISE = 16 * MiB # smaller per-process moves are allocator and compositor churn, not a model loading SAME_PROCESS_SECS = 2.0 # one process's start time can move this much between runs (Linux boot-time rounding, clock steps) MEASURED = ("vram_bytes", "shared_bytes", "committed_bytes", "paged_out_bytes", - "vram_resident_bytes", "gtt_resident_bytes") # resident: amdgpu, shared buffers included (never summed) + "vram_resident_bytes", "gtt_resident_bytes", # resident: amdgpu, shared buffers included (never summed) + "graphics_swapped_bytes") # macOS footprint swapped graphics bytes; not the Windows paged estimate DEVICE = (("vram_used", "dedicated used"), ("shared_used", "shared used"), ("attributed", "attributed to processes"), ("unattributed", "unattributed")) SEGMENT_ORDER = ("weights", "kv", "compute", "runtime", "unknown") @@ -169,15 +171,30 @@ def _identity(s: dict) -> dict: - """What a snapshot says about its adapter that can be compared: vendor, PCI address, adapter key. + """Comparable adapter identity: vendor, PCI address (including a known domain), and adapter key. - Missing, zero (unknown) and malformed values are left out, so they can never conflict.""" + Missing and malformed values are left out. Zero vendor IDs and adapter keys are unknown; + zero PCI components, including the domain, are valid identity values.""" a = s.get("adapter") a = a if isinstance(a, dict) else {} out = {name: a[field] for field, name in (("vendor_id", "vendor"), ("luid", "key")) if _num(a.get(field))} pci = a.get("pci_address") if isinstance(pci, (list, tuple)) and len(pci) == 3 and all(_num(x) is not None and x >= 0 for x in pci): out["pci"] = tuple(pci) + domain = _num(a.get("pci_domain")) + if domain is not None and 0 <= domain <= 0xffffffff: + out["pci_domain"] = domain + else: + # Older snapshots kept the full PCI address only in device telemetry. + device = s.get("device") + bus_id = device.get("pci_bus") if isinstance(device, dict) else None + if isinstance(bus_id, str): + full = re.fullmatch(r"([0-9a-fA-F]{1,8}):([0-9a-fA-F]{1,2}):([0-9a-fA-F]{1,2})\.([0-7])", bus_id) + if full: + domain, bus, slot, function = (int(part, 16) for part in full.groups()) + # Telemetry augments this adapter's identity only when their BDFs agree. + if slot <= 0x1f and (bus, slot, function) == out.get("pci"): + out["pci_domain"] = domain return out @@ -199,6 +216,8 @@ if "pci" in b and "pci" in a: if b["pci"] != a["pci"]: raise different("PCI " + " vs ".join("{:02x}:{:02x}.{}".format(*x) for x in (b["pci"], a["pci"]))) + if "pci_domain" in b and "pci_domain" in a and b["pci_domain"] != a["pci_domain"]: + raise different(f"PCI domains {b['pci_domain']:08x} vs {a['pci_domain']:08x}") return "pci", None if "key" in b and "key" in a: if b["key"] == a["key"]: @@ -302,6 +321,13 @@ for p in procs: detail = [] + swapped = p["measured"]["graphics_swapped_bytes"] + delta = swapped["delta"] # a measured 0 on a new row is not a change + sides = [v for v in (swapped["before"], swapped["after"]) + if isinstance(v, (int, float)) and not isinstance(v, bool)] + if (delta is not None and abs(delta) >= NOISE) or (delta is None and any(abs(v) >= NOISE for v in sides)): + detail.append(f" compressed graphics (footprint swapped) {_gb(swapped['before'])} -> " + f"{_gb(swapped['after'])} {_signed(swapped['delta'])}") inf = p["inferred"]["vram_inferred_bytes"] if _moved(inf): detail.append(f" inferred VRAM (WSL context match) {_gb(inf['before'])} -> {_gb(inf['after'])}" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/gputaskman-0.4.3/src/gputaskman/macos.py new/gputaskman-0.4.4/src/gputaskman/macos.py --- old/gputaskman-0.4.3/src/gputaskman/macos.py 2026-11-16 00:27:14.000000000 +0100 +++ new/gputaskman-0.4.4/src/gputaskman/macos.py 2026-11-17 22:41:52.000000000 +0100 @@ -19,6 +19,7 @@ import ctypes import json +import math import os import plistlib import re @@ -85,9 +86,29 @@ return dict(out) +def _graphics_categories(process: dict) -> list: + return [v for k, v in (process.get("categories") or {}).items() if str(k).endswith("(graphics)")] + + def graphics_bytes(process: dict) -> int: """footprint JSON: dirty bytes of the categories macOS charges to graphics.""" - return int(sum(v.get("dirty", 0) for k, v in (process.get("categories") or {}).items() if k.endswith("(graphics)"))) + return int(sum(v.get("dirty", 0) for v in _graphics_categories(process) if isinstance(v, dict))) + + +def graphics_swapped(process: dict) -> int | None: + """Swapped bytes of those same categories. None if one omits ``swapped``; no categories is a measured 0.""" + categories = _graphics_categories(process) + if not categories: + return 0 + total = 0 + for category in categories: + if not isinstance(category, dict) or "swapped" not in category: + return None + swapped = category["swapped"] + if isinstance(swapped, bool) or not isinstance(swapped, (int, float)) or not math.isfinite(swapped) or swapped < 0: + return None # not a byte count: unknown, not a partial sum + total += int(swapped) + return total def physical_memory() -> int: @@ -143,7 +164,7 @@ self._run = run self._clock = clock self._targets: dict[int, tuple[object, bool]] = {} # pid -> (identity, busy), busiest first - self._sizes: dict[int, tuple[object, int]] = {} # pid -> (identity, graphics bytes) + self._sizes: dict[int, tuple[object, tuple[int, int | None]]] = {} # pid -> (identity, (dirty, swapped)) self._due: dict[int, float] = {} self._fails: dict[int, int] = {} self._retry: dict[int, float] = {} @@ -172,12 +193,12 @@ store.pop(pid, None) self._wake.set() - def get(self, pid: int, identity: object = None) -> int | None: + def get(self, pid: int, identity: object = None) -> tuple[int, int | None] | None: with self._lock: hit = self._sizes.get(pid) return hit[1] if hit and hit[0] == identity else None - def measure(self, pid: int) -> int | None: + def measure(self, pid: int) -> tuple[int, int | None] | None: with tempfile.TemporaryDirectory() as d: path = os.path.join(d, "fp.json") try: @@ -189,7 +210,7 @@ return None for p in data.get("processes") or []: if p.get("pid") == pid: - return graphics_bytes(p) + return graphics_bytes(p), graphics_swapped(p) return None def poll_once(self) -> None: @@ -319,6 +340,9 @@ self._owners[pid] = self._owner(pid) mine = self._root or self._owners[pid] == self._uid g = ProcGpu() + # No commit counter, so the Windows paged estimate stays unavailable. "shared" stays in the + # set: the column is never shown on macOS, and the LLM breakdown gate still requires it. + g.available.discard("committed") if pct is None: g.available.discard("engine") elif pct: @@ -332,7 +356,9 @@ if size is None: g.attributed = False # not measured yet (or footprint failed): unknown, not zero else: - g.dedicated = float(size) + dirty, swapped = size + g.dedicated = float(dirty) # dirty only; swapped is not resident graphics memory + g.graphics_swapped = None if swapped is None else float(swapped) else: g.attributed = False # footprint needs root for other users' processes if (pct is None or pct < 0.5) and self._name(pid).lower() not in ALWAYS_SHOWN: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/gputaskman-0.4.3/src/gputaskman/pdh.py new/gputaskman-0.4.4/src/gputaskman/pdh.py --- old/gputaskman-0.4.3/src/gputaskman/pdh.py 2026-11-16 00:27:14.000000000 +0100 +++ new/gputaskman-0.4.4/src/gputaskman/pdh.py 2026-11-17 22:41:52.000000000 +0100 @@ -101,6 +101,9 @@ resident_gtt: float | None = None drm_reason: str = "" # DRM fdinfo: why dedicated/shared are n/a (drm.REASON_*); empty when they are measured kfd: bool = False # amdgpu: holds /dev/kfd (ROCm/HIP), whose compute isn't timed per process + # macOS footprint: swapped bytes in categories charged to graphics. None when footprint did not report + # the field. Never derived from commit minus resident, and never added to dedicated. + graphics_swapped: float | None = None @property def shown_vram(self) -> float | None: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/gputaskman-0.4.3/src/gputaskman/procinfo.py new/gputaskman-0.4.4/src/gputaskman/procinfo.py --- old/gputaskman-0.4.3/src/gputaskman/procinfo.py 2026-11-16 00:27:14.000000000 +0100 +++ new/gputaskman-0.4.4/src/gputaskman/procinfo.py 2026-11-17 22:41:52.000000000 +0100 @@ -233,15 +233,39 @@ return flags -def _models_from_cmdline(cmd: list[str]) -> list[str]: +def _process_cwd(pid: int | None) -> str: + """The target process's working directory, or "" when it is unknown or not absolute.""" + if pid is None: + return "" + try: + cwd = psutil.Process(pid).cwd() + except (psutil.Error, OSError): + return "" + return cwd if cwd and os.path.isabs(cwd) else "" + + +def _models_from_cmdline(cmd: list[str], pid: int | None = None) -> list[str]: + """Model paths given to known model flags. A relative path is resolved against the target's cwd + (looked up once, only when needed), never the monitor's; it is skipped when that cwd is unknown.""" paths = [] flags = _model_flags(cmd) + cwd, cwd_checked = "", False for i, arg in enumerate(cmd): val = None key, sep, value = arg.partition("=") if key in flags: val = value if sep else (cmd[i + 1] if i + 1 < len(cmd) else None) - if val and os.path.isfile(val): + if not val: + continue + if not os.path.isabs(val): + if not cwd_checked: + cwd, cwd_checked = _process_cwd(pid), True + if not cwd: + continue + val = os.path.join(cwd, val) + if not os.path.isabs(val): + continue # e.g. a Windows drive-relative path on another drive + if os.path.isfile(val): paths.append(os.path.abspath(val)) return paths @@ -298,12 +322,8 @@ 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): + cwd, cwd_checked = _process_cwd(d.pid), True + if not cwd: continue path = os.path.join(cwd, path) if not os.path.isabs(path): @@ -550,7 +570,7 @@ store = store_name(path) if _is_model_file(ext, size, gg, store): models[file_key(path)] = make_model(path, size, m.rss, gg, "mapped", store) - for path in _models_from_cmdline(d.cmdline): + for path in _models_from_cmdline(d.cmdline, d.pid): key = file_key(path) if key in models: models[key].add_source("cmdline") diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/gputaskman-0.4.3/src/gputaskman/replay.py new/gputaskman-0.4.4/src/gputaskman/replay.py --- old/gputaskman-0.4.3/src/gputaskman/replay.py 2026-11-16 00:27:14.000000000 +0100 +++ new/gputaskman-0.4.4/src/gputaskman/replay.py 2026-11-17 22:41:52.000000000 +0100 @@ -314,7 +314,15 @@ return "\n".join(lines) -def process_rows(snapshot: dict) -> tuple[list[tuple[str, str, str, str, str, str, str]], list[str]]: +def _paged(snapshot: dict, proc: dict) -> str: + """macOS compressed graphics memory. Blank on other backends; ``n/a`` when a metal row did not record it.""" + if snapshot.get("backend") != "metal": + return "" + number = _number(proc.get("graphics_swapped_bytes")) + return "n/a" if number is None else gb(number) + + +def process_rows(snapshot: dict) -> tuple[list[tuple[str, str, str, str, str, str, str, str]], list[str]]: """Table cells for the recorded processes, in the order the snapshot stored them. Returns the rows and any notes about rows that were not objects. VRAM is the recorded measured @@ -334,6 +342,7 @@ _plain(proc.get("kind")), _vram(proc), _shared(snapshot, proc), + _paged(snapshot, proc), _pct(proc.get("gpu_pct")), _note(proc), )) @@ -380,7 +389,7 @@ def on_mount(self) -> None: table = self.query_one("#procs", DataTable) - for name in ("PID", "Process", "Kind", "VRAM", "Shared", "GPU%", "Note"): + for name in ("PID", "Process", "Kind", "VRAM", "Shared", "Paged", "GPU%", "Note"): table.add_column(name, key=name) panel = self.query_one("#replay", Static) panel.border_title = "GPU Session Replay" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/gputaskman-0.4.3/src/gputaskman/report.py new/gputaskman-0.4.4/src/gputaskman/report.py --- old/gputaskman-0.4.3/src/gputaskman/report.py 2026-11-16 00:27:14.000000000 +0100 +++ new/gputaskman-0.4.4/src/gputaskman/report.py 2026-11-17 22:41:52.000000000 +0100 @@ -10,6 +10,7 @@ from .llm import gb, server_gauge_text from .nvml import format_metric from .pdh import ProcGpu +from .tcc import TccAdapter WSL_HOST_NOTE = ("WSL + Windows host counters: 'WSL VM' is the exact total of Linux GPU memory (all distros). " @@ -91,8 +92,9 @@ METAL_NOTE = ("macOS: unified memory, so GPU memory is part of system RAM. Rows show each process's graphics " - "footprint; other users' processes (WindowServer, daemons) show GPU% only, since reading their " - "memory needs root.") + "footprint (dirty bytes). Paged is footprint's swapped bytes for those same graphics categories, " + "compressed memory, not a Windows commit estimate. Other users' processes (WindowServer, daemons) " + "show GPU% only, since reading their memory needs root.") INTEL_MEMORY_NOTE = ("Intel: used is a sum over inspectable processes (no device counter); " "total is the PCI window size, an estimate. Free is not shown.") WDDM_DEVICE_NOTE = "Windows does not report temperature, power, clocks or PCIe for this GPU." @@ -112,6 +114,9 @@ def to_dict(s: Snapshot) -> dict: nv = dataclasses.asdict(s.nv) if s.nv else None + adapter = dataclasses.asdict(s.adapter) if s.adapter else None + if isinstance(s.adapter, TccAdapter): + adapter["pci_domain"] = s.adapter.pci_domain procs = [] for p in s.procs: wddm = has_wddm_counters(s, p) @@ -130,6 +135,8 @@ "shared_bytes": int(p.gpu.shared) if has_shared_counters(s, p) else None, "committed_bytes": int(p.gpu.committed) if wddm and "committed" in p.gpu.available else None, "paged_out_bytes": int(p.gpu.paged_out) if wddm and p.gpu.paged_available else None, + "graphics_swapped_bytes": (int(p.gpu.graphics_swapped) if s.backend == "metal" and p.gpu.attributed + and p.gpu.graphics_swapped is not None else None), "gpu_pct": round(p.gpu.gpu_pct, 1) if engines else None, "engines": {k: round(v, 1) for k, v in p.gpu.engines.items() if v} if engines else None, "engine_unavailable_reason": p.gpu.engine_reason or None, @@ -159,7 +166,7 @@ procs.append(item) return { "taken": s.taken, "gpu": s.adapter.name if s.adapter else None, "driver": s.driver, "cuda": s.cuda, - "adapter": dataclasses.asdict(s.adapter) if s.adapter else None, + "adapter": adapter, "vram_total": s.vram_total or None, "vram_used": s.vram_used, "shared_used": s.shared_used, "attributed": s.attributed, "backend": s.backend, "shared_is_spill": s.shared_is_spill, "host_status": s.host_status or None, @@ -230,6 +237,8 @@ shared = "N/A" if wddm and not p.gpu.paged_available: paged = "N/A" + if s.backend == "metal": + paged = "N/A" if not p.gpu.attributed or p.gpu.graphics_swapped is None else gb(p.gpu.graphics_swapped) pid = p.pid_label pct = f"{p.gpu.gpu_pct:.0f}" if has_engine_counters(s, p) else "n/a" out.append(f"{pid:>{w}} {p.name[:24]:<24} {p.kind:<10} {p.runtime[:24]:<24} {vram_label(p.gpu):>9} {shared:>8} " diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/gputaskman-0.4.3/src/gputaskman/tcc.py new/gputaskman-0.4.4/src/gputaskman/tcc.py --- old/gputaskman-0.4.3/src/gputaskman/tcc.py 2026-11-16 00:27:14.000000000 +0100 +++ new/gputaskman-0.4.4/src/gputaskman/tcc.py 2026-11-17 22:41:52.000000000 +0100 @@ -1,4 +1,4 @@ -"""NVIDIA GPUs in TCC mode: compute-only, so Windows lists no adapter and publishes no GPU counters for them.""" +"""NVIDIA TCC/MCDM compute GPUs omitted by DXGI, discovered and sampled through NVML.""" from __future__ import annotations @@ -11,17 +11,19 @@ from .pdh import AdapterGpu, ProcGpu NVML_DRIVER_TCC = 1 +NVML_DRIVER_MCDM = 2 class TccAdapter(Adapter): - """A TCC-mode NVIDIA GPU, found through NVML because DXGI does not list it. It adds no fields, so --json - looks the same for every adapter. Its luid is made up from the PCI address, so it is the same on every run - (`diff` pairs adapters by it).""" + """A TCC/MCDM NVIDIA GPU, found through NVML because DXGI does not list it. JSON includes its PCI domain + even when device telemetry is unavailable. Its luid is made up from the PCI address, so it is the same + on every run (`diff` pairs adapters by it).""" def __init__(self, luid: int, name: str, vendor_id: int, dedicated_vram: int, shared_system: int, software: bool, - pci_address: tuple[int, int, int] | None = None, pci_domain: int = 0) -> None: + pci_address: tuple[int, int, int] | None = None, pci_domain: int = 0, driver_model: str = "TCC") -> None: super().__init__(luid, name, vendor_id, dedicated_vram, shared_system, software, pci_address) self._pci_domain = pci_domain + self.driver_model = driver_model @property def pci_domain(self) -> int: @@ -66,7 +68,8 @@ def _read_device(N, index: int) -> TccAdapter | None: handle = _nvml_call(N, "nvmlDeviceGetHandleByIndex", index) - if _nvml_call(N, "nvmlDeviceGetDriverModel", handle)[0] != NVML_DRIVER_TCC: + model = _nvml_call(N, "nvmlDeviceGetDriverModel", handle)[0] + if model not in (NVML_DRIVER_TCC, NVML_DRIVER_MCDM): return None identity = _pci_identity(_nvml_call(N, "nvmlDeviceGetPciInfo", handle).busId) if identity is None: @@ -76,22 +79,23 @@ luid = (1 << 62) | domain << 16 | packed_bdf return TccAdapter(luid=luid, name=_text(_nvml_call(N, "nvmlDeviceGetName", handle)), vendor_id=VENDOR_NVIDIA, dedicated_vram=_nvml_call(N, "nvmlDeviceGetMemoryInfo", handle).total, - shared_system=0, software=False, pci_address=bdf, pci_domain=domain) + shared_system=0, software=False, pci_address=bdf, pci_domain=domain, + driver_model="MCDM" if model == NVML_DRIVER_MCDM else "TCC") def _discover() -> list[TccAdapter]: global _discovery_status N = nvml_mod.N if N is None: - _discovery_status = "NVML is unavailable; TCC GPUs could not be checked." + _discovery_status = "NVML is unavailable; TCC/MCDM GPUs could not be checked." return [] if nvml_mod._unsafe: - _discovery_status = "NVML is marked unsafe; TCC GPUs were not checked." + _discovery_status = "NVML is marked unsafe; TCC/MCDM GPUs were not checked." return [] try: _nvml_call(N, "nvmlInit") except Exception: - _discovery_status = "NVML initialization failed; TCC GPUs could not be checked." + _discovery_status = "NVML initialization failed; TCC/MCDM GPUs could not be checked." return [] found, faulted, failed, shutdown_failed = [], False, False, False try: @@ -118,25 +122,25 @@ except Exception: shutdown_failed = True if nvml_mod._unsafe: - _discovery_status = "NVML encountered an unsafe driver fault; TCC discovery is incomplete." + _discovery_status = "NVML encountered an unsafe driver fault; TCC/MCDM discovery is incomplete." elif failed: - _discovery_status = "NVML TCC discovery was incomplete; one or more devices could not be read." + _discovery_status = "NVML TCC/MCDM discovery was incomplete; one or more devices could not be read." elif found: - _discovery_status = f"NVML TCC discovery succeeded; found {len(found)} TCC GPU(s)." + _discovery_status = f"NVML TCC/MCDM discovery succeeded; found {len(found)} TCC/MCDM GPU(s)." else: - _discovery_status = "NVML TCC discovery succeeded; no TCC GPUs found." + _discovery_status = "NVML TCC/MCDM discovery succeeded; no TCC/MCDM GPUs found." if shutdown_failed: _discovery_status += " NVML shutdown failed." return found def tcc_discovery_status() -> str: - """A safe, user-facing summary of the one-time TCC discovery attempt.""" + """A safe, user-facing summary of the one-time TCC/MCDM discovery attempt.""" return _discovery_status def tcc_adapters(listed: list[Adapter]) -> list[Adapter]: - """TCC GPUs that DXGI (`listed`) does not show. NVML is asked once, at the first call: a TCC GPU added or + """TCC/MCDM GPUs that DXGI (`listed`) does not show. NVML is asked once, at the first call: a compute GPU added or removed while gputaskman runs needs a restart.""" global _found with _lock: @@ -148,10 +152,10 @@ class TccCounters: - """pdh.GpuCounters' interface for one TCC GPU. Windows publishes no GPU counters for it, so adapter memory and - per-process memory come from NVML. NVML documents per-process memory as never available under WDDM (Windows - manages it); under TCC the NVIDIA driver does, so it is expected here, and an entry without it stays unknown. - It uses the collector's NVML session and never opens or closes one.""" + """pdh.GpuCounters' interface for one TCC/MCDM GPU. Adapter and per-process memory come from NVML. + NVML documents per-process memory as unavailable under WDDM (Windows manages it); under TCC the + NVIDIA driver does, so it is expected on TCC. An entry without it stays unknown, including on MCDM. + Uses the collector's NVML session and never opens or closes one.""" def __init__(self, adapter: TccAdapter, nvml: Nvml) -> None: self.adapter = adapter diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/gputaskman-0.4.3/tests/test_core.py new/gputaskman-0.4.4/tests/test_core.py --- old/gputaskman-0.4.3/tests/test_core.py 2026-11-16 00:27:14.000000000 +0100 +++ new/gputaskman-0.4.4/tests/test_core.py 2026-11-17 22:41:52.000000000 +0100 @@ -43,6 +43,7 @@ make_model) from gputaskman.report import to_dict, to_text from gputaskman.stores import ollama_names, store_name +from gputaskman.tcc import TccAdapter from tools.capture_screenshots import for_publication @@ -421,6 +422,29 @@ self.assertIsNone(select_nv_device(gpu, [nv_gpu, nv_gpu], 0)) intel = Adapter(2, "Intel GPU", 0x8086, 8 * GiB, 0, False) self.assertIsNone(select_nv_device(intel, [nv_gpu], 0)) + # Windows reports PCI segment 15 bus 1 as bus 0xF01 (RTX Spark N1X, driver 621.14). + spark = Adapter(3, "NVIDIA RTX Spark N1X", 0x10DE, 80 * GiB, 0, False, (0xF01, 0, 0)) + nv_spark = NvDevice(index=0, pci_bus="0000000F:01:00.0", driver_model="WDDM") + nv_bus1 = NvDevice(index=1, pci_bus="00000000:01:00.0", driver_model="WDDM") + self.assertIs(select_nv_device(spark, [npu, nv_bus1, nv_spark], 0), nv_spark) + self.assertIsNone(select_nv_device(spark, [npu, nv_bus1], 0)) + + @patch("gputaskman.collector.sys.platform", "win32") + def test_mcdm_peer_in_another_domain_does_not_hide_wddm_telemetry(self): + gpu = Adapter(1, "RTX", 0x10DE, 16 * GiB, 0, False, (6, 0, 0)) + compute = TccAdapter((1 << 62) | 9 << 16 | 6 << 8, "GB300", 0x10DE, 256 * GiB, 0, False, + (6, 0, 0), pci_domain=9, driver_model="MCDM") + nv_gpu = NvDevice(index=0, pci_bus="00000000:06:00.0", driver_model="WDDM") + nv_compute = NvDevice(index=1, pci_bus="00000009:06:00.0", driver_model="MCDM") + devices = [nv_compute, nv_gpu] + self.assertIs(select_nv_device(gpu, devices, 0, [compute, gpu]), nv_gpu) + self.assertIs(select_nv_device(compute, devices, 1, [compute, gpu]), nv_compute) + + other = Adapter(2, "RTX", 0x10DE, 16 * GiB, 0, False, (6, 0, 0)) + self.assertIsNone(select_nv_device(gpu, devices, 0, [compute, gpu, other])) + # TCC remains eligible in the existing DXGI pairing path, so stay conservative. + compute.driver_model = nv_compute.driver_model = "TCC" + self.assertIsNone(select_nv_device(gpu, devices, 0, [compute, gpu])) class MemoryTests(unittest.TestCase): @@ -1282,6 +1306,27 @@ self.assertEqual(classify(d, {}), "diffusion") self.assertIn("diffusion", AI_KINDS) + def test_relative_model_flags_resolve_against_target_cwd(self): + with tempfile.TemporaryDirectory() as target, tempfile.TemporaryDirectory() as monitor: + loaded, decoy = Path(target) / "model.gguf", Path(monitor) / "model.gguf" + loaded.touch() + decoy.touch() + cmd = ["llama-server", "-m", "model.gguf"] + old = os.getcwd() + os.chdir(monitor) + try: + with patch("gputaskman.procinfo.psutil.Process") as process: + process.return_value.cwd.return_value = target + self.assertEqual(_models_from_cmdline(cmd, 123), [str(loaded)]) + process.assert_called_once_with(123) + # The target's cwd is unknown: skip the path rather than guess with the monitor's cwd. + with patch("gputaskman.procinfo.psutil.Process") as process: + process.return_value.cwd.side_effect = PermissionError("protected") + self.assertEqual(_models_from_cmdline(cmd, 123), []) + self.assertEqual(_models_from_cmdline(cmd), []) + finally: + os.chdir(old) + def test_layer_and_kv_estimates(self): model = GgufInfo( path="model.gguf", file_size=1000, version=3, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/gputaskman-0.4.3/tests/test_diff.py new/gputaskman-0.4.4/tests/test_diff.py --- old/gputaskman-0.4.3/tests/test_diff.py 2026-11-16 00:27:14.000000000 +0100 +++ new/gputaskman-0.4.4/tests/test_diff.py 2026-11-17 22:41:52.000000000 +0100 @@ -9,7 +9,10 @@ from unittest.mock import patch from gputaskman.cli import main +from gputaskman.collector import Snapshot from gputaskman.diff import diff, load, match, to_text +from gputaskman.report import to_dict +from gputaskman.tcc import TccAdapter GiB = 1 << 30 MiB = 1 << 20 @@ -160,6 +163,35 @@ self.assertNotIn("dwm.exe", text) self.assertIn("1 process(es) changed by less than 16 MB", text) + def test_compressed_graphics_is_its_own_measured_change(self): + before_row = proc(1, "python", vram=GiB) + after_row = proc(1, "python", vram=GiB) + before_row["graphics_swapped_bytes"] = 0 + after_row["graphics_swapped_bytes"] = 512 * MiB + d = diff(snap([before_row], GiB, GiB, backend="metal", gpu="Apple M2 Ultra"), + snap([after_row], GiB, GiB, backend="metal", gpu="Apple M2 Ultra")) + moved = d["processes"][0]["measured"]["graphics_swapped_bytes"] + self.assertEqual(moved, {"before": 0, "after": 512 * MiB, "delta": 512 * MiB}) + self.assertEqual(d["processes"][0]["measured"]["vram_bytes"]["delta"], 0) + text = to_text(d) + self.assertIn("compressed graphics (footprint swapped) 0 MB -> 512 MB +512 MB", text) + appeared = proc(3, "python", vram=GiB) + appeared["graphics_swapped_bytes"] = 0 + born = diff(snap([], GiB, GiB, backend="metal", gpu="Apple M2 Ultra"), + snap([appeared], GiB, GiB, backend="metal", gpu="Apple M2 Ultra")) + self.assertNotIn("compressed graphics", to_text(born)) + appeared["graphics_swapped_bytes"] = 512 * MiB + born = diff(snap([], GiB, GiB, backend="metal", gpu="Apple M2 Ultra"), + snap([appeared], GiB, GiB, backend="metal", gpu="Apple M2 Ultra")) + self.assertIn("compressed graphics (footprint swapped) N/A -> 512 MB", to_text(born)) + quiet = proc(2, "idle", vram=GiB) + quiet["graphics_swapped_bytes"] = MiB + same = proc(2, "idle", vram=GiB) + same["graphics_swapped_bytes"] = 0 + small = diff(snap([same], GiB, GiB, backend="metal", gpu="Apple M2 Ultra"), + snap([quiet], GiB, GiB, backend="metal", gpu="Apple M2 Ultra")) + self.assertIn("(no process changed by 16 MB or more)", to_text(small)) + def test_runtime_reported_segments_and_unknown_measurements(self): before = snap([proc(1, "llama", vram=None, llm=llm(4096, GiB, exact=True))], used=None, attributed=None) after = snap([proc(1, "llama", vram=None, llm=llm(8192, 2 * GiB, exact=True))], used=None, attributed=None) @@ -218,6 +250,49 @@ self.assertEqual((d["adapter_check"], d["adapter_note"]), ("pci", None)) self.assertNotIn("Warning", to_text(d)) + def test_compute_domains_survive_json_without_device_telemetry(self): + snapshots = [] + for domain in (0, 9): + adapter = TccAdapter((1 << 62) | domain << 16 | 1 << 8, "GB300", 0x10DE, 256 * GiB, 0, False, + (1, 0, 0), pci_domain=domain, driver_model="MCDM") + s = Snapshot(100, adapter, [adapter], None, "", "", 256 * GiB, None, None) + data = json.loads(json.dumps(to_dict(s))) + self.assertEqual(data["adapter"]["pci_domain"], domain) + snapshots.append(data) + with self.assertRaisesRegex(ValueError, "different adapters.*PCI domains 00000000 vs 00000009"): + diff(*snapshots) + self.assertEqual(diff(snapshots[1], snapshots[1])["adapter_check"], "pci") + + def test_historical_device_pci_domains_separate_same_bdf_compute_gpus(self): + before = snap([], 0, 0, adapter=gpu_adapter(luid=(1 << 62) | 9 << 16 | 1 << 8)) + after = snap([], 0, 0, adapter=gpu_adapter(luid=(1 << 62) | 10 << 16 | 1 << 8)) + before["device"] = {"driver_model": "MCDM", "pci_bus": "00000009:01:00.0"} + after["device"] = {"driver_model": "MCDM", "pci_bus": "0000000A:01:00.0"} + for explicit_domain in (False, True): + with self.subTest(explicit_domain=explicit_domain): + if explicit_domain: + after["adapter"]["pci_domain"] = 10 + after["device"] = None + with self.assertRaisesRegex(ValueError, "different adapters.*PCI domains 00000009 vs 0000000a"): + diff(before, after) + after["adapter"].pop("pci_domain") + after["device"] = {"pci_bus": "9:1:0.0"} + self.assertEqual(diff(before, after)["adapter_check"], "pci") + + def test_missing_or_malformed_pci_domains_keep_older_pairing(self): + before = snap([], 0, 0, adapter={**gpu_adapter(), "pci_domain": 9}) + after = snap([], 0, 0, adapter=gpu_adapter(luid=0x5A01)) + for domain in (None, -1, 1 << 32, True, "9"): + with self.subTest(domain=domain): + after["adapter"]["pci_domain"] = domain + self.assertEqual(diff(before, after)["adapter_check"], "pci") + after["adapter"].pop("pci_domain") + for device in (None, {}, {"pci_bus": None}, {"pci_bus": "bad"}, + {"pci_bus": "0000000a:02:00.0"}, {"pci_bus": "100000000:01:00.0"}): + with self.subTest(device=device): + after["device"] = device + self.assertEqual(diff(before, after)["adapter_check"], "pci") + def test_conflicting_vendors_are_refused_without_pci_addresses(self): with self.assertRaisesRegex(ValueError, "vendor 0x10de vs 0x1002"): self.pair(gpu_adapter(pci=None, vendor=0x10DE), gpu_adapter(pci=None, vendor=0x1002)) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/gputaskman-0.4.3/tests/test_macos.py new/gputaskman-0.4.4/tests/test_macos.py --- old/gputaskman-0.4.3/tests/test_macos.py 2026-11-16 00:27:14.000000000 +0100 +++ new/gputaskman-0.4.4/tests/test_macos.py 2026-11-17 22:41:52.000000000 +0100 @@ -47,7 +47,10 @@ self.targets = targets def get(self, pid, identity=None): - return self.sizes.get(pid) if identity == "same" else None + if identity != "same" or pid not in self.sizes: + return None + size = self.sizes[pid] + return size if isinstance(size, tuple) else (size, None) def close(self): pass @@ -80,6 +83,22 @@ "IOAccelerator (graphics)": {"dirty": 8880128, "swapped": 0}, "IOAccelerator": {"dirty": 65536}, "MALLOC_SMALL": {"dirty": 58 << 20}}} self.assertEqual(macos.graphics_bytes(process), 2162163712 + 8880128) + self.assertEqual(macos.graphics_swapped(process), 0) # present zeros stay 0; non-graphics swapped is ignored + + def test_graphics_swapped_ignores_other_categories_and_a_missing_key_is_unknown(self): + both = {"categories": { + "IOAccelerator (graphics)": {"dirty": 10, "swapped": 5}, + "Owned physical footprint (unmapped) (graphics)": {"dirty": 7, "swapped": 4}, + "MALLOC_SMALL": {"dirty": 100, "swapped": 999}}} + self.assertEqual(macos.graphics_swapped(both), 9) + for bad in (float("nan"), float("inf"), float("-inf"), -1, True, "0"): + bad_row = {"categories": {"IOAccelerator (graphics)": {"dirty": 10, "swapped": bad}}} + self.assertIsNone(macos.graphics_swapped(bad_row), bad) + missing = {"categories": {"IOAccelerator (graphics)": {"dirty": 10}}} + self.assertIsNone(macos.graphics_swapped(missing)) + self.assertEqual(macos.graphics_bytes(missing), 10) + none = {"categories": {"MALLOC_SMALL": {"dirty": 1, "swapped": 9}}} + self.assertEqual(macos.graphics_swapped(none), 0) def test_physical_memory_without_sysconf(self): with patch.object(macos.os, "sysconf", side_effect=AttributeError, create=True): @@ -117,6 +136,14 @@ per = procs[macos.ADAPTER_KEY] self.assertAlmostEqual(per[79379].gpu_pct, 98.4) # measured: 98.4% vs Device Utilization 99% self.assertEqual(per[79379].dedicated, 2162163712 + 8880128) + self.assertIsNone(per[79379].graphics_swapped) # this fixture did not report swapped + self.assertIn("shared", per[79379].available) # not displayed; the LLM breakdown gate still requires it + self.assertNotIn("committed", per[79379].available) + self.assertFalse(per[79379].paged_available) + from gputaskman.collector import _llm_wanted + self.assertTrue(_llm_wanted( + type("Row", (), {"kind": "LLM", "detail": type("Detail", (), {"is_diffusion": False, "foundry_local": False, + "has_model_evidence": False})(), "gpu": per[79379]})(), True)) self.assertTrue(per[79379].attributed) self.assertFalse(per[486].attributed) # own process, not measured yet: unknown, not 0 self.assertFalse(per[167].attributed) # root's WindowServer: GPU% only @@ -127,6 +154,15 @@ self.assertEqual(adapters[macos.ADAPTER_KEY].dedicated, 5494423552) self.assertEqual((c.device.name, c.device.util_gpu, c.device.driver_model), ("Apple M4", 99, "Metal")) + def test_swapped_bytes_are_kept_out_of_vram(self): + dirty = 2162163712 + 8880128 + c, _ = self.counters({79379: (dirty, 64 << 20)}, {79379: ME}) + procs, _ = self.sample(c, accel(), [client(79379, "python3.13", 0, cid=1)], now=1.0) + g = procs[macos.ADAPTER_KEY][79379] + self.assertEqual(g.dedicated, dirty) + self.assertEqual(g.graphics_swapped, 64 << 20) + self.assertEqual(g.attributed and "dedicated" in g.available, True) + def test_a_closed_client_does_not_hide_work_on_the_others(self): c, _ = self.counters({}, {1: ME}) self.sample(c, accel(), [client(1, "a", 10 * 10**9, cid=7), client(1, "a", 1 * 10**9, cid=8)], now=1.0) @@ -218,11 +254,25 @@ p = macos.FootprintPoller(run=self.footprint({42: 3 * GiB}, calls), clock=lambda: 0.0) p.set_targets([(42, "a", True)]) p.poll_once() - self.assertEqual(p.get(42, "a"), 3 * GiB) + self.assertEqual(p.get(42, "a"), (3 * GiB, None)) # the fixture omits swapped: unknown, not 0 self.assertIsNone(p.get(42, "b")) p.set_targets([(42, "b", True)]) # reused PID: the old size is gone self.assertIsNone(p.get(42, "a")) + def test_a_reported_swapped_zero_is_kept(self): + def run(args, **kw): + with open(args[args.index("-j") + 1], "w", encoding="utf-8") as f: + json.dump({"processes": [{"pid": 42, "categories": { + "IOAccelerator (graphics)": {"dirty": 100, "swapped": 0}, + "MALLOC_SMALL": {"dirty": 50, "swapped": 80}}}]}, f) + p = macos.FootprintPoller(run=run, clock=lambda: 0.0) + p.set_targets([(42, "a", True)]) + p.poll_once() + self.assertEqual(p.get(42, "a"), (100, 0)) + self.assertIsNone(p.get(42, "b")) + p.set_targets([(42, "b", True)]) # a reused PID drops the swapped reading too + self.assertIsNone(p.get(42, "a")) + def test_idle_processes_are_measured_less_often(self): calls, clock = [], [0.0] p = macos.FootprintPoller(run=self.footprint({1: GiB, 2: GiB}, calls), clock=lambda: clock[0]) @@ -242,7 +292,7 @@ p.poll_once() sizes[5] = None # footprint times out once p.poll_once() - self.assertEqual(p.get(5, "a"), GiB) + self.assertEqual(p.get(5, "a"), (GiB, None)) for _ in range(p.FAIL_LIMIT): p.poll_once() n = len(calls) @@ -256,7 +306,7 @@ def measure(pid): p.set_targets([]) # the process exits while footprint runs - return 2 * GiB + return 2 * GiB, 0 p.measure = measure p.poll_once() @@ -285,6 +335,22 @@ self.assertFalse(procinfo._skip_path("/usr/lib/x86_64-linux-gnu/libcuda.so.1")) +class ListingTests(unittest.TestCase): + def test_idle_compressed_graphics_stays_in_the_snapshot(self): + from gputaskman.collector import _is_live + + MiB = 1 << 20 + held = ProcGpu(dedicated=0, graphics_swapped=20 * MiB) + held.available -= {"shared", "committed"} + self.assertTrue(_is_live(held)) + tiny = ProcGpu(dedicated=0, graphics_swapped=MiB) + tiny.available -= {"shared", "committed"} + self.assertFalse(_is_live(tiny)) + self.assertFalse(_is_live(ProcGpu())) # nothing measured, including an unset swapped field + paged = ProcGpu(dedicated=0, shared=0, committed=16 * MiB) + self.assertTrue(_is_live(paged)) # the Windows estimate still keeps its own row + + class ReportTests(unittest.TestCase): def test_metal_header_and_json(self): rows = [ProcRow(79379, "python3.13", "AI", ProcGpu(dedicated=2 * GiB, engines={"gpu": 98.4}), @@ -301,6 +367,27 @@ data = to_dict(snap)["processes"] self.assertEqual((data[0]["vram_bytes"], data[1]["vram_bytes"], data[1]["gpu_pct"]), (2 * GiB, None, 2.0)) self.assertIsNone(data[0]["shared_bytes"]) + self.assertIsNone(data[0]["paged_out_bytes"]) + self.assertIsNone(data[0]["graphics_swapped_bytes"]) + self.assertIsNone(data[1]["graphics_swapped_bytes"]) + + def test_swapped_graphics_bytes_are_paged_and_not_added_to_vram(self): + gpu = ProcGpu(dedicated=2 * GiB, engines={"gpu": 10.0}, graphics_swapped=0) + row = ProcRow(79379, "python3.13", "AI", gpu, ProcDetail(79379, "python3.13")) + snap = Snapshot(taken=1, adapter=None, adapters=[], nv=None, driver="macOS 26.3.1", cuda="", + vram_total=16 * GiB, vram_used=2 * GiB, shared_used=0, backend="metal", procs=[row]) + text = to_text(snap) + line = next(line for line in text.splitlines() if "python3.13" in line and line.lstrip()[:1].isdigit()) + self.assertIn("2.00 GB", line) + self.assertIn("0 MB", line) + self.assertIsNone(to_dict(snap)["processes"][0]["paged_out_bytes"]) + self.assertEqual(to_dict(snap)["processes"][0]["graphics_swapped_bytes"], 0) + self.assertEqual(to_dict(snap)["processes"][0]["vram_bytes"], 2 * GiB) + gpu.graphics_swapped = 3 * GiB + text = to_text(snap) + line = next(line for line in text.splitlines() if "python3.13" in line and line.lstrip()[:1].isdigit()) + self.assertIn("3.00 GB", line) + self.assertEqual(to_dict(snap)["processes"][0]["vram_bytes"], 2 * GiB) class DisplayTests(unittest.IsolatedAsyncioTestCase): @@ -308,7 +395,8 @@ from gputaskman import app as app_mod from gputaskman.app import GpuTaskManager from textual.widgets import Select - row = ProcRow(42, "Game", "3D/game", ProcGpu(dedicated=GiB, engines={"gpu": 80.0}), ProcDetail(42, "Game")) + row = ProcRow(42, "Game", "3D/game", ProcGpu(dedicated=GiB, engines={"gpu": 80.0}, graphics_swapped=0), + ProcDetail(42, "Game")) snap = Snapshot(taken=1, adapter=None, adapters=[], nv=None, driver="macOS 26.3.1", cuda="", vram_total=16 * GiB, vram_used=3 * GiB, shared_used=0, backend="metal", procs=[row]) with patch.object(app_mod, "BACKEND", "metal"), patch.object(GpuTaskManager, "poll"): @@ -327,6 +415,7 @@ self.assertEqual(len(options), 3) table = app.query_one("#procs") self.assertEqual(table.get_cell("42", "GPU%").plain, "80") + self.assertEqual(table.get_cell("42", "Paged").plain, "0 MB") for column in ("3D", "Copy", "Video"): self.assertEqual(table.get_cell("42", column).plain, "n/a") diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/gputaskman-0.4.3/tests/test_replay.py new/gputaskman-0.4.4/tests/test_replay.py --- old/gputaskman-0.4.3/tests/test_replay.py 2026-11-16 00:27:14.000000000 +0100 +++ new/gputaskman-0.4.4/tests/test_replay.py 2026-11-17 22:41:52.000000000 +0100 @@ -289,12 +289,12 @@ self.assertNotIn("0 MB", text) rows, _notes = process_rows(body) self.assertEqual(rows[0][3], "n/a") - self.assertEqual(rows[0][5], "n/a") + self.assertEqual(rows[0][6], "n/a") measured_zero = snap(processes=[proc(vram=0, gpu_pct=0)]) measured_zero["vram_used"] = 0 zero_text = describe(_view(), Playback(1, [1.0], timed=False), measured_zero) self.assertIn("Memory: 0 MB / 24.00 GB", zero_text) - self.assertEqual(process_rows(measured_zero)[0][0][5], "0") + self.assertEqual(process_rows(measured_zero)[0][0][6], "0") def test_shared_is_blank_only_when_the_row_has_no_shared_counter(self): self.assertEqual(process_rows(snap(processes=[proc(shared_bytes=None)]))[0][0][4], "n/a") @@ -304,6 +304,18 @@ windows = snap(backend="wsl", processes=[proc(shared_bytes=None, host="windows")]) self.assertEqual(process_rows(windows)[0][0][4], "n/a") + def test_paged_is_footprint_swapped_on_metal_and_blank_elsewhere(self): + blank = process_rows(snap(processes=[proc()]))[0][0][5] + self.assertEqual(blank, "") + measured = snap(backend="metal", processes=[proc(graphics_swapped_bytes=0)]) + self.assertEqual(process_rows(measured)[0][0][5], "0 MB") + missing = snap(backend="metal", processes=[proc(graphics_swapped_bytes=None)]) + self.assertEqual(process_rows(missing)[0][0][5], "n/a") + compressed = snap(backend="metal", processes=[proc(graphics_swapped_bytes=2 * GiB, vram=GiB)]) + row = process_rows(compressed)[0][0] + self.assertEqual(row[3], "1.00 GB") + self.assertEqual(row[5], "2.00 GB") + def test_inferred_bytes_are_marked_and_not_added_to_the_device_total(self): inferred = proc(name="wsl-python", vram=None, vram_attributed=False, vram_inferred_bytes=3 * GiB, vram_inferred_by="order") @@ -314,12 +326,12 @@ self.assertIn("12.00 GB / 24.00 GB", text) self.assertNotIn("15.00 GB", text) self.assertEqual(process_rows(body)[0][0][3], "3.00 GB?") - self.assertIn("inferred", process_rows(body)[0][0][6]) + self.assertIn("inferred", process_rows(body)[0][0][7]) unmarked = proc(name="plain", vram=None, vram_attributed=False, vram_inferred_bytes=GiB, vram_inferred_by=None) cells = process_rows(snap(processes=[unmarked]))[0][0] self.assertEqual(cells[3], "1.00 GB") self.assertNotIn("?", cells[3]) - self.assertIn("inferred", cells[6]) + self.assertIn("inferred", cells[7]) agreed = proc(name="agreed", vram=None, vram_attributed=False, vram_inferred_bytes=GiB, vram_inferred_by="consistent") self.assertTrue(process_rows(snap(processes=[agreed]))[0][0][3].endswith("*")) @@ -328,7 +340,7 @@ host_pid = proc(vram=GiB, vram_attributed=True, vram_inferred_by="consistent") cells = process_rows(snap(processes=[host_pid]))[0][0] self.assertEqual(cells[3], "1.00 GB*") - self.assertIn("inferred", cells[6]) + self.assertIn("inferred", cells[7]) self.assertIn("* matched", describe(_view(), Playback(1, [1.0], timed=False), snap(processes=[host_pid]))) def test_malformed_inferred_by_renders_unmarked(self): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/gputaskman-0.4.3/tests/test_tcc.py new/gputaskman-0.4.4/tests/test_tcc.py --- old/gputaskman-0.4.3/tests/test_tcc.py 2026-11-16 00:27:14.000000000 +0100 +++ new/gputaskman-0.4.4/tests/test_tcc.py 2026-11-17 22:41:52.000000000 +0100 @@ -6,7 +6,6 @@ """ import contextlib -import dataclasses import io import sys import threading @@ -172,11 +171,19 @@ found.software, found.pci_address), ("Tesla P40", VENDOR_NVIDIA, "NVIDIA", 24 * GiB, 0, False, (0x0A, 0, 0))) - def test_only_a_gpu_that_is_in_tcc_mode_now_counts(self): + def test_only_a_gpu_in_tcc_or_mcdm_mode_now_counts(self): # WDDM, MCDM, an unknown model, a WDDM GPU that will switch to TCC at the next reboot, and the reverse. self.api.devices = [device(1, model=0), device(2, model=2), device(3, model=7), device(4, model=0, pending=1), device(5, model=1, pending=0)] - self.assertEqual([a.pci_address[0] for a in tcc_adapters([])], [5]) + self.assertEqual([a.pci_address[0] for a in tcc_adapters([])], [2, 5]) + + def test_mcdm_preserves_driver_model_and_pci_domain(self): + self.api.devices = [device(6, model=2, bus_id="00000009:06:00.0")] + (found,) = tcc_adapters([]) + self.assertEqual(found.driver_model, "MCDM") + self.assertEqual(found.pci_domain, 9) + self.assertTrue(found.matches_pci("00000009:06:00.0")) + self.assertFalse(found.matches_pci("00000002:06:00.0")) def test_a_gpu_dxgi_lists_is_never_added_again(self): self.api.devices = [device(0x0A), device(0x0B)] @@ -288,7 +295,7 @@ def test_discovery_status_distinguishes_no_tcc_devices_from_a_failed_probe(self): self.assertEqual(tcc_adapters([]), []) - self.assertIn("succeeded; no TCC GPUs found", tcc_mod.tcc_discovery_status()) + self.assertIn("succeeded; no TCC/MCDM GPUs found", tcc_mod.tcc_discovery_status()) tcc_mod._found = None self.api.init_error = NvmlError("private driver detail") self.assertEqual(tcc_adapters([]), []) @@ -362,9 +369,6 @@ with self.assertRaisesRegex(ValueError, "out of range; 2 GPU adapter"): select_adapter([tcc, listed], 2) - def test_json_describes_a_tcc_adapter_like_any_other(self): - self.assertEqual(set(dataclasses.asdict(tcc_adapter())), set(dataclasses.asdict(listed_adapter(1)))) - class CounterTests(TccTestCase): def test_reports_nvml_memory_for_the_adapter_and_each_process(self): @@ -570,6 +574,21 @@ with patch("gputaskman.collector.BACKEND", "wddm"), patch("gputaskman.collector.sys.platform", "win32"): return c.sample() + def test_mcdm_device_metrics_pair_by_driver_model(self): + self.api.devices = [device(6, model=2, used=9 * GiB, bus_id="00000009:06:00.0", + processes=[(100, NOT_AVAILABLE)])] + (adapter,) = tcc_adapters([]) + snap = self.sample(self.collector(adapter=adapter)) + self.assertEqual(snap.nv.driver_model, "MCDM") + self.assertEqual(snap.nv.pci_bus, "00000009:06:00.0") + self.assertEqual(snap.vram_used, 9 * GiB) + self.assertIn("MCDM compute-only", snap.counter_status) + data = to_dict(snap) + self.assertIsNone(data["attributed"]) + (process,) = data["processes"] + for key in ("vram_bytes", "shared_bytes", "committed_bytes", "gpu_pct", "engines"): + self.assertIsNone(process[key], key) + def test_a_tcc_gpu_gets_its_memory_and_processes_from_nvml(self): self.api.devices = [device(0x0A, used=9 * GiB, processes=[(200, 2 * GiB), (100, 6 * GiB)])] snap = self.sample(self.collector()) @@ -683,12 +702,12 @@ with patch("sys.argv", ["gputaskman", "--list-gpus"]), \ patch("gputaskman.collector.enumerate_adapters", return_value=[]), \ patch("gputaskman.tcc.tcc_discovery_status", - return_value="NVML initialization failed; TCC GPUs could not be checked."), \ + return_value="NVML initialization failed; TCC/MCDM GPUs could not be checked."), \ contextlib.redirect_stdout(output), contextlib.redirect_stderr(error): main() self.assertEqual(output.getvalue(), "") self.assertEqual(error.getvalue().strip(), - "TCC discovery: NVML initialization failed; TCC GPUs could not be checked.") + "TCC/MCDM discovery: NVML initialization failed; TCC/MCDM GPUs could not be checked.") def test_list_gpus_displays_full_domain_for_tcc_gpu(self): output = io.StringIO() @@ -700,6 +719,18 @@ self.assertEqual(output.getvalue().strip(), "0: Tesla P40 (NVIDIA, TCC compute-only, PCI 00010000:01:00.0)") + def test_list_gpus_labels_mcdm_and_preserves_its_domain(self): + adapter = tcc_adapter(6, name="GB300", domain=9) + adapter.driver_model = "MCDM" + output = io.StringIO() + with patch("sys.argv", ["gputaskman", "--list-gpus"]), \ + patch("gputaskman.collector.enumerate_adapters", return_value=[adapter]), \ + patch("gputaskman.tcc.tcc_discovery_status", return_value=""), \ + contextlib.redirect_stdout(output): + main() + self.assertEqual(output.getvalue().strip(), + "0: GB300 (NVIDIA, MCDM compute-only, PCI 00000009:06:00.0)") + @unittest.skipUnless(sys.platform == "win32", "the DXGI wrapper exists only on Windows") class WindowsEnumerationTests(unittest.TestCase): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/gputaskman-0.4.3/uv.lock new/gputaskman-0.4.4/uv.lock --- old/gputaskman-0.4.3/uv.lock 2026-11-16 00:27:14.000000000 +0100 +++ new/gputaskman-0.4.4/uv.lock 2026-11-17 22:41:52.000000000 +0100 @@ -13,7 +13,7 @@ [[package]] name = "gputaskman" -version = "0.4.3" +version = "0.4.4" source = { editable = "." } dependencies = [ { name = "nvidia-ml-py" },
