Skip to content

Commit 40c324b

Browse files
committed
Merge branch 'master' into sdxs
2 parents ac51cbf + 48d3161 commit 40c324b

Some content is hidden

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

41 files changed

+675
-522
lines changed

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
build*/
2+
docs/
23
test/
34

45
.cache/

.github/workflows/build.yml

Lines changed: 126 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ on:
3838
env:
3939
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
4040

41+
concurrency:
42+
group: ${{ github.workflow }}-${{ github.head_ref && github.ref || github.run_id }}
43+
cancel-in-progress: true
44+
4145
jobs:
4246
ubuntu-latest-cmake:
4347
runs-on: ubuntu-latest
@@ -92,6 +96,123 @@ jobs:
9296
path: |
9397
sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-${{ steps.system-info.outputs.OS_TYPE }}-${{ steps.system-info.outputs.OS_NAME }}-${{ steps.system-info.outputs.OS_VERSION }}-${{ steps.system-info.outputs.CPU_ARCH }}.zip
9498
99+
ubuntu-latest-cmake-vulkan:
100+
runs-on: ubuntu-latest
101+
102+
steps:
103+
- name: Clone
104+
id: checkout
105+
uses: actions/checkout@v3
106+
with:
107+
submodules: recursive
108+
109+
- name: Dependencies
110+
id: depends
111+
run: |
112+
sudo apt-get update
113+
sudo apt-get install build-essential libvulkan-dev glslc
114+
115+
- name: Build
116+
id: cmake_build
117+
run: |
118+
mkdir build
119+
cd build
120+
cmake .. -DSD_BUILD_SHARED_LIBS=ON -DSD_VULKAN=ON
121+
cmake --build . --config Release
122+
123+
- name: Get commit hash
124+
id: commit
125+
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
126+
uses: pr-mpt/actions-commit-hash@v2
127+
128+
- name: Fetch system info
129+
id: system-info
130+
run: |
131+
echo "CPU_ARCH=`uname -m`" >> "$GITHUB_OUTPUT"
132+
echo "OS_NAME=`lsb_release -s -i`" >> "$GITHUB_OUTPUT"
133+
echo "OS_VERSION=`lsb_release -s -r`" >> "$GITHUB_OUTPUT"
134+
echo "OS_TYPE=`uname -s`" >> "$GITHUB_OUTPUT"
135+
136+
- name: Pack artifacts
137+
id: pack_artifacts
138+
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
139+
run: |
140+
cp ggml/LICENSE ./build/bin/ggml.txt
141+
cp LICENSE ./build/bin/stable-diffusion.cpp.txt
142+
zip -j sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-${{ steps.system-info.outputs.OS_TYPE }}-${{ steps.system-info.outputs.OS_NAME }}-${{ steps.system-info.outputs.OS_VERSION }}-${{ steps.system-info.outputs.CPU_ARCH }}-vulkan.zip ./build/bin/*
143+
144+
- name: Upload artifacts
145+
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
146+
uses: actions/upload-artifact@v4
147+
with:
148+
name: sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-${{ steps.system-info.outputs.OS_TYPE }}-${{ steps.system-info.outputs.OS_NAME }}-${{ steps.system-info.outputs.OS_VERSION }}-${{ steps.system-info.outputs.CPU_ARCH }}-vulkan.zip
149+
path: |
150+
sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-${{ steps.system-info.outputs.OS_TYPE }}-${{ steps.system-info.outputs.OS_NAME }}-${{ steps.system-info.outputs.OS_VERSION }}-${{ steps.system-info.outputs.CPU_ARCH }}-vulkan.zip
151+
152+
build-and-push-docker-images:
153+
name: Build and push container images
154+
runs-on: ubuntu-latest
155+
156+
permissions:
157+
contents: read
158+
packages: write
159+
id-token: write
160+
attestations: write
161+
artifact-metadata: write
162+
163+
strategy:
164+
matrix:
165+
variant: [musa, sycl, vulkan]
166+
167+
env:
168+
REGISTRY: ghcr.io
169+
IMAGE_NAME: ${{ github.repository }}
170+
171+
steps:
172+
- name: Checkout
173+
uses: actions/checkout@v6
174+
with:
175+
submodules: recursive
176+
177+
- name: Get commit hash
178+
id: commit
179+
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
180+
uses: pr-mpt/actions-commit-hash@v2
181+
182+
- name: Set up Docker Buildx
183+
uses: docker/setup-buildx-action@v3
184+
185+
- name: Log in to the container registry
186+
uses: docker/login-action@v3
187+
with:
188+
registry: ${{ env.REGISTRY }}
189+
username: ${{ github.actor }}
190+
password: ${{ secrets.GITHUB_TOKEN }}
191+
192+
- name: Extract metadata for Docker
193+
id: meta
194+
uses: docker/metadata-action@v5
195+
with:
196+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
197+
198+
- name: Free Disk Space (Ubuntu)
199+
uses: jlumbroso/[email protected]
200+
with:
201+
# this might remove tools that are actually needed,
202+
# if set to "true" but frees about 6 GB
203+
tool-cache: false
204+
205+
- name: Build and push Docker image
206+
id: build-push
207+
uses: docker/build-push-action@v6
208+
with:
209+
platforms: linux/amd64
210+
push: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
211+
file: Dockerfile.${{ matrix.variant }}
212+
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.BRANCH_NAME }}-${{ matrix.variant }}
213+
labels: ${{ steps.meta.outputs.labels }}
214+
annotations: ${{ steps.meta.outputs.annotations }}
215+
95216
macOS-latest-cmake:
96217
runs-on: macos-latest
97218

@@ -146,7 +267,7 @@ jobs:
146267
sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-${{ steps.system-info.outputs.OS_TYPE }}-${{ steps.system-info.outputs.OS_NAME }}-${{ steps.system-info.outputs.OS_VERSION }}-${{ steps.system-info.outputs.CPU_ARCH }}.zip
147268
148269
windows-latest-cmake:
149-
runs-on: windows-2025
270+
runs-on: windows-2022
150271

151272
env:
152273
VULKAN_VERSION: 1.4.328.1
@@ -164,7 +285,7 @@ jobs:
164285
defines: "-DGGML_NATIVE=OFF -DGGML_AVX512=ON -DGGML_AVX=ON -DGGML_AVX2=ON -DSD_BUILD_SHARED_LIBS=ON"
165286
- build: "cuda12"
166287
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\"'"
167-
- build: 'vulkan'
288+
- build: "vulkan"
168289
defines: "-DSD_VULKAN=ON -DSD_BUILD_SHARED_LIBS=ON"
169290
steps:
170291
- name: Clone
@@ -200,7 +321,7 @@ jobs:
200321
run: |
201322
mkdir build
202323
cd build
203-
cmake .. -DCMAKE_CXX_FLAGS='/bigobj' -G Ninja -DCMAKE_C_COMPILER=cl.exe -DCMAKE_CXX_COMPILER=cl.exe ${{ matrix.defines }}
324+
cmake .. -DCMAKE_CXX_FLAGS='/bigobj' -G Ninja -DCMAKE_C_COMPILER=cl.exe -DCMAKE_CXX_COMPILER=cl.exe -DCMAKE_BUILD_TYPE=Release ${{ matrix.defines }}
204325
cmake --build .
205326
206327
- name: Check AVX512F support
@@ -371,6 +492,8 @@ jobs:
371492

372493
needs:
373494
- ubuntu-latest-cmake
495+
- ubuntu-latest-cmake-vulkan
496+
- build-and-push-docker-images
374497
- macOS-latest-cmake
375498
- windows-latest-cmake
376499
- windows-latest-cmake-hip

CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ if (NOT XCODE AND NOT MSVC AND NOT CMAKE_BUILD_TYPE)
88
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
99
endif()
1010

11+
if (MSVC)
12+
add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
13+
add_compile_definitions(_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING)
14+
endif()
15+
1116
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
1217
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
1318

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
ARG UBUNTU_VERSION=22.04
1+
ARG UBUNTU_VERSION=24.04
22

33
FROM ubuntu:$UBUNTU_VERSION AS build
44

@@ -18,5 +18,6 @@ RUN apt-get update && \
1818
apt-get clean
1919

2020
COPY --from=build /sd.cpp/build/bin/sd-cli /sd-cli
21+
COPY --from=build /sd.cpp/build/bin/sd-server /sd-server
2122

2223
ENTRYPOINT [ "/sd-cli" ]

Dockerfile.musa

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,6 @@ RUN mkdir build && cd build && \
1919
FROM mthreads/musa:${MUSA_VERSION}-runtime-ubuntu${UBUNTU_VERSION}-amd64 as runtime
2020

2121
COPY --from=build /sd.cpp/build/bin/sd-cli /sd-cli
22+
COPY --from=build /sd.cpp/build/bin/sd-server /sd-server
2223

2324
ENTRYPOINT [ "/sd-cli" ]

Dockerfile.sycl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@ RUN mkdir build && cd build && \
1515
FROM intel/oneapi-basekit:${SYCL_VERSION}-devel-ubuntu24.04 AS runtime
1616

1717
COPY --from=build /sd.cpp/build/bin/sd-cli /sd-cli
18+
COPY --from=build /sd.cpp/build/bin/sd-server /sd-server
1819

1920
ENTRYPOINT [ "/sd-cli" ]

Dockerfile.vulkan

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
ARG UBUNTU_VERSION=24.04
2+
3+
FROM ubuntu:$UBUNTU_VERSION AS build
4+
5+
RUN apt-get update && apt-get install -y --no-install-recommends build-essential git cmake libvulkan-dev glslc
6+
7+
WORKDIR /sd.cpp
8+
9+
COPY . .
10+
11+
RUN cmake . -B ./build -DSD_VULKAN=ON
12+
RUN cmake --build ./build --config Release --parallel
13+
14+
FROM ubuntu:$UBUNTU_VERSION AS runtime
15+
16+
RUN apt-get update && \
17+
apt-get install --yes --no-install-recommends libgomp1 libvulkan1 mesa-vulkan-drivers && \
18+
apt-get clean
19+
20+
COPY --from=build /sd.cpp/build/bin/sd-cli /sd-cli
21+
COPY --from=build /sd.cpp/build/bin/sd-server /sd-server
22+
23+
ENTRYPOINT [ "/sd-cli" ]

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ API and command-line option may change frequently.***
7070
- SYCL
7171
- Supported weight formats
7272
- Pytorch checkpoint (`.ckpt` or `.pth`)
73-
- Safetensors (`./safetensors`)
73+
- Safetensors (`.safetensors`)
7474
- GGUF (`.gguf`)
7575
- Supported platforms
7676
- Linux

cache_dit.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ struct TaylorSeerState {
117117
continue;
118118
if (o > 0)
119119
factorial *= static_cast<float>(o);
120-
float coeff = std::pow(static_cast<float>(elapsed), o) / factorial;
120+
float coeff = ::powf(static_cast<float>(elapsed), static_cast<float>(o)) / factorial;
121121
for (size_t i = 0; i < size; i++) {
122122
output[i] += coeff * dY_prev[o][i];
123123
}

clip.hpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ class CLIPTokenizer {
296296
size_t max_length = 0,
297297
bool padding = false) {
298298
if (max_length > 0 && padding) {
299-
size_t n = std::ceil(tokens.size() * 1.0 / (max_length - 2));
299+
size_t n = static_cast<size_t>(std::ceil(tokens.size() * 1.0 / (max_length - 2)));
300300
if (n == 0) {
301301
n = 1;
302302
}
@@ -525,10 +525,10 @@ struct CLIPLayer : public GGMLBlock {
525525

526526
struct CLIPEncoder : public GGMLBlock {
527527
protected:
528-
int64_t n_layer;
528+
int n_layer;
529529

530530
public:
531-
CLIPEncoder(int64_t n_layer,
531+
CLIPEncoder(int n_layer,
532532
int64_t d_model,
533533
int64_t n_head,
534534
int64_t intermediate_size,
@@ -623,10 +623,10 @@ class CLIPEmbeddings : public GGMLBlock {
623623
class CLIPVisionEmbeddings : public GGMLBlock {
624624
protected:
625625
int64_t embed_dim;
626-
int64_t num_channels;
627-
int64_t patch_size;
628-
int64_t image_size;
629-
int64_t num_patches;
626+
int num_channels;
627+
int patch_size;
628+
int image_size;
629+
int num_patches;
630630
int64_t num_positions;
631631

632632
void init_params(struct ggml_context* ctx, const String2TensorStorage& tensor_storage_map = {}, const std::string prefix = "") override {
@@ -641,9 +641,9 @@ class CLIPVisionEmbeddings : public GGMLBlock {
641641

642642
public:
643643
CLIPVisionEmbeddings(int64_t embed_dim,
644-
int64_t num_channels = 3,
645-
int64_t patch_size = 14,
646-
int64_t image_size = 224)
644+
int num_channels = 3,
645+
int patch_size = 14,
646+
int image_size = 224)
647647
: embed_dim(embed_dim),
648648
num_channels(num_channels),
649649
patch_size(patch_size),

0 commit comments

Comments
 (0)