Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
45a63ac
refactor: move model-specific operators and fusions into backend exte…
leejet Nov 1, 2026
5356982
fix: chunk MiniMax-H3 MLP to respect backend buffer limits (#2257)
leejet Nov 1, 2026
df0fa26
fix: update CUTLASS license paths in Docker and Windows CUDA packaging
leejet Nov 1, 2026
fe2682b
fix: retry Vulkan capacity checks after memory reclamation (#2256)
leejet Nov 1, 2026
62c5443
fix: include missing cassert headers in SageAttention CUDA code
leejet Nov 1, 2026
5d33b1b
ci: trigger builds on CUDA header changes
leejet Nov 1, 2026
133087d
fix: prefer discrete GPUs in auto-fit device selection (#2259)
leejet Nov 1, 2026
290148d
feat: add custom modulate operator and ConvRot fusion (#2258)
leejet Nov 1, 2026
1350cf5
ci: cache CUDA compilation for Windows and Docker builds
leejet Nov 2, 2026
250ea6e
fix: layer split across cuda (#2262)
cumal Nov 2, 2026
b4d6b83
fix: support integer LoRA scalar conversion to FP32 (#2263)
leejet Nov 2, 2026
3be2378
ci: use ccache to fix Windows CUDA command parsing failures
leejet Nov 2, 2026
f8ea2e1
perf: use native SiTU for MOSS with composite fallback (#2210)
mirek190 Nov 3, 2026
6225bf8
perf: view qkv slices for moss instead of slice+reshape (#2232)
pwilkin Nov 3, 2026
d308544
perf: fuse Z-Image GPU operations and optimize BF16 GEMM (#2265)
leejet Nov 3, 2026
984eb06
perf(cuda): fuse MOSS modulation and direct RoPE F16 output (#2269)
leejet Nov 3, 2026
3e92bf9
feat: add P-H3-Image generation and editing support (#2272)
leejet Nov 4, 2026
d135894
feat: MiniMax-H3 latent hires second pass (#2249)
farawayso Nov 4, 2026
58bb3c1
perf(vulkan): accelerate MOSS normalization and SiTU staging (#2273)
leejet Nov 4, 2026
7952693
feat: support packed INT4 convrot models (#2276)
leejet Nov 5, 2026
f5df5f8
perf: accelerate packed INT4 CUDA inference with CUTLASS (#2278)
leejet Nov 5, 2026
5a1ba5d
perf(vulkan): accelerate packed INT4 with cooperative matrices (#2280)
leejet Nov 6, 2026
fdfc913
feat: ControlNet Union support for SDXL (#2284)
daniandtheweb Nov 7, 2026
b1f5a51
fix: chunk MiniMax-H3 QKV projections within backend buffer limits (#…
leejet Nov 7, 2026
9234ad8
feat: add RelayVSR video upscaling with CUDA window attention (#2285)
leejet Nov 7, 2026
5f8c19f
perf: reduce fused compute buffers (#2290)
leejet Nov 8, 2026
7bcd4ce
fix: clean LoRA multiplier and prompt spacing in image metadata (#2283)
LWWZH Nov 8, 2026
de00baf
feat: add configurable attention chunk budget for MiniMax-H3 (#2292)
leejet Nov 8, 2026
0b3b98d
fix: avoid CPU fallback based on backend allocation chunk size (#2294)
leejet Nov 8, 2026
f61053c
fix(metal): handle all batch elements in group normalization (#2296)
leejet Nov 8, 2026
b43af40
fix: use patch token count for the Flux scheduler (#2293)
DrMkdaddy Nov 8, 2026
3d315c4
feat: add Metal INT8 ConvRot support (#2297)
leejet Nov 8, 2026
80c4707
feat: support HyperFlow H3 Flash (#2299)
leejet Nov 8, 2026
abc6718
fix(metal): reclaim completed transfer resources without blocking
leejet Nov 8, 2026
cd5594e
feat: add SeedVR2 image and video upscaling (#2300)
leejet Nov 8, 2026
b43ce4b
fix: preserve Krea2 text-fusion names in Kohya LoRAs (#2301)
leejet Nov 8, 2026
fc350be
feat(server): report generation stages independently of previews (#2303)
leejet Nov 8, 2026
f977add
fix: disable batch_cfg for Metal when building with upstream ggml (#2…
wbruna Nov 9, 2026
d22dcda
perf: cache the device type in sd_backend_is_cpu (#2307)
Windyskr Nov 9, 2026
cfdf3cf
fix: merge LoRAs in F32 when convert changes the tensor type (#2302)
Windyskr Nov 9, 2026
008b9a2
fix: apply MiniMax-H3 Diffusers LoRA token_refiner weights (#2306)
Windyskr Nov 9, 2026
991f825
fix: limit default MSVC compilation parallelism
leejet Nov 9, 2026
fbb381d
docs: add Prisme to the UIs list (#2274)
d3Ita Nov 9, 2026
c44cbec
docs: add Quo to UIs (#2279)
0xConflict Nov 9, 2026
46da352
fix: size layer-split ranges in proportion to device capacity (#2309)
Windyskr Nov 9, 2026
d36f72b
docs: add NodeTool link to README (#2277)
georgi Nov 9, 2026
73fef08
feat: update server web UI with streaming prompt enhancement (#2312)
leejet Nov 9, 2026
a3c49b1
refactor: unify ggml operation helpers around runner context (#2314)
leejet Nov 9, 2026
a3f46b6
feat(server): make async job queue limits configurable (#2316)
linsen458-spec Nov 10, 2026
e1ca5e8
perf(cuda): fuse bias into INT8 CUTLASS epilogues (#2320)
losewayy Nov 10, 2026
0bb1328
feat: support Sol-H3-VAE decoding for MiniMax-H3 (#2317)
losewayy Nov 10, 2026
56070ea
refactor: replace QKV split helpers with ggml_ext_chunk (#2322)
leejet Nov 10, 2026
ddc367a
refactor: unify runner execution and weight residency (#2321)
leejet Nov 10, 2026
0678d04
fix(vae): order Sol attention and FFN writes to reduce VRAM
leejet Nov 10, 2026
465adf3
fix: avoid structured binding capture in MiniMax H3 SOL attention
leejet Nov 10, 2026
f8417d0
perf(cuda): fuse RMSNorm and RoPE in Sol-H3-VAE (#2323)
losewayy Nov 10, 2026
32d516c
feat: add MiniMax-H3-Image support (#2324)
leejet Nov 10, 2026
f0b1071
Merge upstream master-1088-32d516c
Vect0rM Nov 11, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 37 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ on:
".github/workflows/**",
".dockerignore",
"docker/Dockerfile*",
"scripts/ci-cuda-cache.sh",
"**/CMakeLists.txt",
"**/Makefile",
"**/*.h",
"**/*.hpp",
"**/*.c",
"**/*.cpp",
"**/*.cu",
"**/*.cuh",
"ggml",
"examples/server/frontend",
"examples/server/frontend/**",
Expand All @@ -37,13 +39,15 @@ on:
".github/workflows/**",
".dockerignore",
"docker/Dockerfile*",
"scripts/ci-cuda-cache.sh",
"**/CMakeLists.txt",
"**/Makefile",
"**/*.h",
"**/*.hpp",
"**/*.c",
"**/*.cpp",
"**/*.cu",
"**/*.cuh",
"ggml",
"examples/server/frontend",
"examples/server/frontend/**",
Expand Down Expand Up @@ -251,6 +255,7 @@ jobs:
run: echo "short=${GITHUB_SHA:0:7}" >> "$GITHUB_OUTPUT"

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v4

- name: Log in to the container registry
Expand All @@ -273,6 +278,21 @@ jobs:
# if set to "true" but frees about 6 GB
tool-cache: false

- name: Cache CUDA compilation
if: matrix.variant == 'cuda'
uses: actions/cache@v5
with:
path: ${{ runner.temp }}/cuda-ccache
key: cuda-ccache-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('docker/Dockerfile.cuda') }}-${{ github.run_id }}-${{ github.run_attempt }}
restore-keys: |
cuda-ccache-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('docker/Dockerfile.cuda') }}-

- name: Restore CUDA compiler cache mount
if: matrix.variant == 'cuda'
env:
CUDA_CACHE_BUILDER: ${{ steps.buildx.outputs.name }}
run: bash scripts/ci-cuda-cache.sh restore

- name: Build and push Docker image
id: build-push
uses: docker/build-push-action@v7
Expand All @@ -286,6 +306,12 @@ jobs:
annotations: ${{ steps.meta.outputs.annotations }}
build-args: ${{ matrix.build-args }}

- name: Export CUDA compiler cache mount
if: matrix.variant == 'cuda'
env:
CUDA_CACHE_BUILDER: ${{ steps.buildx.outputs.name }}
run: bash scripts/ci-cuda-cache.sh save

macOS-latest-cmake:
runs-on: macos-latest

Expand Down Expand Up @@ -363,7 +389,7 @@ jobs:
- build: "cpu"
defines: "-DGGML_NATIVE=OFF -DSD_BUILD_SHARED_LIBS=ON -DSD_BUILD_SHARED_GGML_LIB=ON -DGGML_BACKEND_DL=ON -DGGML_CPU_ALL_VARIANTS=ON"
- build: "cuda12"
defines: "-DSD_CUDA=ON -DSD_BUILD_SHARED_LIBS=ON -DCMAKE_CUDA_ARCHITECTURES='61;70;75;80;86;89;90;100;120' -DCMAKE_CUDA_FLAGS='-Xcudafe \"--diag_suppress=177\" -Xcudafe \"--diag_suppress=550\"' -DGGML_NATIVE=OFF -DSD_BUILD_SHARED_GGML_LIB=ON -DGGML_BACKEND_DL=ON -DGGML_CPU_ALL_VARIANTS=ON"
defines: "-DSD_CUDA=ON -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_CUDA_COMPILER_LAUNCHER=ccache -DSD_BUILD_SHARED_LIBS=ON -DCMAKE_CUDA_ARCHITECTURES='61;70;75;80;86;89;90;100;120' -DCMAKE_CUDA_FLAGS='-Xcudafe \"--diag_suppress=177\" -Xcudafe \"--diag_suppress=550\"' -DGGML_NATIVE=OFF -DSD_BUILD_SHARED_GGML_LIB=ON -DGGML_BACKEND_DL=ON -DGGML_CPU_ALL_VARIANTS=ON"
- build: "vulkan"
defines: "-DSD_VULKAN=ON -DSD_BUILD_SHARED_LIBS=ON -DGGML_NATIVE=OFF -DSD_BUILD_SHARED_GGML_LIB=ON -DGGML_BACKEND_DL=ON -DGGML_CPU_ALL_VARIANTS=ON"
steps:
Expand Down Expand Up @@ -392,6 +418,15 @@ jobs:
method: "network"
sub-packages: '["nvcc", "cudart", "cublas", "cublas_dev", "thrust", "visual_studio_integration"]'

- name: Cache CUDA compilation
if: matrix.build == 'cuda12'
uses: ggml-org/ccache-action@v1.2.21
with:
variant: ccache
install: binary
key: windows-cuda-12.8.1-x64
max-size: "2G"

- name: Install Vulkan SDK
id: get_vulkan
if: ${{ matrix.build == 'vulkan' }}
Expand Down Expand Up @@ -440,7 +475,7 @@ jobs:
throw "Can't find stable-diffusion.dll"
}
if ("${{ matrix.build }}" -eq "cuda12") {
Copy-Item ggml/src/ggml-cuda/vendors/cutlass/LICENSE.txt (Join-Path (Split-Path -Parent $filePath) 'cutlass.txt')
Copy-Item thirdparty/cutlass/LICENSE.txt (Join-Path (Split-Path -Parent $filePath) 'cutlass.txt')
}
7z a sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-win-${{ matrix.build }}-x64.zip $filePath .\start-server.sh .\start-server.bat

Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@
[submodule "thirdparty/libwebm"]
path = thirdparty/libwebm
url = https://github.com/webmproject/libwebm.git
[submodule "thirdparty/cutlass"]
path = thirdparty/cutlass
url = https://github.com/NVIDIA/cutlass.git
72 changes: 70 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,28 @@ if (NOT XCODE AND NOT MSVC AND NOT CMAKE_BUILD_TYPE)
endif()

if (MSVC)
cmake_host_system_information(RESULT SD_LOGICAL_CORES QUERY NUMBER_OF_LOGICAL_CORES)
if (SD_LOGICAL_CORES GREATER 8)
math(EXPR SD_DEFAULT_MSVC_MP_COUNT "${SD_LOGICAL_CORES} - 2")
elseif (SD_LOGICAL_CORES GREATER 2)
math(EXPR SD_DEFAULT_MSVC_MP_COUNT "${SD_LOGICAL_CORES} - 1")
else()
set(SD_DEFAULT_MSVC_MP_COUNT "${SD_LOGICAL_CORES}")
endif()
if (NOT SD_DEFAULT_MSVC_MP_COUNT GREATER 0)
set(SD_DEFAULT_MSVC_MP_COUNT 1)
endif()
set(SD_MSVC_MP_COUNT "${SD_DEFAULT_MSVC_MP_COUNT}" CACHE STRING "Maximum parallel MSVC compilations per project")
if (NOT SD_MSVC_MP_COUNT MATCHES "^[1-9][0-9]*$" OR SD_MSVC_MP_COUNT GREATER 65536)
message(FATAL_ERROR "SD_MSVC_MP_COUNT must be an integer between 1 and 65536")
endif()
add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
add_compile_definitions(_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING)
# /MP is MSVC-only: icx rejects it outright once offloading is enabled.
add_compile_options(
$<$<AND:$<COMPILE_LANGUAGE:C>,$<C_COMPILER_ID:MSVC>>:/MP>
$<$<AND:$<COMPILE_LANGUAGE:C>,$<C_COMPILER_ID:MSVC>>:/MP${SD_MSVC_MP_COUNT}>
$<$<COMPILE_LANGUAGE:C>:/utf-8>
$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CXX_COMPILER_ID:MSVC>>:/MP>
$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CXX_COMPILER_ID:MSVC>>:/MP${SD_MSVC_MP_COUNT}>
$<$<COMPILE_LANGUAGE:CXX>:/utf-8>
)
endif()
Expand Down Expand Up @@ -111,6 +126,12 @@ if(SD_CUDA)
endif()

if(SD_METAL)
if(NOT SD_USE_UPSTREAM_GGML)
if(CMAKE_VERSION VERSION_LESS 3.16)
message(FATAL_ERROR "SD_METAL with SD_USE_UPSTREAM_GGML=OFF requires CMake 3.16 or later for OBJC and OBJCXX support")
endif()
enable_language(OBJC OBJCXX)
endif()
message("-- Use Metal as backend stable-diffusion")
set(GGML_METAL ON)
endif()
Expand Down Expand Up @@ -225,6 +246,8 @@ file(GLOB SD_LIB_SOURCES CONFIGURE_DEPENDS
"src/core/*.h"
"src/core/*.cpp"
"src/core/*.hpp"
"src/core/cpu/*.h"
"src/core/cpu/*.cpp"
"src/core/probe/*.h"
"src/core/probe/*.cpp"
"src/extensions/*.h"
Expand Down Expand Up @@ -343,6 +366,51 @@ if (SD_CUDA)
# Keep the driver stub on downstream link lines when no driver is installed.
target_link_libraries(${SD_LIB} PUBLIC CUDA::cuda_driver)
set_property(SOURCE src/core/ggml_extend_backend.cpp APPEND PROPERTY COMPILE_DEFINITIONS SD_USE_CUDA)
if (NOT SD_USE_UPSTREAM_GGML)
include(cmake/cutlass.cmake)
enable_language(CUDA)
set_target_properties(${SD_LIB} PROPERTIES CUDA_STANDARD 17 CUDA_STANDARD_REQUIRED ON)
if (SD_CUDA_CUTLASS_PATH)
target_sources(${SD_LIB} PRIVATE src/core/cuda/cute_attention.cu src/core/cuda/i8_projection.cu src/core/cuda/i8_gated_residual.cu src/core/cuda/i8_gemm.cu src/core/cuda/bf16_gemm.cu)
set_source_files_properties(src/core/cuda/cute_attention.cu src/core/cuda/i8_projection.cu src/core/cuda/i8_gated_residual.cu src/core/cuda/i8_gemm.cu src/core/cuda/bf16_gemm.cu PROPERTIES
INCLUDE_DIRECTORIES "${SD_CUDA_CUTLASS_PATH}/include"
COMPILE_OPTIONS "--use_fast_math;--extended-lambda;--expt-relaxed-constexpr")
if (MSVC)
set_property(SOURCE src/core/cuda/cute_attention.cu src/core/cuda/i8_projection.cu src/core/cuda/i8_gated_residual.cu src/core/cuda/i8_gemm.cu src/core/cuda/bf16_gemm.cu APPEND PROPERTY COMPILE_OPTIONS -Xcompiler=/Zc:preprocessor,/Zc:__cplusplus)
endif()
if (GGML_CUDA_FORCE_CUBLAS)
set_property(SOURCE src/core/cuda/i8_projection.cu src/core/cuda/i8_gated_residual.cu src/core/cuda/i8_gemm.cu src/core/cuda/bf16_gemm.cu APPEND PROPERTY COMPILE_DEFINITIONS SD_CUDA_FORCE_CUBLAS)
endif()
endif()
endif()
endif()
set(SD_BACKEND_REGISTRATIONS)
if (SD_METAL AND NOT SD_USE_UPSTREAM_GGML)
add_subdirectory(src/core/metal)
target_link_libraries(${SD_LIB} PRIVATE "-framework Foundation" "-framework Metal")
list(APPEND SD_BACKEND_REGISTRATIONS sd_ggml_register_metal_i8)
endif()
if (NOT SD_USE_UPSTREAM_GGML AND (SD_CUDA OR SD_HIPBLAS OR SD_MUSA))
if(SD_HIPBLAS)
include(cmake/hip.cmake)
endif()
add_subdirectory(src/core/cuda)
foreach(VENDOR CUDA HIP MUSA)
if(SD_${VENDOR} OR (VENDOR STREQUAL "HIP" AND SD_HIPBLAS))
string(TOLOWER "${VENDOR}" NAMESPACE)
list(APPEND SD_BACKEND_REGISTRATIONS "sd_${NAMESPACE}::register_extensions")
endif()
endforeach()
endif()
if (SD_VULKAN AND NOT SD_USE_UPSTREAM_GGML)
add_subdirectory(src/core/vulkan)
list(APPEND SD_BACKEND_REGISTRATIONS sd_ggml_register_vulkan_rope sd_ggml_register_vulkan_i8 sd_ggml_register_vulkan_modulate sd_ggml_register_vulkan_rms_affine)
endif()
if(SD_BACKEND_REGISTRATIONS)
string(REPLACE ";" ",\n " SD_BACKEND_REGISTRATIONS "${SD_BACKEND_REGISTRATIONS}")
configure_file(cmake/backend_extensions.h.in generated/sd_backend_extensions.h @ONLY)
set_property(SOURCE src/core/ggml_extensions.cpp APPEND PROPERTY INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}/generated")
set_property(SOURCE src/core/ggml_extensions.cpp APPEND PROPERTY COMPILE_DEFINITIONS SD_BACKEND_EXTENSIONS)
endif()
if (SD_HIPBLAS)
find_package(hip REQUIRED CONFIG HINTS "$ENV{ROCM_PATH}" /opt/rocm)
Expand Down
12 changes: 12 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,18 @@ PRs should include:
- Linked issue/PR context when applicable.
- Screenshots or sample outputs for UI/visual behavior changes.

## Documentation

Write model usage guides in `docs/` for users. Focus on supported weights,
setup, runnable commands, parameter meanings, output behavior, and practical
limits such as memory requirements. Include technical details only when they
help users choose settings or troubleshoot a problem.

Keep tensor layouts, internal class names, kernel implementation details,
algorithm derivations, and development history out of usage guides. Keep task-specific
profiling logs, numerical comparison procedures, and test artifacts local, and
summarize relevant verification results in the PR description.

## README UI Listings

The [UIs list in the README](README.md#uis) only includes open-source projects that use `stable-diffusion.cpp` as a backend. Do not submit PRs to add closed-source UIs.
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ API and command-line option may change frequently.***

## 🔥Important News

* **2026/11/11** 🚀 stable-diffusion.cpp adds **Day-0 support for MiniMax-H3-Image**
* **2026/10/16** 🚀 stable-diffusion.cpp adds **Day-0 support for MOSS-Image-Base / MOSS-Image-SFT**
* **2026/10/16** 🚀 stable-diffusion.cpp adds **Day-0 support for FLUX.3 Image Klein / Klein Base**
* **2026/09/20** 🚀 stable-diffusion.cpp adds **Day-0 support for Qwen-Image-2.1**
Expand Down Expand Up @@ -59,6 +60,8 @@ API and command-line option may change frequently.***
- [Z-Image](./docs/z_image.md)
- [Z-Image L2P](./docs/z_image_l2p.md)
- [MiniT2I](./docs/minit2i.md)
- [P-H3-Image](./docs/p_h3_image.md)
- [MiniMax-H3-Image](./docs/minimax_h3_image.md)
- [SenseNova U1.5](./docs/sensenova_u1.md)
- [Ovis-Image](./docs/ovis_image.md)
- [Anima](./docs/anima.md)
Expand Down Expand Up @@ -87,6 +90,9 @@ API and command-line option may change frequently.***
- [LTX-2.3/LTX-2.5](./docs/ltx2.md)
- [HunyuanVideo 1.5](./docs/hunyuan_video.md)
- [LingBot-Video](./docs/lingbot_video.md)
- Video Upscale Models
- [RelayVSR](./docs/relay_vsr.md)
- [SeedVR2](./docs/seedvr2.md)
- [PhotoMaker](./docs/photo_maker.md) support.
- [IP-Adapter](./docs/ip_adapter.md) support (SD 1.5 and SDXL, including Plus)
- Control Net support with SD 1.5
Expand Down Expand Up @@ -197,6 +203,9 @@ These projects use `stable-diffusion.cpp` as a backend for their image generatio
- [Neural-Pixel](https://github.com/Luiz-Alcantara/Neural-Pixel)
- [KoboldCpp](https://github.com/LostRuins/koboldcpp)
- [Kokon](https://github.com/GabrieleLozupone/kokon)
- [NodeTool](https://github.com/nodetool-ai/nodetool)
- [Quo](https://github.com/quo-ai/quo)
- [Prisme](https://github.com/d3Ita/prisme)

## Contributors

Expand Down
17 changes: 17 additions & 0 deletions cmake/backend_extensions.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#ifndef __SD_BACKEND_EXTENSIONS_H__
#define __SD_BACKEND_EXTENSIONS_H__

#include "core/cuda/registration.h"

void sd_ggml_register_metal_i8(ggml_backend_dev_t device);

void sd_ggml_register_vulkan_rope(ggml_backend_dev_t device);
void sd_ggml_register_vulkan_i8(ggml_backend_dev_t device);
void sd_ggml_register_vulkan_rms_affine(ggml_backend_dev_t device);
void sd_ggml_register_vulkan_modulate(ggml_backend_dev_t device);

static void (*const sd_backend_extensions[])(ggml_backend_dev_t) = {
@SD_BACKEND_REGISTRATIONS@
};

#endif
20 changes: 20 additions & 0 deletions cmake/cutlass.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
set(sd_cutlass_default "${PROJECT_SOURCE_DIR}/thirdparty/cutlass")
if(NOT DEFINED SD_CUDA_CUTLASS_PATH AND DEFINED GGML_CUDA_CUTLASS_PATH)
get_filename_component(sd_old_cutlass_default "${SD_GGML_SOURCE_DIR}/src/ggml-cuda/vendors/cutlass" ABSOLUTE)
if(NOT GGML_CUDA_CUTLASS_PATH STREQUAL sd_old_cutlass_default)
set(sd_cutlass_default "${GGML_CUDA_CUTLASS_PATH}")
endif()
message(STATUS "Migrating GGML_CUDA_CUTLASS_PATH to SD_CUDA_CUTLASS_PATH")
endif()
set(SD_CUDA_CUTLASS_PATH "${sd_cutlass_default}" CACHE PATH "sd: CUTLASS source directory for INT8 GEMM and CuTe attention, empty to disable")
unset(GGML_CUDA_CUTLASS_PATH CACHE)
if(SD_CUDA_CUTLASS_PATH)
if(NOT EXISTS "${SD_CUDA_CUTLASS_PATH}/include/cutlass/gemm/kernel/default_gemm_universal_with_visitor.h" OR
NOT EXISTS "${SD_CUDA_CUTLASS_PATH}/include/cute/tensor.hpp")
message(FATAL_ERROR
"CUTLASS headers not found at ${SD_CUDA_CUTLASS_PATH}. "
"Run git submodule update --init --recursive from the sd.cpp repository root, "
"set SD_CUDA_CUTLASS_PATH to a CUTLASS source tree (tested with 3.9.2), "
"or set SD_CUDA_CUTLASS_PATH to an empty string to disable CUTLASS.")
endif()
endif()
3 changes: 3 additions & 0 deletions cmake/embed_spirv.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
file(READ "${INPUT}" SPIRV HEX)
string(REGEX REPLACE "(..)(..)(..)(..)" "0x\\4\\3\\2\\1," SPIRV_WORDS "${SPIRV}")
file(WRITE "${OUTPUT}" "#include <cstdint>\nnamespace sd_vulkan_shaders {\nstatic const uint32_t ${NAME}[] = {${SPIRV_WORDS}};\n}\n")
22 changes: 12 additions & 10 deletions cmake/ggml.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,19 @@ if(NOT TARGET ggml)
add_library(ggml ALIAS ggml::ggml)
endif()

get_target_property(sd_ggml_imported ggml IMPORTED)
if(sd_ggml_imported)
set(sd_ggml_private_include "${SD_GGML_SOURCE_DIR}/src")
else()
get_target_property(sd_ggml_private_include ggml SOURCE_DIR)
endif()
if(NOT EXISTS "${sd_ggml_private_include}/ggml-impl.h")
message(FATAL_ERROR "Set SD_GGML_SOURCE_DIR to the source tree matching the selected ggml library (ggml-impl.h is required).")
if(SD_USE_UPSTREAM_GGML)
get_target_property(sd_ggml_imported ggml IMPORTED)
if(sd_ggml_imported)
set(sd_ggml_private_include "${SD_GGML_SOURCE_DIR}/src")
else()
get_target_property(sd_ggml_private_include ggml SOURCE_DIR)
endif()
if(NOT EXISTS "${sd_ggml_private_include}/ggml-impl.h")
message(FATAL_ERROR "Set SD_GGML_SOURCE_DIR to the source tree matching the selected ggml library (ggml-impl.h is required).")
endif()
target_include_directories(${SD_LIB} PRIVATE "${sd_ggml_private_include}")
set_property(TARGET ${SD_LIB} PROPERTY SD_GGML_PRIVATE_INCLUDE_DIR "${sd_ggml_private_include}")
endif()
target_include_directories(${SD_LIB} PRIVATE "${sd_ggml_private_include}")
set_property(TARGET ${SD_LIB} PROPERTY SD_GGML_PRIVATE_INCLUDE_DIR "${sd_ggml_private_include}")

if(SD_USE_UPSTREAM_GGML)
target_compile_definitions(${SD_LIB} PUBLIC SD_USE_UPSTREAM_GGML)
Expand Down
12 changes: 12 additions & 0 deletions cmake/hip.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
if(NOT WIN32 AND NOT CMAKE_CXX_COMPILER MATCHES "hipcc")
if(NOT CMAKE_HIP_ARCHITECTURES)
if(GPU_TARGETS)
set(CMAKE_HIP_ARCHITECTURES ${GPU_TARGETS})
elseif(AMDGPU_TARGETS)
set(CMAKE_HIP_ARCHITECTURES ${AMDGPU_TARGETS})
endif()
endif()
# HIP objects are linked by the parent target, so initialize its link rules here.
enable_language(HIP)
set_property(TARGET ${SD_LIB} PROPERTY HIP_ARCHITECTURES "${CMAKE_HIP_ARCHITECTURES}")
endif()
Loading
Loading