Skip to content

feat(gpu): add Linux AMD probes and tested 780M APU leasing - #135

Merged
T-Crypt merged 4 commits into
T-Crypt:mainfrom
jenerestain:wnzn/feat/amd-support
Oct 22, 2026
Merged

T-Crypt merged 4 commits into
T-Crypt:mainfrom
jenerestain:wnzn/feat/amd-support

Conversation

@jenerestain

Copy link
Copy Markdown
Contributor

Summary

Add experimental Linux AMD support through the existing gpu.Probe interface, now including physically validated Radeon 780M/Phoenix APU leasing. This replaces closed PR #132, which was withdrawn so APU implementation and testing could happen first.

Adapter and selection

  • Keep the vendor-neutral broker/probe boundary; add amdgpu sysfs/DRM observations alongside the existing NVIDIA probes and optional streaming.
  • Select --gpu-backend auto|nvidia|amd in the daemon and generated service, and reuse backend selection in the swap benchmark.
  • Match processes and cards by normalized PCI identity; AMD indices retain Linux DRM cardN numbering, not HIP ordinals.
  • Support discrete RDNA3 GC 11.0.0/2/3, discrete RDNA4 GC 12.0.0/1, and Phoenix GC 11.0.1. Unknown/unvalidated APU IPs remain excluded.
  • No ROCm, amd-smi, CGO, new Go dependencies, inference contexts, or monitoring service required by the runtime probe.

APU safety policy

  • Keep reserved UMA VRAM and shared-system-RAM GTT independent in driver readings, process attribution, status, and release confirmation. Never add GTT capacity to dedicated VRAM or present it as reserved/available host RAM.
  • Track GTT-only clients, deduplicate inherited DRM clients, discount shared buffers, and retain ownership for explicitly unobservable processes.
  • Require fresh driver observations and independent return to both pre-load baselines before a released APU lease frees.
  • Allow exclusive APU leases only. Refuse sized APU requests because a scalar needs-mib cannot express both pools.
  • Gate new APU admissions on current host RAM headroom (default 2 GiB) and memory pressure, without preventing a low-RAM holder from draining.
  • Explicitly refuse APU parking and use the normal drain path; do not mistake GTT-resident weights for a completed offload. Discrete-GPU sized leases and parking retain their existing behavior.
  • Preserve PID/start-time identity checks, report-only stowaways, and upstream VFIO hold/probe suppression. The existing VFIO CLI remains NVIDIA-specific.

Validation

Checked with the repository's Go 1.27.1 and exact linter version:

  • go build ./... && test -z "$(gofmt -l .)" && go vet ./... && go test ./...
  • go run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.14.0 run ./... — 0 issues
  • GOOS=windows go build ./... && GOOS=windows go vet ./...
  • go test -race ./internal/gpu ./internal/broker ./internal/cli ./internal/server
  • Repeated guarded/APU broker race regressions (-count=3)
  • Read-only W7900 and 780M driver/process observations on Linux 6.12.107+deb13-amd64
  • W7900 bounded real allocation, attribution, priority drain, measured release, and handoff
  • 780M reserved-UMA to GTT handoff, with independent pool accounting and an impossible-RAM-floor check proving a refused child never starts
  • 780M real Vulkan llama.cpp embedding smoke, then idle /slots drain and handoff to a real GTT allocation

Real 780M inference evidence

Used an existing 175 MiB EmbeddingGemma 2 GGUF, a 512-token context, and two CPU threads in a private Berth daemon/config/socket and an unused loopback port. Two requests returned finite normalized 768-dimensional embeddings. Berth confirmed the model's release before admitting the next 64 MiB GTT workload.

The isolated model process's only observed GPU was the selected 780M. A process-local Landlock allowlist denied access to other DRM nodes; environment selection alone was insufficient in the first aborted attempt. Landlock is a validation-helper-only requirement, not a Berth runtime dependency.

The final smoke used a 1 GiB host-RSS watchdog budget while preserving the same 2 GiB admission floor. Observed kernel RSS high-water was 297,431,040 bytes and observed GPU residency 181,530,624 bytes. These are smoke-test observations, not reservations, hard cgroup guarantees, throughput benchmarks, or full-context stress results.

Reserved UMA usage returned to 3,924,680,704 bytes, and GTT usage to 460,148,736 bytes, exactly matching their pre-test readings. Both unattributed baselines also returned exactly. Existing workload process identities were unchanged; no existing service was stopped or reconfigured, and no driver/BIOS settings were changed.

Repeatable commands, fixture gates, resource checks, prior failed/blocked attempts, and explicit limits are documented in contrib/amd/README.md. Optional helpers are not part of CI or the runtime dependency chain.

Explicit remaining limits

  • RDNA4 is fixture-tested, not physically validated here.
  • No NVIDIA GPU was available for a live regression run. NVIDIA tests and Windows build/vet pass; native Windows execution remains an upstream CI gate.
  • APU sized sharing and park/resume are not supported in this initial implementation.
  • Other APU IPs, AMD Windows, every ROCm/HIP memory mode, model-quality validation, and full-context stress testing are not claimed.
  • Unobservable/shared background allocations can conservatively delay release confirmation. Whole-card leases retain existing report-only contested-grant behavior and do not isolate engine device placement.
  • No unrelated fixes, toolchain/dependency version changes, or production deployment are included. Please keep CI green before merge; fork workflows may require maintainer approval.

@T-Crypt

T-Crypt commented Oct 22, 2026

Copy link
Copy Markdown
Owner

Thank you for this, and for the careful 780M validation. The dual-pool accounting and the exclusive-only APU policy are exactly the right calls.

I'm landing it through #136, which keeps your commits and authorship and adds one commit on top:

  • auto now keeps NVIDIA whenever nvidia-smi is installed. Refusing on mixed hosts would have stopped berthd from starting after an upgrade for existing NVIDIA users on Phoenix laptops with an RTX dGPU, or 8000G desktops with a GeForce card, because their installed units have no --gpu-backend. AMD users on mixed hosts pass --gpu-backend amd.
  • The guarded broker tests now use an empty sysfs root. On a host whose card was bound to vfio-pci, the VFIO fallback turned the stale-read test into a passthrough and it failed.

This PR will show as merged once #136 lands.

T-Crypt added a commit that referenced this pull request Oct 22, 2026
Linux AMD support (#135) with NVIDIA kept as the auto default
@T-Crypt
T-Crypt merged commit 4030e8e into T-Crypt:main Oct 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants