Skip to content

Studio diffusion: test-launch sd.cpp binaries without the Windows missing-DLL box - #16031

Merged
danielhanchen merged 5 commits into
unslothai:mainfrom
oobabooga:sd-cpp-probe-error-mode
Oct 30, 2026
Merged

danielhanchen merged 5 commits into
unslothai:mainfrom
oobabooga:sd-cpp-probe-error-mode

Conversation

@oobabooga

@oobabooga oobabooga commented Oct 29, 2026 •

Copy link
Copy Markdown
Member

Reported on Reddit in a reply to "Anyone manage to get MOSS Image to load?": the hipblas.dll box still pops up on load after switching to Vulkan.

Problem

On Windows, an sd.cpp bundle that cannot load its DLLs (for example a ROCm bundle installed before #15371 on a host without the HIP SDK) opens a modal "sd-server.exe - System Error: ... hipblas.dll was not found" box when the backend test-launches it. The probes pass only windows_hidden_subprocess_kwargs(), which hides the console but not the loader's hard-error box. The installer's probe_binary_starts and _vulkan_probe already suppress it; the backend's probes did not.

The child stays blocked until someone clicks OK, so an unattended probe hits its timeout instead of reading 0xC0000135:

  • _server_binary_runnable returns True from its timeout branch, so an unrunnable managed binary is kept instead of being reinstalled.
  • With Vulkan requested, ensure_sd_server_binary probes again under _install_lock: a second box and another 20 s.
  • With ROCm still requested (UNSLOTH_SD_CPP_WINDOWS_ROCM=1, or hipblas.dll present but another HIP DLL missing), the broken binary is returned and later probes open more boxes.

Fix

windows_loader_error_boxes_suppressed() in utils/subprocess_compat.py ORs SEM_FAILCRITICALERRORS into the process error mode around a test-launch, so the child inherits it and exits at once with 0xC0000135. It wraps the four sd.cpp test-launches: _server_binary_runnable, _sd_cpp_probe_output, sd_cpp_binary_identifies and SdCppEngine.version.

The error mode is process-wide and these probes can overlap the installer's own probe, so all holders, including the installer's _windows_error_mode_suppressed (still 0x8003), share one record: the mode before the first holder plus the current holders' flags, restored when the last one leaves. The record lives in sys.modules because the installer and the backend import this module under different names.

Boundaries

  • windows_hidden_subprocess_kwargs and its ~95 callers are unchanged; the error mode is parent process state, not a CreateProcess argument.
  • The long-lived spawns are unchanged; the probes gate them.
  • The installer still runs standalone.

Verification

Windows 11, Radeon 8060S, no HIP SDK, with the upstream ROCm bundle installed without the start check (as v0.1.911-beta did). Each scenario ran against main (A) and this PR (B) in the logged-on desktop session:

Scenario A: main B: this PR
_server_binary_runnable(sd-server) box, 20.3 s, returns True no box, 0.56 s, False
_sd_cpp_probe_output(sd-cli, --help) box, 20.3 s no box, 0.59 s
sd_cpp_binary_identifies + version() box, 20.3 s no box, 0.58 s
Upgrade through both ensure_*, Vulkan requested 2 popups, 42.9 s no popup, 3.5 s
ROCm forced 3 popups, 60.5 s, keeps the broken ROCm binary no popup, 1.2 s, removes it for reinstall

An installer scope and a probe scope overlapping on the same host, with the installer leaving first, kept the bit for the probe and restored the original mode afterwards. On main in the non-interactive service session, the same probe returns in 0.6 s with no box, which is why headless runs never showed this.

tests/test_sd_cpp_probe_error_mode.py adds 11 tests with a fake kernel32, all failing on main. The sd.cpp, router, hires and Vulkan probe suites pass (1798 passed, 9 skipped).

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 29, 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 ⚠️ Failed 2026-10-29T19:48:18.969240Z
We couldn’t complete this review. Comment @codex review to try again.
9b255fa PR opened
ℹ️ 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#435.

@danielhanchen danielhanchen self-assigned this Oct 30, 2026
danielhanchen added a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Oct 30, 2026
@shimmyshimmer

shimmyshimmer commented Oct 30, 2026 •

Copy link
Copy Markdown
Member

Review record for #16031, carried over from the mirror it was reviewed on: danielhanchen/unsloth-staging-review#633.

Findings are quoted as posted and attributed to the account that posted them. The reactions shown are the triage recorded on the mirror; none were re-applied here. Commits are named as the mirror's, with this PR's equivalent where one was found.

Round 1: reviewed mirror 211627b6e (no equivalent commit found on this PR)

chatgpt-codex-connector[bot] (on the mirror)

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: 211627b6e5

No triage reaction was recorded on the mirror

Round 2: reviewed mirror 427e982739 (this PR's e2b014c4c)

chatgpt-codex-connector[bot] (on the mirror)

Codex Review: Didn't find any major issues. Nice work!

Reviewed commit: 427e982739

No triage reaction was recorded on the mirror

Verdict

The round converged at mirror 427e982739 (this PR's e2b014c4c).

This is the review as it stood at that commit. Anything pushed to this PR afterwards was not part of it.

danielhanchen added a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Oct 30, 2026
@danielhanchen
danielhanchen merged commit 982ab34 into unslothai:main Oct 30, 2026
danielhanchen added a commit that referenced this pull request Oct 30, 2026
…16108)

Since #16031 (test-launch sd.cpp binaries without the Windows
missing-DLL box), the AV shapes lint finds a new error on main. Every
PR's `Source lint` job and the
`test_lint_av_shapes.py::test_the_repository_is_clean_against_its_baseline`
test in the CPU shards fail on it, for example on #16018 and #15994:

```
studio/backend/tests/test_sd_cpp_probe_error_mode.py:221: [AV009] error: copies a Windows system binary
    line: shutil.copy(getattr(sys, "_base_executable", sys.executable), binary)
1 new error(s).
```

`test_a_real_binary_missing_its_dll_is_reported_unrunnable` copies
`python.exe` into `tmp_path` as `sd-server.exe`, away from
`pythonXY.dll`, and cuts `PATH` to System32. The result is a real PE
whose loader fails with `STATUS_DLL_NOT_FOUND`, the same failure as an
sd.cpp ROCm build without HIP. The lint's suggested replacement,
`windows_console_stub.py`, links nothing and starts fine, so it cannot
produce that failure. The copy has to stay. The lint documents this
route for that case: the finding is recorded in
`scripts/av_shapes_baseline.json` with the reason. The entry carries the
digest of that one line, so any other copy in the file is still a new
error.

I did not use `--update`. It would also have pruned many unrelated stale
entries across the baseline. This adds the one group (9 lines).

The CI message also prints an AV010 warning for
`.github/workflows/studio-tauri-smoke.yml:374` first, but warnings do
not fail the check. With only this entry added, the test passes.

## Verification

- `python scripts/lint_av_shapes.py`: `1 new error(s)` on main, `0 new
errors` here.
-
`tests/security/test_lint_av_shapes.py::test_the_repository_is_clean_against_its_baseline`:
fails on main on the AV009 line, passes here. The rest of the file
passes (19 passed).
- `--self-test` still passes, since the lint is unchanged.
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.

3 participants