Skip to content

Studio: reserve MiniMax-H3's pinned weights from sd.cpp's budget on integrated AMD GPUs - #13786

Merged
danielhanchen merged 6 commits into
unslothai:mainfrom
oobabooga:h3-native-amd-followup
Oct 18, 2026
Merged

danielhanchen merged 6 commits into
unslothai:mainfrom
oobabooga:h3-native-amd-followup

Conversation

@oobabooga

@oobabooga oobabooga commented Oct 15, 2026 •

Copy link
Copy Markdown
Member

Follow-up to #13531.

MiniMax-H3 GGUF on an integrated AMD GPU (Strix Halo, Strix Point, Phoenix) loads and passes Studio's GTT fit, then fails every default-size render on the Vulkan build when GTT is the half-of-RAM default:

[W] model manager cannot make enough memory available on Vulkan0: need 5687.60 MB device / 5175.60 MB budget, available 1356.88 MB device / 11346.88 MB budget
[E] minimax_h3 segment 1/1 (graph) failed during workspace capacity check

The UI reports "The renderer stopped unexpectedly".

Cause

  1. Studio passes --max-vram -1, which sd.cpp resolves at startup (resolve_auto_max_vram_bytes) from ggml's free memory, before it pins anything. For an integrated GPU, ggml-vulkan's free memory includes the GTT that the pinned denoiser and VAEs (15.5 GiB at Q4) are about to take. With 22.5 GiB free, sd.cpp budgets 21.8 GiB, plans one segment, stages the whole denoiser, and has 1.4 GB left for a 5.2 GB compute buffer.
  2. Studio: fit MiniMax-H3 GGUF to a Vulkan host's GTT pool before rendering #13531's fit checks only the pinned weights against free GTT. On a UMA card the compute buffer comes from the same pool, and the launch fit has no render size to estimate it.
  3. sd.cpp's capacity failure strings are not in _ACCELERATOR_CAPACITY_FAILURE_MARKERS, so the failure gets no memory advice.

Fix

  • sd_cpp_vulkan_device_is_uma reads ggml-vulkan's uma: 1 from the cached --list-devices output.
  • On a UMA device with a GTT reading, the fit replaces --max-vram -1 with --max-vram -<pinned + 1 GiB>, so sd.cpp's budget excludes the weights it pins. An explicit memory mode keeps its placement and only gets the corrected budget.
  • h3_native_live_fit takes the render's estimated compute buffer. On a UMA device, the part the carve-out cannot hold counts against GTT beside the pinned weights. The render, the sd-server start (pre_spawn) and the load (smallest clip) all pass a size.
  • The capacity markers gain sd.cpp's three graph-cut strings, so these failures get the Low VRAM / 864x480 / smaller quant advice and never count as accelerator failures.

Unchanged: discrete cards (uma: 0), CUDA, ROCm, Windows (no amdgpu sysfs, so no GTT reading), devices whose listing has no uma field, resident renders, and UNSLOTH_H3_NATIVE_FIT_CHECK=0.

Verification

AMD DevLab Linux runner (gfx1151, RADV, 0.5 GiB carve-out, 62.5 GiB GTT), Studio's pinned Vulkan prebuilt, Q4_K denoiser and Q4_K_M encoder, Studio's Auto flags, 124 frames, 2 steps. A Vulkan allocation held the rest of GTT so that a fixed amount stayed free. The "this PR" column ran this PR's h3_native_live_fit on the runner's live sysfs readings and passed sd-cli exactly the flags it returned.

GTT free Size main (--max-vram -1) This PR
22.0 to 25.0 GiB 864x480 capacity check fails
22.5 GiB 864x480 capacity check fails -17.05, renders in 387 s
30.0 GiB 1344x768 -17.05, renders in 2268 s
22.5 GiB 1344x768 capacity check fails refused: 26.4 GiB needed, 10.4 GiB of it activations
20.0 GiB 864x480 refused, naming the Q2_K denoiser
62.5 GiB both renders

Runs: main, main, full and 22.5 GiB, this PR.

The fit charges only the compute buffer, not sd.cpp's per-segment working set on top of it (0.3 GiB at 864x480, 1.2 GiB at 1344x768), so it refused no size that rendered. A render inside that margin fails in sd.cpp's capacity check and now gets the memory advice.

test_h3_native_memory_fit.py, test_video_backend.py and test_sd_cpp_backend.py: 740 passed.

Not tested:

  • A UMA part with a large carve-out. The reserve still applies; it only shrinks a budget the carve-out already covers.
  • The sd-server render path. Its start uses the same _h3_launch_flags, but only sd-cli was run.
  • A reused offloaded sd-server is not re-fitted, as on main, because a reading would count its own weights. A larger render on it relies on sd.cpp's capacity check.

Independent verification on the real target

Each tree's own Studio code (load fit, Auto resident choice, the sd-cli launch fit, the engine and the failure classifier) ran on gfx1151 Linux (RADV, 0.5 GiB carve-out, 62.47 GiB GTT), merge base 97ed941 vs head 33599d4, in the same job. Q4_K denoiser, Q4_K_M encoder, 124 frames, 2 steps, Studio's real Auto flags.

GTT held to 22.5 GiB free:

Size Base Head
864x480 --max-vram -1, budget 21.80 GiB, fails after 9.7 s in the workspace capacity check --max-vram -17.05, budget 5.75 GiB, renders in 386.6 s (864x480, 124 frames, audio)
1344x768 fails after 8.3 s in the same check refused before launch (26.4 GiB needed, 22.5 GiB free)
Low VRAM, 864x480 --max-vram -1 same placement, --max-vram -17.05

Nothing held (healthy host), 3 renders each:

Flags Runs (s) Median Peak GTT
Base --max-vram -1 386.2, 374.9, 377.6 377.6 42.73 GiB
Head --max-vram -34.02 374.6, 377.4, 370.9 374.6 42.73 GiB

The 3.0 s difference is inside the 18.9 s run-to-run spread. On Windows 11 gfx1151 (Vulkan prebuilt) the launch flags and the load fit are byte-identical to base. Across 4,800 enumerated fit cells, only the 40 Vulkan cells with a GTT reading and a UMA device move, and only in their --max-vram value.

Follow-up: capacity markers

The model manager's "cannot make enough memory available" warning is printed by renders that complete too (twice in the head render above), so matching it could relabel an unrelated crash as out of memory and skip recording a build failure. Commit d107ffe matches only sd.cpp's failing-segment lines (failed during workspace capacity check, failed during workspace allocation, failed during allocated capacity check). The real capacity failure above still gets the memory advice. New test: test_a_recovered_capacity_warning_is_not_a_capacity_failure.

Also not covered: Strix Point and Phoenix, Windows renders under GTT pressure, and the ROCm sd.cpp build under the same pressure.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-15T09:02:01.860897Z d107ffe Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@oobabooga

Copy link
Copy Markdown
Member Author

Reached Codex review convergence at oobabooga#374.

The model manager's "cannot make enough memory available" warning is
printed before recoveries too: renders that complete log it. Read as a
capacity failure, it made output_shows_accelerator_failure ignore a
build-level failure that followed it and explained unrelated crashes as
memory. Keep the fail_segment phrases, and add the allocated capacity
check that sd.cpp reports the same way.
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

Reviewed commit: d107ffef60

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@danielhanchen
danielhanchen merged commit 4232f63 into unslothai:main Oct 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants