Skip to content

feat(stablediffusion): Enable SYCL #5144

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 10, 2025
Merged

feat(stablediffusion): Enable SYCL #5144

merged 2 commits into from
Apr 10, 2025

Conversation

richiejp
Copy link
Collaborator

@richiejp richiejp commented Apr 8, 2025

  • feat(stablediffusion): Re-enable Sycl
  • fix(stablediffusion): Use ICX compiler with CGO and SYCL
  • Update SYCL and add debug flags (do not merge)

Description

Enable SYCL for Stablediffusion. It's supported by SD, we just have issues compiling.

#5132

Notes for Reviewers

WIP

Signed commits

  • Yes, I signed my commits.

Copy link

netlify bot commented Apr 8, 2025

Deploy Preview for localai ready!

Name Link
🔨 Latest commit 7959b35
🔍 Latest deploy log https://app.netlify.com/sites/localai/deploys/67f67b54d79e9c00086d865f
😎 Deploy Preview https://deploy-preview-5144--localai.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@@ -76,21 +94,35 @@ ifneq (,$(findstring sycl,$(BUILD_TYPE)))
mkdir -p build && \
cd build && \
cmake $(CMAKE_ARGS) ../../../../../sources/stablediffusion-ggml.cpp && \
cmake --build . --config Release"
cmake --build . --config Release -j$(nproc)"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this could bust our CIs

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, it's already in llama ccp's build now from my last pr, but I guess it should be passed down from the main makefile invocation

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, it appears that just passing -j to the top level Makefile I get 100% CPU usage, probably meaning the nest make process launched by cmake cooperates with the top level one. Now I feel silly.

@richiejp
Copy link
Collaborator Author

richiejp commented Apr 9, 2025

Hit a bit of wall here, there are linker errors for mkl and dnnl when compiling the CGO executable which of course is not using CMake. Maybe I can use pkg-config instead, I'm not sure? (https://www.intel.com/content/www/us/en/developer/articles/technical/intel-math-kernel-library-intel-mkl-and-pkg-config-tool.html)

Other options would be to avoid CGO, which I guess sucks because that means more C++ or try to produce an SO file for SD that has everything linked in already. That doesn't seem like the greatest solution...

@richiejp
Copy link
Collaborator Author

richiejp commented Apr 9, 2025

We have a teapot!
image

I ended up using this: https://www.intel.com/content/www/us/en/developer/tools/oneapi/onemkl-link-line-advisor.html and pkg-config to setup the CGO flags

richiejp added 2 commits April 9, 2025 14:50
This is a pain because we compile with CGO, but SD is compiled with
CMake. I don't think we can easily use CMake to set the linker flags
necessary. Also I could not find pkg-config calls that would fully set
the flags, so some of them are set manually.

See https://www.intel.com/content/www/us/en/developer/tools/oneapi/onemkl-link-line-advisor.html
for reference. I also resorted to searching the shared object files in
MKLROOT/lib for the symbols.

Signed-off-by: Richard Palethorpe <[email protected]>
Signed-off-by: Richard Palethorpe <[email protected]>
@richiejp
Copy link
Collaborator Author

richiejp commented Apr 9, 2025

Assuming no CI failures, now waiting on leejet/stable-diffusion.cpp#651

@mudler mudler changed the title (WIP) feat(stablediffusion): Enable SYCL feat(stablediffusion): Enable SYCL Apr 10, 2025
@mudler mudler added bug Something isn't working and removed dependencies labels Apr 10, 2025
@mudler mudler added enhancements and removed bug Something isn't working labels Apr 10, 2025
@mudler mudler merged commit 1b899e1 into mudler:master Apr 10, 2025
23 of 25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants