Repository navigation
First impressions info dump #1
Copy link
Copy link
Closed
Description
Hey, finally stable diffusion for ggml 😄
Did a test run
$ ./sd -t 8 -m ../models/v1-5-pruned-emaonly-ggml-model-q8_0.bin -p "alps, distant alms, small church, (cinematic:1.3), intricate details, (ArtStation:1.2), nikon dlsr, masterpiece, hyperreal"
[INFO] stable-diffusion.cpp:2189 - loading model from '../models/v1-5-pruned-emaonly-ggml-model-q8_0.bin'
[INFO] stable-diffusion.cpp:2214 - ftype: q8_0
[INFO] stable-diffusion.cpp:2259 - params ctx size = 1618.72 MB
[INFO] stable-diffusion.cpp:2399 - loading model from '../models/v1-5-pruned-emaonly-ggml-model-q8_0.bin' completed, taking 0.46s
[INFO] stable-diffusion.cpp:2477 - condition graph use 4.34MB of memory: static 1.41MB, dynamic = 2.93MB
[INFO] stable-diffusion.cpp:2477 - condition graph use 4.34MB of memory: static 1.41MB, dynamic = 2.93MB
[INFO] stable-diffusion.cpp:2822 - get_learned_condition completed, taking 0.16s
[INFO] stable-diffusion.cpp:2830 - start sampling
[INFO] stable-diffusion.cpp:2674 - step 1 sampling completed, taking 18.34s
[INFO] stable-diffusion.cpp:2674 - step 2 sampling completed, taking 18.24s
[INFO] stable-diffusion.cpp:2674 - step 3 sampling completed, taking 18.65s
[INFO] stable-diffusion.cpp:2674 - step 4 sampling completed, taking 18.41s
[INFO] stable-diffusion.cpp:2674 - step 5 sampling completed, taking 18.31s
[INFO] stable-diffusion.cpp:2674 - step 6 sampling completed, taking 18.18s
[INFO] stable-diffusion.cpp:2674 - step 7 sampling completed, taking 18.21s
[INFO] stable-diffusion.cpp:2674 - step 8 sampling completed, taking 18.29s
[INFO] stable-diffusion.cpp:2674 - step 9 sampling completed, taking 18.21s
[INFO] stable-diffusion.cpp:2674 - step 10 sampling completed, taking 18.28s
[INFO] stable-diffusion.cpp:2674 - step 11 sampling completed, taking 18.19s
[INFO] stable-diffusion.cpp:2674 - step 12 sampling completed, taking 18.00s
[INFO] stable-diffusion.cpp:2674 - step 13 sampling completed, taking 18.03s
[INFO] stable-diffusion.cpp:2674 - step 14 sampling completed, taking 18.54s
[INFO] stable-diffusion.cpp:2674 - step 15 sampling completed, taking 18.32s
[INFO] stable-diffusion.cpp:2674 - step 16 sampling completed, taking 18.41s
[INFO] stable-diffusion.cpp:2674 - step 17 sampling completed, taking 18.29s
[INFO] stable-diffusion.cpp:2674 - step 18 sampling completed, taking 18.51s
[INFO] stable-diffusion.cpp:2674 - step 19 sampling completed, taking 18.62s
[INFO] stable-diffusion.cpp:2674 - step 20 sampling completed, taking 18.11s
[INFO] stable-diffusion.cpp:2686 - diffusion graph use 623.74MB of memory: static 69.53MB, dynamic = 554.21MB
[INFO] stable-diffusion.cpp:2835 - sampling completed, taking 366.14s
[INFO] stable-diffusion.cpp:2766 - vae graph use 2177.12MB of memory: static 1153.12MB, dynamic = 1024.00MB
[INFO] stable-diffusion.cpp:2842 - decode_first_stage completed, taking 57.66s
[INFO] stable-diffusion.cpp:2843 - txt2img completed in 423.96s, with a runtime memory usage of 2177.12MB and parameter memory usage of 1618.58MB
save result image to 'output.png'
Painpoint: the extra python libs for conversion. Got a pip install error bc i have an incompatible version of something installed already, convert.py worked anyway though. :)
Timings: I used the q8_0 quantization and ran with different thread counts:
I have a 12core(24threads) cpu.
I took the timing of a sampling step.
| quant | q8_0 | q4_0 | f16 |
|---|---|---|---|
| -t 1 | 75.31s | 75.20s | 82.92s |
| -t 2 | 42.44s | ||
| -t 4 | 28.65s | 29.23s | 30.00s |
| -t 6 | 21.68s | ||
| -t 8 | 18.34s | 18.89s | 19.05s |
| -t 10 | 16.38s | 16.78s | 17.61s |
| -t 12 | 16.26s | 16.98s | 18.11s |
| -t 14 | 17.93s | ||
| -t 16 | 16.80s | ||
| -t 18 | 16.70s | ||
| -t 20 | 16.20s | ||
| -t 22 | 16.96s | ||
| -t 24 | 18.93s |
Additional questions:
- do you have/plan to support token weighing? ( eg:
(cinematic:1.3)) - are you looking into supporting cuda/opencl backends from ggml?
- are you looking into k-quants (like llama.cpp) and some form of quality mesurement of quantizations? (since k-quants use different quant for different parts of the model)
- it would be nice if the tool printed the "system line" (see https://github.com/ggerganov/llama.cpp/blob/f64d44a9b9581cd58f7ec40f4fa1c3ca5ca18e1e/llama.cpp#L4267 )
- did not see it mentioned, does it support sd 2.x / do you plan to add support for that ?
- my little benchmark suggests the bottleneck is not the model file, but the dynamic data. What number type do you use for it, llama.cpp has shown little to no degradation in quality when using f16 instead of f32 for the kv-cache.
edit: added f16 timings
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels

Activity
leejet commentedon Aug 13, 2023
Thanks for the feedback.
Green-Sky commentedon Aug 13, 2023
very nice
i see
oh, i overlooked that one
run with verbose
the tokenizer really looks like it needs some work, really surprised the image came out that good.
good to hear.
cant wait 😄
slaren commentedon Aug 13, 2023
Adding my first impressions here as well. I had some compile errors in my system:
After adding these includes (
<cstring>and<iterator>) tostable-diffusion.cppit worked great.Even with

q4_0the results are pretty good! I got this image with the example prompt:leejet commentedon Aug 13, 2023
Thanks for the feedback.
Following your advice, I've addressed this issue in the latest commit. This compilation error might have occurred due to differences in compiler implementations. I tested with MSVC and GCC and didn't encounter this problem. May I ask which compiler you are using?
slaren commentedon Aug 13, 2023
I am using
gcc (Ubuntu 12.3.0-1ubuntu1~23.04) 12.3.0, which should be the current version of GCC in Ubuntu-latest.leejet commentedon Aug 13, 2023
I'm using
gcc version 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04). Haha, environmental issues can indeed be quite frustrating.Green-Sky commentedon Aug 13, 2023
ah yes, a fellow ubuntu20.04 user stuck on lts 🤣
ggerganov commentedon Aug 13, 2023
Cool stuff!
Here is a sample run on M2 Ultra:
another seed
Here is a rough breakdown of the time per op using
GGML_PERF:Looks like
CONV_2Dneeds some work.ggmloperators at some point. Not sure about the "dynamic mode" thoughview+cpyleejet commentedon Aug 14, 2023
Thank you for the feedback. Thank you for creating such amazing ggml.
OK, I will sort out the code of new operators and upstream later. I'm also considering whether to upstream the "dynamic mode".
I've tried it before,but it seems that combining
view+cpycannot fulfill the concatenation requirement along dim=1.x-legion commentedon Aug 14, 2023
Any plans for sdxl?
leejet commentedon Aug 14, 2023
I'm willing to implement SDXL once I've improved the support for SD 1.x and added support for SD 2.x.
Green-Sky commentedon Aug 16, 2023
Took a stab at a larger resolution 768x768
Details
unsurprisingly it takes way (way) longer:
whoreson commentedon Aug 16, 2023
Wow, this is so cool. Easy to convert existing models, quantization.. very nice.
https://github.com/bes-dev/stable_diffusion.openvino <- this is way faster though, probably due to it using OpenVINO.
leejet commentedon Aug 16, 2023
I've implemented a memory optimization, and now when using txt2img with fp16 precision to generate a 512x512 image, it only requires 2.3GB.
leejet commentedon Aug 16, 2023
Oh, yeah. Now I'm working hard to make it run faster.
Green-Sky commentedon Aug 16, 2023
is this already on master? bc i reran my diffusion above with similar timings and memory usage (? memory reporting changed)
Details
leejet commentedon Aug 16, 2023
Since you are generating 768x768 images, this will cause the runtime memory to grow, and there is still room for optimization
Green-Sky commentedon Aug 17, 2023
@leejet i dont think that is how that label is supposed to be used 😄
leejet commentedon Aug 17, 2023
You're right, I made a mistake. I accidentally clicked on it while browsing, it wasn't my intention.
BrutalCoding commentedon Aug 20, 2023
Found this repo thanks to HN (hackernews). Had 0 issues when trying out this for the first time yesterday.
Just to share along, I've added 2 outputs of v1-5 in f16 and q4_1. This is coming from my MBP 16" (2021/M1PRO/16GB/512GB).
f16
Expand to see re-run in verbose
q4_1
Expand to see re-run in verbose
cond cache #1