Repository navigation
studio: give minimax-h3 the sd.cpp graph-cut flags so it renders on a smaller card - #8644
Conversation
|
@codex review |
… smaller card H3 allocates each module whole on the device when its graph runs, so --offload-to-cpu is not enough on its own: the 20.5 GB pruned denoiser and the 17 GB Qwen3-VL encoder ask for the full module at once and cudaMalloc fails on a 12 GB card. The abort lands in the conditioner before any tensor is resident, so VRAM never rises and it presents as a model that never loaded rather than an out-of-memory error. sd.cpp's graph-cut executor is what splits a module into segments that fit, and Studio never asked for it. The H3 native path now adds --max-vram -1 --stream-layers. A negative budget auto-detects free VRAM per device, sparing that many GiB, and a module that already fits merges back into a single segment, so a setup with room pays nothing for this. It is deliberately not gated on the memory mode: auto and fast are what users reach first and are exactly the modes that fail. sd_cpp_supports_graph_cut reads both options out of --help and fails closed, the opposite default to the H3 gate next to it. sd-cli exits non-zero on an option it does not know, so an unreadable probe has to emit nothing rather than break a build that renders today. The CPU runtime never asks, since it allocates from system RAM. Part of unslothai#8636.
|
Codex Review: Didn't find any major issues. 🎉 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
The identity gate added in unslothai#8560 reads --help for a stable-diffusion.cpp banner before the H3 capability marker, so these fixtures need one to reach the load path they exercise.
4ef3353 to
0d263aa
Compare
|
@codex review |
|
Codex Review: Didn't find any major issues. More of your lovely PRs please. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
|
Went through this one carefully, including the thing that looked like a blocking bug and is not. The
|
c09bed3 to
7819bde
Compare
|
Took this over and pushed a commit that gates Before and afterBefore: MiniMax-H3 allocates each module whole on the device (20.5 GB DiT, 17 GB encoder), so After: when the binary advertises the graph-cut executor, the load also passes Real issue. The only thing wrong with the original patch was that half of it was inert in one memory mode. Why I changed itUpstream leejet/stable-diffusion.cpp,
and separately, for the other flag:
The constant is now split, so Does it break anythingThe important direction is old sd-cli builds, because sd-cli exits non-zero on an unknown option, which would kill every render rather than degrade. That is still fail-closed: I ran the whole platform and accelerator product through the real load with a stubbed sd-cli, since the flags depend only on what Two rules enforced there: no graph-cut flag ever reaches a build whose The CPU rows matter too: The thing that looked like a blocking bug and is not
TestsThe one failure is New test Still not verified, and worth doing before mergeNo real sd-cli with the graph-cut executor was executed here, so the flags are validated against upstream source and docs only. The evidence this change actually deserves is a real H3 render on a 12 GB class card in Minor, non-blocking: this adds a third |
|
@codex review |
1 similar comment
|
@codex review |
|
Codex Review: Didn't find any major issues. 🚀 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
Part of #8636 (issue 2).
unsloth/MiniMax-H3-GGUFcannot render on a card smaller than its checkpoint, and fails in a way that reads as the model never loading.The problem
offload_flags()produces--offload-to-cpu, which parks parameters in RAM, but each module is still allocated whole on the device when its graph runs. H3's pruned denoiser is 20.5 GB and its Qwen3-VL encoder 17 GB, so on a 12 GB card the allocation fails outright:The abort lands in the conditioner before any tensor is resident, so VRAM never rises and the UI shows a bare "generation failed". That looks like a model that never loaded rather than an out-of-memory error, which is what makes it hard to diagnose.
The change
sd.cpp already ships the graph-cut executor that splits a module into segments that fit; Studio never asked for it. The H3 native path now appends
--max-vram -1 --stream-layers.A negative
--max-vramauto-detects free VRAM per device sparing that many GiB, rather than pinning a fixed ceiling, so it adapts to whichever card the graph lands on. A module that already fits merges back into a single segment, so a setup with room pays nothing:Deliberately not gated on the memory mode.
autoandfastare what users reach first and are exactly the modes that fail;low_vramis not where this belongs.sd_cpp_supports_graph_cut()reads both options out of--helpand fails closed — the opposite default tosd_cpp_supports_minimax_h3()next to it. That gate refuses a build, so "cannot tell" has to keep it; this one adds flags, andsd-cliexits non-zero on an option it does not know, so an unreadable probe must emit nothing rather than break a build that renders today. Both markers are required, since--stream-layersis documented as a no-op without--max-vram. The probe runs under the same_tree_readerclaim as every other one on this path, and the CPU runtime never asks, since it allocates from system RAM.Testing
Focused tests for the probe (both flags required, fails closed on an unreadable or non-zero
--help) and for the load path (flags emitted on an accelerator, absent on an older build, absent on CPU).Verified against fake
sd-cliexecutables through the real subprocess probe path: a build advertising both flags gates open, one without them gates shut, and a binary exiting non-zero yields no flags. The auto-mode argv comes out--offload-to-cpu --diffusion-fa --max-vram -1 --stream-layers.Flag semantics confirmed against
examples/common/common.cppinleejet/stable-diffusion.cpp.No H3 render was run here — the 23.8s figure and the log above are the reporter's, measured on a 12 GB RTX 4070 Ti at 320x192, 22 frames, 2 steps.
Issue 3 in that report (
--split-mode layeralways short by ~157 MB) is upstream C++ and untouched here.