Skip to content

feat(hardware): read free VRAM and the UMD CUDA banner - #640

Merged
ion-alpha-dev merged 3 commits into
mainfrom
feat/hardware-vram-free-cuda-umd
Nov 1, 2026
Merged

ion-alpha-dev merged 3 commits into
mainfrom
feat/hardware-vram-free-cuda-umd

Conversation

@ion-alpha-dev

Copy link
Copy Markdown
Collaborator

What

Reads the free GPU memory in the same nvidia-smi query that hardware.Detect already runs, exposes it as Box.VRAMFreeBytes, and has flynn models --local --fit judge models against that figure. The separate free-VRAM probe is removed. The CUDA banner parser also accepts the CUDA UMD Version: label that drivers 610 and later print.

Why

The fit judged models against the card's total memory. The desktop and other programs already hold part of the card, so a model that fits the total can fail to load. The fit now uses the free figure Detect reports, and falls back to the total when the driver does not report one.

Drivers 610 and later print the CUDA version as CUDA UMD Version:. The parser only matched CUDA Version:, so the detected CUDA version was lost on those drivers.

How to verify

Run go test ./internal/hardware/... ./cmd/flynn/.... TestParseNvidiaSMIFreeVRAM covers the free-memory column, including hidden, zero, negative and above-total readings. TestParseCUDAVersion covers both banner labels. TestDetectReadsFreeVRAMAndUMDBanner runs Detect end to end against recorded nvidia-smi output.

On a machine with an NVIDIA GPU, go run ./cmd/flynn models --local --fit prints the free VRAM in its first line. Compare it with nvidia-smi --query-gpu=memory.free --format=csv.

Notes for reviewers

The signatures of resolveMachine, renderFit, and fitMachine are unchanged. detectBox replaces the removed probe hook as the seam tests stub.

A card whose free memory is reported as 0 is treated as not reported, so the fit uses the total for it. A fully occupied card is therefore judged at its total. This is a known gap.

internal/inference/gpu keeps its own CUDA banner parser, since sharing one needs an export from that package. Consolidating the two is a possible follow-up.

The two changes are in one commit because they touch the same parser and the same test files.

The fit judged models against the card's total memory, so a model that
fit an empty card could fail to load while the desktop held part of it.
Free memory now comes from the same nvidia-smi query Detect already
runs, as Box.VRAMFreeBytes, so the fit no longer needs a second probe.
The separate free-VRAM probe and its hook in the models command are
removed; a fit with no free figure falls back to the total.

Drivers 610 and later print the CUDA version as "CUDA UMD Version:"
instead of "CUDA Version:". The banner parser accepts both labels, so
the detected CUDA version is not lost on those drivers.

Signed-off-by: Ion Alpha <[email protected]>
Signed-off-by: Ion Alpha <[email protected]>
@codecov

codecov Bot commented Oct 31, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

The table in TestPolicyRejectsMutatedClaims was not gofmt-aligned, so
the repository format gate printed this file and failed. The change is
whitespace only: the case names and mutations are untouched.

Signed-off-by: Ion Alpha <[email protected]>
Signed-off-by: Ion Alpha <[email protected]>
The earlier gofmt-only commit on this file is outside this change and
undoes gofumpt alignment that CI's lint enforces. Putting main's
content back leaves the branch diff limited to the hardware probe.

Signed-off-by: Ion Alpha <[email protected]>
ion-alpha-dev added a commit that referenced this pull request Oct 31, 2026
…origin needs

Serve refused every entry that was not a vetted catalog source with
ErrNotServable. The flynn binary hands overlay entries (models add,
catalog.user.json) to Host.Serve, so none of them could run. Serve now
runs any entry in the host's catalog. An entry below TrustBlessed is
classified by the origin it names and is refused with ErrNotAdmitted
where the sandbox gives less isolation than that origin needs. A
reference that names no catalog entry is still ErrNotServable.

Admission reads the isolation through a hook the tests set, so an
entry that needs a microvm can reach the admitted path on a machine
that has none.

entrySource decided whether a Hub claim was fetched from its
repository with a prefix test on the URL text, which accepted
"/acme/tiny/../other/x.gguf". The path is now cleaned first, an
encoded parent segment included.

Free VRAM comes from Box.VRAMFreeBytes, which replaces
hardware.FreeVRAM. This depends on #640 and must merge after it.

Tests assert the exact source kind per origin (file, URL, Hub
repository) and serve a TrustLocal overlay entry end to end.

Signed-off-by: Ion Alpha <[email protected]>
@ion-alpha-dev
ion-alpha-dev merged commit b17ca3e into main Nov 1, 2026
32 checks passed
@ion-alpha-dev
ion-alpha-dev deleted the feat/hardware-vram-free-cuda-umd branch November 1, 2026 07:07
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 1, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant