Skip to content

Commit 5975e1e

Browse files
authored
Merge branch 'master' into tiling-support
2 parents 144c278 + 11ab095 commit 5975e1e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+500892
-6871
lines changed

.clang-tidy

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Checks: >
2+
modernize-make-shared,
3+
modernize-use-nullptr,
4+
modernize-use-override,
5+
modernize-pass-by-value,
6+
modernize-return-braced-init-list,
7+
modernize-deprecated-headers,
8+
HeaderFilterRegex: '^$'
9+
WarningsAsErrors: ''
10+
FormatStyle: none

.github/workflows/build.yml

Lines changed: 105 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ jobs:
6565
6666
- name: Get commit hash
6767
id: commit
68-
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/main' ) || github.event.inputs.create_release == 'true' }}
68+
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
6969
uses: pr-mpt/actions-commit-hash@v2
7070

7171
- name: Fetch system info
@@ -118,7 +118,7 @@ jobs:
118118
119119
- name: Get commit hash
120120
id: commit
121-
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/main' ) || github.event.inputs.create_release == 'true' }}
121+
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
122122
uses: pr-mpt/actions-commit-hash@v2
123123

124124
- name: Fetch system info
@@ -163,9 +163,7 @@ jobs:
163163
- build: "avx512"
164164
defines: "-DGGML_NATIVE=OFF -DGGML_AVX512=ON -DGGML_AVX=ON -DGGML_AVX2=ON -DSD_BUILD_SHARED_LIBS=ON"
165165
- build: "cuda12"
166-
defines: "-DSD_CUDA=ON -DSD_BUILD_SHARED_LIBS=ON -DCMAKE_CUDA_ARCHITECTURES=90;89;86;80;75"
167-
# - build: "rocm5.5"
168-
# defines: '-G Ninja -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DSD_HIPBLAS=ON -DCMAKE_BUILD_TYPE=Release -DAMDGPU_TARGETS="gfx1100;gfx1102;gfx1030" -DSD_BUILD_SHARED_LIBS=ON'
166+
defines: "-DSD_CUDA=ON -DSD_BUILD_SHARED_LIBS=ON -DCMAKE_CUDA_ARCHITECTURES='61;70;75;80;86;89;90;100;120'"
169167
- build: 'vulkan'
170168
defines: "-DSD_VULKAN=ON -DSD_BUILD_SHARED_LIBS=ON"
171169
steps:
@@ -178,28 +176,15 @@ jobs:
178176
- name: Install cuda-toolkit
179177
id: cuda-toolkit
180178
if: ${{ matrix.build == 'cuda12' }}
181-
uses: Jimver/cuda-toolkit@v0.2.19
179+
uses: Jimver/cuda-toolkit@v0.2.22
182180
with:
183-
cuda: "12.6.2"
181+
cuda: "12.8.1"
184182
method: "network"
185183
sub-packages: '["nvcc", "cudart", "cublas", "cublas_dev", "thrust", "visual_studio_integration"]'
186184

187-
- name: Install rocm-toolkit
188-
id: rocm-toolkit
189-
if: ${{ matrix.build == 'rocm5.5' }}
190-
uses: Cyberhan123/rocm-toolkit@v0.1.0
191-
with:
192-
rocm: "5.5.0"
193-
194-
- name: Install Ninja
195-
id: install-ninja
196-
if: ${{ matrix.build == 'rocm5.5' }}
197-
uses: urkle/action-get-ninja@v1
198-
with:
199-
version: 1.11.1
200185
- name: Install Vulkan SDK
201186
id: get_vulkan
202-
if: ${{ matrix.build == 'vulkan' }} https://sdk.lunarg.com/sdk/download/1.4.328.1/windows/vulkansdk-windows-X64-1.4.328.1.exe
187+
if: ${{ matrix.build == 'vulkan' }}
203188
run: |
204189
curl.exe -o $env:RUNNER_TEMP/VulkanSDK-Installer.exe -L "https://sdk.lunarg.com/sdk/download/${env:VULKAN_VERSION}/windows/vulkansdk-windows-X64-${env:VULKAN_VERSION}.exe"
205190
& "$env:RUNNER_TEMP\VulkanSDK-Installer.exe" --accept-licenses --default-answer --confirm-command install
@@ -277,6 +262,104 @@ jobs:
277262
path: |
278263
sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-win-${{ matrix.build }}-x64.zip
279264
265+
windows-latest-cmake-hip:
266+
runs-on: windows-2022
267+
268+
env:
269+
HIPSDK_INSTALLER_VERSION: "25.Q3"
270+
GPU_TARGETS: "gfx1151;gfx1200;gfx1201;gfx1100;gfx1101;gfx1102;gfx1030;gfx1031;gfx1032"
271+
272+
steps:
273+
- uses: actions/checkout@v3
274+
with:
275+
submodules: recursive
276+
277+
- name: Cache ROCm Installation
278+
id: cache-rocm
279+
uses: actions/cache@v4
280+
with:
281+
path: C:\Program Files\AMD\ROCm
282+
key: rocm-${{ env.HIPSDK_INSTALLER_VERSION }}-${{ runner.os }}
283+
284+
- name: ccache
285+
uses: ggml-org/ccache-action@v1.2.16
286+
with:
287+
key: windows-latest-cmake-hip-${{ env.HIPSDK_INSTALLER_VERSION }}-x64
288+
evict-old-files: 1d
289+
290+
- name: Install ROCm
291+
if: steps.cache-rocm.outputs.cache-hit != 'true'
292+
run: |
293+
$ErrorActionPreference = "Stop"
294+
write-host "Downloading AMD HIP SDK Installer"
295+
Invoke-WebRequest -Uri "https://download.amd.com/developer/eula/rocm-hub/AMD-Software-PRO-Edition-${{ env.HIPSDK_INSTALLER_VERSION }}-WinSvr2022-For-HIP.exe" -OutFile "${env:RUNNER_TEMP}\rocm-install.exe"
296+
write-host "Installing AMD HIP SDK"
297+
$proc = Start-Process "${env:RUNNER_TEMP}\rocm-install.exe" -ArgumentList '-install' -NoNewWindow -PassThru
298+
$completed = $proc.WaitForExit(600000)
299+
if (-not $completed) {
300+
Write-Error "ROCm installation timed out after 10 minutes. Killing the process"
301+
$proc.Kill()
302+
exit 1
303+
}
304+
if ($proc.ExitCode -ne 0) {
305+
Write-Error "ROCm installation failed with exit code $($proc.ExitCode)"
306+
exit 1
307+
}
308+
write-host "Completed AMD HIP SDK installation"
309+
310+
- name: Verify ROCm
311+
run: |
312+
# Find and test ROCm installation
313+
$clangPath = Get-ChildItem 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' | Select-Object -First 1
314+
if (-not $clangPath) {
315+
Write-Error "ROCm installation not found"
316+
exit 1
317+
}
318+
& $clangPath.FullName --version
319+
# Set HIP_PATH environment variable for later steps
320+
echo "HIP_PATH=$(Resolve-Path 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' | split-path | split-path)" >> $env:GITHUB_ENV
321+
322+
- name: Build
323+
run: |
324+
mkdir build
325+
cd build
326+
$env:CMAKE_PREFIX_PATH="${env:HIP_PATH}"
327+
cmake .. `
328+
-G "Unix Makefiles" `
329+
-DSD_HIPBLAS=ON `
330+
-DSD_BUILD_SHARED_LIBS=ON `
331+
-DGGML_NATIVE=OFF `
332+
-DCMAKE_C_COMPILER=clang `
333+
-DCMAKE_CXX_COMPILER=clang++ `
334+
-DCMAKE_BUILD_TYPE=Release `
335+
-DGPU_TARGETS="${{ env.GPU_TARGETS }}"
336+
cmake --build . --config Release --parallel ${env:NUMBER_OF_PROCESSORS}
337+
338+
- name: Get commit hash
339+
id: commit
340+
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
341+
uses: pr-mpt/actions-commit-hash@v2
342+
343+
- name: Pack artifacts
344+
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
345+
run: |
346+
md "build\bin\rocblas\library\"
347+
md "build\bin\hipblaslt\library"
348+
cp "${env:HIP_PATH}\bin\hipblas.dll" "build\bin\"
349+
cp "${env:HIP_PATH}\bin\hipblaslt.dll" "build\bin\"
350+
cp "${env:HIP_PATH}\bin\rocblas.dll" "build\bin\"
351+
cp "${env:HIP_PATH}\bin\rocblas\library\*" "build\bin\rocblas\library\"
352+
cp "${env:HIP_PATH}\bin\hipblaslt\library\*" "build\bin\hipblaslt\library\"
353+
7z a sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-win-rocm-x64.zip .\build\bin\*
354+
355+
- name: Upload artifacts
356+
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
357+
uses: actions/upload-artifact@v4
358+
with:
359+
name: sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-win-rocm-x64.zip
360+
path: |
361+
sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-win-rocm-x64.zip
362+
280363
release:
281364
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
282365

@@ -286,6 +369,7 @@ jobs:
286369
- ubuntu-latest-cmake
287370
- macOS-latest-cmake
288371
- windows-latest-cmake
372+
- windows-latest-cmake-hip
289373

290374
steps:
291375
- name: Clone

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ test/
1212
output*.png
1313
models*
1414
*.log
15+
preview.png

CMakeLists.txt

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,38 @@ file(GLOB SD_LIB_SOURCES
8787
"*.hpp"
8888
)
8989

90+
find_program(GIT_EXE NAMES git git.exe NO_CMAKE_FIND_ROOT_PATH)
91+
if(GIT_EXE)
92+
execute_process(COMMAND ${GIT_EXE} describe --tags --abbrev=7 --dirty=+
93+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
94+
OUTPUT_VARIABLE SDCPP_BUILD_VERSION
95+
OUTPUT_STRIP_TRAILING_WHITESPACE
96+
ERROR_QUIET
97+
)
98+
execute_process(COMMAND ${GIT_EXE} rev-parse --short HEAD
99+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
100+
OUTPUT_VARIABLE SDCPP_BUILD_COMMIT
101+
OUTPUT_STRIP_TRAILING_WHITESPACE
102+
ERROR_QUIET
103+
)
104+
endif()
105+
106+
if(NOT SDCPP_BUILD_VERSION)
107+
set(SDCPP_BUILD_VERSION unknown)
108+
endif()
109+
message(STATUS "stable-diffusion.cpp version ${SDCPP_BUILD_VERSION}")
110+
111+
if(NOT SDCPP_BUILD_COMMIT)
112+
set(SDCPP_BUILD_COMMIT unknown)
113+
endif()
114+
message(STATUS "stable-diffusion.cpp commit ${SDCPP_BUILD_COMMIT}")
115+
116+
set_property(
117+
SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/version.cpp
118+
APPEND PROPERTY COMPILE_DEFINITIONS
119+
SDCPP_BUILD_COMMIT=${SDCPP_BUILD_COMMIT} SDCPP_BUILD_VERSION=${SDCPP_BUILD_VERSION}
120+
)
121+
90122
if(SD_BUILD_SHARED_LIBS)
91123
message("-- Build shared library")
92124
message(${SD_LIB_SOURCES})

README.md

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<p align="center">
2-
<img src="./assets/cat_with_sd_cpp_42.png" width="360x">
2+
<img src="./assets/logo.png" width="360x">
33
</p>
44

55
# stable-diffusion.cpp
@@ -15,6 +15,12 @@ API and command-line option may change frequently.***
1515

1616
## 🔥Important News
1717

18+
* **2025/12/01** 🚀 stable-diffusion.cpp now supports **Z-Image**
19+
👉 Details: [PR #1020](https://github.com/leejet/stable-diffusion.cpp/pull/1020)
20+
21+
* **2025/11/30** 🚀 stable-diffusion.cpp now supports **FLUX.2-dev**
22+
👉 Details: [PR #1016](https://github.com/leejet/stable-diffusion.cpp/pull/1016)
23+
1824
* **2025/10/13** 🚀 stable-diffusion.cpp now supports **Qwen-Image-Edit / Qwen-Image-Edit 2509**
1925
👉 Details: [PR #877](https://github.com/leejet/stable-diffusion.cpp/pull/877)
2026

@@ -29,16 +35,21 @@ API and command-line option may change frequently.***
2935

3036
## Features
3137

32-
- Plain C/C++ implementation based on [ggml](https://github.com/ggerganov/ggml), working in the same way as [llama.cpp](https://github.com/ggerganov/llama.cpp)
38+
- Plain C/C++ implementation based on [ggml](https://github.com/ggml-org/ggml), working in the same way as [llama.cpp](https://github.com/ggml-org/llama.cpp)
3339
- Super lightweight and without external dependencies
3440
- Supported models
3541
- Image Models
3642
- SD1.x, SD2.x, [SD-Turbo](https://huggingface.co/stabilityai/sd-turbo)
3743
- SDXL, [SDXL-Turbo](https://huggingface.co/stabilityai/sdxl-turbo)
44+
- [Some SD1.x and SDXL distilled models](./docs/distilled_sd.md)
3845
- [SD3/SD3.5](./docs/sd3.md)
39-
- [Flux-dev/Flux-schnell](./docs/flux.md)
46+
- [FlUX.1-dev/FlUX.1-schnell](./docs/flux.md)
47+
- [FLUX.2-dev](./docs/flux2.md)
4048
- [Chroma](./docs/chroma.md)
49+
- [Chroma1-Radiance](./docs/chroma_radiance.md)
4150
- [Qwen Image](./docs/qwen_image.md)
51+
- [Z-Image](./docs/z_image.md)
52+
- [Ovis-Image](./docs/ovis_image.md)
4253
- Image Edit Models
4354
- [FLUX.1-Kontext-dev](./docs/kontext.md)
4455
- [Qwen Image Edit/Qwen Image Edit 2509](./docs/qwen_image_edit.md)
@@ -79,7 +90,9 @@ API and command-line option may change frequently.***
7990
- [`DPM++ 2M v2`](https://github.com/AUTOMATIC1111/stable-diffusion-webui/discussions/8457)
8091
- `DPM++ 2S a`
8192
- [`LCM`](https://github.com/AUTOMATIC1111/stable-diffusion-webui/issues/13952)
82-
- Cross-platform reproducibility (`--rng cuda`, consistent with the `stable-diffusion-webui GPU RNG`)
93+
- Cross-platform reproducibility
94+
- `--rng cuda`, default, consistent with the `stable-diffusion-webui GPU RNG`
95+
- `--rng cpu`, consistent with the `comfyui RNG`
8396
- Embedds generation parameters into png output as webui-compatible text string
8497

8598
## Quick Start
@@ -92,7 +105,7 @@ API and command-line option may change frequently.***
92105
### Download model weights
93106

94107
- download weights(.ckpt or .safetensors or .gguf). For example
95-
- Stable Diffusion v1.5 from https://huggingface.co/runwayml/stable-diffusion-v1-5
108+
- Stable Diffusion v1.5 from https://huggingface.co/stable-diffusion-v1-5/stable-diffusion-v1-5
96109

97110
```sh
98111
curl -L -O https://huggingface.co/runwayml/stable-diffusion-v1-5/resolve/main/v1-5-pruned-emaonly.safetensors
@@ -114,12 +127,15 @@ If you want to improve performance or reduce VRAM/RAM usage, please refer to [pe
114127

115128
- [SD1.x/SD2.x/SDXL](./docs/sd.md)
116129
- [SD3/SD3.5](./docs/sd3.md)
117-
- [Flux-dev/Flux-schnell](./docs/flux.md)
130+
- [FlUX.1-dev/FlUX.1-schnell](./docs/flux.md)
131+
- [FLUX.2-dev](./docs/flux2.md)
118132
- [FLUX.1-Kontext-dev](./docs/kontext.md)
119133
- [Chroma](./docs/chroma.md)
120134
- [🔥Qwen Image](./docs/qwen_image.md)
121135
- [🔥Qwen Image Edit/Qwen Image Edit 2509](./docs/qwen_image_edit.md)
122136
- [🔥Wan2.1/Wan2.2](./docs/wan.md)
137+
- [🔥Z-Image](./docs/z_image.md)
138+
- [Ovis-Image](./docs/ovis_image.md)
123139
- [LoRA](./docs/lora.md)
124140
- [LCM/LCM-LoRA](./docs/lcm.md)
125141
- [Using PhotoMaker to personalize image generation](./docs/photo_maker.md)
@@ -150,6 +166,7 @@ These projects use `stable-diffusion.cpp` as a backend for their image generatio
150166
- [sd.cpp-webui](https://github.com/daniandtheweb/sd.cpp-webui)
151167
- [LocalAI](https://github.com/mudler/LocalAI)
152168
- [Neural-Pixel](https://github.com/Luiz-Alcantara/Neural-Pixel)
169+
- [KoboldCpp](https://github.com/LostRuins/koboldcpp)
153170

154171
## Contributors
155172

@@ -163,7 +180,7 @@ Thank you to all the people who have already contributed to stable-diffusion.cpp
163180

164181
## References
165182

166-
- [ggml](https://github.com/ggerganov/ggml)
183+
- [ggml](https://github.com/ggml-org/ggml)
167184
- [diffusers](https://github.com/huggingface/diffusers)
168185
- [stable-diffusion](https://github.com/CompVis/stable-diffusion)
169186
- [sd3-ref](https://github.com/Stability-AI/sd3-ref)

assets/flux/chroma1-radiance.png

477 KB
Loading

assets/flux2/example.png

556 KB
Loading

assets/logo.png

1.02 MB
Loading

assets/ovis_image/example.png

401 KB
Loading

assets/z_image/bf16.png

1.01 MB
Loading

0 commit comments

Comments
 (0)