Repository navigation
PR #6796 staging CI - #47
Closed
Imagineer99 wants to merge 26 commits into
Closed
Imagineer99 wants to merge 26 commits into
Imagineer99 wants to merge 26 commits into
Conversation
… MLX checkpoint - finish_run: add clear_output_dir flag; preserve output_dir for stopped/error unless cancel explicitly clears it (fixes pump finalization wiping persisted path). - training pump: pass interrupted stop-and-save context into finalize_run_in_db. - MLX stop-and-save: verify resumable checkpoint exists before sending complete; return bool from _write_mlx_stop_checkpoint and add regression tests.
…nalize
- Only skip MLX stop checkpoint write when checkpoint-{current_step} exists;
stale periodic checkpoints no longer mask missing stop saves.
- Pass clear_output_dir through error-event finalization so Stop-without-save
cannot leave a persisted output_dir that still offers Resume.
# Conflicts: # studio/frontend/src/features/studio/historical-training-view.tsx
Owner
Author
|
Closing the redundant full staging run; the focused PR unslothai#6796 workflow is running separately. |
danielhanchen
added a commit
that referenced
this pull request
Nov 6, 2026
…e CPU repack (unslothai#16758) ## Summary On Linux and Windows CPU hosts Studio starts sd.cpp without `--mmap`, so every weight is copied into anonymous memory. Z-Image Turbo Q4_K_M with the BF16 Qwen3-4B encoder peaks at about 12.9 GB of anonymous RSS at 512 px. The current pin's `--mmap` is not a fix: it skips the CPU weight repack for mapped weights, which changes the pixels. unslothai/stable-diffusion.cpp#43 makes `--mmap` keep the repack (repackable weights are loaded and repacked, everything else stays file-backed, copied ranges are released) and says so in `--help`. This PR is the Studio half of #43 (the commit prepared alongside it, rebased onto current main). It sends `--mmap` for CPU renders only on builds whose `--help` carries that text, so it stays off until the pin includes #43, then turns on by itself. - `mmap_flags()` replaces `mac_mmap_flags()` at the three command builders (sd-cli image, sd-cli video, sd-server). macOS is unchanged. - Off macOS it sends `--mmap` when the render runs on the CPU (the CPU bundle per the install record, or an explicit `--backend cpu`) and `sd-cli --help` contains `weights the CPU repacks are still loaded`. GPU bundles are left alone. - `UNSLOTH_DIFFUSION_SD_CPP_MMAP=1/0` now forces it on or off on every OS. ## Evidence (Colab CPU High-RAM, 4 cores x 2 SMT, 50 GB, same VM, interleaved) Z-Image Turbo Q4_K_M + Qwen3-4B BF16 + FLUX.1 VAE, 512 px, 2 steps, Studio's CPU argv, median [min, max] of 3 timed renders: | build | s/img | peak anon RSS | peak RSS | pixels | |---|---|---|---|---| | pin, no `--mmap` (today) | 206.1 [205.3, 216.3] | 12.9 GB | 12.9 GB | reference for the pin | | pin, `--mmap` | 222.4 [200.9, 233.7] | 1.9 GB | 12.2 GB | differ (repack skipped) | | #43, no `--mmap` | 219.7 [208.6, 225.1] | 12.9 GB | 12.9 GB | reference for #43 | | #43, `--mmap` | 203.1 [202.3, 221.4] | 3.9 GB | 12.1 GB | identical to #43 without `--mmap` | FLUX.2 klein 4B Q4_K_M + Qwen3-4B BF16, 512 px, 2 steps, 2 timed renders: #43 232.1 [223.8, 240.4] s, 10.3 GB anonymous, vs #43 `--mmap` 226.0 [215.2, 236.7] s, 3.4 GB anonymous, identical pixels. Weight load time (sd.cpp's `loading tensors completed`, median [min, max] over first + timed runs): Z-Image #43 18.0 [5.2, 34.3] s vs #43 `--mmap` 4.3 [3.8, 7.9] s; klein 6.4 [4.0, 9.4] s vs 2.6 [2.6, 3.0] s. Studio keeps sd-server resident, so this is paid once per model load. Speed is a tie (the spreads overlap). Anonymous memory drops 12.9 to 3.9 GB (Z-Image) and 10.3 to 3.4 GB (klein); the rest is clean page cache the kernel can drop under pressure. The pin bundle and a source build differ in pixels from each other (compiler), which is why each build is compared with itself. ## Tests - New tests in `test_sd_cpp_args.py`: CPU bundle with the help text gets `--mmap`; a build without it, a GPU bundle, an explicit `--mmap` in extra args and the env override are covered. They fail on main. - `pytest -o addopts= tests/test_*sd_cpp*.py` with no GPU visible: 1558 passed, 3 skipped (main: 1554 passed, 3 skipped). ## Not covered - Not run against a release bundle: no release carries #43 yet. Covered by unit tests and the #43 build's `--help`. - Measured on #43 alone. When the pin also takes the fork's F16 / BF16 tinyBLAS default (#47), the identity check (`--mmap` vs none, same build) should be repeated on that build. - Windows keeps the copied pages resident (#43 releases them with `madvise`, which it skips on Windows); the flag is still pixel-identical there.
danielhanchen
added a commit
that referenced
this pull request
Nov 11, 2026
…nslothai#17459) ## Summary Moves Studio's stable-diffusion.cpp prebuilt from `master-982-0518b34-uba6ac30` to `master-982-0518b34-ueb0e729`, the release built from fork master `eb0e729`. That is 36 fork commits on top of the current pin. The tag keeps the `master-982` prefix because the fork's release naming still counts from its last upstream release tag. What the new build brings: - Upstream resync to `master-1056` (unslothai/stable-diffusion.cpp#54): packed INT4 convrot, MiniMax-H3 QKV chunking, RelayVSR, SDXL ControlNet Union. Also Cosmos3-Nano-Sim-Transfer video-to-video (#53). - x86 CPU: llamafile tinyBLAS GEMM for Q8_0 (#42), F16 / BF16 (#47) and Q4_1 / Q5_0 / Q5_1 (#56) weights; an int8 tiled GEMM for Q8_0 / Q4_0 / Q4_1 / Q5_0 / Q5_1 / IQ4_NL (#76); AVX512 kernels on Intel and a faster direct convolution by default (#36, #70); Q4_K / Q2_K kept on the tiled matmul on AMD (#57); Q5_0 / Q5_1 / Q4_1 through the Q8_0 GEMM at diffusion batch sizes (#74); tiled flash attention and SIMD max fixes (#66, #68, #62). - aarch64 CPU: ik_llama.cpp GEMM kernels for K-quant and I-quant weights (#48, #75), a NEON + i8mm variant for 128-bit SVE cores (#58), SVE flash attention on the NEON path (#69), a 4x4 flash attention register tile (#67). - Metal: long graphs spread over more command buffers so the GPU watchdog does not fire (#44), a coalesced im2col kernel (#45), flash attention `auto` now means on without the timing probe (#46). - Vulkan: RMS norm for short rows (#37), direct convolution chosen by an output check instead of a timing race (#38), no host-buffer import on AMD and MoltenVK (#60). - HIP: bf16 WMMA operands for gfx11 / gfx12 (#59), FP32 accumulators in the tile flash attention kernel (#61). - CUDA: the Q8_1 block sum is computed from the quantized values, which lowers matmul error for Q4_1 / Q5_1 / Q4_K / Q5_K / Q2_K weights (#63); BF16 cuBLAS for large Q8_0 matmuls on A100, Hopper and datacenter Blackwell (#39). - Memory: the conditioning cache keeps entries across output sizes and denoiser-only LoRA changes (#71); auto-fit charges unified-memory devices against the RAM budget (#73, `SD_AUTOFIT_UMA=0` disables); CPU-resident text-encoder weights are released when the next phase would not fit (#72, `SD_TE_RELEASE=0` disables); `--mmap` repacks only what the CPU repacks (#43); Qwen Image 2.1 prefix cache concatenated in F16 (#64). - Packaging: bundles are smaller (#41; the Linux CPU bundle is 38.4 to 26.0 MiB, Linux CUDA 12 is 368.5 to 338.3 MiB, Linux Vulkan is 57.9 to 30.5 MiB), the Linux CPU bundles are run on emulated CPUs before shipping (#49), and there is a new native Windows arm64 CPU bundle (#55). ## Changes - `studio/install_sd_cpp_prebuilt.py`: `DEFAULT_TAG` now names the new release. - Tests that pin the release name and its asset list now point at the new tag. `test_sd_cpp_args.py` keeps the old pin in its list of builds that support `--mmap`. - The pinned asset lists gain `win-cpu-arm64`, with a test that a Windows ARM64 host gets that bundle for `auto` / `cpu` while an x64 host keeps `win-cpu-x64`, and that ARM64 with `cuda` or `vulkan` still gets no match. No Studio code changes. The existing selector already filters Windows bundles by host architecture, so a Windows arm64 host, which today finds no bundle in the pinned release and falls through to the upstream fallback, now installs the native arm64 CPU build. An x64 Python running under emulation on Windows arm64 reports `AMD64` and keeps the x64 bundle, as before. No option was removed from `sd-cli --help` or `sd-server --help`; the new build only adds `--control-type`, `--input-frames`, `--upscale-factor` and `--vsr-window-size`. ## Testing - The sd.cpp, args, families, install, pin upgrade and download retry tests pass (1406 passed). One test and one fixture error fail on main and on this branch alike on this host, because its huggingface_hub is older than the installed diffusers expects: `test_create_causal_mask_patch_is_self_disabling_and_idempotent` and `test_selection_installs_the_cuda_build`. - Asset names: every bundle the selector can return was enumerated over Linux x86_64 / aarch64, Windows AMD64 / ARM64 and macOS arm64 / x86_64, with `auto`, `cpu`, `cuda` (no major, 12, 13), `vulkan` and `rocm`, against the real asset list of the new release. Every returned name exists in the release. The only change from the current pin is Windows ARM64 `auto` / `cpu`, which goes from no match to `win-cpu-arm64`. - SD1.5 (`v1-5-pruned-emaonly`), 512x512, 8 steps on CPU and 20 steps on CUDA, euler, cfg 7, seed 42, both builds on the same machine. Each arm repeated two or three times; every repeat was pixel-identical to the first run of its arm. LPIPS is AlexNet. Linux x86_64 CPU bundle, Xeon Platinum 8559C, 32 threads, wall time per image: | Weights | current pin | this branch | old vs new LPIPS | max pixel diff | | --- | --- | --- | --- | --- | | f16 | 34.8 / 34.8 s | 16.4 / 17.2 s | 0.0001 | 13 | | q8_0 | 31.3 / 32.4 s | 15.7 / 15.2 s | 0.007 | 118 | | q4_K | 35.5 / 35.0 s | 18.7 / 19.0 s | 0.023 | 211 | VAE decode alone went from 10 to 12 s down to 3.6 to 3.7 s. The quantized CPU renders are not bit-identical to the current pin, but they stay as close to the f16 render as before (q8_0 LPIPS to f16: 0.038 old, 0.046 new; q4_K: 0.163 old, 0.173 new). Linux CUDA 12 bundle, Colab L4, wall time per image: | Weights | current pin | this branch | old vs new LPIPS | max pixel diff | | --- | --- | --- | --- | --- | | f16 | 4.70 / 4.70 / 4.71 s | 4.70 / 4.91 / 4.73 s | 0 | 0 | | q8_0 | 7.42 / 4.92 / 4.90 s | 4.94 / 4.93 / 4.93 s | 0 | 0 | | q4_1 | 18.13 / 17.97 / 17.94 s | 18.02 / 17.97 / 18.01 s | 0.025 | 198 | | q4_K | 19.14 / 17.63 / 17.79 s | 17.74 / 17.63 / 17.61 s | 0.106 | 253 | The current pin's first q8_0 run includes a cold start. f16 and q8_0 are pixel-identical. q4_K moves, as the Q8_1 fix intends, and moves toward the f16 render: LPIPS to f16 drops from 0.240 to 0.176 (q4_1: 0.327 to 0.322). ## Not covered - macOS (Metal) and Windows were not run on hardware yet; the cross-platform staging legs (Ubuntu, macOS 15, Windows) are still to run. - The new Windows arm64 bundle is covered only by the selector test and the asset check. No Windows arm64 host ran it. - No Vulkan, ROCm or HIP render with this build, no aarch64 Linux render, and no Studio HTTP flow run (only `sd-cli` directly). - No MiniMax-H3, MOSS-Image, Qwen-Image or FLUX.2 render with this build; only SD1.5. - CPU timings are from a shared host (both arms ran back to back with the same thread count), and the CUDA timings come from one L4 VM, three runs per arm. No T4 run.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Staging-only CI validation for unslothai#6796.
This PR exists only to run fork GitHub Actions checks and should be closed after validation.