Skip to content

Add stable-diffusion.cpp hosting integration - #1494

Merged
aaronpowell merged 5 commits into
CommunityToolkit:mainfrom
axies20:StableDiffusionCpp
Aug 7, 2026
Merged

Add stable-diffusion.cpp hosting integration#1494
aaronpowell merged 5 commits into
CommunityToolkit:mainfrom
axies20:StableDiffusionCpp

Conversation

@axies20

@axies20 axies20 commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Closes #1495

Adds a new CommunityToolkit.Aspire.Hosting.StableDiffusionCpp integration backed by the official stable-diffusion.cpp GHCR images.

The integration includes configurable compute image variants, Hugging Face model downloads with token and resume support, model child resources, GPU and server arguments, persistent model/LoRA/upscaler directories, tests, documentation, and a runnable example.

PR Checklist

  • Created a feature/dev branch in your fork (vs. submitting directly from a commit on main)
  • Based off latest main branch of toolkit
  • PR doesn't include merge commits (always rebase on top of our main, if needed)
  • New integration
    • Docs are written
    • Added description of major feature to project description for NuGet package (4000 total character limit, so don't push entire description over that)
  • Tests for the changes have been added (for bug fixes / features) (if applicable)
  • Contains NO breaking changes
  • Every new API (including internal ones) has full XML docs
  • Code follows all style conventions

Other information

Validation completed locally:

  • 18 integration tests passed
  • Example AppHost builds without warnings or errors
  • NuGet packaging succeeds for .NET 8, .NET 9, and .NET 10
  • dotnet format --verify-no-changes passes
  • git diff --check passes

- Implement `CommunityToolkit.Aspire.Hosting.StableDiffusionCpp` for integrating the `stable-diffusion.cpp` container.
- Introduce support for official image variants (`Cuda`, `CudaSpark`, `Vulkan`, `Sycl`, `Musa`) with GPU configurations.
- Add example projects demonstrating the usage of Stable Diffusion resources.
- Implement Hugging Face model resource integration with token-based authentication and download support.
- Include tests to validate container configurations, runtime arguments, endpoints, and Hugging Face model interactions.
- Add extensive XML documentation and a `README.md` for library usage and guidance.
- Register the package in solution and centralize dependency management.
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/CommunityToolkit/Aspire/main/eng/scripts/dogfood-pr.sh | bash -s -- 1494

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/CommunityToolkit/Aspire/main/eng/scripts/dogfood-pr.ps1) } 1494"

@axies20
axies20 marked this pull request as ready for review July 30, 2026 17:52

@aaronpowell aaronpowell left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Couple of comments/questions, and also the README will need updating, which can be done by dotnet run .\eng\scripts\generate-readme-integrations.cs

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds a new Aspire hosting integration package, CommunityToolkit.Aspire.Hosting.StableDiffusionCpp, to simplify running the official stable-diffusion.cpp container images as an Aspire resource (including GPU runtime args and Hugging Face model pre-download), with accompanying tests and a runnable AppHost example.

Changes:

  • Introduces StableDiffusionCppResource + builder extensions (image variants, GPU support, VAE tiling, Hugging Face model download + child resource).
  • Adds a Hugging Face model downloader that supports resumable downloads and gated/private repo tokens.
  • Adds a new example AppHost and new test project; wires projects into CommunityToolkit.Aspire.slnx.
Show a summary per file
File Description
tests/CommunityToolkit.Aspire.Hosting.StableDiffusionCpp.Tests/CommunityToolkit.Aspire.Hosting.StableDiffusionCpp.Tests.csproj Adds test project for the new integration.
tests/CommunityToolkit.Aspire.Hosting.StableDiffusionCpp.Tests/AddStableDiffusionCppTests.cs Validates image selection, endpoint/health checks, GPU args, child model resource wiring, and downloader helpers.
src/CommunityToolkit.Aspire.Hosting.StableDiffusionCpp/StableDiffusionCppResourceBuilderExtensions.cs Main public extension methods for adding/configuring the stable-diffusion.cpp resource and models.
src/CommunityToolkit.Aspire.Hosting.StableDiffusionCpp/StableDiffusionCppResource.cs Defines the stable-diffusion.cpp container resource and connection-string/endpoint expressions.
src/CommunityToolkit.Aspire.Hosting.StableDiffusionCpp/StableDiffusionCppModelResource.cs Defines the child “model” resource exported to the dashboard/model.
src/CommunityToolkit.Aspire.Hosting.StableDiffusionCpp/StableDiffusionCppImageVariant.cs Defines the supported official image variants.
src/CommunityToolkit.Aspire.Hosting.StableDiffusionCpp/StableDiffusionCppContainerImageTags.cs Centralizes official image registry/name/tag constants.
src/CommunityToolkit.Aspire.Hosting.StableDiffusionCpp/README.md Documents how to use the new integration.
src/CommunityToolkit.Aspire.Hosting.StableDiffusionCpp/HuggingFaceModelDownloader.cs Implements model download (token + resume + progress) and path safety checks.
src/CommunityToolkit.Aspire.Hosting.StableDiffusionCpp/CommunityToolkit.Aspire.Hosting.StableDiffusionCpp.csproj Adds the new hosting integration package project.
README.md Adds NuGet preview link references for the new integration.
examples/stable-diffusion-cpp/CommunityToolkit.Aspire.Hosting.StableDiffusionCpp.AppHost/Properties/launchSettings.json Launch settings for the new example AppHost.
examples/stable-diffusion-cpp/CommunityToolkit.Aspire.Hosting.StableDiffusionCpp.AppHost/Program.cs Minimal runnable example wiring the new resource + model.
examples/stable-diffusion-cpp/CommunityToolkit.Aspire.Hosting.StableDiffusionCpp.AppHost/CommunityToolkit.Aspire.Hosting.StableDiffusionCpp.AppHost.csproj Adds the example AppHost project.
examples/stable-diffusion-cpp/CommunityToolkit.Aspire.Hosting.StableDiffusionCpp.AppHost/.gitignore Ignores local model/output cache under the example.
CommunityToolkit.Aspire.slnx Adds the new src/tests/example projects to the solution.

Review details

  • Files reviewed: 16/16 changed files
  • Comments generated: 4
  • Review effort level: Lite

Comment thread README.md
@aaronpowell
aaronpowell enabled auto-merge (squash) August 7, 2026 02:11
@aaronpowell
aaronpowell merged commit ef0aa30 into CommunityToolkit:main Aug 7, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add stable-diffusion.cpp hosting integration

3 participants