hypomnesis
ὑπόμνησις — External RAM and VRAM, measured.
🆕
0.2.4surfaces NVIDIA's driver/firmware reserved memory. A new additiveGpuDeviceInfo::reserved_bytes: Option<u64>exposes the carve-out NVML holds within its reportedtotal(total = reserved + free + used) — live-measured at 259 MiB on anRTX 5060 Ti, exactly matchingnvidia-smi -q -d MEMORY'sReservedline next toTotal: 16311 MiB. It is a subset oftotal_bytes, so allocation headroom istotal_bytes − reserved_bytes(whichfree_bytesalready reflects). Sourced from NVML's v2 memory query (nvmlDeviceGetMemoryInfo_v2, R510+) with a graceful pre-R510 fallback toNone;total_bytesis unchanged. Driven by acandle-miv0.1.16dogfooding report. SeeCHANGELOG.mdanddocs/roadmap-v0.2.4.md.
🚀
0.2.3adds first-class macOS support on Apple Silicon. Three platforms now share one contract —Windows,Linux, andmacOSall expose processRSS, device-wide GPU memory, per-process GPU memory, and ahmn pslisting with the same JSON shape on every platform. The macOS backend is libSystem-only (task_info,ledger,sysctl,proc_listpids,proc_pidpath) for everything except the device-wide GPU budget, which readsMTLDevice.recommendedMaxWorkingSetSizethrough a minimalobjc2-metalbinding. Cross-platformused_bytessemantics are preserved — the macOSgraphics_footprintledger entry behaves the same way WindowsWorkingSetSizeand LinuxVmRSSdo under memory pressure. Authored by contributor @LittleCoinCoin (PR #1); daily-driven on M3 Pro / 36 GiB. All additive under the#[non_exhaustive]policy carried over from v0.2.0–v0.2.2. SeeCHANGELOG.mdfor the v0.2.3 entry andROADMAP.mdfor the rationale.
Table of Contents
Install
[]
= "0.2"
The default feature set (nvml, dxgi, nvidia-smi-fallback) covers process RSS and per-process / device-wide GPU memory on both Windows (IDXGIAdapter3 + NVML) and Linux (NVML), with a nvidia-smi subprocess fallback. The dxgi dependency on the windows crate is target-conditional — Linux users pay nothing for it.
On macOS, the metal feature is in the default set. Process RSS and per-process GPU memory come from libSystem syscalls (task_info, ledger, sysctl). The device-wide "free" figure comes from MTLDevice.recommendedMaxWorkingSetSize via the objc2-metal binding (target-conditional, macOS-only) — no libSystem signal on Apple Silicon UMA approximates Apple's own kernel-projected GPU working-set budget within useful accuracy.
For candle-mi-compatible delta and printing helpers (MemoryReport, print_delta, print_before_after, ram_mb, vram_mb):
= { = "0.2", = ["report"] }
For a stripped-down build (process RSS only, no GPU backends):
= { = "0.2", = false }
Usage
use Snapshot;
Expected output (RTX 5060 Ti, Windows, idle process):
RAM: 142475264 bytes
GPU 0 [NVIDIA GeForce RTX 5060 Ti]: 1.8 / 15.9 GiB used
(259 MiB reserved)
This process: 119 MiB (per-process)
Binary (hmn)
hypomnesis ships a small CLI binary, hmn, behind the default-off cli feature. Install it with:
Two subcommands:
Example default output (single NVIDIA dGPU, the maintainer's reference machine — Ryzen 9 5950X has no iGPU, so only one adapter surfaces):
GPU 0 [NVIDIA GeForce RTX 5060 Ti]: free 13284 MiB / 16311 MiB (259 MiB reserved)
The (259 MiB reserved) parenthetical (NVML R510+) is the driver/firmware carve-out within the 16311 MiB total — matching nvidia-smi -q -d MEMORY's Reserved line. It is elided on backends that don't expose it (DXGI, nvidia-smi, Metal, pre-R510).
Apple Silicon, idle process (Apple M3 Pro, 36 GiB unified memory):
GPU 0 [Apple M3 Pro]: free 28753 MiB / 36864 MiB
The free figure here is MTLDevice.recommendedMaxWorkingSetSize — the kernel-projected GPU working-set budget on UMA — and total is sysctl hw.memsize. See the macOS UMA semantics section below for what these numbers mean and why they differ from the discrete-GPU "free vs total" model.
Illustrative output on a heterogeneous machine (NVIDIA dGPU + Intel/AMD iGPU on Windows). Not yet verified end-to-end on real hardware — see docs/roadmap-v0.2.0.md "Verification plan":
GPU 0 [NVIDIA GeForce RTX 5060 Ti]: free 13284 MiB / 16311 MiB (259 MiB reserved)
GPU 1 [Intel Iris Xe Graphics]: free 32768 MiB / 32768 MiB
(The Intel iGPU line has no reserved parenthetical — DXGI does not expose the NVML carve-out, so reserved_bytes is None there.)
hmn ps (illustrative — empty on machines with no active CUDA workload):
PID NAME VRAM DEVICE
12345 lm-studio.exe 8.2 GiB NVIDIA GeForce RTX 5060 Ti
67890 python.exe 1.4 GiB NVIDIA GeForce RTX 5060 Ti
A one-line summary is written to stderr after each hmn ps run:
hmn: 2 compute processes found.
hmn: 0 compute processes found matching pid=99 device=0. # with filters
The stderr summary is always printed, even when the table is empty, so interactive users get an unambiguous "command worked, here's the count" line without breaking stdout's scriptability. Pipelines like hmn ps | awk 'NR>1 {print $1}' or hmn ps --json | jq work as expected. Redirect 2>/dev/null to suppress the summary.
Limitations (intrinsic to the underlying data sources, not bugs):
-
Per-platform semantics differ — compute-only on Linux, all-GPU-users on Windows.
hmn pson Linux (viaNVML'snvmlDeviceGetComputeRunningProcesses_v3) enumerates only processes with an activeCUDAcontext — browsers using GPU compositing, games, and pure-graphics apps do not appear.hmn pson Windows (viaPDH's\GPU Process Memory(*)\Dedicated Usage) enumerates every process holding GPU memory — the desktop compositor (dwm.exe), browsers, games, andCUDA/ compute alongside. The semantic shift reflects what each platform's kernel actually accounts for; check thesourcefield onGpuProcessEntryif you care about the distinction. -
Windows
used_bytesreflects WDDM's dedicated commit, not resident set. UnderWDDMa process can commit GPU allocations exceeding physicalVRAM— the kernel pages them via the shared system memory budget. Numbers exceeding the device's totalVRAMare real, not bugs: they match Task Manager'sDedicated GPU memorycolumn. (Example: on a 16 GiB GPU, a heavy browser process can show 15+ GiB committed.) -
?in the NAME column means the calling user cannot resolve that PID's name viaOpenProcess. Most cases — system services, other-user processes likedwm.exe,csrss.exe, vendor services — resolve whenhmn psis run as Administrator. The Windows kernel itself (PID 4) is rendered as[kernel], not?— there is no executable image to read, so it's special-cased so it does not pollute the "unresolvable" count.PPL-protected processes (Windows Defender, anti-cheat engines) would also remain?even elevated, but typically do not appear inhmn psoutput unless they are actively holding GPU memory.Security note. By construction, a
?row that does not resolve under elevation is one of: a process owned by another user, a process running asSYSTEM/LOCAL SERVICE/NETWORK SERVICE, aPPL-protected process, or a transient race between PDH's sample and theOpenProcesscall. None of these are intrinsically malicious — but on a single-user desktop, an unexpected?row holding substantial VRAM is worth investigating: a malicious local process (including a privileged-or-cross-user AI agent) using GPU resources would land in exactly this set. The(N protected — re-run elevated for names)parenthetical on thehmn pssummary line is intentionally surfaced because this distinction is security-relevant.hypomnesisis a measurement tool, not a malware scanner — but its honesty about the gap is itself a defensive primitive. -
Pre-
WDDM 2.0Windows falls back tonvidia-smi --query-compute-apps. Vanishingly rare in 2026 —WDDM 2.0shipped with Windows 10 1709 (October 2017). On the fallback path,hmn psis compute-only (matching the Linux semantic) andused_memorymay be[N/A]underWDDM(parser drops those rows). Thesourcefield onGpuProcessEntryreadsGpuQuerySource::NvidiaSmirather thanGpuQuerySource::Pdhon this path. -
R570-class driver-bug filtering. Theu64::MAXsentinel (R570driver bug onRTX 5060 Tiand similar consumer GeForce cards) and theused > totalcorruption checks are applied per-row inhmn ps; affected rows are dropped rather than reported as garbage. -
macOS
used_bytesreflects currently-resident GPU pages. The kernel evicts idle Metal pages from a process'sgraphics_footprint, so the same PID may report different values across successivehmn pscalls when its working set has cooled. This is the same resident-bytes semantics as WindowsWorkingSetSizeand LinuxVmRSS— not a macOS quirk, the cross-platform contract. -
macOS cross-user PIDs are silently skipped. The per-PID
ledgersyscall returnsEPERMfor processes owned by another user.hmn psenumerates same-user PIDs only by default; run elevated (sudo hmn ps) to include cross-user PIDs such asWindowServer,kernel_task, and other-user-owned applications.
Composable workflows
hmn ps --json exists for scripting and survives across platforms (same JSON shape on Windows, Linux, and macOS). Two recipes that have come up in dogfooding:
Top-5 GPU consumers (any platform with jq installed):
|
Terminate any process holding more than 1 GiB of VRAM — the JSON output composes with the platform's native kill command. Windows (PowerShell or cmd):
| |
Linux / macOS:
| |
(Use kill -KILL instead of -TERM if you want the hard variant; -r skips empty input.)
Why no hmn kill?
A hmn kill <pid> subcommand was considered for v0.2.3 and rejected to preserve hypomnesis's "measurement, not control" scope discipline. Process termination is not a measurement operation — it's a control operation, and one with platform-specific permission models (taskkill vs kill -SIGNAL vs sudo kill) that hmn would inevitably get wrong on at least one platform. Piping JSON to the platform's native killer is more honest about what's happening, more flexible (filter on any field, not just PID), and keeps hypomnesis's API surface small.
Capabilities
| Metric | Windows | Linux | macOS |
|---|---|---|---|
| Process RSS | K32GetProcessMemoryInfo |
/proc/self/status (no unsafe) |
task_info(TASK_VM_INFO_PURGEABLE).phys_footprint |
| Device-wide GPU memory | NVML (nvml.dll) |
NVML (libnvidia-ml.so.1) |
sysctl hw.memsize (total) + MTLDevice.recommendedMaxWorkingSetSize (free) |
| Device reserved memory | NVML v2 (nvmlDeviceGetMemoryInfo_v2, R510+) |
NVML v2 (R510+) |
n/a (None — UMA has no carve-out) |
| Per-process GPU memory | DXGI (IDXGIAdapter3::QueryVideoMemoryInfo) |
NVML (nvmlDeviceGetComputeRunningProcesses) |
ledger(LEDGER_ENTRY_INFO_V2).graphics_footprint |
| Fallback | nvidia-smi subprocess |
nvidia-smi subprocess |
none (libSystem syscalls always succeed on Apple Silicon) |
hypomnesis uses IDXGIAdapter3 on Windows because WDDM means the kernel memory manager — not the NVIDIA driver — owns GPU allocations, so NVML's per-process query returns NOT_AVAILABLE under Windows. DXGI 1.4 is the only reliable per-process source. On Linux, NVML's nvmlDeviceGetComputeRunningProcesses_v3 returns true per-process figures. On Apple Silicon (M-series), the GPU shares system DRAM via unified memory architecture (UMA), so hw.memsize is both the system RAM total and the GPU memory pool.
The crate handles two known driver bugs out of the box:
NVMLu64::MAXsentinel — someR570-series drivers report0xFFFFFFFFFFFFFFFFfor every running process's memory (observed onRTX 5060 Ti).hypomnesisdetects this and falls back tonvidia-smi.used > totalcorruption — sanity-checks each per-process reading against the device-wide total; falls back tonvidia-smion detected corruption.
macOS UMA semantics: what free_bytes means
On a discrete GPU, free_bytes is "untaken bytes in the VRAM pool" — a hard number bounded by the card's physical memory. On Apple Silicon the GPU has no separate pool: it shares system DRAM via unified memory architecture (UMA). hypomnesis therefore reports free_bytes as MTLDevice.recommendedMaxWorkingSetSize — the kernel-projected GPU working-set budget that Apple's Metal driver itself computes, factoring in wired-page reserves, system memory pressure, and the kernel's known compression / eviction capability.
Two consequences worth noting:
- The number changes slowly under load. Apple's driver smooths it; it is a policy figure, not an instant-state reading. Expect it to shrink modestly as system memory pressure rises and recover as pressure abates.
- Per-process
used_bytes(fromgraphics_footprint, used bygpu_processes()andprocess_gpu_info()) reflects currently resident GPU pages, matching the resident-bytes semantics of WindowsWorkingSetSizeand LinuxVmRSS. Idle apps' Metal pages get evicted by the kernel; the same PID may report different values across calls. This is the contract Windows and Linux already exhibit, not a macOS-specific quirk.
Feature Flags
| Feature | Default | Description |
|---|---|---|
nvml |
yes | NVML dynamic load via libloading (Linux + Windows-WDDM device-wide) |
dxgi |
yes | Windows per-process VRAM via IDXGIAdapter3 (no-op on non-Windows) |
metal |
yes | macOS device-wide GPU budget via objc2-metal (MTLDevice.recommendedMaxWorkingSetSize); no-op on non-macOS. RAM and per-process GPU paths are libSystem-only and unaffected by this flag. |
nvidia-smi-fallback |
yes | Subprocess fallback when NVML / DXGI fail or are disabled |
report |
no | MemoryReport delta + print_delta / print_before_after / ram_mb / vram_mb helpers (candle-mi parity, candidate for candle-mi v0.2 migration via Cargo flag flip); format_free / print_free / format_total / format_used formatting helpers on GpuDeviceInfo |
debug-output |
no | Print raw NVML / DXGI values to stderr (diagnostic) |
cli |
no | Build the hmn CLI binary (pulls clap 4 as a dep). Library users do not need this; install via cargo install hypomnesis --features cli. |
test-helpers |
no | Expose GpuDeviceInfoBuilder for downstream tests that need synthetic GpuDeviceInfo fixtures. Default-off, additive — production code must never enable it. |
Used by
- candle-mi — mechanistic-interpretability toolkit for
candle. As of v0.1.16 it deletes its in-tree measurement FFI and delegatessrc/memory.rstohypomnesis(lean feature set:nvml,dxgi,nvidia-smi-fallback,metal), flattening ahypomnesis::Snapshotinto its ownMemorySnapshot. Its v0.1.16 dogfooding report — live-validated on anRTX 5060 Ti(16 GiB, Windows /WDDM) — drove this release'sreserved_bytesaddition. - hf-fetch-model — Hugging Face model weights and metadata fetcher (uses
device_infoforinspect --check-gpu)
License
Licensed under either of Apache License, Version 2.0 or MIT License at your option.
Development
- Exclusively developed with Claude Code (dev) and Augment Code (review)
- Git workflow managed with Fork
- All code follows CONVENTIONS.md, derived from Amphigraphic-Strict's Grit — a strict Rust subset designed to improve AI coding accuracy.