Skip to content

Make the memory preflight OOM guard configurable (auto: on for APUs, off for dGPUs) - #697

Open
ghazni101 wants to merge 2 commits into
warpfront:masterfrom
ghazni101:patch/oom-guard-multislot
Open

Make the memory preflight OOM guard configurable (auto: on for APUs, off for dGPUs)#697
ghazni101 wants to merge 2 commits into
warpfront:masterfrom
ghazni101:patch/oom-guard-multislot

Conversation

@ghazni101

Copy link
Copy Markdown
Contributor

Summary

Fixes #696.

The memory preflight OOM guard assumed GPU memory always comes from system RAM (true on unified-memory APUs like Strix Halo, false on discrete GPUs). This made it refuse valid loads on dGPU dev boxes with no way to opt out — biting multi-daemon dev workflows and bench sweeps where MemAvailable is temporarily depressed.

Changes

Two commits:

1. feat(config): make the memory preflight OOM guard configurable

Adds typed, process-scoped config key memory.oom_guard (default true, env compat HIPFIRE_OOM_GUARD). Both guard sites (kv_slots::preflight_alloc and the CLI bench-sweep preflight_headroom_for_model) honor the knob. A disabled guard prints a one-line stderr note. Default behavior unchanged.

2. feat(config): oom_guard auto mode — enable only on unified-memory APUs

Default flips from always-on to auto, resolved by deployment class:

  • Unified-memory APU (gfx1035/1036/1103/1150/1151/1152) → guard ON (GPU allocations come from system RAM)
  • Discrete GPU (gfx90x/10x/1100-02/1200-01, CDNA) → guard OFF (overshoot is a failed hipMalloc)
  • Unrecognized arch → guard ON (fail safe)
  • No GPU arch known (CLI pre-init) → host swap state decides

Explicit true/false overrides auto. The auto decision is logged once to stderr with its reason.

Files

File Change
crates/hipfire-config/src/lib.rs OomGuardMode, arch classification tables, oom_guard_effective() resolver, AutoBool config field, tests
crates/rdna-compute/src/kv_slots.rs preflight_alloc resolves through oom_guard_effective
crates/rdna-compute/src/arch_caps.rs process_gpu_arch() — records detected arch at Gpu::init
crates/rdna-compute/src/dispatch.rs Calls note_process_gpu_arch at init
crates/hipfire-cli/src/main.rs Bench-sweep headroom check resolves with arch=None
AGENTS.md, docs/CONFIG.md, docs/env-vars.md Documentation

Verification

  • hipfire-config and kv_slots unit test suites pass
  • config list shows default auto; HIPFIRE_OOM_GUARD=0 and config set memory.oom_guard auto both resolve correctly
  • All touched crates compile

The preflight OOM guard (kv_slots::preflight_alloc: deployment-target
ceiling + MemAvailable headroom, plus the CLI bench-sweep headroom
check) assumed GPU memory always comes from system RAM. That is true on
unified-memory APUs (Strix Halo, no swap), where an overshoot is a
global OOM that kills the desktop — and is exactly why the guard exists.
On a discrete-GPU dev box an overshoot is a plain failed hipMalloc, and
reviewer feedback points out agents running multiple daemons/serves
there get refused loads the hardware would survive.

Add a typed, process-scoped schema key memory.oom_guard (default true,
env compat HIPFIRE_OOM_GUARD) so the operator can opt out:

  hipfire config set memory.oom_guard false   # or: HIPFIRE_OOM_GUARD=0

Both production guard sites honor the knob at the single
preflight_alloc choke point and in preflight_headroom_for_model; a
disabled guard prints a one-line stderr note so a skipped refusal is
visible in logs. Default behavior is unchanged: the guard stays on
unless explicitly disabled, and scripts/run-bounded.sh remains the hard
cgroup backstop either way.
Follow-up to 375f446. The guard's default is now the three-state
`auto` (bool spellings still parse) instead of always-on, so dGPU dev
boxes run unguarded by default and unified-memory boxes stay protected
without anyone setting anything:

  auto:  unified-memory APU arch  (gfx1035/1036/1103/1150/1151/1152)
           → guard ON  — GPU allocations come out of system RAM
         discrete-GPU arch        (gfx90x/10x/1100-02/1200-01, CDNA)
           → guard OFF — an overshoot is a failed hipMalloc, not an OOM
         unrecognized arch
           → guard ON  — fail safe; extend the table when support lands
         no GPU arch known in this process (CLI side, pre-init)
           → host swap state decides: swap → OFF (overcommit degrades,
             does not kill), no/unreadable swap → ON (fail safe)

Mechanics:
- hipfire-config: `memory.oom_guard` flips to process_auto_bool_field
  (AutoBool rule, default "auto"); new OomGuardMode + is_unified_memory_arch
  tables + /proc/meminfo SwapTotal probe + oom_guard_effective(arch)
  resolver that logs the auto decision once with its reason. Tables live
  here because rdna-compute cannot depend back on this crate.
- rdna-compute: arch_caps records the DETECTED (not HIPFIRE_TARGET_ARCH-
  overridden) arch at Gpu::init — first init wins; kv_slots::preflight_alloc
  resolves through it. The refusal checks are split into preflight_checks
  so unit tests stay deterministic regardless of host config.
- hipfire-cli: bench-sweep headroom check resolves with arch=None (host
  swap signal).

Verified: config list shows default `auto`, HIPFIRE_OOM_GUARD=0 and
`config set memory.oom_guard auto` both resolve; hipfire-config and
kv_slots suites green; all touched crates compile.
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.

Memory preflight OOM guard is unconditionally enabled — refuses valid loads on discrete-GPU dev boxes

1 participant