Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
115 commits
Select commit Hold shift + click to select a range
a7ddced
updated for sd
Feb 24, 2026
dfa0f59
updated and successfuly built
Feb 24, 2026
5564ec7
downloads
Feb 24, 2026
ce927db
Merge pull request #517 from aegioscy/sd
aegioscy Feb 24, 2026
c239c8b
updated with working loading
Feb 24, 2026
72aa075
Merge pull request #523 from tetherto/sd
aegioscy Feb 24, 2026
e06fea6
updated load model js for Q4_K test
Feb 25, 2026
4713ab2
rewrote parameter handling to support multiple params and also two di…
Feb 25, 2026
ff0be14
got sd inference to work
Feb 25, 2026
6bf7db6
Merge pull request #545 from tetherto/sd
aegioscy Feb 25, 2026
21b2257
updated for sd2
Feb 26, 2026
b6ee2b8
Merge pull request #557 from tetherto/sd
aegioscy Feb 26, 2026
834f069
got full sdxl to work
Feb 27, 2026
ee1b525
Merge pull request #593 from tetherto/sd
aegioscy Feb 27, 2026
a9cb009
rename folder to qvac-lib-infer-diffusion
gianni-cor Feb 27, 2026
8730525
update package name
gianni-cor Feb 27, 2026
ba0cccd
sd3 finished
Mar 1, 2026
139b0b6
Merge feature-media-generation: rename package to qvac-lib-infer-diff…
Mar 1, 2026
d9a9642
Merge pull request #618 from tetherto/sd
aegioscy Mar 1, 2026
cc9327a
rename: qvac-lib-infer-diffusion -> lib-infer-diffusion
Mar 2, 2026
40e104f
Merge pull request #620 from tetherto/media-gen-rename
aegioscy Mar 2, 2026
1683a05
updated for cuda linux
Mar 2, 2026
2573b6f
updated for model
Mar 2, 2026
9b30ad0
have something working
Mar 3, 2026
8287228
changelog
Mar 3, 2026
ba1068a
cpp lint
Mar 3, 2026
4b031d6
Merge branch 'main' into feature-media-generation
donriddo Mar 3, 2026
6d96bda
formatt
Mar 3, 2026
38ad01d
Merge branch 'feature-media-generation' of github.com:tetherto/qvac i…
Mar 3, 2026
d284265
Merge branch 'main' into feature-media-generation
donriddo Mar 4, 2026
f6b1417
updated model for gian
Mar 4, 2026
3874f3a
Merge branch 'feature-media-generation' of github.com:tetherto/qvac i…
Mar 4, 2026
f469311
Merge branch 'main' into feature-media-generation
Proletter Mar 4, 2026
9b5bc5f
integration test
Mar 4, 2026
c0bd401
Merge branch 'feature-media-generation' of https://github.com/tethert…
Mar 4, 2026
8a6a1d5
fixing according to boss
Mar 4, 2026
12b6f38
fix(android): enable BUILD_SHARED_LIBS and stub pthread_cancel for GG…
Mar 4, 2026
b814301
fix(android): exclude Vulkan on Android and fix pthread_cancel stub
Mar 4, 2026
ecf9a71
ci: dump vcpkg configure logs on failure for android build
Mar 4, 2026
a279e0e
fix(android): insert pthread_cancel stub after pthread.h include
Mar 4, 2026
9cd62b9
fix(android): resolve BUILD_SHARED_LIBS override and pthread_cancel i…
Mar 4, 2026
b2ca6bd
updated for android hopefully works
Mar 4, 2026
0fac183
added opencl support for android
Mar 5, 2026
23f778d
windows attempt fix
Mar 5, 2026
02c5471
attempting to fix windows again
Mar 5, 2026
e704ab6
NORM problem with ggml operation
Mar 5, 2026
63a3b61
attempting to patch norm
Mar 5, 2026
df09ddd
attempting again to fix
Mar 5, 2026
f033816
diagonstic step
Mar 5, 2026
a678b6d
update for opencl
Mar 5, 2026
94b6bcd
Merge branch 'main' into feature-media-generation
gianni-cor Mar 6, 2026
e3a1568
Merge branch 'main' into feature-media-generation
gianni-cor Mar 6, 2026
b0f3b9c
updated for device selection
Mar 6, 2026
63ce363
Merge branch 'feature-media-generation' of https://github.com/tethert…
Mar 6, 2026
75c2d36
fix(diffusion): add CI/CD workflows, test infra, and integration test…
donriddo Mar 6, 2026
7e89d1e
fixed integration tests
Mar 6, 2026
57c5404
resolved
Mar 6, 2026
c710640
updated
Mar 6, 2026
9d1c040
updated timeout
Mar 6, 2026
9c37577
cpp unit tests complete and tested YAY BABY
Mar 9, 2026
c50921c
cpp lint
Mar 9, 2026
052f222
updated
Mar 9, 2026
29db6db
test(diffusion): add integration tests for SDXL, SD3, and FLUX.2 (#757)
donriddo Mar 9, 2026
a0f033a
QVAC-13954: Clean up vcpkg deps in lib-infer-diffusion (#781)
jpgaribotti Mar 9, 2026
fd84602
updated for runtime stats
Mar 10, 2026
1fadd8d
fixed connection to logger, as it was not properly connected before
Mar 10, 2026
38320db
fixed for license file, validated working run on m1 air
Mar 10, 2026
f17de01
quickstart quick-maths
Mar 10, 2026
d2910fb
fixed integration for windows
Mar 10, 2026
c7b4f48
fix(diffusion): add real cancel/abort support to native generation (#…
donriddo Mar 10, 2026
f912111
Merge branch 'main' into feature-media-generation
gianni-cor Mar 11, 2026
f551adb
refactor(diffusion): static ggml core with DL backends and CMakeLists…
jpgaribotti Mar 11, 2026
e2f140e
feat(diffusion): hybrid static CPU + dynamic GPU backends for Android…
jpgaribotti Mar 11, 2026
809e31a
Merge branch 'main' into feature-media-generation
gianni-cor Mar 11, 2026
51081c7
fix(diffusion): JS layer review fixes and cancel test coverage (#783)
donriddo Mar 12, 2026
d47cb08
feat(diffusion): move stable-diffusion-cpp to registry (#865)
jpgaribotti Mar 12, 2026
de42bac
cpp lint
Mar 13, 2026
c3cb5bf
trying to fix seg faults
Mar 13, 2026
2cae262
fix(diffusion): Add fallback to load backend by filename (#879)
jpgaribotti Mar 13, 2026
2c182c7
Merge branch 'main' into feature-media-generation
donriddo Mar 13, 2026
c97323b
Merge branch 'main' into feature-media-generation
donriddo Mar 16, 2026
7f0d94f
Merge branch 'main' into feature-media-generation
Proletter Mar 16, 2026
b54fc82
Merge branch 'main' into feature-media-generation
gianni-cor Mar 16, 2026
39a6c4d
QVAC-14129: skip generation tests on GPU-less runners (#897)
donriddo Mar 16, 2026
db9b6ae
Merge branch 'main' into feature-media-generation
gianni-cor Mar 16, 2026
47bcea3
Merge branch 'main' into feature-media-generation
gianni-cor Mar 16, 2026
71491ab
refactor[notask]: address PR review comments for lib-infer-diffusion …
Mar 17, 2026
09186a3
Merge branch 'main' into feature-media-generation
gianni-cor Mar 17, 2026
903570e
style[notask]: apply clang-format-19 to test_sd_gen_handlers.cpp
Mar 17, 2026
e869bb2
fix: remove trailing blank line in addon.js to pass standard lint (#951)
donriddo Mar 17, 2026
b0d8178
Merge branch 'main' into feature-media-generation
donriddo Mar 17, 2026
c76d1a3
refactor[notask]: remove public unload() from SdModel; expand TypeScr…
Mar 17, 2026
1f55408
Merge branch 'feature-media-generation' of https://github.com/tethert…
Mar 17, 2026
c09eec8
fix: sync JS layer types (#950)
donriddo Mar 17, 2026
21274a2
refactor[notask]: remove notifyProcessExit mechanism from lib-infer-d…
Mar 18, 2026
7b1169a
ci[notask]: enable C++ unit tests on linux-x64 in cpp-tests-diffusion…
Mar 18, 2026
cf6fbc5
feat(diffusion): reduce reported generation stats to primitive fields
Mar 18, 2026
6fc6c34
feat(diffusion): add RuntimeStats TypeScript interface and bump to 0.1.1
Mar 18, 2026
9755a80
fix: add Android Vulkan init diagnostics (#981)
jpgaribotti Mar 18, 2026
b567a44
fix(diffusion): detect JobEnded by structural type instead of stats k…
gianni-cor Mar 18, 2026
4e938c1
Merge branch 'main' into feature-media-generation
gianni-cor Mar 18, 2026
8164c99
Merge branch 'main' into feature-media-generation
donriddo Mar 18, 2026
66d1adb
Merge branch 'main' into feature-media-generation
gianni-cor Mar 19, 2026
6525573
refactor(diffusion): remove circular padding options and fix example …
Mar 19, 2026
0b11a46
Merge branch 'main' into feature-media-generation
gianni-cor Mar 19, 2026
1a1fd38
refactor(diffusion): rename CHANGELOG to CHANGELOG.md and align forma…
gianni-cor Mar 19, 2026
c3cdbfd
refactor(diffusion): remove CUDA build references from docs
gianni-cor Mar 19, 2026
95a557d
fix(diffusion): remove CPU fallback from macOS x64 GPU column in README
gianni-cor Mar 19, 2026
39613cc
docs(diffusion): add Other Examples section to README
gianni-cor Mar 19, 2026
a54d96c
docs(diffusion): extract build instructions into build.md
gianni-cor Mar 19, 2026
3fb817d
chore(diffusion): generate NOTICE file with third-party attributions
gianni-cor Mar 19, 2026
bbf717c
Merge branch 'main' into feature-media-generation
donriddo Mar 19, 2026
ab5f4fb
feat(diffusion): throw early if img2img is attempted
Mar 19, 2026
4563ef5
Merge branch 'main' into feature-media-generation
gianni-cor Mar 19, 2026
c576e63
Merge branch 'main' into feature-media-generation
gianni-cor Mar 19, 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
30 changes: 29 additions & 1 deletion .github/workflows/integration-test-lib-infer-diffusion.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ on:

jobs:
run-integration-tests:
timeout-minutes: 360
timeout-minutes: ${{ matrix.timeout || 360 }}
continue-on-error: true
runs-on: ${{ matrix.runner }}
name: test-${{ matrix.platform }}-${{ matrix.arch }}
Expand Down Expand Up @@ -72,6 +72,7 @@ jobs:
platform: win32
arch: x64
runner: ai-run-windows11-gpu
timeout: 600

steps:
- name: Setup Node.js
Expand Down Expand Up @@ -238,6 +239,33 @@ jobs:
shell: bash
run: sudo apt-get update && sudo apt-get install -y mesa-vulkan-drivers

- name: macOS — Metal GPU diagnostic
if: matrix.platform == 'darwin'
shell: bash
run: |
echo "=== GPU Hardware ==="
system_profiler SPDisplaysDataType 2>/dev/null || echo "(system_profiler unavailable)"
echo ""
echo "=== Metal Device Check ==="
cat > /tmp/metal_check.m << 'OBJC'
#import <Metal/Metal.h>
#import <stdio.h>
int main() {
id<MTLDevice> dev = MTLCreateSystemDefaultDevice();
if (!dev) { printf("No Metal device available\n"); return 1; }
printf("Device : %s\n", [[dev name] UTF8String]);
printf("Headless : %s\n", dev.headless ? "yes" : "no");
printf("LowPower : %s\n", dev.lowPower ? "yes" : "no");
printf("Apple4 : %d\n", [dev supportsFamily:MTLGPUFamilyApple4]);
printf("Apple7 : %d\n", [dev supportsFamily:MTLGPUFamilyApple7]);
printf("Metal3 : %d\n", [dev supportsFamily:MTLGPUFamilyMetal3]);
printf("simdgroup : %d\n", [dev supportsFamily:MTLGPUFamilyApple7]);
return 0;
}
OBJC
clang -x objective-c -framework Metal -framework Foundation \
-o /tmp/metal_check /tmp/metal_check.m 2>/dev/null && /tmp/metal_check || echo "(Metal check failed to compile/run)"

- name: Run integration test (Linux/macOS)
if: ${{ matrix.platform != 'win32' }}
working-directory: ${{ env.WORKDIR }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/prebuilds-lib-infer-diffusion.yml
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ jobs:
working-directory: ${{ env.WORKDIR }}
run: |
if [[ "${{ matrix.platform }}" == "android" ]]; then
find prebuilds -name "*.bare" -exec $ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip {} \;
find prebuilds \( -name "*.bare" -o -name "*.so" \) -exec $ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip {} \;
elif [[ "${{ matrix.platform }}" == "darwin" || "${{ matrix.platform }}" == "ios" ]]; then
find prebuilds -name "*.bare" -exec strip -S {} \;
else
Expand Down
26 changes: 26 additions & 0 deletions packages/lib-infer-diffusion/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
.vs/
build/
dist/
models/
store/
node_modules/
prebuilds/

.npmrc
package-lock.json
.cache/
.idea/
**/store/
.DS_Store
logs/
*.gguf
*.safetensors
*.ckpt
*.log
.clang-tidy
# Added by qvac-lint-cpp
.clang-format
output/
temp/
*.deb
test/integration/all.js
3 changes: 3 additions & 0 deletions packages/lib-infer-diffusion/.lsan-suppressions.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Known false positive with N-API callbacks under ASan
leak:SdModel::process
leak:SdModel::load
24 changes: 24 additions & 0 deletions packages/lib-infer-diffusion/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Changelog

## [0.1.0] - 2026-03-19

### Added

#### Stable Diffusion inference addon

Initial release of the `@qvac/diffusion-cpp` native addon for image generation, supporting SD1.x, SD2.x, SDXL, SD3, and FLUX model families.

#### GPU acceleration

- Metal backend on macOS, iOS
- Vulkan backends on Windows, Linux, Android
- OpenCL backend on Android devices with Adreno GPU
- CPU fallback on all platforms

#### Android dynamic backend loading

Dynamic ggml backend loading (`GGML_BACKEND_DL`) on Android with `libqvac-diffusion-ggml-*` naming to avoid symbol conflicts with system-installed ggml libraries. CPU backends remain statically linked (`GGML_CPU_STATIC`) while GPU backends are loaded at runtime.

#### vcpkg-based build system

vcpkg overlay ports for `ggml` and `stable-diffusion-cpp` with clang override triplets for Linux and PIC static linking. Custom patches for runtime backend selection, abort callbacks, failure-path cleanup, and Android Vulkan diagnostics.
145 changes: 145 additions & 0 deletions packages/lib-infer-diffusion/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
cmake_minimum_required(VERSION 3.25)

option(ANDROID_STL "Android STL linkage" c++_shared)
option(BUILD_TESTING "Build tests" OFF)
if(BUILD_TESTING)
list(APPEND VCPKG_MANIFEST_FEATURES "tests")
endif()

option(SD_CUDA "Enable CUDA GPU backend" OFF)
if(SD_CUDA)
list(APPEND VCPKG_MANIFEST_FEATURES "cuda")
endif()

option(SD_OPENCL "Enable OpenCL GPU backend (Android/Adreno)" OFF)
if(SD_OPENCL)
list(APPEND VCPKG_MANIFEST_FEATURES "opencl")
endif()

# Vulkan and Metal are auto-enabled via default-features in the ggml and
# stable-diffusion-cpp overlay ports. CUDA requires a specific build machine
# so it remains opt-in via SD_CUDA.
#
# GGML_BACKEND_DL is ON only on Android (set in the ggml portfile), mirroring
# qvac-fabric. On Linux/macOS/Windows GPU backends are statically linked.

find_package(cmake-bare REQUIRED PATHS node_modules/cmake-bare)
find_package(cmake-vcpkg REQUIRED PATHS node_modules/cmake-vcpkg)

set(VCPKG_OVERLAY_TRIPLETS "${CMAKE_CURRENT_SOURCE_DIR}/vcpkg/triplets;${VCPKG_OVERLAY_TRIPLETS}")

project(qvac-lib-inference-addon-sd C CXX)

if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
add_compile_options(-stdlib=libc++)
add_link_options(-stdlib=libc++ -static-libstdc++)
endif()

find_path(VCPKG_INSTALLED_PATH share/qvac-lint-cpp/.clang-format REQUIRED)
configure_file(${VCPKG_INSTALLED_PATH}/share/qvac-lint-cpp/.clang-format
${CMAKE_CURRENT_SOURCE_DIR}/.clang-format COPYONLY)
configure_file(${VCPKG_INSTALLED_PATH}/share/qvac-lint-cpp/.clang-tidy
${CMAKE_CURRENT_SOURCE_DIR}/.clang-tidy COPYONLY)

find_path(PICOJSON_INCLUDE_DIRS "picojson/picojson.h")
find_path(QVAC_LIB_INFERENCE_ADDON_CPP_INCLUDE_DIRS "qvac-lib-inference-addon-cpp/JsInterface.hpp")

# stable-diffusion.cpp – uses the CMake config installed by the overlay port
find_package(stable-diffusion-cpp CONFIG REQUIRED)

# ggml is installed alongside stable-diffusion.cpp as separate static libs.
# stable-diffusion.a references ggml symbols externally, so we must link them.
find_package(ggml CONFIG REQUIRED)

find_path(STB_IMAGE_WRITE_INCLUDE_DIR "stb_image_write.h" REQUIRED)

if(WIN32)
add_definitions(-DNOMINMAX -DWIN32_LEAN_AND_MEAN -DNOGDI)
endif()

bare_target(bare_target_value)
bare_module_target("." unused_target NAME module_name VERSION unused_version)
set(BACKENDS_SUBDIR_VALUE "${bare_target_value}/${module_name}")
message("Building qvac-lib-inference-addon-sd with BACKENDS_SUBDIR='${BACKENDS_SUBDIR_VALUE}'")

# On Android with GGML_BACKEND_DL, install GPU backend .so modules alongside
# the addon so ggml can dlopen them at runtime. CPU backends are statically
# linked (GGML_CPU_STATIC) and excluded from this loop.
set(BACKEND_DL_EXPORTS "")
if(ANDROID AND GGML_BACKEND_DL)
foreach(_backend ${GGML_AVAILABLE_BACKENDS})
if("${_backend}" MATCHES "^ggml-cpu")
continue()
endif()
# qvac ggml overlays prefix backend module filenames (e.g.
# libqvac-ggml-vulkan.so / libqvac-diffusion-ggml-vulkan.so). These
# modules are installed under vcpkg's bin/ directory on Android.
find_library(_${_backend}_LIB NAMES
"qvac-diffusion-${_backend}"
"${_backend}"
PATHS
"${VCPKG_INSTALLED_PATH}/bin"
"${VCPKG_INSTALLED_PATH}/lib"
REQUIRED)
add_library(ggml::${_backend} SHARED IMPORTED)
set_target_properties(ggml::${_backend} PROPERTIES
IMPORTED_LOCATION "${_${_backend}_LIB}"
IMPORTED_NO_SONAME TRUE)
list(APPEND BACKEND_DL_EXPORTS INSTALL TARGET ggml::${_backend})
endforeach()
endif()

add_bare_module(qvac-lib-inference-addon-sd EXPORTS ${BACKEND_DL_EXPORTS})
set(ADDON_SOURCES
${PROJECT_SOURCE_DIR}/addon/src/js-interface/binding.cpp
${PROJECT_SOURCE_DIR}/addon/src/handlers/SdCtxHandlers.cpp
${PROJECT_SOURCE_DIR}/addon/src/handlers/SdGenHandlers.cpp
${PROJECT_SOURCE_DIR}/addon/src/model-interface/SdModel.cpp
${PROJECT_SOURCE_DIR}/addon/src/utils/LoggingMacros.cpp
${PROJECT_SOURCE_DIR}/addon/src/utils/BackendSelection.cpp
)

target_sources(
${qvac-lib-inference-addon-sd}
PRIVATE
${ADDON_SOURCES}
)

target_include_directories(
${qvac-lib-inference-addon-sd}
PRIVATE
${PICOJSON_INCLUDE_DIRS}
${QVAC_LIB_INFERENCE_ADDON_CPP_INCLUDE_DIRS}
${STB_IMAGE_WRITE_INCLUDE_DIR}
${PROJECT_SOURCE_DIR}/addon/src
)

target_link_libraries(
${qvac-lib-inference-addon-sd}
PRIVATE
stable-diffusion::stable-diffusion
)

target_compile_features(${qvac-lib-inference-addon-sd} PRIVATE cxx_std_20)
target_compile_definitions(${qvac-lib-inference-addon-sd} PUBLIC JS_LOGGER)
target_compile_definitions(${qvac-lib-inference-addon-sd} PRIVATE BACKENDS_SUBDIR="${BACKENDS_SUBDIR_VALUE}")

if(GGML_BACKEND_DL)
target_compile_definitions(${qvac-lib-inference-addon-sd} PRIVATE GGML_BACKEND_DL)
endif()

if(BUILD_TESTING)
find_package(GTest CONFIG REQUIRED)
include(GoogleTest)
enable_testing()
add_subdirectory(test/unit)
endif()

if(WIN32)
target_link_libraries(
${qvac-lib-inference-addon-sd}
PRIVATE
msvcrt.lib
)
endif()

Loading
Loading