Skip to content

Modernise Diffusionfile Support - #970

Merged
aittalam merged 2 commits into
mozilla-ai:mainfrom
cbk-res:diffusionfile
May 28, 2026
Merged

aittalam merged 2 commits into
mozilla-ai:mainfrom
cbk-res:diffusionfile

Conversation

@cbk-res

@cbk-res cbk-res commented May 18, 2026

Copy link
Copy Markdown
Contributor

Description

This PR attempts to modernise support for stable-diffusion.cpp within llamafile through diffusionfile. I have updated the submodule in use to the latest branch (baf7eda1), removed the now redundant and obsolete patches which were needed by the old version, but seemingly are resolved at present. The new implementation patches SDcpp minimally, following the approach used for whispercpp, and in doing so, removes substantial amounts of code, and therefore maintenance burden. It is working well for me locally as you can see below (although only CPU tested so far), testing with SDXS Q8 gguf, and everything seems to work as expected on my system.

./diffusionfile -m sdxs-512-tinySDdistilled_Q8_0.gguf -p "a happy donkey" --steps  8
a-supposed-happy-donkey

PR Type

  • 🆕 New Feature
  • 🐛 Bug Fix

Relevant issues

#827
#229

Checklist

  • I understand the code I am submitting.
  • I have run this code locally and verified the change.
  • New and existing tests pass locally, or I have explained why tests were not run.
  • Documentation was updated where necessary.
  • If I changed code in llama.cpp/, whisper.cpp/, or stable-diffusion.cpp/, I also updated the matching *.patches/ files.
  • I have read and followed the contribution guidelines.
  • AI Usage:
    • No AI was used.
    • AI was used in an assistive capacity.
    • This PR includes substantial AI-generated content.

AI Usage Information

  • AI Model used: Qwen 3.6 Plus
  • AI Developer Tool used: OpenCode
  • Any other info you'd like to share: This code has been implemented by my agent under strict instructions to remain firmly within the conventions used in stock llamafile, and as such, the modernisation of diffusionfile follows closely that of the implementation used for whisperfile. I have personally reviewed this code, and had a second human review also. This code has been tested extensively locally, as well as using using the automated tests (integrations pytests - although the nothink shortened output one times out on my cpu, and URI test) to verify that stock functionality is unaffected, and the SDcpp implementation with SDXS, to ensure that all is in working order. However, I do not have a GPU, so testing of this functionality is unverified.

When answering reviewer questions, please respond yourself rather than pasting reviewer comments into an AI system and posting the reply back unchanged.

  • I am an AI Agent filling out this form (check box if true)


extern "C" {
long long llround(double x) {
return static_cast<long long>(x >= 0.0 ? x + 0.5 : x - 0.5);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

These should be defined as:

long long llround(double x) {
  return round(x);
}
long long llroundf(float x) {
  return roundf(x);
}
long long llroundl(long double x) {
  return roundl(x);
}

I'm adding them to cosmo libc next release.

@cbk-res cbk-res May 18, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the review, this should be corrected now :)
I built with the changes and it seems to work as expected.

@aittalam

aittalam commented May 28, 2026 •

Copy link
Copy Markdown
Member

Hi @cbk-res ! Many thanks for your contribution 🙏

Given this adds back a feature we had lost, I think it's great even if it does support CPU alone and we can merge it as-is (similarly to what we did with whisperfile) then work to bring GPU support back into it.

Code runs well on my system too, from setup to building and testing it

@aittalam
aittalam self-requested a review May 28, 2026 11:11
@aittalam
aittalam merged commit a0f4f28 into mozilla-ai:main May 28, 2026
2 checks passed
@cbk-res
cbk-res deleted the diffusionfile branch May 28, 2026 11:24
@cbk-res

cbk-res commented May 28, 2026

Copy link
Copy Markdown
Contributor Author

No problem at all @aittalam, glad it is working well. I hope to contribute more in the future :)

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.

3 participants