Compare commits
688 commits
master-463
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d68f2883c9 | ||
|
|
3771ef249c | ||
|
|
cab31f12b5 | ||
|
|
58d1126feb | ||
|
|
3b0426f7fa | ||
|
|
05adb5b9d6 | ||
|
|
dee497f4df | ||
|
|
9d1fe30013 | ||
|
|
c80ed92a54 | ||
|
|
908965df8c | ||
|
|
e637c7bccd | ||
|
|
ea3f6ec703 | ||
|
|
6b51a955b4 | ||
|
|
00a944fdf4 | ||
|
|
fce8619ba0 | ||
|
|
439e77a52e | ||
|
|
514e786d84 | ||
|
|
456f52d2de | ||
|
|
52491bd9f1 | ||
|
|
5fa203c758 | ||
|
|
c33eebc5a6 | ||
|
|
82c19c8fee | ||
|
|
f296cb047e | ||
|
|
5303199be7 | ||
|
|
79dc7ca907 | ||
|
|
ce7ef90edf | ||
|
|
d697a0a230 | ||
|
|
571fc44437 | ||
|
|
20e2b79f14 | ||
|
|
3b12781fac | ||
|
|
8187e47c4a | ||
|
|
91ed00931f | ||
|
|
5b80e1f2d5 | ||
|
|
6667be6529 | ||
|
|
0d71f963af | ||
|
|
bf31b9c299 | ||
|
|
2c678bcfe9 | ||
|
|
6cd0ef1e1e | ||
|
|
9e7eed71e4 | ||
|
|
422b10dbd2 | ||
|
|
6874e490c8 | ||
|
|
56d95bfa12 | ||
|
|
a852f494c5 | ||
|
|
f0816c9ade | ||
|
|
9860a9281c | ||
|
|
532d2c15c4 | ||
|
|
01c463a223 | ||
|
|
5dcfa79801 | ||
|
|
394d2104fc | ||
|
|
6201bcc7ea | ||
|
|
f7120ceb36 | ||
|
|
ca4e755dfa | ||
|
|
85a0b90ca5 | ||
|
|
b521db4835 | ||
|
|
4b51674b66 | ||
|
|
0f8a46702b | ||
|
|
ce94719254 | ||
|
|
3bad89267b | ||
|
|
a59298ed51 | ||
|
|
5d787408c0 | ||
|
|
b9d7176bf8 | ||
|
|
8b1e9df27d | ||
|
|
766ce0ec4e | ||
|
|
32d516c019 | ||
|
|
f8417d02e1 | ||
|
|
465adf389f | ||
|
|
0678d04ae7 | ||
|
|
ddc367ab5d | ||
|
|
56070ea034 | ||
|
|
0bb132831f | ||
|
|
e1ca5e8bc7 | ||
|
|
a3f46b665a | ||
|
|
a3c49b13be | ||
|
|
73fef08224 | ||
|
|
d36f72bbe5 | ||
|
|
46da352af0 | ||
|
|
c44cbec722 | ||
|
|
fbb381da25 | ||
|
|
991f825583 | ||
|
|
008b9a20ca | ||
|
|
cfdf3cf037 | ||
|
|
d22dcda1cf | ||
|
|
f977addf06 | ||
|
|
fc350be2ce | ||
|
|
b43ce4badd | ||
|
|
cd5594e9f9 | ||
|
|
abc6718455 | ||
|
|
80c4707c53 | ||
|
|
3d315c47d4 | ||
|
|
b43af40461 | ||
|
|
f61053c25d | ||
|
|
0b3b98d7b8 | ||
|
|
de00bafc3d | ||
|
|
7bcd4ce8ce | ||
|
|
5f8c19f98d | ||
|
|
9234ad822a | ||
|
|
b1f5a51a1e | ||
|
|
fdfc913c51 | ||
|
|
5a1ba5d895 | ||
|
|
f5df5f8b84 | ||
|
|
7952693004 | ||
|
|
58bb3c1b1c | ||
|
|
d1358945dc | ||
|
|
3e92bf990a | ||
|
|
984eb0686c | ||
|
|
d30854463d | ||
|
|
6225bf8c88 | ||
|
|
f8ea2e162c | ||
|
|
3be23788fc | ||
|
|
b4d6b83af6 | ||
|
|
250ea6e385 | ||
|
|
1350cf5097 | ||
|
|
290148d2e3 | ||
|
|
133087deb8 | ||
|
|
5d33b1bd2b | ||
|
|
62c54439c8 | ||
|
|
fe2682ba16 | ||
|
|
df0fa26a61 | ||
|
|
5356982584 | ||
|
|
45a63ac460 | ||
|
|
c6dfa9def1 | ||
|
|
0a067120b3 | ||
|
|
e239e4b0fd | ||
|
|
37bc88b5e9 | ||
|
|
e7b7ec6d6f | ||
|
|
997478a4cb | ||
|
|
8ee08e3cb9 | ||
|
|
77b72a2efe | ||
|
|
8cbe905fdd | ||
|
|
687915518e | ||
|
|
d09cb4c63a | ||
|
|
209b28c3cd | ||
|
|
9bfc4d1089 | ||
|
|
2032526e8c | ||
|
|
be486498ea | ||
|
|
bb6b128b2d | ||
|
|
e41fbcf455 | ||
|
|
012c7f8866 | ||
|
|
a5e48c66aa | ||
|
|
b29962db7a | ||
|
|
0f76bf5c1e | ||
|
|
bb6a0ccfa3 | ||
|
|
e6370bf093 | ||
|
|
2a5f81095d | ||
|
|
d234ac62fa | ||
|
|
0886f11b6b | ||
|
|
ea209dbfcf | ||
|
|
a85db96aa5 | ||
|
|
b29cad540a | ||
|
|
4c870cc60c | ||
|
|
50a64f075e | ||
|
|
95ff762308 | ||
|
|
e0ed724e28 | ||
|
|
40b1788476 | ||
|
|
cd7f986058 | ||
|
|
baf45b49e2 | ||
|
|
fd21ecfcee | ||
|
|
e779d4f149 | ||
|
|
deaeed6a2f | ||
|
|
39bc9d0b4b | ||
|
|
f18dbfced7 | ||
|
|
530fa39073 | ||
|
|
ddd6b3aa35 | ||
|
|
a0c8508e72 | ||
|
|
a77d362318 | ||
|
|
b15c8aac39 | ||
|
|
2e2ba3faec | ||
|
|
939895f00e | ||
|
|
845646b034 | ||
|
|
0518b34374 | ||
|
|
9b7da27374 | ||
|
|
269045e92c | ||
|
|
20050815ac | ||
|
|
a068716fab | ||
|
|
b13a48219d | ||
|
|
d55cc0f75f | ||
|
|
95b3090664 | ||
|
|
ab8d5ea8c3 | ||
|
|
f0aac524d3 | ||
|
|
68285df319 | ||
|
|
af0fc72c96 | ||
|
|
2f016e8e30 | ||
|
|
8c442fb0ad | ||
|
|
8cd731e7b4 | ||
|
|
e47426c044 | ||
|
|
2891378bb1 | ||
|
|
120e3e875c | ||
|
|
1d0a58a350 | ||
|
|
46362fc4c0 | ||
|
|
d763dae3b8 | ||
|
|
60423ab5f6 | ||
|
|
7e3e20a50b | ||
|
|
d637cfb935 | ||
|
|
792bcd344c | ||
|
|
2988060a43 | ||
|
|
1b0ba10893 | ||
|
|
b7a74e68d7 | ||
|
|
05845fde41 | ||
|
|
0e1d733b7a | ||
|
|
ce95c09ce1 | ||
|
|
f89d9b13d7 | ||
|
|
f2f168fa70 | ||
|
|
7867f6da4a | ||
|
|
228c707fde | ||
|
|
e16d26a96a | ||
|
|
a4a966990d | ||
|
|
a1ded76da5 | ||
|
|
8cc5ad8f1c | ||
|
|
4a892293ac | ||
|
|
fd43b542a6 | ||
|
|
0963357214 | ||
|
|
1da55ebde8 | ||
|
|
fb8ee71f55 | ||
|
|
96f67fe631 | ||
|
|
203a882a28 | ||
|
|
019bcfc0ae | ||
|
|
c150a6bafe | ||
|
|
f4b5326da7 | ||
|
|
bbdcad48dd | ||
|
|
b6947b8bdc | ||
|
|
9db0db6570 | ||
|
|
d4bfcd5d78 | ||
|
|
3f8527a46c | ||
|
|
42ab1c12f1 | ||
|
|
27f7c430c0 | ||
|
|
ede32a621e | ||
|
|
47e83d7136 | ||
|
|
f8890b9db3 | ||
|
|
61a83b85cc | ||
|
|
9947eebec8 | ||
|
|
168f7b88b9 | ||
|
|
2f886889e6 | ||
|
|
19bbbca1c7 | ||
|
|
39ada0863b | ||
|
|
4c3cf7543d | ||
|
|
510bccf330 | ||
|
|
5e7b29131e | ||
|
|
0a9340c599 | ||
|
|
b167b942f7 | ||
|
|
1a2330de68 | ||
|
|
740c7ae193 | ||
|
|
4dfe8f5d45 | ||
|
|
caa111adf3 | ||
|
|
88411ef1e0 | ||
|
|
500ef5fa7c | ||
|
|
2a4ebba818 | ||
|
|
70c1dbc01e | ||
|
|
36746936c0 | ||
|
|
2dc7f5408a | ||
|
|
e6281b6318 | ||
|
|
241518b35d | ||
|
|
c92d73c408 | ||
|
|
28b454bda1 | ||
|
|
2bb72947cb | ||
|
|
ac45422a05 | ||
|
|
e112ab5a50 | ||
|
|
e01206574b | ||
|
|
6dcb5bbd42 | ||
|
|
97d932b8f8 | ||
|
|
78557f88d9 | ||
|
|
2726dd35c2 | ||
|
|
74988b290e | ||
|
|
c678dfe704 | ||
|
|
b56c68617d | ||
|
|
187b2561ea | ||
|
|
15f335daa5 | ||
|
|
b8248a869c | ||
|
|
008ca5b492 | ||
|
|
137f7409bb | ||
|
|
1330cebae8 | ||
|
|
17860c0e45 | ||
|
|
275ab58e01 | ||
|
|
d32b4e893b | ||
|
|
9982c9caae | ||
|
|
3e037a81e4 | ||
|
|
2ea8aff7ef | ||
|
|
adcac69650 | ||
|
|
656a1354c3 | ||
|
|
269e726015 | ||
|
|
cc515a01f9 | ||
|
|
3161505fe8 | ||
|
|
59c23bce0d | ||
|
|
07a85c74cb | ||
|
|
f9ddc0f388 | ||
|
|
4964abdfc5 | ||
|
|
42d6c0ab92 | ||
|
|
5a5400bf0c | ||
|
|
ca37fad89a | ||
|
|
0bd72f075a | ||
|
|
4a7da26b73 | ||
|
|
9a977388a8 | ||
|
|
44dd13716d | ||
|
|
7f410a3793 | ||
|
|
5ebce93342 | ||
|
|
7f986a9d73 | ||
|
|
e06b205384 | ||
|
|
3191b23d4b | ||
|
|
e95ab96997 | ||
|
|
b68d58624d | ||
|
|
14eddb32b1 | ||
|
|
469fc49bb7 | ||
|
|
6b47fec013 | ||
|
|
d04e8950c1 | ||
|
|
9cdb6b6fc0 | ||
|
|
31ab2b2e08 | ||
|
|
d8fb10c029 | ||
|
|
80bac2d5fc | ||
|
|
dbb611264e | ||
|
|
462d675018 | ||
|
|
6c57cc3b38 | ||
|
|
6b3edaaf32 | ||
|
|
40e605f3f1 | ||
|
|
9029655a54 | ||
|
|
d9b6e27e9f | ||
|
|
134c8212de | ||
|
|
2540a4fc25 | ||
|
|
dc4000d9f8 | ||
|
|
c797899732 | ||
|
|
afd5306d88 | ||
|
|
2c929495ab | ||
|
|
be0e34480d | ||
|
|
50d6405683 | ||
|
|
0a565f2950 | ||
|
|
12ee60dc02 | ||
|
|
97d2990807 | ||
|
|
16304cc3fd | ||
|
|
760717a060 | ||
|
|
88b044be7f | ||
|
|
1706b32813 | ||
|
|
58b6cb6b0c | ||
|
|
6100d8339b | ||
|
|
de298c225b | ||
|
|
fabe481212 | ||
|
|
06c359f17a | ||
|
|
bcc7e29568 | ||
|
|
487de75c96 | ||
|
|
b4f1fd6d7f | ||
|
|
c6beeef355 | ||
|
|
bfbef5b7e6 | ||
|
|
ea7f0c87cf | ||
|
|
b4e67d1221 | ||
|
|
db99efdd6d | ||
|
|
eb7f35ca49 | ||
|
|
50062a4bba | ||
|
|
8457624101 | ||
|
|
10378f42db | ||
|
|
e31a86ce91 | ||
|
|
735a4ef520 | ||
|
|
af92790ffc | ||
|
|
e92e86fb11 | ||
|
|
9cfe2af8f9 | ||
|
|
2993b7fb43 | ||
|
|
53856e7ec8 | ||
|
|
22516991cb | ||
|
|
5ef4a7557d | ||
|
|
2d0385ba85 | ||
|
|
87a01773be | ||
|
|
b0f856804c | ||
|
|
78124b6454 | ||
|
|
b338b4b4b9 | ||
|
|
b8bf67615c | ||
|
|
8d377073e3 | ||
|
|
5114672c48 | ||
|
|
8a51eb9284 | ||
|
|
35fb21f3e0 | ||
|
|
cfd4cff2e6 | ||
|
|
5e4e03c8dd | ||
|
|
2961182365 | ||
|
|
ea4e566ccf | ||
|
|
b290693977 | ||
|
|
7717e82c00 | ||
|
|
fafe8e606c | ||
|
|
a8a91b24cd | ||
|
|
c00a9e956d | ||
|
|
833369da84 | ||
|
|
74bce049d0 | ||
|
|
b5d812008e | ||
|
|
c79d24bdbd | ||
|
|
1b042838d9 | ||
|
|
ead6bf521b | ||
|
|
9beb6aca69 | ||
|
|
12b6fbff28 | ||
|
|
cc73429228 | ||
|
|
6314af404a | ||
|
|
885f01a555 | ||
|
|
9ef6e7398f | ||
|
|
bb84971129 | ||
|
|
e22272ee63 | ||
|
|
4fcc6fef10 | ||
|
|
9e1055d2e3 | ||
|
|
8b135b5489 | ||
|
|
e071aa390b | ||
|
|
dff0e88265 | ||
|
|
c674225b38 | ||
|
|
0321ce17fb | ||
|
|
2abbc773ac | ||
|
|
da6db07c5c | ||
|
|
e9dee542c4 | ||
|
|
c60b36af0f | ||
|
|
38a51f8105 | ||
|
|
45714b1069 | ||
|
|
e790073e1c | ||
|
|
b11c95a41c | ||
|
|
68f3d6df9f | ||
|
|
7bcd189639 | ||
|
|
2574f59365 | ||
|
|
7dab3668d0 | ||
|
|
556f04bb3f | ||
|
|
3590aa8d62 | ||
|
|
1a13107bac | ||
|
|
484baa41e5 | ||
|
|
2bb0389683 | ||
|
|
ccda89e09c | ||
|
|
f0271076ad | ||
|
|
3b6c9ca97c | ||
|
|
57e19fa954 | ||
|
|
61a637bfd5 | ||
|
|
3ec374aecc | ||
|
|
0484600284 | ||
|
|
c1790754d3 | ||
|
|
9f855c933b | ||
|
|
7b5f34d93e | ||
|
|
d77b8f5ee8 | ||
|
|
03e9a22f4d | ||
|
|
f54e45e81c | ||
|
|
9956436c92 | ||
|
|
ec4cb8104b | ||
|
|
3973015ed7 | ||
|
|
9ee77fc227 | ||
|
|
39f7962d69 | ||
|
|
8caa3f908a | ||
|
|
2938272d82 | ||
|
|
f440ad9c29 | ||
|
|
41f7acbfb0 | ||
|
|
b395a6972d | ||
|
|
854bebfe02 | ||
|
|
787d229d84 | ||
|
|
b12098f5d0 | ||
|
|
2bd249c971 | ||
|
|
e9e952462f | ||
|
|
e8e012eef2 | ||
|
|
7f0e728b7d | ||
|
|
92a3b73cdb | ||
|
|
710bc91c8f | ||
|
|
5a34bc7f6e | ||
|
|
146b6cc49e | ||
|
|
93527fda74 | ||
|
|
6e66a1a4a4 | ||
|
|
bb90bfa00f | ||
|
|
517abc777d | ||
|
|
6f00939f75 | ||
|
|
c2df4e1228 | ||
|
|
9838264c49 | ||
|
|
17d70b91e6 | ||
|
|
5db680c2c7 | ||
|
|
749186c0eb | ||
|
|
bdb431ad95 | ||
|
|
276025e054 | ||
|
|
8d4c7af95b | ||
|
|
9b0fceb41b | ||
|
|
563137a592 | ||
|
|
3a54597776 | ||
|
|
1365008348 | ||
|
|
1fb6b22850 | ||
|
|
c20769b2c8 | ||
|
|
1b702a51e7 | ||
|
|
19bdfe22d2 | ||
|
|
138da14cc3 | ||
|
|
17a2b4a315 | ||
|
|
b3d56d0ba1 | ||
|
|
2a07540c2a | ||
|
|
81abfb2548 | ||
|
|
f3fd359b58 | ||
|
|
dfb2390dd4 | ||
|
|
cfbc19d186 | ||
|
|
b9254dda0d | ||
|
|
0648f4426b | ||
|
|
74f513d512 | ||
|
|
064001b524 | ||
|
|
1f9ee88e09 | ||
|
|
a7f2e03da4 | ||
|
|
4513e3fda9 | ||
|
|
2d40a8b2ad | ||
|
|
9c7f9a20b3 | ||
|
|
ed74577c40 | ||
|
|
7948df8ac1 | ||
|
|
02f06370a7 | ||
|
|
f8935d6f25 | ||
|
|
be65ac7511 | ||
|
|
20901f6d8e | ||
|
|
0982807139 | ||
|
|
d2797b8667 | ||
|
|
d3b2cb047e | ||
|
|
b4ba55d8d7 | ||
|
|
b54bd83a3f | ||
|
|
0e4ee04488 | ||
|
|
29ab511fc7 | ||
|
|
55c2aed52c | ||
|
|
8eded497e5 | ||
|
|
92dc7268fc | ||
|
|
07b2b18e70 | ||
|
|
1ceb5bd9df | ||
|
|
202c6154a2 | ||
|
|
a397e03488 | ||
|
|
72e512a0cc | ||
|
|
0baf721215 | ||
|
|
645e6e9089 | ||
|
|
cbf92191c3 | ||
|
|
8cf55a3b3b | ||
|
|
3a8788cb7d | ||
|
|
449165caf5 | ||
|
|
adaa599a3b | ||
|
|
2e3514625a | ||
|
|
47d8198b69 | ||
|
|
ef92a0027e | ||
|
|
b3374e6a71 | ||
|
|
bdd937f29a | ||
|
|
c51ec7cad9 | ||
|
|
5b0267e941 | ||
|
|
0045a72b96 | ||
|
|
99bd062546 | ||
|
|
9d8c9e4279 | ||
|
|
caa823a8c0 | ||
|
|
22c8c40b0d | ||
|
|
b706d682ad | ||
|
|
b758b7de13 | ||
|
|
f683c88a28 | ||
|
|
21fd4e6788 | ||
|
|
830804262b | ||
|
|
82e03ef137 | ||
|
|
baf7eda1e4 | ||
|
|
e7eb92fd84 | ||
|
|
50134e51dd | ||
|
|
e43b24cf48 | ||
|
|
06accf2b39 | ||
|
|
cde20d5ef0 | ||
|
|
67dda3f897 | ||
|
|
3b4d26f3d9 | ||
|
|
bd17f53b73 | ||
|
|
d7ecbe1d01 | ||
|
|
36330724bd | ||
|
|
0c1ca170ca | ||
|
|
839f6a94d2 | ||
|
|
38b14adb67 | ||
|
|
fd1a2794f3 | ||
|
|
db08b84607 | ||
|
|
686856edca | ||
|
|
0b8296915c | ||
|
|
381e0df50f | ||
|
|
0665a7f8bf | ||
|
|
eeac950b44 | ||
|
|
57ff2eb0f4 | ||
|
|
9d683417cb | ||
|
|
60477fd50f | ||
|
|
6ee0684d74 | ||
|
|
90e87bc846 | ||
|
|
586b6f1481 | ||
|
|
9097ce5211 | ||
|
|
3d6064b37e | ||
|
|
b8079e253d | ||
|
|
331cfa5387 | ||
|
|
a81677f59c | ||
|
|
f40a707d0f | ||
|
|
970c4a3312 | ||
|
|
b8bdffc199 | ||
|
|
c97702e105 | ||
|
|
44cca3d626 | ||
|
|
0a7ae07f94 | ||
|
|
66143340b6 | ||
|
|
7023fc4cfb | ||
|
|
e77e4c46bf | ||
|
|
7d33d4b2dd | ||
|
|
3c99f700de | ||
|
|
4d626d24b2 | ||
|
|
f3f69e2fbe | ||
|
|
6a9cb31150 | ||
|
|
2bcff67480 | ||
|
|
a564fdf642 | ||
|
|
84fc5446d2 | ||
|
|
1b4e9be643 | ||
|
|
d73b4198a4 | ||
|
|
5c243db9a8 | ||
|
|
c41c5ded7a | ||
|
|
9ac7b672c2 | ||
|
|
ee5bf956b0 | ||
|
|
6b675a5ede | ||
|
|
12a369cc67 | ||
|
|
fd3504760f | ||
|
|
7ade90e478 | ||
|
|
118489eb5c | ||
|
|
be9f51b25c | ||
|
|
e8323cabb0 | ||
|
|
dd753729cc | ||
|
|
8afbeb6ba9 | ||
|
|
5bf438d568 | ||
|
|
359eb8b8de | ||
|
|
7397ddaa86 | ||
|
|
9369ab759f | ||
|
|
687a81f251 | ||
|
|
87ecb95cbc | ||
|
|
99c1de379b | ||
|
|
09b12d5f6d | ||
|
|
6dfe945958 | ||
|
|
bf0216765a | ||
|
|
4fe7a35939 | ||
|
|
4d5232083f | ||
|
|
1d6cb0f8c3 | ||
|
|
83e8f6f0af | ||
|
|
8d878872d9 | ||
|
|
02dd5e5dd2 | ||
|
|
8f2967c006 | ||
|
|
f16a110f87 | ||
|
|
ed88e215a2 | ||
|
|
6293ab5aaf | ||
|
|
545fac4f3f | ||
|
|
5265a5efa1 | ||
|
|
84cbd88df1 | ||
|
|
997bb11fb6 | ||
|
|
862a6586cb | ||
|
|
61d8331ef3 | ||
|
|
acc3bf1fdc | ||
|
|
83eabd7c01 | ||
|
|
630ee03f23 | ||
|
|
f6968bc589 | ||
|
|
adfef62900 | ||
|
|
6fa7ca9317 | ||
|
|
d6dd6d7b55 | ||
|
|
dea4980f4e | ||
|
|
c8fb3d2458 | ||
|
|
3d33caaef8 | ||
|
|
9b424db0f4 | ||
|
|
d95062737e | ||
|
|
7c880f80c7 | ||
|
|
aaa8a51bd8 | ||
|
|
ba35dd734e | ||
|
|
d41f5fff69 | ||
|
|
810ef0cf76 | ||
|
|
5792c66879 | ||
|
|
39d54702a6 | ||
|
|
60889bc9a1 | ||
|
|
e64baa3611 | ||
|
|
cec4aedcfd | ||
|
|
4cdfff5ff2 | ||
|
|
0752cc9d3a | ||
|
|
b314d80ad0 | ||
|
|
c9cd49701a | ||
|
|
c5eb1e4137 | ||
|
|
636d3cb6ff | ||
|
|
adea272225 | ||
|
|
45ce78a3ae | ||
|
|
28ef93c0e1 | ||
|
|
3296545090 | ||
|
|
d60fb27560 | ||
|
|
c7ccafbd6f | ||
|
|
aa0b899397 | ||
|
|
5e264372ce | ||
|
|
f0f641a142 | ||
|
|
9f56833e14 | ||
|
|
65891d74cc | ||
|
|
f957fa3d2a | ||
|
|
c252e03c6b | ||
|
|
e63daba33d | ||
|
|
3959109281 | ||
|
|
e411520407 | ||
|
|
43e829f219 | ||
|
|
7837232631 | ||
|
|
4ccce027b2 | ||
|
|
fa61ea744d | ||
|
|
5e4579c11d | ||
|
|
329571131d | ||
|
|
a48b4a3ade | ||
|
|
b87fe13afd | ||
|
|
e50e1f253d | ||
|
|
c6206fb351 | ||
|
|
639091fbe9 | ||
|
|
9293016c9d | ||
|
|
2efd19978d | ||
|
|
61659ef299 | ||
|
|
9565c7f6bd | ||
|
|
fbce16e02d | ||
|
|
7010bb4dff | ||
|
|
48d3161a8d | ||
|
|
271b594e74 | ||
|
|
885e62ea82 | ||
|
|
0e52afc651 | ||
|
|
27b5f17401 | ||
|
|
dfe6d6c664 | ||
|
|
9be0b91927 |
|
|
@ -1,7 +1,8 @@
|
||||||
build*/
|
build*/
|
||||||
docs/
|
docs/
|
||||||
test/
|
test/
|
||||||
|
tests/
|
||||||
|
|
||||||
.cache/
|
.cache/
|
||||||
*.swp
|
*.swp
|
||||||
models/
|
models/
|
||||||
|
|
|
||||||
2
.gitattributes
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
/start-server.sh text eol=lf
|
||||||
|
/start-server.bat text eol=crlf
|
||||||
4
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
|
|
@ -6,7 +6,9 @@ body:
|
||||||
- type: markdown
|
- type: markdown
|
||||||
attributes:
|
attributes:
|
||||||
value: |
|
value: |
|
||||||
Please use this template and include as many details as possible to help us reproduce and fix the issue.
|
Before submitting a bug report, please read the [Troubleshooting guide](https://github.com/leejet/stable-diffusion.cpp/blob/master/docs/troubleshooting.md) and try the steps relevant to your problem.
|
||||||
|
|
||||||
|
If the problem persists, complete this form and include what you tried and the results, along with enough details to help us reproduce and fix the issue.
|
||||||
- type: textarea
|
- type: textarea
|
||||||
id: commit
|
id: commit
|
||||||
attributes:
|
attributes:
|
||||||
|
|
|
||||||
4
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
contact_links:
|
||||||
|
- name: Troubleshooting
|
||||||
|
url: https://github.com/leejet/stable-diffusion.cpp/blob/master/docs/troubleshooting.md
|
||||||
|
about: Read the troubleshooting guide first. If the problem persists, submit a bug report.
|
||||||
16
.github/pull_request_template.md
vendored
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
## Summary
|
||||||
|
|
||||||
|
<!-- Describe what changed and why. Keep the PR focused on one clear change. -->
|
||||||
|
|
||||||
|
## Related Issue / Discussion
|
||||||
|
|
||||||
|
<!-- Link related issues, discussions, or previous PRs if applicable. -->
|
||||||
|
|
||||||
|
## Additional Information
|
||||||
|
|
||||||
|
<!-- Add verification notes, screenshots, sample output, or other context when applicable. -->
|
||||||
|
|
||||||
|
## Checklist
|
||||||
|
|
||||||
|
- [ ] I have read and confirmed this PR follows the [contribution guidelines](https://github.com/leejet/stable-diffusion.cpp/blob/master/CONTRIBUTING.md).
|
||||||
|
- [ ] If this PR adds or changes model support, I have added or updated its usage guide and relevant model index/README entries following the [model documentation requirements](https://github.com/leejet/stable-diffusion.cpp/blob/master/CONTRIBUTING.md#model-documentation).
|
||||||
600
.github/workflows/build.yml
vendored
|
|
@ -14,6 +14,10 @@ on:
|
||||||
paths:
|
paths:
|
||||||
[
|
[
|
||||||
".github/workflows/**",
|
".github/workflows/**",
|
||||||
|
".dockerignore",
|
||||||
|
"docs/dgl-builtins.md",
|
||||||
|
"docker/Dockerfile*",
|
||||||
|
"scripts/ci-cuda-cache.sh",
|
||||||
"**/CMakeLists.txt",
|
"**/CMakeLists.txt",
|
||||||
"**/Makefile",
|
"**/Makefile",
|
||||||
"**/*.h",
|
"**/*.h",
|
||||||
|
|
@ -21,11 +25,23 @@ on:
|
||||||
"**/*.c",
|
"**/*.c",
|
||||||
"**/*.cpp",
|
"**/*.cpp",
|
||||||
"**/*.cu",
|
"**/*.cu",
|
||||||
|
"**/*.cuh",
|
||||||
|
"ggml",
|
||||||
|
"examples/server/frontend",
|
||||||
|
"examples/server/frontend/**",
|
||||||
|
"examples/server/recipes/*.json",
|
||||||
|
"start-server.sh",
|
||||||
|
"start-server.bat",
|
||||||
]
|
]
|
||||||
pull_request:
|
pull_request:
|
||||||
types: [opened, synchronize, reopened]
|
types: [opened, synchronize, reopened]
|
||||||
paths:
|
paths:
|
||||||
[
|
[
|
||||||
|
".github/workflows/**",
|
||||||
|
".dockerignore",
|
||||||
|
"docs/dgl-builtins.md",
|
||||||
|
"docker/Dockerfile*",
|
||||||
|
"scripts/ci-cuda-cache.sh",
|
||||||
"**/CMakeLists.txt",
|
"**/CMakeLists.txt",
|
||||||
"**/Makefile",
|
"**/Makefile",
|
||||||
"**/*.h",
|
"**/*.h",
|
||||||
|
|
@ -33,11 +49,21 @@ on:
|
||||||
"**/*.c",
|
"**/*.c",
|
||||||
"**/*.cpp",
|
"**/*.cpp",
|
||||||
"**/*.cu",
|
"**/*.cu",
|
||||||
|
"**/*.cuh",
|
||||||
|
"ggml",
|
||||||
|
"examples/server/frontend",
|
||||||
|
"examples/server/frontend/**",
|
||||||
|
"examples/server/recipes/*.json",
|
||||||
|
"start-server.sh",
|
||||||
|
"start-server.bat",
|
||||||
]
|
]
|
||||||
|
|
||||||
env:
|
env:
|
||||||
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
|
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
concurrency:
|
concurrency:
|
||||||
group: ${{ github.workflow }}-${{ github.head_ref && github.ref || github.run_id }}
|
group: ${{ github.workflow }}-${{ github.head_ref && github.ref || github.run_id }}
|
||||||
cancel-in-progress: true
|
cancel-in-progress: true
|
||||||
|
|
@ -49,10 +75,20 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
- name: Clone
|
- name: Clone
|
||||||
id: checkout
|
id: checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
submodules: recursive
|
submodules: recursive
|
||||||
|
|
||||||
|
- name: Setup Node
|
||||||
|
uses: actions/setup-node@v5
|
||||||
|
with:
|
||||||
|
node-version: 24
|
||||||
|
|
||||||
|
- name: Setup pnpm
|
||||||
|
uses: pnpm/action-setup@v5
|
||||||
|
with:
|
||||||
|
version: 10.15.1
|
||||||
|
|
||||||
- name: Dependencies
|
- name: Dependencies
|
||||||
id: depends
|
id: depends
|
||||||
run: |
|
run: |
|
||||||
|
|
@ -64,13 +100,15 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
mkdir build
|
mkdir build
|
||||||
cd build
|
cd build
|
||||||
cmake .. -DGGML_AVX2=ON -DSD_BUILD_SHARED_LIBS=ON
|
cmake .. -DSD_BUILD_SHARED_LIBS=ON -DGGML_NATIVE=OFF -DSD_BUILD_SHARED_GGML_LIB=ON -DGGML_BACKEND_DL=ON -DGGML_CPU_ALL_VARIANTS=ON -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON -DCMAKE_INSTALL_RPATH='$ORIGIN'
|
||||||
cmake --build . --config Release
|
cmake --build . --config Release
|
||||||
|
cmake --build . --config Release --target dgl-check-builtins
|
||||||
|
|
||||||
- name: Get commit hash
|
- name: Get commit hash
|
||||||
id: commit
|
id: commit
|
||||||
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
|
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
|
||||||
uses: pr-mpt/actions-commit-hash@v2
|
shell: bash
|
||||||
|
run: echo "short=${GITHUB_SHA:0:7}" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
- name: Fetch system info
|
- name: Fetch system info
|
||||||
id: system-info
|
id: system-info
|
||||||
|
|
@ -86,11 +124,14 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
cp ggml/LICENSE ./build/bin/ggml.txt
|
cp ggml/LICENSE ./build/bin/ggml.txt
|
||||||
cp LICENSE ./build/bin/stable-diffusion.cpp.txt
|
cp LICENSE ./build/bin/stable-diffusion.cpp.txt
|
||||||
zip -j sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-${{ steps.system-info.outputs.OS_TYPE }}-${{ steps.system-info.outputs.OS_NAME }}-${{ steps.system-info.outputs.OS_VERSION }}-${{ steps.system-info.outputs.CPU_ARCH }}.zip ./build/bin/*
|
cp thirdparty/libwebm/LICENSE.TXT ./build/bin/libwebm.txt
|
||||||
|
cp thirdparty/libwebp/COPYING ./build/bin/libwebp.txt
|
||||||
|
chmod +x start-server.sh
|
||||||
|
zip -j sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-${{ steps.system-info.outputs.OS_TYPE }}-${{ steps.system-info.outputs.OS_NAME }}-${{ steps.system-info.outputs.OS_VERSION }}-${{ steps.system-info.outputs.CPU_ARCH }}.zip ./build/bin/* ./start-server.sh ./start-server.bat
|
||||||
|
|
||||||
- name: Upload artifacts
|
- name: Upload artifacts
|
||||||
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
|
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v6
|
||||||
with:
|
with:
|
||||||
name: sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-${{ steps.system-info.outputs.OS_TYPE }}-${{ steps.system-info.outputs.OS_NAME }}-${{ steps.system-info.outputs.OS_VERSION }}-${{ steps.system-info.outputs.CPU_ARCH }}.zip
|
name: sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-${{ steps.system-info.outputs.OS_TYPE }}-${{ steps.system-info.outputs.OS_NAME }}-${{ steps.system-info.outputs.OS_VERSION }}-${{ steps.system-info.outputs.CPU_ARCH }}.zip
|
||||||
path: |
|
path: |
|
||||||
|
|
@ -102,28 +143,39 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
- name: Clone
|
- name: Clone
|
||||||
id: checkout
|
id: checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
submodules: recursive
|
submodules: recursive
|
||||||
|
|
||||||
|
- name: Setup Node
|
||||||
|
uses: actions/setup-node@v5
|
||||||
|
with:
|
||||||
|
node-version: 24
|
||||||
|
|
||||||
|
- name: Setup pnpm
|
||||||
|
uses: pnpm/action-setup@v5
|
||||||
|
with:
|
||||||
|
version: 10.15.1
|
||||||
|
|
||||||
- name: Dependencies
|
- name: Dependencies
|
||||||
id: depends
|
id: depends
|
||||||
run: |
|
run: |
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install build-essential libvulkan-dev glslc
|
sudo apt-get install build-essential libvulkan-dev glslc spirv-headers
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
id: cmake_build
|
id: cmake_build
|
||||||
run: |
|
run: |
|
||||||
mkdir build
|
mkdir build
|
||||||
cd build
|
cd build
|
||||||
cmake .. -DSD_BUILD_SHARED_LIBS=ON -DSD_VULKAN=ON
|
cmake .. -DSD_BUILD_SHARED_LIBS=ON -DSD_VULKAN=ON -DGGML_NATIVE=OFF -DSD_BUILD_SHARED_GGML_LIB=ON -DGGML_BACKEND_DL=ON -DGGML_CPU_ALL_VARIANTS=ON -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON -DCMAKE_INSTALL_RPATH='$ORIGIN'
|
||||||
cmake --build . --config Release
|
cmake --build . --config Release
|
||||||
|
|
||||||
- name: Get commit hash
|
- name: Get commit hash
|
||||||
id: commit
|
id: commit
|
||||||
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
|
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
|
||||||
uses: pr-mpt/actions-commit-hash@v2
|
shell: bash
|
||||||
|
run: echo "short=${GITHUB_SHA:0:7}" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
- name: Fetch system info
|
- name: Fetch system info
|
||||||
id: system-info
|
id: system-info
|
||||||
|
|
@ -139,11 +191,14 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
cp ggml/LICENSE ./build/bin/ggml.txt
|
cp ggml/LICENSE ./build/bin/ggml.txt
|
||||||
cp LICENSE ./build/bin/stable-diffusion.cpp.txt
|
cp LICENSE ./build/bin/stable-diffusion.cpp.txt
|
||||||
zip -j sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-${{ steps.system-info.outputs.OS_TYPE }}-${{ steps.system-info.outputs.OS_NAME }}-${{ steps.system-info.outputs.OS_VERSION }}-${{ steps.system-info.outputs.CPU_ARCH }}-vulkan.zip ./build/bin/*
|
cp thirdparty/libwebm/LICENSE.TXT ./build/bin/libwebm.txt
|
||||||
|
cp thirdparty/libwebp/COPYING ./build/bin/libwebp.txt
|
||||||
|
chmod +x start-server.sh
|
||||||
|
zip -j sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-${{ steps.system-info.outputs.OS_TYPE }}-${{ steps.system-info.outputs.OS_NAME }}-${{ steps.system-info.outputs.OS_VERSION }}-${{ steps.system-info.outputs.CPU_ARCH }}-vulkan.zip ./build/bin/* ./start-server.sh ./start-server.bat
|
||||||
|
|
||||||
- name: Upload artifacts
|
- name: Upload artifacts
|
||||||
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
|
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v6
|
||||||
with:
|
with:
|
||||||
name: sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-${{ steps.system-info.outputs.OS_TYPE }}-${{ steps.system-info.outputs.OS_NAME }}-${{ steps.system-info.outputs.OS_VERSION }}-${{ steps.system-info.outputs.CPU_ARCH }}-vulkan.zip
|
name: sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-${{ steps.system-info.outputs.OS_TYPE }}-${{ steps.system-info.outputs.OS_NAME }}-${{ steps.system-info.outputs.OS_VERSION }}-${{ steps.system-info.outputs.CPU_ARCH }}-vulkan.zip
|
||||||
path: |
|
path: |
|
||||||
|
|
@ -151,7 +206,8 @@ jobs:
|
||||||
|
|
||||||
build-and-push-docker-images:
|
build-and-push-docker-images:
|
||||||
name: Build and push container images
|
name: Build and push container images
|
||||||
runs-on: ubuntu-latest
|
if: ${{ github.event_name != 'pull_request' }}
|
||||||
|
runs-on: ${{ matrix.runner }}
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
|
|
@ -162,7 +218,22 @@ jobs:
|
||||||
|
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
variant: [musa, sycl, vulkan]
|
variant: [musa, sycl, vulkan, cuda]
|
||||||
|
platform: [linux/amd64]
|
||||||
|
runner: [ubuntu-latest]
|
||||||
|
build-args: [""]
|
||||||
|
tag-suffix: [""]
|
||||||
|
include:
|
||||||
|
- variant: cuda
|
||||||
|
platform: linux/arm64
|
||||||
|
runner: ubuntu-24.04-arm
|
||||||
|
tag-suffix: "-spark"
|
||||||
|
build-args: |
|
||||||
|
CUDA_VERSION=13.0.0
|
||||||
|
UBUNTU_VERSION=24.04
|
||||||
|
CUDA_ARCHITECTURES=121
|
||||||
|
GGML_CUDA_FA_ALL_QUANTS=ON
|
||||||
|
GGML_CUDA_ENABLE_DYNAMIC_CPU_BACKENDS=OFF
|
||||||
|
|
||||||
env:
|
env:
|
||||||
REGISTRY: ghcr.io
|
REGISTRY: ghcr.io
|
||||||
|
|
@ -174,16 +245,28 @@ jobs:
|
||||||
with:
|
with:
|
||||||
submodules: recursive
|
submodules: recursive
|
||||||
|
|
||||||
|
- name: Setup Node
|
||||||
|
uses: actions/setup-node@v5
|
||||||
|
with:
|
||||||
|
node-version: 24
|
||||||
|
|
||||||
|
- name: Setup pnpm
|
||||||
|
uses: pnpm/action-setup@v5
|
||||||
|
with:
|
||||||
|
version: 10.15.1
|
||||||
|
|
||||||
- name: Get commit hash
|
- name: Get commit hash
|
||||||
id: commit
|
id: commit
|
||||||
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
|
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
|
||||||
uses: pr-mpt/actions-commit-hash@v2
|
shell: bash
|
||||||
|
run: echo "short=${GITHUB_SHA:0:7}" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
id: buildx
|
||||||
|
uses: docker/setup-buildx-action@v4
|
||||||
|
|
||||||
- name: Log in to the container registry
|
- name: Log in to the container registry
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v4
|
||||||
with:
|
with:
|
||||||
registry: ${{ env.REGISTRY }}
|
registry: ${{ env.REGISTRY }}
|
||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
|
|
@ -191,7 +274,7 @@ jobs:
|
||||||
|
|
||||||
- name: Extract metadata for Docker
|
- name: Extract metadata for Docker
|
||||||
id: meta
|
id: meta
|
||||||
uses: docker/metadata-action@v5
|
uses: docker/metadata-action@v6
|
||||||
with:
|
with:
|
||||||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||||
|
|
||||||
|
|
@ -202,16 +285,39 @@ jobs:
|
||||||
# if set to "true" but frees about 6 GB
|
# if set to "true" but frees about 6 GB
|
||||||
tool-cache: false
|
tool-cache: false
|
||||||
|
|
||||||
|
- name: Cache CUDA compilation
|
||||||
|
if: matrix.variant == 'cuda'
|
||||||
|
uses: actions/cache@v5
|
||||||
|
with:
|
||||||
|
path: ${{ runner.temp }}/cuda-ccache
|
||||||
|
key: cuda-ccache-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('docker/Dockerfile.cuda') }}-${{ github.run_id }}-${{ github.run_attempt }}
|
||||||
|
restore-keys: |
|
||||||
|
cuda-ccache-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('docker/Dockerfile.cuda') }}-
|
||||||
|
|
||||||
|
- name: Restore CUDA compiler cache mount
|
||||||
|
if: matrix.variant == 'cuda'
|
||||||
|
env:
|
||||||
|
CUDA_CACHE_BUILDER: ${{ steps.buildx.outputs.name }}
|
||||||
|
run: bash scripts/ci-cuda-cache.sh restore
|
||||||
|
|
||||||
- name: Build and push Docker image
|
- name: Build and push Docker image
|
||||||
id: build-push
|
id: build-push
|
||||||
uses: docker/build-push-action@v6
|
uses: docker/build-push-action@v7
|
||||||
with:
|
with:
|
||||||
platforms: linux/amd64
|
context: .
|
||||||
push: true
|
platforms: ${{ matrix.platform }}
|
||||||
file: Dockerfile.${{ matrix.variant }}
|
push: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
|
||||||
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.BRANCH_NAME }}-${{ matrix.variant }}
|
file: docker/Dockerfile.${{ matrix.variant }}
|
||||||
|
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.BRANCH_NAME }}-${{ matrix.variant }}${{ matrix.tag-suffix }}
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
annotations: ${{ steps.meta.outputs.annotations }}
|
annotations: ${{ steps.meta.outputs.annotations }}
|
||||||
|
build-args: ${{ matrix.build-args }}
|
||||||
|
|
||||||
|
- name: Export CUDA compiler cache mount
|
||||||
|
if: matrix.variant == 'cuda'
|
||||||
|
env:
|
||||||
|
CUDA_CACHE_BUILDER: ${{ steps.buildx.outputs.name }}
|
||||||
|
run: bash scripts/ci-cuda-cache.sh save
|
||||||
|
|
||||||
macOS-latest-cmake:
|
macOS-latest-cmake:
|
||||||
runs-on: macos-latest
|
runs-on: macos-latest
|
||||||
|
|
@ -219,10 +325,20 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
- name: Clone
|
- name: Clone
|
||||||
id: checkout
|
id: checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
submodules: recursive
|
submodules: recursive
|
||||||
|
|
||||||
|
- name: Setup Node
|
||||||
|
uses: actions/setup-node@v5
|
||||||
|
with:
|
||||||
|
node-version: 24
|
||||||
|
|
||||||
|
- name: Setup pnpm
|
||||||
|
uses: pnpm/action-setup@v5
|
||||||
|
with:
|
||||||
|
version: 10.15.1
|
||||||
|
|
||||||
- name: Dependencies
|
- name: Dependencies
|
||||||
id: depends
|
id: depends
|
||||||
run: |
|
run: |
|
||||||
|
|
@ -240,7 +356,8 @@ jobs:
|
||||||
- name: Get commit hash
|
- name: Get commit hash
|
||||||
id: commit
|
id: commit
|
||||||
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
|
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
|
||||||
uses: pr-mpt/actions-commit-hash@v2
|
shell: bash
|
||||||
|
run: echo "short=${GITHUB_SHA:0:7}" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
- name: Fetch system info
|
- name: Fetch system info
|
||||||
id: system-info
|
id: system-info
|
||||||
|
|
@ -256,11 +373,14 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
cp ggml/LICENSE ./build/bin/ggml.txt
|
cp ggml/LICENSE ./build/bin/ggml.txt
|
||||||
cp LICENSE ./build/bin/stable-diffusion.cpp.txt
|
cp LICENSE ./build/bin/stable-diffusion.cpp.txt
|
||||||
zip -j sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-${{ steps.system-info.outputs.OS_TYPE }}-${{ steps.system-info.outputs.OS_NAME }}-${{ steps.system-info.outputs.OS_VERSION }}-${{ steps.system-info.outputs.CPU_ARCH }}.zip ./build/bin/*
|
cp thirdparty/libwebm/LICENSE.TXT ./build/bin/libwebm.txt
|
||||||
|
cp thirdparty/libwebp/COPYING ./build/bin/libwebp.txt
|
||||||
|
chmod +x start-server.sh
|
||||||
|
zip -j sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-${{ steps.system-info.outputs.OS_TYPE }}-${{ steps.system-info.outputs.OS_NAME }}-${{ steps.system-info.outputs.OS_VERSION }}-${{ steps.system-info.outputs.CPU_ARCH }}.zip ./build/bin/* ./start-server.sh ./start-server.bat
|
||||||
|
|
||||||
- name: Upload artifacts
|
- name: Upload artifacts
|
||||||
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
|
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v6
|
||||||
with:
|
with:
|
||||||
name: sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-${{ steps.system-info.outputs.OS_TYPE }}-${{ steps.system-info.outputs.OS_NAME }}-${{ steps.system-info.outputs.OS_VERSION }}-${{ steps.system-info.outputs.CPU_ARCH }}.zip
|
name: sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-${{ steps.system-info.outputs.OS_TYPE }}-${{ steps.system-info.outputs.OS_NAME }}-${{ steps.system-info.outputs.OS_VERSION }}-${{ steps.system-info.outputs.CPU_ARCH }}.zip
|
||||||
path: |
|
path: |
|
||||||
|
|
@ -275,34 +395,47 @@ jobs:
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- build: "noavx"
|
- build: "cpu"
|
||||||
defines: "-DGGML_NATIVE=OFF -DGGML_AVX=OFF -DGGML_AVX2=OFF -DGGML_FMA=OFF -DSD_BUILD_SHARED_LIBS=ON"
|
defines: "-DGGML_NATIVE=OFF -DSD_BUILD_SHARED_LIBS=ON -DSD_BUILD_SHARED_GGML_LIB=ON -DGGML_BACKEND_DL=ON -DGGML_CPU_ALL_VARIANTS=ON"
|
||||||
- build: "avx2"
|
|
||||||
defines: "-DGGML_NATIVE=OFF -DGGML_AVX2=ON -DSD_BUILD_SHARED_LIBS=ON"
|
|
||||||
- build: "avx"
|
|
||||||
defines: "-DGGML_NATIVE=OFF -DGGML_AVX=ON -DGGML_AVX2=OFF -DSD_BUILD_SHARED_LIBS=ON"
|
|
||||||
- build: "avx512"
|
|
||||||
defines: "-DGGML_NATIVE=OFF -DGGML_AVX512=ON -DGGML_AVX=ON -DGGML_AVX2=ON -DSD_BUILD_SHARED_LIBS=ON"
|
|
||||||
- build: "cuda12"
|
- build: "cuda12"
|
||||||
defines: "-DSD_CUDA=ON -DSD_BUILD_SHARED_LIBS=ON -DCMAKE_CUDA_ARCHITECTURES='61;70;75;80;86;89;90;100;120' -DCMAKE_CUDA_FLAGS='-Xcudafe \"--diag_suppress=177\" -Xcudafe \"--diag_suppress=550\"'"
|
defines: "-DSD_CUDA=ON -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_CUDA_COMPILER_LAUNCHER=ccache -DSD_BUILD_SHARED_LIBS=ON -DCMAKE_CUDA_ARCHITECTURES='61;70;75;80;86;89;90;100;120' -DCMAKE_CUDA_FLAGS='-Xcudafe \"--diag_suppress=177\" -Xcudafe \"--diag_suppress=550\"' -DGGML_NATIVE=OFF -DSD_BUILD_SHARED_GGML_LIB=ON -DGGML_BACKEND_DL=ON -DGGML_CPU_ALL_VARIANTS=ON"
|
||||||
- build: "vulkan"
|
- build: "vulkan"
|
||||||
defines: "-DSD_VULKAN=ON -DSD_BUILD_SHARED_LIBS=ON"
|
defines: "-DSD_VULKAN=ON -DSD_BUILD_SHARED_LIBS=ON -DGGML_NATIVE=OFF -DSD_BUILD_SHARED_GGML_LIB=ON -DGGML_BACKEND_DL=ON -DGGML_CPU_ALL_VARIANTS=ON"
|
||||||
steps:
|
steps:
|
||||||
- name: Clone
|
- name: Clone
|
||||||
id: checkout
|
id: checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
submodules: recursive
|
submodules: recursive
|
||||||
|
|
||||||
|
- name: Setup Node
|
||||||
|
uses: actions/setup-node@v5
|
||||||
|
with:
|
||||||
|
node-version: 24
|
||||||
|
|
||||||
|
- name: Setup pnpm
|
||||||
|
uses: pnpm/action-setup@v5
|
||||||
|
with:
|
||||||
|
version: 10.15.1
|
||||||
|
|
||||||
- name: Install cuda-toolkit
|
- name: Install cuda-toolkit
|
||||||
id: cuda-toolkit
|
id: cuda-toolkit
|
||||||
if: ${{ matrix.build == 'cuda12' }}
|
if: ${{ matrix.build == 'cuda12' }}
|
||||||
uses: Jimver/cuda-toolkit@v0.2.22
|
uses: Jimver/cuda-toolkit@v0.2.35
|
||||||
with:
|
with:
|
||||||
cuda: "12.8.1"
|
cuda: "12.8.1"
|
||||||
method: "network"
|
method: "network"
|
||||||
sub-packages: '["nvcc", "cudart", "cublas", "cublas_dev", "thrust", "visual_studio_integration"]'
|
sub-packages: '["nvcc", "cudart", "cublas", "cublas_dev", "thrust", "visual_studio_integration"]'
|
||||||
|
|
||||||
|
- name: Cache CUDA compilation
|
||||||
|
if: matrix.build == 'cuda12'
|
||||||
|
uses: ggml-org/ccache-action@v1.2.21
|
||||||
|
with:
|
||||||
|
variant: ccache
|
||||||
|
install: binary
|
||||||
|
key: windows-cuda-12.8.1-x64
|
||||||
|
max-size: "2G"
|
||||||
|
|
||||||
- name: Install Vulkan SDK
|
- name: Install Vulkan SDK
|
||||||
id: get_vulkan
|
id: get_vulkan
|
||||||
if: ${{ matrix.build == 'vulkan' }}
|
if: ${{ matrix.build == 'vulkan' }}
|
||||||
|
|
@ -312,35 +445,25 @@ jobs:
|
||||||
Add-Content $env:GITHUB_ENV "VULKAN_SDK=C:\VulkanSDK\${env:VULKAN_VERSION}"
|
Add-Content $env:GITHUB_ENV "VULKAN_SDK=C:\VulkanSDK\${env:VULKAN_VERSION}"
|
||||||
Add-Content $env:GITHUB_PATH "C:\VulkanSDK\${env:VULKAN_VERSION}\bin"
|
Add-Content $env:GITHUB_PATH "C:\VulkanSDK\${env:VULKAN_VERSION}\bin"
|
||||||
|
|
||||||
- name: Activate MSVC environment
|
|
||||||
id: msvc_dev_cmd
|
|
||||||
uses: ilammy/msvc-dev-cmd@v1
|
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
id: cmake_build
|
id: cmake_build
|
||||||
|
shell: pwsh
|
||||||
run: |
|
run: |
|
||||||
|
$vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
|
||||||
|
$vsPath = & $vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath
|
||||||
|
if (-not $vsPath) { throw "Visual Studio C++ tools not found" }
|
||||||
|
& "$vsPath\Common7\Tools\Launch-VsDevShell.ps1" -Arch amd64 -HostArch amd64 -SkipAutomaticLocation
|
||||||
|
|
||||||
mkdir build
|
mkdir build
|
||||||
cd build
|
cd build
|
||||||
cmake .. -DCMAKE_CXX_FLAGS='/bigobj' -G Ninja -DCMAKE_C_COMPILER=cl.exe -DCMAKE_CXX_COMPILER=cl.exe -DCMAKE_BUILD_TYPE=Release ${{ matrix.defines }}
|
cmake .. -DCMAKE_CXX_FLAGS='/bigobj' -G Ninja -DCMAKE_C_COMPILER=cl.exe -DCMAKE_CXX_COMPILER=cl.exe -DCMAKE_BUILD_TYPE=Release ${{ matrix.defines }}
|
||||||
cmake --build .
|
cmake --build .
|
||||||
|
|
||||||
- name: Check AVX512F support
|
|
||||||
id: check_avx512f
|
|
||||||
if: ${{ matrix.build == 'avx512' }}
|
|
||||||
continue-on-error: true
|
|
||||||
run: |
|
|
||||||
cd build
|
|
||||||
$vcdir = $(vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath)
|
|
||||||
$msvc = $(join-path $vcdir $('VC\Tools\MSVC\'+$(gc -raw $(join-path $vcdir 'VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.txt')).Trim()))
|
|
||||||
$cl = $(join-path $msvc 'bin\Hostx64\x64\cl.exe')
|
|
||||||
echo 'int main(void){unsigned int a[4];__cpuid(a,7);return !(a[1]&65536);}' >> avx512f.c
|
|
||||||
& $cl /O2 /GS- /kernel avx512f.c /link /nodefaultlib /entry:main
|
|
||||||
.\avx512f.exe && echo "AVX512F: YES" && ( echo HAS_AVX512F=1 >> $env:GITHUB_ENV ) || echo "AVX512F: NO"
|
|
||||||
|
|
||||||
- name: Get commit hash
|
- name: Get commit hash
|
||||||
id: commit
|
id: commit
|
||||||
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
|
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
|
||||||
uses: pr-mpt/actions-commit-hash@v2
|
shell: bash
|
||||||
|
run: echo "short=${GITHUB_SHA:0:7}" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
- name: Pack artifacts
|
- name: Pack artifacts
|
||||||
id: pack_artifacts
|
id: pack_artifacts
|
||||||
|
|
@ -360,7 +483,13 @@ jobs:
|
||||||
ls .\build\bin
|
ls .\build\bin
|
||||||
throw "Can't find stable-diffusion.dll"
|
throw "Can't find stable-diffusion.dll"
|
||||||
}
|
}
|
||||||
7z a sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-win-${{ matrix.build }}-x64.zip $filePath
|
$binPath = Split-Path -Parent $filePath
|
||||||
|
Copy-Item thirdparty/libwebm/LICENSE.TXT (Join-Path $binPath 'libwebm.txt')
|
||||||
|
Copy-Item thirdparty/libwebp/COPYING (Join-Path $binPath 'libwebp.txt')
|
||||||
|
if ("${{ matrix.build }}" -eq "cuda12") {
|
||||||
|
Copy-Item thirdparty/cutlass/LICENSE.txt (Join-Path $binPath 'cutlass.txt')
|
||||||
|
}
|
||||||
|
7z a sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-win-${{ matrix.build }}-x64.zip $filePath .\start-server.sh .\start-server.bat
|
||||||
|
|
||||||
- name: Copy and pack Cuda runtime
|
- name: Copy and pack Cuda runtime
|
||||||
id: pack_cuda_runtime
|
id: pack_cuda_runtime
|
||||||
|
|
@ -373,7 +502,7 @@ jobs:
|
||||||
|
|
||||||
- name: Upload Cuda runtime
|
- name: Upload Cuda runtime
|
||||||
if: ${{ matrix.build == 'cuda12' && (github.event_name == 'push' && github.ref == 'refs/heads/master' || github.event.inputs.create_release == 'true') }}
|
if: ${{ matrix.build == 'cuda12' && (github.event_name == 'push' && github.ref == 'refs/heads/master' || github.event.inputs.create_release == 'true') }}
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v6
|
||||||
with:
|
with:
|
||||||
name: sd-cudart-sd-bin-win-cu12-x64.zip
|
name: sd-cudart-sd-bin-win-cu12-x64.zip
|
||||||
path: |
|
path: |
|
||||||
|
|
@ -381,81 +510,116 @@ jobs:
|
||||||
|
|
||||||
- name: Upload artifacts
|
- name: Upload artifacts
|
||||||
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
|
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v6
|
||||||
with:
|
with:
|
||||||
name: sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-win-${{ matrix.build }}-x64.zip
|
name: sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-win-${{ matrix.build }}-x64.zip
|
||||||
path: |
|
path: |
|
||||||
sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-win-${{ matrix.build }}-x64.zip
|
sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-win-${{ matrix.build }}-x64.zip
|
||||||
|
|
||||||
windows-latest-cmake-hip:
|
windows-latest-rocm:
|
||||||
runs-on: windows-2022
|
runs-on: windows-2022
|
||||||
|
|
||||||
env:
|
env:
|
||||||
HIPSDK_INSTALLER_VERSION: "25.Q3"
|
ROCM_VERSION: "10.1.0"
|
||||||
GPU_TARGETS: "gfx1151;gfx1200;gfx1201;gfx1100;gfx1101;gfx1102;gfx1030;gfx1031;gfx1032"
|
gpu_targets: "gfx1010;gfx1011;gfx1012;gfx1030;gfx1031;gfx1032;gfx1033;gfx1034;gfx1035;gfx1036;gfx1100;gfx1101;gfx1102;gfx1103;gfx1150;gfx1151;gfx1152;gfx1153;gfx1200;gfx1201"
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
submodules: recursive
|
submodules: recursive
|
||||||
|
|
||||||
|
- name: Setup Node
|
||||||
|
uses: actions/setup-node@v5
|
||||||
|
with:
|
||||||
|
node-version: 24
|
||||||
|
|
||||||
|
- name: Setup pnpm
|
||||||
|
uses: pnpm/action-setup@v5
|
||||||
|
with:
|
||||||
|
version: 10.15.1
|
||||||
|
|
||||||
- name: Cache ROCm Installation
|
- name: Cache ROCm Installation
|
||||||
id: cache-rocm
|
id: cache-rocm
|
||||||
uses: actions/cache@v4
|
uses: actions/cache@v5
|
||||||
with:
|
with:
|
||||||
path: C:\Program Files\AMD\ROCm
|
path: C:\TheRock\build
|
||||||
key: rocm-${{ env.HIPSDK_INSTALLER_VERSION }}-${{ runner.os }}
|
key: rocm-wheels-${{ env.ROCM_VERSION }}-${{ runner.os }}
|
||||||
|
|
||||||
- name: ccache
|
- name: ccache
|
||||||
uses: ggml-org/ccache-action@v1.2.16
|
uses: ggml-org/ccache-action@v1.2.21
|
||||||
with:
|
with:
|
||||||
key: windows-latest-cmake-hip-${{ env.HIPSDK_INSTALLER_VERSION }}-x64
|
key: windows-rocm-${{ env.ROCM_VERSION }}-x64
|
||||||
evict-old-files: 1d
|
evict-old-files: 1d
|
||||||
|
|
||||||
- name: Install ROCm
|
- name: Install ROCm with Wheels
|
||||||
if: steps.cache-rocm.outputs.cache-hit != 'true'
|
if: steps.cache-rocm.outputs.cache-hit != 'true'
|
||||||
run: |
|
run: |
|
||||||
$ErrorActionPreference = "Stop"
|
$ErrorActionPreference = "Stop"
|
||||||
write-host "Downloading AMD HIP SDK Installer"
|
write-host "Setting up Python virtual environment"
|
||||||
Invoke-WebRequest -Uri "https://download.amd.com/developer/eula/rocm-hub/AMD-Software-PRO-Edition-${{ env.HIPSDK_INSTALLER_VERSION }}-WinSvr2022-For-HIP.exe" -OutFile "${env:RUNNER_TEMP}\rocm-install.exe"
|
|
||||||
write-host "Installing AMD HIP SDK"
|
|
||||||
$proc = Start-Process "${env:RUNNER_TEMP}\rocm-install.exe" -ArgumentList '-install' -NoNewWindow -PassThru
|
|
||||||
$completed = $proc.WaitForExit(600000)
|
|
||||||
if (-not $completed) {
|
|
||||||
Write-Error "ROCm installation timed out after 10 minutes. Killing the process"
|
|
||||||
$proc.Kill()
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
if ($proc.ExitCode -ne 0) {
|
|
||||||
Write-Error "ROCm installation failed with exit code $($proc.ExitCode)"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
write-host "Completed AMD HIP SDK installation"
|
|
||||||
|
|
||||||
- name: Verify ROCm
|
# Create the venv directly at the cache location to avoid relocation issues
|
||||||
|
New-Item -Path "C:\TheRock\build" -ItemType Directory -Force | Out-Null
|
||||||
|
python -m venv C:\TheRock\build\.venv
|
||||||
|
& C:\TheRock\build\.venv\Scripts\Activate.ps1
|
||||||
|
|
||||||
|
write-host "Upgrading pip"
|
||||||
|
python -m pip install --upgrade pip
|
||||||
|
|
||||||
|
write-host "Installing ROCm wheels for multi-arch support"
|
||||||
|
# Install ROCm wheels for multi-arch support (this may take several minutes)
|
||||||
|
python -m pip install --index-url https://stable.repo.amd.com/rocm/whl-next/ "rocm[libraries,devel]==${{env.ROCM_VERSION}}"
|
||||||
|
|
||||||
|
# Pre-expand the devel tree so it is included in the cache
|
||||||
|
write-host "Initializing ROCm devel tree"
|
||||||
|
rocm-sdk init
|
||||||
|
if ($LASTEXITCODE -ne 0) { throw "rocm-sdk init failed with exit code $LASTEXITCODE" }
|
||||||
|
write-host "Completed ROCm wheel installation to C:\TheRock\build"
|
||||||
|
|
||||||
|
- name: Setup ROCm Environment
|
||||||
run: |
|
run: |
|
||||||
# Find and test ROCm installation
|
$ErrorActionPreference = "Stop"
|
||||||
$clangPath = Get-ChildItem 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' | Select-Object -First 1
|
|
||||||
if (-not $clangPath) {
|
# Activate venv from cache or fresh install
|
||||||
Write-Error "ROCm installation not found"
|
& C:\TheRock\build\.venv\Scripts\Activate.ps1
|
||||||
exit 1
|
|
||||||
}
|
# Expand the devel tree (idempotent; no-op if already done during install)
|
||||||
& $clangPath.FullName --version
|
rocm-sdk init
|
||||||
# Set HIP_PATH environment variable for later steps
|
if ($LASTEXITCODE -ne 0) { throw "rocm-sdk init failed with exit code $LASTEXITCODE" }
|
||||||
echo "HIP_PATH=$(Resolve-Path 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' | split-path | split-path)" >> $env:GITHUB_ENV
|
|
||||||
|
# Get ROCm installation paths using the rocm-sdk CLI tool
|
||||||
|
$rocmPath = (rocm-sdk path --root)
|
||||||
|
if (-not $rocmPath) { throw "rocm-sdk path --root returned empty - devel package may not be installed" }
|
||||||
|
$rocmPath = $rocmPath.Trim()
|
||||||
|
$cmakePath = (rocm-sdk path --cmake).Trim()
|
||||||
|
$binPath = (rocm-sdk path --bin).Trim()
|
||||||
|
write-host "ROCm root: $rocmPath"
|
||||||
|
write-host "CMake path: $cmakePath"
|
||||||
|
write-host "Bin path: $binPath"
|
||||||
|
|
||||||
|
echo "HIP_PATH=$rocmPath" >> $env:GITHUB_ENV
|
||||||
|
echo "CMAKE_PREFIX_PATH=$cmakePath" >> $env:GITHUB_ENV
|
||||||
|
echo "HIP_DEVICE_LIB_PATH=$rocmPath\lib\llvm\amdgcn\bitcode" >> $env:GITHUB_ENV
|
||||||
|
echo "HIP_PLATFORM=amd" >> $env:GITHUB_ENV
|
||||||
|
echo "LLVM_PATH=$rocmPath\lib\llvm" >> $env:GITHUB_ENV
|
||||||
|
echo "$binPath" >> $env:GITHUB_PATH
|
||||||
|
|
||||||
|
# Keep venv in PATH for subsequent steps
|
||||||
|
echo "C:\TheRock\build\.venv\Scripts" >> $env:GITHUB_PATH
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: |
|
run: |
|
||||||
mkdir build
|
mkdir build
|
||||||
cd build
|
cd build
|
||||||
$env:CMAKE_PREFIX_PATH="${env:HIP_PATH}"
|
|
||||||
cmake .. `
|
cmake .. `
|
||||||
-G "Unix Makefiles" `
|
-G "Unix Makefiles" `
|
||||||
|
-DCMAKE_PREFIX_PATH="${env:HIP_PATH}" `
|
||||||
-DSD_HIPBLAS=ON `
|
-DSD_HIPBLAS=ON `
|
||||||
-DSD_BUILD_SHARED_LIBS=ON `
|
-DSD_BUILD_SHARED_LIBS=ON `
|
||||||
-DGGML_NATIVE=OFF `
|
-DGGML_NATIVE=OFF `
|
||||||
-DCMAKE_C_COMPILER=clang `
|
-DCMAKE_C_COMPILER="${env:HIP_PATH}\lib\llvm\bin\clang.exe" `
|
||||||
-DCMAKE_CXX_COMPILER=clang++ `
|
-DCMAKE_CXX_COMPILER="${env:HIP_PATH}\lib\llvm\bin\clang++.exe" `
|
||||||
|
-DCMAKE_HIP_COMPILER="${env:HIP_PATH}\lib\llvm\bin\clang.exe" `
|
||||||
|
-DHIP_PATH="${env:HIP_PATH}" `
|
||||||
-DCMAKE_BUILD_TYPE=Release `
|
-DCMAKE_BUILD_TYPE=Release `
|
||||||
-DGPU_TARGETS="${{ env.GPU_TARGETS }}"
|
-DGPU_TARGETS="${{ env.GPU_TARGETS }}"
|
||||||
cmake --build . --config Release --parallel ${env:NUMBER_OF_PROCESSORS}
|
cmake --build . --config Release --parallel ${env:NUMBER_OF_PROCESSORS}
|
||||||
|
|
@ -463,50 +627,227 @@ jobs:
|
||||||
- name: Get commit hash
|
- name: Get commit hash
|
||||||
id: commit
|
id: commit
|
||||||
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
|
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
|
||||||
uses: pr-mpt/actions-commit-hash@v2
|
shell: bash
|
||||||
|
run: echo "short=${GITHUB_SHA:0:7}" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
- name: Bundle HIP runtime libraries
|
||||||
|
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
|
||||||
|
run: |
|
||||||
|
$ErrorActionPreference = "Stop"
|
||||||
|
$binPath = (rocm-sdk path --bin).Trim()
|
||||||
|
if (-not $binPath) { throw "rocm-sdk path --bin returned empty" }
|
||||||
|
foreach ($dll in @("amdhip64_7.dll", "rocm_kpack.dll", "amd_comgr.dll")) {
|
||||||
|
$f = Get-ChildItem -Path $binPath -Filter $dll -ErrorAction SilentlyContinue
|
||||||
|
if (-not $f) { throw "no match for $dll in $binPath" }
|
||||||
|
Copy-Item $f.FullName -Destination .\build\bin\ -Force
|
||||||
|
}
|
||||||
|
|
||||||
- name: Pack artifacts
|
- name: Pack artifacts
|
||||||
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
|
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
|
||||||
run: |
|
run: |
|
||||||
md "build\bin\rocblas\library\"
|
Copy-Item thirdparty/libwebm/LICENSE.TXT .\build\bin\libwebm.txt
|
||||||
md "build\bin\hipblaslt\library"
|
Copy-Item thirdparty/libwebp/COPYING .\build\bin\libwebp.txt
|
||||||
cp "${env:HIP_PATH}\bin\hipblas.dll" "build\bin\"
|
7z a sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-win-rocm-${{ env.ROCM_VERSION }}-x64.zip .\build\bin\* .\start-server.sh .\start-server.bat
|
||||||
cp "${env:HIP_PATH}\bin\hipblaslt.dll" "build\bin\"
|
|
||||||
cp "${env:HIP_PATH}\bin\rocblas.dll" "build\bin\"
|
|
||||||
cp "${env:HIP_PATH}\bin\rocblas\library\*" "build\bin\rocblas\library\"
|
|
||||||
cp "${env:HIP_PATH}\bin\hipblaslt\library\*" "build\bin\hipblaslt\library\"
|
|
||||||
7z a sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-win-rocm-x64.zip .\build\bin\*
|
|
||||||
|
|
||||||
- name: Upload artifacts
|
- name: Upload artifacts
|
||||||
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
|
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v6
|
||||||
with:
|
with:
|
||||||
name: sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-win-rocm-x64.zip
|
name: sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-win-rocm-${{ env.ROCM_VERSION }}-x64.zip
|
||||||
path: |
|
path: |
|
||||||
sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-win-rocm-x64.zip
|
sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-win-rocm-${{ env.ROCM_VERSION }}-x64.zip
|
||||||
|
|
||||||
|
ubuntu-latest-rocm:
|
||||||
|
runs-on: ubuntu-24.04
|
||||||
|
|
||||||
|
env:
|
||||||
|
UBUNTU_VERSION: "24.04"
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- ROCM_VERSION: "10.1.0"
|
||||||
|
gpu_targets: "gfx900;gfx906;gfx908;gfx90a;gfx90c;gfx942;gfx950;gfx1010;gfx1011;gfx1012;gfx1030;gfx1031;gfx1032;gfx1033;gfx1034;gfx1035;gfx1036;gfx1100;gfx1101;gfx1102;gfx1103;gfx1150;gfx1151;gfx1152;gfx1153;gfx1200;gfx1201"
|
||||||
|
build: 'x64'
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Clone
|
||||||
|
id: checkout
|
||||||
|
uses: actions/checkout@v6
|
||||||
|
with:
|
||||||
|
submodules: recursive
|
||||||
|
|
||||||
|
- name: ccache
|
||||||
|
uses: ggml-org/ccache-action@v1.2.21
|
||||||
|
with:
|
||||||
|
key: ubuntu-rocm-cmake-${{ matrix.ROCM_VERSION }}-${{ matrix.build }}
|
||||||
|
evict-old-files: 1d
|
||||||
|
max-size: "2G"
|
||||||
|
|
||||||
|
- name: Tune ccache for reinstalled ROCm toolchain
|
||||||
|
run: |
|
||||||
|
# ROCm is pip-installed fresh each run, so the clang binary's mtime
|
||||||
|
# changes every time. With the default compiler_check=mtime that
|
||||||
|
# invalidates the cache; hash compiler contents instead so warm
|
||||||
|
# builds hit.
|
||||||
|
ccache --set-config=compiler_check=content
|
||||||
|
ccache --set-config=sloppiness=time_macros,include_file_mtime,include_file_ctime
|
||||||
|
|
||||||
|
- name: Dependencies
|
||||||
|
id: depends
|
||||||
|
run: |
|
||||||
|
sudo apt install -y build-essential git cmake wget
|
||||||
|
|
||||||
|
- name: Free disk space
|
||||||
|
run: |
|
||||||
|
df -h
|
||||||
|
|
||||||
|
# Remove preinstalled SDKs and caches not needed for this job before
|
||||||
|
# installing ROCm. The legacy ROCm apt packages are large enough to
|
||||||
|
# exhaust ubuntu-latest if cleanup runs after installation.
|
||||||
|
sudo rm -rf /usr/share/dotnet || true
|
||||||
|
sudo rm -rf /usr/local/lib/android || true
|
||||||
|
sudo rm -rf /opt/ghc || true
|
||||||
|
sudo rm -rf /usr/local/.ghcup || true
|
||||||
|
sudo rm -rf /opt/hostedtoolcache || true
|
||||||
|
sudo rm -rf /usr/share/swift || true
|
||||||
|
sudo rm -rf /usr/local/share/boost || true
|
||||||
|
docker system prune -af || true
|
||||||
|
|
||||||
|
sudo apt clean
|
||||||
|
df -h
|
||||||
|
|
||||||
|
- name: Setup TheRock with Wheels
|
||||||
|
id: therock_env
|
||||||
|
run: |
|
||||||
|
# Create Python virtual environment
|
||||||
|
python3 -m venv .venv
|
||||||
|
source .venv/bin/activate
|
||||||
|
|
||||||
|
# Install ROCm wheels for build
|
||||||
|
# libraries = HIP runtime and CMake configs needed for linking
|
||||||
|
# devel = compilers, headers, static libs
|
||||||
|
python -m pip install --upgrade pip
|
||||||
|
python -m pip install --index-url https://stable.repo.amd.com/rocm/whl-next/ "rocm[libraries,devel]==${{matrix.ROCM_VERSION}}"
|
||||||
|
|
||||||
|
# Get ROCm installation paths using the rocm-sdk CLI tool
|
||||||
|
ROCM_PATH=$(rocm-sdk path --root)
|
||||||
|
CMAKE_PATH=$(rocm-sdk path --cmake)
|
||||||
|
BIN_PATH=$(rocm-sdk path --bin)
|
||||||
|
echo "ROCM_PATH=$ROCM_PATH"
|
||||||
|
echo "CMAKE_PATH=$CMAKE_PATH"
|
||||||
|
echo "BIN_PATH=$BIN_PATH"
|
||||||
|
|
||||||
|
# Set environment variables
|
||||||
|
echo "ROCM_PATH=$ROCM_PATH" >> $GITHUB_ENV
|
||||||
|
echo "CMAKE_PREFIX_PATH=$CMAKE_PATH" >> $GITHUB_ENV
|
||||||
|
echo "HIP_PATH=$ROCM_PATH" >> $GITHUB_ENV
|
||||||
|
echo "PATH=$BIN_PATH:${PATH}" >> $GITHUB_ENV
|
||||||
|
echo "LD_LIBRARY_PATH=$ROCM_PATH/lib:${LD_LIBRARY_PATH:-}" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
# Keep venv activated for subsequent steps
|
||||||
|
echo "$(pwd)/.venv/bin" >> $GITHUB_PATH
|
||||||
|
|
||||||
|
# setup-node installs into /opt/hostedtoolcache, which is removed above.
|
||||||
|
# Keep Node/pnpm setup after disk cleanup so the server frontend can be embedded.
|
||||||
|
- name: Setup Node
|
||||||
|
uses: actions/setup-node@v5
|
||||||
|
with:
|
||||||
|
node-version: 24
|
||||||
|
|
||||||
|
- name: Setup pnpm
|
||||||
|
uses: pnpm/action-setup@v5
|
||||||
|
with:
|
||||||
|
version: 10.15.1
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
id: cmake_build
|
||||||
|
run: |
|
||||||
|
mkdir build
|
||||||
|
cd build
|
||||||
|
cmake .. -G Ninja \
|
||||||
|
-DCMAKE_HIP_COMPILER="$(hipconfig -l)/clang" \
|
||||||
|
-DCMAKE_HIP_FLAGS="-mllvm --amdgpu-unroll-threshold-local=600" \
|
||||||
|
-DCMAKE_BUILD_TYPE=Release \
|
||||||
|
-DSD_HIPBLAS=ON \
|
||||||
|
-DHIP_PLATFORM=amd \
|
||||||
|
-DGPU_TARGETS="${{ matrix.gpu_targets }}" \
|
||||||
|
-DCMAKE_BUILD_WITH_INSTALL_RPATH=ON \
|
||||||
|
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
|
||||||
|
-DCMAKE_INSTALL_RPATH='$ORIGIN' \
|
||||||
|
-DGGML_NATIVE=OFF \
|
||||||
|
-DSD_BUILD_SHARED_GGML_LIB=ON \
|
||||||
|
-DGGML_BACKEND_DL=ON \
|
||||||
|
-DGGML_CPU_ALL_VARIANTS=ON \
|
||||||
|
-DSD_BUILD_SHARED_LIBS=ON
|
||||||
|
cmake --build . --config Release
|
||||||
|
|
||||||
|
- name: Get commit hash
|
||||||
|
id: commit
|
||||||
|
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
|
||||||
|
shell: bash
|
||||||
|
run: echo "short=${GITHUB_SHA:0:7}" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
- name: Prepare artifacts
|
||||||
|
id: prepare_artifacts
|
||||||
|
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
|
||||||
|
run: |
|
||||||
|
# Copy licenses
|
||||||
|
cp ggml/LICENSE ./build/bin/ggml.txt
|
||||||
|
cp LICENSE ./build/bin/stable-diffusion.cpp.txt
|
||||||
|
|
||||||
|
- name: Fetch system info
|
||||||
|
id: system-info
|
||||||
|
run: |
|
||||||
|
echo "CPU_ARCH=`uname -m`" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "OS_NAME=`lsb_release -s -i`" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "OS_VERSION=`lsb_release -s -r`" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "OS_TYPE=`uname -s`" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
- name: Pack artifacts
|
||||||
|
id: pack_artifacts
|
||||||
|
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
|
||||||
|
run: |
|
||||||
|
cp ggml/LICENSE ./build/bin/ggml.txt
|
||||||
|
cp LICENSE ./build/bin/stable-diffusion.cpp.txt
|
||||||
|
cp thirdparty/libwebm/LICENSE.TXT ./build/bin/libwebm.txt
|
||||||
|
cp thirdparty/libwebp/COPYING ./build/bin/libwebp.txt
|
||||||
|
chmod +x start-server.sh
|
||||||
|
zip -y -r sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-${{ steps.system-info.outputs.OS_TYPE }}-Ubuntu-${{ env.UBUNTU_VERSION }}-${{ steps.system-info.outputs.CPU_ARCH }}-rocm-${{ matrix.ROCM_VERSION }}.zip ./build/bin ./start-server.sh ./start-server.bat
|
||||||
|
|
||||||
|
- name: Upload artifacts
|
||||||
|
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
|
||||||
|
uses: actions/upload-artifact@v6
|
||||||
|
with:
|
||||||
|
name: sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-${{ steps.system-info.outputs.OS_TYPE }}-Ubuntu-${{ env.UBUNTU_VERSION }}-${{ steps.system-info.outputs.CPU_ARCH }}-rocm-${{ matrix.ROCM_VERSION }}.zip
|
||||||
|
path: |
|
||||||
|
sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-${{ steps.system-info.outputs.OS_TYPE }}-Ubuntu-${{ env.UBUNTU_VERSION }}-${{ steps.system-info.outputs.CPU_ARCH }}-rocm-${{ matrix.ROCM_VERSION }}.zip
|
||||||
|
|
||||||
release:
|
release:
|
||||||
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
|
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
|
||||||
needs:
|
needs:
|
||||||
- ubuntu-latest-cmake
|
- ubuntu-latest-cmake
|
||||||
- ubuntu-latest-cmake-vulkan
|
- ubuntu-latest-cmake-vulkan
|
||||||
- build-and-push-docker-images
|
- ubuntu-latest-rocm
|
||||||
- macOS-latest-cmake
|
- macOS-latest-cmake
|
||||||
- windows-latest-cmake
|
- windows-latest-cmake
|
||||||
- windows-latest-cmake-hip
|
- windows-latest-rocm
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Clone
|
- name: Clone
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Download artifacts
|
- name: Download artifacts
|
||||||
id: download-artifact
|
id: download-artifact
|
||||||
uses: actions/download-artifact@v4
|
uses: actions/download-artifact@v7
|
||||||
with:
|
with:
|
||||||
path: ./artifact
|
path: ./artifact
|
||||||
pattern: sd-*
|
pattern: sd-*
|
||||||
|
|
@ -519,36 +860,47 @@ jobs:
|
||||||
|
|
||||||
- name: Get commit hash
|
- name: Get commit hash
|
||||||
id: commit
|
id: commit
|
||||||
uses: pr-mpt/actions-commit-hash@v2
|
shell: bash
|
||||||
|
run: echo "short=${GITHUB_SHA:0:7}" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
- name: Create release
|
- name: Create release
|
||||||
id: create_release
|
id: create_release
|
||||||
if: ${{ github.event_name == 'workflow_dispatch' || github.ref_name == 'master' }}
|
if: ${{ github.event_name == 'workflow_dispatch' || github.ref_name == 'master' }}
|
||||||
uses: anzz1/action-create-release@v1
|
uses: actions/github-script@v9
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
RELEASE_TAG: ${{ format('{0}-{1}-{2}', env.BRANCH_NAME, steps.commit_count.outputs.count, steps.commit.outputs.short) }}
|
||||||
with:
|
with:
|
||||||
tag_name: ${{ format('{0}-{1}-{2}', env.BRANCH_NAME, steps.commit_count.outputs.count, steps.commit.outputs.short) }}
|
script: |
|
||||||
|
const { data: release } = await github.rest.repos.createRelease({
|
||||||
|
...context.repo,
|
||||||
|
tag_name: process.env.RELEASE_TAG,
|
||||||
|
name: process.env.RELEASE_TAG,
|
||||||
|
target_commitish: context.sha,
|
||||||
|
draft: false,
|
||||||
|
prerelease: false,
|
||||||
|
});
|
||||||
|
core.setOutput('id', release.id);
|
||||||
|
|
||||||
- name: Upload release
|
- name: Upload release
|
||||||
id: upload_release
|
id: upload_release
|
||||||
if: ${{ github.event_name == 'workflow_dispatch' || github.ref_name == 'master' }}
|
if: ${{ github.event_name == 'workflow_dispatch' || github.ref_name == 'master' }}
|
||||||
uses: actions/github-script@v3
|
uses: actions/github-script@v9
|
||||||
|
env:
|
||||||
|
RELEASE_ID: ${{ steps.create_release.outputs.id }}
|
||||||
with:
|
with:
|
||||||
github-token: ${{secrets.GITHUB_TOKEN}}
|
|
||||||
script: |
|
script: |
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const fs = require('fs');
|
const fs = require('fs').promises;
|
||||||
const release_id = '${{ steps.create_release.outputs.id }}';
|
const release_id = Number(process.env.RELEASE_ID);
|
||||||
for (let file of await fs.readdirSync('./artifact')) {
|
for (const file of await fs.readdir('./artifact')) {
|
||||||
if (path.extname(file) === '.zip') {
|
if (path.extname(file) === '.zip') {
|
||||||
console.log('uploadReleaseAsset', file);
|
console.log('uploadReleaseAsset', file);
|
||||||
await github.repos.uploadReleaseAsset({
|
await github.rest.repos.uploadReleaseAsset({
|
||||||
owner: context.repo.owner,
|
owner: context.repo.owner,
|
||||||
repo: context.repo.repo,
|
repo: context.repo.repo,
|
||||||
release_id: release_id,
|
release_id: release_id,
|
||||||
name: file,
|
name: file,
|
||||||
data: await fs.readFileSync(`./artifact/${file}`)
|
data: await fs.readFile(`./artifact/${file}`)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
48
.github/workflows/close-inactive-issues.yml
vendored
Normal file
|
|
@ -0,0 +1,48 @@
|
||||||
|
name: Close inactive issues
|
||||||
|
|
||||||
|
on:
|
||||||
|
schedule:
|
||||||
|
# Run daily. GitHub cron schedules use UTC.
|
||||||
|
- cron: "30 1 * * *"
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
debug_only:
|
||||||
|
description: "Dry run: log intended actions without changing issues"
|
||||||
|
required: false
|
||||||
|
default: false
|
||||||
|
type: boolean
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
issues: write
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.workflow }}
|
||||||
|
cancel-in-progress: false
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
close-inactive-issues:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Comment and close inactive issues
|
||||||
|
uses: actions/stale@v10
|
||||||
|
with:
|
||||||
|
days-before-issue-stale: 365
|
||||||
|
days-before-issue-close: 0
|
||||||
|
|
||||||
|
days-before-pr-stale: -1
|
||||||
|
days-before-pr-close: -1
|
||||||
|
|
||||||
|
stale-issue-label: issue:inactive
|
||||||
|
close-issue-label: issue:auto-closed
|
||||||
|
close-issue-reason: completed
|
||||||
|
stale-issue-message: ""
|
||||||
|
close-issue-message: >
|
||||||
|
This issue has had no activity for one year. The latest version of
|
||||||
|
the code may already have fixed the problem.
|
||||||
|
|
||||||
|
If the issue still exists in the latest version, you can reopen
|
||||||
|
this issue at any time with updated reproduction details.
|
||||||
|
|
||||||
|
remove-issue-stale-when-updated: true
|
||||||
|
operations-per-run: 1000
|
||||||
|
debug-only: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_only || false }}
|
||||||
61
.github/workflows/close-organization-fork-prs.yml
vendored
Normal file
|
|
@ -0,0 +1,61 @@
|
||||||
|
name: Close PRs from organization forks
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request_target:
|
||||||
|
types: [opened, reopened]
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
pull-requests: write
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
|
||||||
|
cancel-in-progress: false
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
close-organization-fork-pr:
|
||||||
|
if: >-
|
||||||
|
github.event.pull_request.head.repo.owner.type == 'Organization' &&
|
||||||
|
github.event.pull_request.head.repo.id != github.event.pull_request.base.repo.id
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
timeout-minutes: 5
|
||||||
|
steps:
|
||||||
|
- name: Explain the contribution policy and close the PR
|
||||||
|
uses: actions/github-script@v9
|
||||||
|
with:
|
||||||
|
script: |
|
||||||
|
const { data: pr } = await github.rest.pulls.get({
|
||||||
|
...context.repo,
|
||||||
|
pull_number: context.issue.number,
|
||||||
|
});
|
||||||
|
const headRepo = pr.head.repo;
|
||||||
|
if (pr.state !== 'open' || !headRepo ||
|
||||||
|
headRepo.id === pr.base.repo.id || headRepo.owner.type !== 'Organization') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const marker = '<!-- organization-fork-policy -->';
|
||||||
|
const comments = await github.paginate(github.rest.issues.listComments, {
|
||||||
|
...context.repo,
|
||||||
|
issue_number: pr.number,
|
||||||
|
per_page: 100,
|
||||||
|
});
|
||||||
|
const alreadyExplained = comments.some(comment =>
|
||||||
|
comment.user?.login === 'github-actions[bot]' && comment.body?.includes(marker));
|
||||||
|
if (!alreadyExplained) {
|
||||||
|
await github.rest.issues.createComment({
|
||||||
|
...context.repo,
|
||||||
|
issue_number: pr.number,
|
||||||
|
body: [
|
||||||
|
marker,
|
||||||
|
'This repository requires contributions from forks to use a personal fork with **Allow edits from maintainers** enabled.',
|
||||||
|
'GitHub does not support this option for organization-owned forks, so this PR is being closed automatically.',
|
||||||
|
'Please open a new PR from a fork in your personal GitHub account and enable **Allow edits from maintainers** so maintainers can help update the branch.',
|
||||||
|
'See [the GitHub documentation](https://docs.github.com/en/pull-requests/how-tos/work-with-forks/allowing-changes-to-a-pull-request-branch-created-from-a-fork).',
|
||||||
|
].join('\n\n'),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
await github.rest.pulls.update({
|
||||||
|
...context.repo,
|
||||||
|
pull_number: pr.number,
|
||||||
|
state: 'closed',
|
||||||
|
});
|
||||||
55
.github/workflows/stale-prs.yml
vendored
Normal file
|
|
@ -0,0 +1,55 @@
|
||||||
|
name: Close inactive PRs
|
||||||
|
|
||||||
|
on:
|
||||||
|
schedule:
|
||||||
|
# Run daily. GitHub cron schedules use UTC.
|
||||||
|
- cron: "30 1 * * *"
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
debug_only:
|
||||||
|
description: "Dry run: log intended actions without changing PRs"
|
||||||
|
required: false
|
||||||
|
default: false
|
||||||
|
type: boolean
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
issues: write
|
||||||
|
pull-requests: write
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.workflow }}
|
||||||
|
cancel-in-progress: false
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
stale-prs:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Mark and close inactive PRs
|
||||||
|
uses: actions/stale@v10
|
||||||
|
with:
|
||||||
|
days-before-issue-stale: -1
|
||||||
|
days-before-issue-close: -1
|
||||||
|
|
||||||
|
days-before-pr-stale: 365
|
||||||
|
days-before-pr-close: 7
|
||||||
|
|
||||||
|
stale-pr-label: pr:inactive
|
||||||
|
close-pr-label: pr:auto-closed
|
||||||
|
exempt-pr-labels: pr:keep-open
|
||||||
|
|
||||||
|
stale-pr-message: >
|
||||||
|
This PR has been inactive for 365 days. If there is no new activity
|
||||||
|
within 7 days, it will be closed automatically. Comment, push new
|
||||||
|
commits, or remove the pr:inactive label to keep it open. Add
|
||||||
|
pr:keep-open to exempt it from future inactive PR cleanup.
|
||||||
|
|
||||||
|
close-pr-message: >
|
||||||
|
Closing this PR because it has had no activity for 7 days after
|
||||||
|
being marked inactive. If this is still useful or ready to move
|
||||||
|
forward, feel free to reopen it with fresh context or updated
|
||||||
|
details. Sorry for any inconvenience.
|
||||||
|
|
||||||
|
remove-pr-stale-when-updated: true
|
||||||
|
delete-branch: false
|
||||||
|
operations-per-run: 100
|
||||||
|
debug-only: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_only || false }}
|
||||||
16
.gitignore
vendored
|
|
@ -1,15 +1,29 @@
|
||||||
build*/
|
build*/
|
||||||
cmake-build-*/
|
cmake-build-*/
|
||||||
test/
|
test/
|
||||||
|
tests/
|
||||||
|
/dgl/*
|
||||||
|
!/dgl/.gitkeep
|
||||||
|
logs/
|
||||||
|
input/
|
||||||
|
output/
|
||||||
.vscode/
|
.vscode/
|
||||||
.idea/
|
.idea/
|
||||||
.cache/
|
.cache/
|
||||||
*.swp
|
*.swp
|
||||||
*.bat
|
*.bat
|
||||||
|
!/start-server.bat
|
||||||
|
/start-server.local.sh
|
||||||
|
/start-server.local.bat
|
||||||
|
/start-server.local.ps1
|
||||||
*.bin
|
*.bin
|
||||||
*.exe
|
*.exe
|
||||||
*.gguf
|
*.gguf
|
||||||
output*.png
|
output*.png
|
||||||
models*
|
/models*
|
||||||
*.log
|
*.log
|
||||||
preview.png
|
preview.png
|
||||||
|
.claude/
|
||||||
|
CLAUDE.local.md
|
||||||
|
.agents/
|
||||||
|
.codex/
|
||||||
|
|
|
||||||
14
.gitmodules
vendored
|
|
@ -1,3 +1,15 @@
|
||||||
[submodule "ggml"]
|
[submodule "ggml"]
|
||||||
path = ggml
|
path = ggml
|
||||||
url = https://github.com/ggml-org/ggml.git
|
url = https://github.com/leejet/ggml.git
|
||||||
|
[submodule "examples/server/frontend"]
|
||||||
|
path = examples/server/frontend
|
||||||
|
url = https://github.com/leejet/sdcpp-webui.git
|
||||||
|
[submodule "thirdparty/libwebp"]
|
||||||
|
path = thirdparty/libwebp
|
||||||
|
url = https://github.com/webmproject/libwebp.git
|
||||||
|
[submodule "thirdparty/libwebm"]
|
||||||
|
path = thirdparty/libwebm
|
||||||
|
url = https://github.com/webmproject/libwebm.git
|
||||||
|
[submodule "thirdparty/cutlass"]
|
||||||
|
path = thirdparty/cutlass
|
||||||
|
url = https://github.com/NVIDIA/cutlass.git
|
||||||
|
|
|
||||||
204
AGENTS.md
Normal file
|
|
@ -0,0 +1,204 @@
|
||||||
|
# Instructions for stable-diffusion.cpp
|
||||||
|
|
||||||
|
This document is for AI coding agents working in this repository. It should
|
||||||
|
describe agent-specific workflow, repository routing, editing boundaries, and
|
||||||
|
project-specific pitfalls.
|
||||||
|
|
||||||
|
For general contribution rules, including PR scope, commit conventions, code
|
||||||
|
style, dependency updates, security hygiene, and AI-assisted contribution policy,
|
||||||
|
see `CONTRIBUTING.md`.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Agent Operating Rules
|
||||||
|
|
||||||
|
Before analyzing or modifying the repository:
|
||||||
|
|
||||||
|
1. Read this file.
|
||||||
|
2. Use `rg` / `rg --files` or directory listing commands to confirm the current
|
||||||
|
tree before relying on a path.
|
||||||
|
3. Start from `src/` and relevant `docs/` for runtime behavior.
|
||||||
|
4. Read the relevant code before editing.
|
||||||
|
5. Prefer the smallest change that fits the existing architecture.
|
||||||
|
6. Report focused verification and mention any tests not run.
|
||||||
|
|
||||||
|
Agents must not:
|
||||||
|
|
||||||
|
* Run `git push`, create PRs, or submit issue/PR comments on the user's behalf.
|
||||||
|
* Create commits unless the user explicitly requests that specific commit.
|
||||||
|
* Modify `ggml/`, `thirdparty/`, or `examples/server/frontend/` unless
|
||||||
|
explicitly requested and necessary.
|
||||||
|
* Read large local model files or tokenizer vocabulary files.
|
||||||
|
* Rewrite unrelated code for style-only reasons.
|
||||||
|
* Add secrets, model weights, generated binaries, local absolute paths, or
|
||||||
|
machine-specific output.
|
||||||
|
|
||||||
|
When a change is large, architectural, or likely to affect public behavior,
|
||||||
|
pause and present a short plan before editing.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Repository Map and Editing Boundaries
|
||||||
|
|
||||||
|
This is a routing map for agents, not a full architecture document. The layout
|
||||||
|
can change, so verify paths before using them. Do not inspect excluded
|
||||||
|
large-data directories while checking the tree.
|
||||||
|
|
||||||
|
### Primary Project Code
|
||||||
|
|
||||||
|
Core implementation lives under `src/`.
|
||||||
|
|
||||||
|
Current source layout includes:
|
||||||
|
|
||||||
|
* `src/api/` - C API options, generation requests, and translation to DGL.
|
||||||
|
* `src/core/` - shared tensor, ggml integration, backend, graph, RNG, and utility
|
||||||
|
code.
|
||||||
|
* `src/dgl/` - DGL compilation, execution, and built-in operations. See the
|
||||||
|
[DGL architecture guide](docs/development/dgl.md) for layer boundaries.
|
||||||
|
* `src/model/` - model families and model components.
|
||||||
|
* `src/model_io/` - model file loading, GGUF, safetensors, pickle, and related
|
||||||
|
serialization helpers.
|
||||||
|
* `src/runtime/` - sampling, denoising, guidance, caching, preprocessing, and
|
||||||
|
runtime execution helpers.
|
||||||
|
* `src/tokenizers/` - tokenizer implementations.
|
||||||
|
* `src/conditioning/` - conditioning and prompt-related implementation.
|
||||||
|
* `src/extensions/` - optional feature extensions.
|
||||||
|
* top-level `src/*.cpp` and `src/*.h` files - public implementation entry
|
||||||
|
points, model loading, conversion, versioning, and shared managers.
|
||||||
|
|
||||||
|
`src/tokenizers/vocab/` contains large tokenizer vocabulary data. Do not read or
|
||||||
|
parse files in this directory; reference the path only when necessary.
|
||||||
|
|
||||||
|
### Public API
|
||||||
|
|
||||||
|
`include/` contains the C API exposed by the project. Currently the primary
|
||||||
|
public header is `include/stable-diffusion.h`.
|
||||||
|
|
||||||
|
Treat public headers as stable API. Avoid breaking compatibility unless the user
|
||||||
|
explicitly requests it. If public behavior changes, update relevant examples or
|
||||||
|
documentation.
|
||||||
|
|
||||||
|
### Examples
|
||||||
|
|
||||||
|
`examples/` contains programs demonstrating library usage.
|
||||||
|
|
||||||
|
* `examples/cli/` - command line program for running models, testing features,
|
||||||
|
and debugging.
|
||||||
|
* `examples/common/` - shared example support code.
|
||||||
|
* `examples/server/` - server application built on top of the library.
|
||||||
|
Before modifying built-in recipes, read and follow
|
||||||
|
[the built-in recipe policy](examples/server/recipes/README.md).
|
||||||
|
* `examples/server/frontend/` - git submodule containing independent frontend
|
||||||
|
code. Avoid modifying it unless explicitly requested.
|
||||||
|
|
||||||
|
### Documentation and Tooling
|
||||||
|
|
||||||
|
* `docs/` - documentation for supported models, build options, behavior, and
|
||||||
|
workflows; start from `docs/README.md`.
|
||||||
|
* `docs/dgl/` - runnable DGL examples grouped by model.
|
||||||
|
* `docs/models/` - model and component usage guides, including LoRAs, adapters,
|
||||||
|
auxiliary models, and model-specific examples.
|
||||||
|
* `docs/guides/` - shared usage workflows, configuration, and performance guides.
|
||||||
|
* `docs/development/` - internal implementation and model integration conventions.
|
||||||
|
* `scripts/` - development, model processing, build automation, formatting, and
|
||||||
|
tooling scripts.
|
||||||
|
* `cmake/` - CMake support modules.
|
||||||
|
* `docker/` - Docker-related project files.
|
||||||
|
* `assets/` - documentation assets; not runtime code.
|
||||||
|
|
||||||
|
### External, Local, and Generated State
|
||||||
|
|
||||||
|
* `ggml/` - git submodule for the ggml dependency.
|
||||||
|
* `thirdparty/` - vendored third-party dependencies.
|
||||||
|
* `models/` - local model storage. Ignore this directory and do not read model
|
||||||
|
files.
|
||||||
|
* `test/` - local testing scripts. Use only when relevant to the task.
|
||||||
|
* `build/`, `build_*`, and similar directories - generated build outputs.
|
||||||
|
Inspect them only when debugging a build result.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Agent Workflow for Code Changes
|
||||||
|
|
||||||
|
1. Identify the relevant modules under `src/`.
|
||||||
|
2. Check whether the change touches the public API in `include/`.
|
||||||
|
3. Consult relevant `docs/` and examples before changing user-facing behavior.
|
||||||
|
4. For model or component integrations, read and follow
|
||||||
|
[the model documentation requirements](CONTRIBUTING.md#model-documentation).
|
||||||
|
Add or update the usage guide and relevant index/README entries in the same
|
||||||
|
change. Treat the integration as incomplete until this documentation is included.
|
||||||
|
5. Follow existing local patterns before adding new abstractions.
|
||||||
|
6. Keep edits scoped to the requested behavior.
|
||||||
|
7. Run the narrowest useful build, test, or inspection command available.
|
||||||
|
|
||||||
|
Regenerate [the DGL built-in catalog](docs/dgl-builtins.md) whenever a
|
||||||
|
registered function is added, removed, renamed, or changes its parameters,
|
||||||
|
defaults, or outputs. Run the `dgl-update-builtins` CMake target to
|
||||||
|
regenerate the catalog and `dgl-check-builtins` to verify it. Update the
|
||||||
|
DGL guide or examples when a built-in changes behavior.
|
||||||
|
|
||||||
|
Follow `CONTRIBUTING.md` for formatting, naming, PR expectations, dependency
|
||||||
|
update policy, and security rules. For tokenizer additions, follow its embedded-data
|
||||||
|
allowlist and default to an external `tokenizer.json`.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Code Comments
|
||||||
|
|
||||||
|
Keep comments rare and useful.
|
||||||
|
|
||||||
|
Do not add comments that only describe what the code does. Add comments only
|
||||||
|
when the code cannot fully express the logic, the logic is unusually complex, or
|
||||||
|
there are historical reasons, invariants, constraints, compatibility concerns,
|
||||||
|
or known pitfalls that future maintainers need to understand.
|
||||||
|
|
||||||
|
Do not add task-specific comments that will be meaningless after review.
|
||||||
|
|
||||||
|
Examples from the current codebase:
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
// GOOD: explains a safety constraint that is not obvious from the assignment.
|
||||||
|
// From src/model_io/pickle_io.cpp.
|
||||||
|
// Non-tensor checkpoint metadata can use REDUCE for arbitrary
|
||||||
|
// Python objects. Do not execute it; keep stack shape only.
|
||||||
|
stack.push_back(make_none_value());
|
||||||
|
|
||||||
|
// BAD: describes only what the next line does.
|
||||||
|
// Set the token count to zero.
|
||||||
|
token_count = 0;
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Text File Encoding
|
||||||
|
|
||||||
|
When reading or editing repository text files:
|
||||||
|
|
||||||
|
* Prefer UTF-8 with LF for Markdown, frontend source, JSON, and other text-first
|
||||||
|
project files unless the file already clearly uses a different encoding.
|
||||||
|
* Do not assume terminal output encoding matches file encoding on Windows.
|
||||||
|
* A file that looks garbled in PowerShell output may still be valid UTF-8.
|
||||||
|
* When inspecting UTF-8 files in PowerShell, prefer explicit UTF-8 reads such as:
|
||||||
|
* `[Console]::OutputEncoding = [System.Text.Encoding]::UTF8`
|
||||||
|
* `Get-Content -Encoding utf8 <path>`
|
||||||
|
* Avoid rewriting a file purely because console output looked garbled; verify
|
||||||
|
the actual file encoding first.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Tensor and Layout Notes
|
||||||
|
|
||||||
|
Additional tensor/layout rules for this codebase:
|
||||||
|
|
||||||
|
* `sd::Tensor` shape order is not PyTorch/NumPy-style. `shape()[0]` is the
|
||||||
|
lowest and most contiguous dimension, and higher indices are higher
|
||||||
|
dimensions.
|
||||||
|
* Broadcasting for `sd::Tensor` must align dimensions from low to high dimension
|
||||||
|
indices. If one tensor has fewer dimensions, append implicit `1`s at the
|
||||||
|
higher-dimension end.
|
||||||
|
* `ggml_n_dims` / `ggml_n_dims(tensor)` can drop trailing singleton high
|
||||||
|
dimensions. Do not assume a logical trailing dimension of `1` will still be
|
||||||
|
counted in ggml metadata.
|
||||||
|
* Internal tensor-returning interfaces use an empty `sd::Tensor` to represent
|
||||||
|
null, absent, or failure states. Do not add `std::optional<sd::Tensor<...>>`
|
||||||
|
for internal APIs unless a distinct semantic state is truly required.
|
||||||
11
CLAUDE.md
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
@AGENTS.md
|
||||||
|
|
||||||
|
## Claude Code
|
||||||
|
|
||||||
|
Follow `AGENTS.md` as the shared repository instructions.
|
||||||
|
|
||||||
|
Do not duplicate contribution, style, PR, dependency, or security policy here;
|
||||||
|
use `CONTRIBUTING.md` as the canonical source for those rules.
|
||||||
|
|
||||||
|
Keep Claude-specific project notes in this file only when they do not apply to
|
||||||
|
other coding agents.
|
||||||
403
CMakeLists.txt
|
|
@ -9,19 +9,81 @@ if (NOT XCODE AND NOT MSVC AND NOT CMAKE_BUILD_TYPE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (MSVC)
|
if (MSVC)
|
||||||
|
cmake_host_system_information(RESULT SD_PHYSICAL_CORES QUERY NUMBER_OF_PHYSICAL_CORES)
|
||||||
|
set(SD_DEFAULT_MSVC_MP_COUNT "${SD_PHYSICAL_CORES}")
|
||||||
|
if (NOT SD_DEFAULT_MSVC_MP_COUNT GREATER 0)
|
||||||
|
set(SD_DEFAULT_MSVC_MP_COUNT 1)
|
||||||
|
endif()
|
||||||
|
set(SD_MSVC_MP_COUNT "${SD_DEFAULT_MSVC_MP_COUNT}" CACHE STRING "Maximum parallel MSVC compilations per project")
|
||||||
|
if (NOT SD_MSVC_MP_COUNT MATCHES "^[1-9][0-9]*$" OR SD_MSVC_MP_COUNT GREATER 65536)
|
||||||
|
message(FATAL_ERROR "SD_MSVC_MP_COUNT must be an integer between 1 and 65536")
|
||||||
|
endif()
|
||||||
|
message("-- SD_MSVC_MP_COUNT: ${SD_MSVC_MP_COUNT}")
|
||||||
add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
|
add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
|
||||||
add_compile_definitions(_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING)
|
add_compile_definitions(_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING)
|
||||||
|
# /MP is MSVC-only: icx rejects it outright once offloading is enabled.
|
||||||
|
add_compile_options(
|
||||||
|
$<$<AND:$<COMPILE_LANGUAGE:C>,$<C_COMPILER_ID:MSVC>>:/MP${SD_MSVC_MP_COUNT}>
|
||||||
|
$<$<COMPILE_LANGUAGE:C>:/utf-8>
|
||||||
|
$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CXX_COMPILER_ID:MSVC>>:/MP${SD_MSVC_MP_COUNT}>
|
||||||
|
$<$<COMPILE_LANGUAGE:CXX>:/utf-8>
|
||||||
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
||||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
||||||
|
|
||||||
|
if(APPLE)
|
||||||
|
function(sd_set_macos_rpaths target)
|
||||||
|
get_target_property(target_type ${target} TYPE)
|
||||||
|
if(target_type STREQUAL "EXECUTABLE")
|
||||||
|
set(runtime_paths "@executable_path" "@executable_path/../lib")
|
||||||
|
elseif(target_type STREQUAL "SHARED_LIBRARY" OR target_type STREQUAL "MODULE_LIBRARY")
|
||||||
|
set(runtime_paths "@loader_path" "@loader_path/../lib")
|
||||||
|
set_target_properties(${target} PROPERTIES
|
||||||
|
MACOSX_RPATH ON
|
||||||
|
INSTALL_NAME_DIR "@rpath"
|
||||||
|
BUILD_WITH_INSTALL_NAME_DIR ON
|
||||||
|
)
|
||||||
|
else()
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Release artifacts zip the build output directly, so keep macOS rpaths relocatable.
|
||||||
|
set_target_properties(${target} PROPERTIES
|
||||||
|
BUILD_RPATH "${runtime_paths}"
|
||||||
|
INSTALL_RPATH "${runtime_paths}"
|
||||||
|
BUILD_WITH_INSTALL_RPATH ON
|
||||||
|
)
|
||||||
|
endfunction()
|
||||||
|
endif()
|
||||||
|
|
||||||
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
|
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
|
||||||
set(SD_STANDALONE ON)
|
set(SD_STANDALONE ON)
|
||||||
else()
|
else()
|
||||||
set(SD_STANDALONE OFF)
|
set(SD_STANDALONE OFF)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
set(SD_SUBMODULE_WEBP FALSE)
|
||||||
|
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/libwebp/CMakeLists.txt")
|
||||||
|
set(SD_SUBMODULE_WEBP TRUE)
|
||||||
|
endif()
|
||||||
|
if(SD_SUBMODULE_WEBP)
|
||||||
|
set(SD_WEBP_DEFAULT ON)
|
||||||
|
else()
|
||||||
|
set(SD_WEBP_DEFAULT ${SD_USE_SYSTEM_WEBP})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(SD_SUBMODULE_WEBM FALSE)
|
||||||
|
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/libwebm/CMakeLists.txt")
|
||||||
|
set(SD_SUBMODULE_WEBM TRUE)
|
||||||
|
endif()
|
||||||
|
if(SD_SUBMODULE_WEBM)
|
||||||
|
set(SD_WEBM_DEFAULT ON)
|
||||||
|
else()
|
||||||
|
set(SD_WEBM_DEFAULT ${SD_USE_SYSTEM_WEBM})
|
||||||
|
endif()
|
||||||
|
|
||||||
#
|
#
|
||||||
# Option list
|
# Option list
|
||||||
#
|
#
|
||||||
|
|
@ -29,6 +91,10 @@ endif()
|
||||||
# general
|
# general
|
||||||
#option(SD_BUILD_TESTS "sd: build tests" ${SD_STANDALONE})
|
#option(SD_BUILD_TESTS "sd: build tests" ${SD_STANDALONE})
|
||||||
option(SD_BUILD_EXAMPLES "sd: build examples" ${SD_STANDALONE})
|
option(SD_BUILD_EXAMPLES "sd: build examples" ${SD_STANDALONE})
|
||||||
|
option(SD_WEBP "sd: enable WebP image I/O support" ${SD_WEBP_DEFAULT})
|
||||||
|
option(SD_USE_SYSTEM_WEBP "sd: link against system libwebp" OFF)
|
||||||
|
option(SD_WEBM "sd: enable WebM video I/O support" ${SD_WEBM_DEFAULT})
|
||||||
|
option(SD_USE_SYSTEM_WEBM "sd: link against system libwebm" OFF)
|
||||||
option(SD_CUDA "sd: cuda backend" OFF)
|
option(SD_CUDA "sd: cuda backend" OFF)
|
||||||
option(SD_HIPBLAS "sd: rocm backend" OFF)
|
option(SD_HIPBLAS "sd: rocm backend" OFF)
|
||||||
option(SD_METAL "sd: metal backend" OFF)
|
option(SD_METAL "sd: metal backend" OFF)
|
||||||
|
|
@ -36,60 +102,195 @@ option(SD_VULKAN "sd: vulkan backend" OFF)
|
||||||
option(SD_OPENCL "sd: opencl backend" OFF)
|
option(SD_OPENCL "sd: opencl backend" OFF)
|
||||||
option(SD_SYCL "sd: sycl backend" OFF)
|
option(SD_SYCL "sd: sycl backend" OFF)
|
||||||
option(SD_MUSA "sd: musa backend" OFF)
|
option(SD_MUSA "sd: musa backend" OFF)
|
||||||
option(SD_FAST_SOFTMAX "sd: x1.5 faster softmax, indeterministic (sometimes, same seed don't generate same image), cuda only" OFF)
|
|
||||||
option(SD_BUILD_SHARED_LIBS "sd: build shared libs" OFF)
|
option(SD_BUILD_SHARED_LIBS "sd: build shared libs" OFF)
|
||||||
option(SD_BUILD_SHARED_GGML_LIB "sd: build ggml as a separate shared lib" OFF)
|
option(SD_BUILD_SHARED_GGML_LIB "sd: build ggml as a separate shared lib" OFF)
|
||||||
option(SD_USE_SYSTEM_GGML "sd: use system-installed GGML library" OFF)
|
option(SD_USE_SYSTEM_GGML "sd: use system-installed GGML library" OFF)
|
||||||
|
option(SD_USE_UPSTREAM_GGML "sd: build with upstream GGML instead of the patched GGML extensions" OFF)
|
||||||
|
set(SD_GGML_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ggml" CACHE PATH "sd: ggml source directory (also supplies private headers for system ggml)")
|
||||||
#option(SD_BUILD_SERVER "sd: build server example" ON)
|
#option(SD_BUILD_SERVER "sd: build server example" ON)
|
||||||
|
|
||||||
|
set(CMAKE_C_STANDARD 11)
|
||||||
|
set(CMAKE_C_STANDARD_REQUIRED true)
|
||||||
|
|
||||||
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
|
set(CMAKE_CXX_STANDARD_REQUIRED true)
|
||||||
|
|
||||||
if(SD_CUDA)
|
if(SD_CUDA)
|
||||||
message("-- Use CUDA as backend stable-diffusion")
|
message("-- Use CUDA as backend stable-diffusion")
|
||||||
set(GGML_CUDA ON)
|
set(GGML_CUDA ON)
|
||||||
add_definitions(-DSD_USE_CUDA)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(SD_METAL)
|
if(SD_METAL)
|
||||||
|
if(NOT SD_USE_UPSTREAM_GGML)
|
||||||
|
if(CMAKE_VERSION VERSION_LESS 3.16)
|
||||||
|
message(FATAL_ERROR "SD_METAL with SD_USE_UPSTREAM_GGML=OFF requires CMake 3.16 or later for OBJC and OBJCXX support")
|
||||||
|
endif()
|
||||||
|
enable_language(OBJC OBJCXX)
|
||||||
|
endif()
|
||||||
message("-- Use Metal as backend stable-diffusion")
|
message("-- Use Metal as backend stable-diffusion")
|
||||||
set(GGML_METAL ON)
|
set(GGML_METAL ON)
|
||||||
add_definitions(-DSD_USE_METAL)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (SD_VULKAN)
|
if (SD_VULKAN)
|
||||||
message("-- Use Vulkan as backend stable-diffusion")
|
message("-- Use Vulkan as backend stable-diffusion")
|
||||||
set(GGML_VULKAN ON)
|
set(GGML_VULKAN ON)
|
||||||
add_definitions(-DSD_USE_VULKAN)
|
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
if (SD_OPENCL)
|
if (SD_OPENCL)
|
||||||
message("-- Use OpenCL as backend stable-diffusion")
|
message("-- Use OpenCL as backend stable-diffusion")
|
||||||
set(GGML_OPENCL ON)
|
set(GGML_OPENCL ON)
|
||||||
add_definitions(-DSD_USE_OPENCL)
|
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
if (SD_HIPBLAS)
|
if (SD_HIPBLAS)
|
||||||
message("-- Use HIPBLAS as backend stable-diffusion")
|
message("-- Use HIPBLAS as backend stable-diffusion")
|
||||||
set(GGML_HIP ON)
|
set(GGML_HIP ON)
|
||||||
add_definitions(-DSD_USE_CUDA)
|
# ggml-hip's device-stub objects must be position-independent, or the
|
||||||
if(SD_FAST_SOFTMAX)
|
# default-PIE sd-cli link fails with `relocation R_X86_64_32 ... cannot be
|
||||||
set(GGML_CUDA_FAST_SOFTMAX ON)
|
# used when making a PIE object` on distros that default to PIE
|
||||||
endif()
|
# (Ubuntu 24.04, Fedora 40+, Debian 12+). The shared-library branch below
|
||||||
|
# already sets this; the static build (the HIP default) did not.
|
||||||
|
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
if(SD_MUSA)
|
if(SD_MUSA)
|
||||||
message("-- Use MUSA as backend stable-diffusion")
|
message("-- Use MUSA as backend stable-diffusion")
|
||||||
set(GGML_MUSA ON)
|
set(GGML_MUSA ON)
|
||||||
add_definitions(-DSD_USE_CUDA)
|
endif()
|
||||||
if(SD_FAST_SOFTMAX)
|
|
||||||
set(GGML_CUDA_FAST_SOFTMAX ON)
|
if(SD_WEBP)
|
||||||
|
if(NOT SD_SUBMODULE_WEBP AND NOT SD_USE_SYSTEM_WEBP)
|
||||||
|
message(FATAL_ERROR "WebP support enabled but no source found.
|
||||||
|
Either initialize the submodule:\n git submodule update --init thirdparty/libwebp\n\n"
|
||||||
|
"Or link against system library:\n cmake (...) -DSD_USE_SYSTEM_WEBP=ON")
|
||||||
|
endif()
|
||||||
|
if(SD_USE_SYSTEM_WEBP)
|
||||||
|
find_package(WebP)
|
||||||
|
if(WebP_FOUND)
|
||||||
|
add_library(webp ALIAS WebP::webp)
|
||||||
|
# libwebp CMake target naming is not consistent across versions/distros.
|
||||||
|
# Some export WebP::libwebpmux, others export WebP::webpmux.
|
||||||
|
if(TARGET WebP::libwebpmux)
|
||||||
|
add_library(libwebpmux ALIAS WebP::libwebpmux)
|
||||||
|
elseif(TARGET WebP::webpmux)
|
||||||
|
add_library(libwebpmux ALIAS WebP::webpmux)
|
||||||
|
else()
|
||||||
|
message(FATAL_ERROR
|
||||||
|
"Could not find a compatible webpmux target in system WebP package. "
|
||||||
|
"Expected WebP::libwebpmux or WebP::webpmux."
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
if(TARGET WebP::webpdemux)
|
||||||
|
add_library(webpdemux ALIAS WebP::webpdemux)
|
||||||
|
elseif(TARGET WebP::libwebpdemux)
|
||||||
|
add_library(webpdemux ALIAS WebP::libwebpdemux)
|
||||||
|
else()
|
||||||
|
message(FATAL_ERROR "System WebP package must provide WebP::webpdemux or WebP::libwebpdemux.")
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
find_package(PkgConfig REQUIRED)
|
||||||
|
pkg_check_modules(WebP REQUIRED IMPORTED_TARGET GLOBAL libwebp)
|
||||||
|
pkg_check_modules(WebPMux REQUIRED IMPORTED_TARGET GLOBAL libwebpmux)
|
||||||
|
pkg_check_modules(WebPDemux REQUIRED IMPORTED_TARGET GLOBAL libwebpdemux)
|
||||||
|
add_library(webp ALIAS PkgConfig::WebP)
|
||||||
|
add_library(libwebpmux ALIAS PkgConfig::WebPMux)
|
||||||
|
add_library(webpdemux ALIAS PkgConfig::WebPDemux)
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(SD_WEBM)
|
||||||
|
if(NOT SD_WEBP)
|
||||||
|
message(FATAL_ERROR "SD_WEBM requires SD_WEBP because WebM output reuses libwebp VP8 encoding.")
|
||||||
|
endif()
|
||||||
|
if(NOT SD_SUBMODULE_WEBM AND NOT SD_USE_SYSTEM_WEBM)
|
||||||
|
message(FATAL_ERROR "WebM support enabled but no source found.
|
||||||
|
Either initialize the submodule:\n git submodule update --init thirdparty/libwebm\n\n"
|
||||||
|
"Or link against system library:\n cmake (...) -DSD_USE_SYSTEM_WEBM=ON")
|
||||||
|
endif()
|
||||||
|
if(SD_USE_SYSTEM_WEBM)
|
||||||
|
find_package(PkgConfig)
|
||||||
|
if(PkgConfig_FOUND)
|
||||||
|
pkg_check_modules(WebM REQUIRED IMPORTED_TARGET GLOBAL libwebm)
|
||||||
|
endif()
|
||||||
|
if(PkgConfig_FOUND AND WebM_FOUND)
|
||||||
|
add_library(webm ALIAS PkgConfig::WebM)
|
||||||
|
else()
|
||||||
|
find_path(WEBM_INCLUDE_DIR
|
||||||
|
NAMES mkvmuxer/mkvmuxer.h mkvparser/mkvparser.h common/webmids.h
|
||||||
|
PATH_SUFFIXES webm
|
||||||
|
REQUIRED)
|
||||||
|
find_library(WEBM_LIBRARY
|
||||||
|
NAMES webm libwebm
|
||||||
|
REQUIRED)
|
||||||
|
|
||||||
|
add_library(webm UNKNOWN IMPORTED)
|
||||||
|
set_target_properties(webm PROPERTIES
|
||||||
|
IMPORTED_LOCATION "${WEBM_LIBRARY}"
|
||||||
|
INTERFACE_INCLUDE_DIRECTORIES "${WEBM_INCLUDE_DIR}")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (SD_RPC)
|
||||||
|
message("-- Use RPC as backend stable-diffusion")
|
||||||
|
set(GGML_RPC ON)
|
||||||
|
add_definitions(-DSD_USE_RPC)
|
||||||
|
endif ()
|
||||||
|
|
||||||
set(SD_LIB stable-diffusion)
|
set(SD_LIB stable-diffusion)
|
||||||
|
|
||||||
file(GLOB SD_LIB_SOURCES
|
file(GLOB SD_API_TEMPLATES CONFIGURE_DEPENDS "src/api/templates/*.dgl")
|
||||||
"*.h"
|
set(SD_API_TEMPLATE_CONTENT "#ifndef __SD_API_TEMPLATES_H__\n#define __SD_API_TEMPLATES_H__\n#include <map>\n#include <string>\n#include <string_view>\nnamespace sd::api::templates {\ninline const std::map<std::string, std::string_view> sources = {\n")
|
||||||
"*.cpp"
|
foreach(SD_API_TEMPLATE IN LISTS SD_API_TEMPLATES)
|
||||||
"*.hpp"
|
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${SD_API_TEMPLATE}")
|
||||||
|
get_filename_component(SD_API_TEMPLATE_NAME "${SD_API_TEMPLATE}" NAME_WE)
|
||||||
|
file(READ "${SD_API_TEMPLATE}" SD_API_TEMPLATE_TEXT)
|
||||||
|
string(APPEND SD_API_TEMPLATE_CONTENT "{\"${SD_API_TEMPLATE_NAME}\", R\"SD_DGL(${SD_API_TEMPLATE_TEXT})SD_DGL\"},\n")
|
||||||
|
endforeach()
|
||||||
|
string(APPEND SD_API_TEMPLATE_CONTENT "};\n}\n#endif\n")
|
||||||
|
file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/generated/api_templates.h" CONTENT "${SD_API_TEMPLATE_CONTENT}")
|
||||||
|
|
||||||
|
file(GLOB SD_LIB_SOURCES CONFIGURE_DEPENDS
|
||||||
|
"src/*.h"
|
||||||
|
"src/*.cpp"
|
||||||
|
"src/*.hpp"
|
||||||
|
"src/api/*.h"
|
||||||
|
"src/api/*.cpp"
|
||||||
|
"src/conditioning/*.h"
|
||||||
|
"src/conditioning/*.cpp"
|
||||||
|
"src/conditioning/*.hpp"
|
||||||
|
"src/core/*.h"
|
||||||
|
"src/core/*.cpp"
|
||||||
|
"src/core/*.hpp"
|
||||||
|
"src/core/cpu/*.h"
|
||||||
|
"src/core/cpu/*.cpp"
|
||||||
|
"src/core/probe/*.h"
|
||||||
|
"src/core/probe/*.cpp"
|
||||||
|
"src/extensions/*.h"
|
||||||
|
"src/extensions/*.cpp"
|
||||||
|
"src/extensions/*.hpp"
|
||||||
|
"src/dgl/*.h"
|
||||||
|
"src/dgl/*.cpp"
|
||||||
|
"src/dgl/syntax/*.h"
|
||||||
|
"src/dgl/syntax/*.cpp"
|
||||||
|
"src/dgl/bindings/*.h"
|
||||||
|
"src/dgl/bindings/*.cpp"
|
||||||
|
"src/dgl/models/*.h"
|
||||||
|
"src/dgl/models/*.cpp"
|
||||||
|
"src/dgl/ops/*.h"
|
||||||
|
"src/dgl/ops/*.cpp"
|
||||||
|
"src/model/*/*.h"
|
||||||
|
"src/model/*/*.cpp"
|
||||||
|
"src/model/*/*.hpp"
|
||||||
|
"src/runtime/*.h"
|
||||||
|
"src/runtime/*.cpp"
|
||||||
|
"src/runtime/*.hpp"
|
||||||
|
"src/model_io/*.h"
|
||||||
|
"src/model_io/*.cpp"
|
||||||
|
"src/tokenizers/*.h"
|
||||||
|
"src/tokenizers/*.cpp"
|
||||||
|
"src/tokenizers/vocab/*.h"
|
||||||
|
"src/tokenizers/vocab/*.cpp"
|
||||||
)
|
)
|
||||||
|
|
||||||
find_program(GIT_EXE NAMES git git.exe NO_CMAKE_FIND_ROOT_PATH)
|
find_program(GIT_EXE NAMES git git.exe NO_CMAKE_FIND_ROOT_PATH)
|
||||||
|
|
@ -119,7 +320,7 @@ endif()
|
||||||
message(STATUS "stable-diffusion.cpp commit ${SDCPP_BUILD_COMMIT}")
|
message(STATUS "stable-diffusion.cpp commit ${SDCPP_BUILD_COMMIT}")
|
||||||
|
|
||||||
set_property(
|
set_property(
|
||||||
SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/version.cpp
|
SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/src/version.cpp
|
||||||
APPEND PROPERTY COMPILE_DEFINITIONS
|
APPEND PROPERTY COMPILE_DEFINITIONS
|
||||||
SDCPP_BUILD_COMMIT=${SDCPP_BUILD_COMMIT} SDCPP_BUILD_VERSION=${SDCPP_BUILD_VERSION}
|
SDCPP_BUILD_COMMIT=${SDCPP_BUILD_COMMIT} SDCPP_BUILD_VERSION=${SDCPP_BUILD_VERSION}
|
||||||
)
|
)
|
||||||
|
|
@ -142,11 +343,20 @@ else()
|
||||||
add_library(${SD_LIB} STATIC ${SD_LIB_SOURCES})
|
add_library(${SD_LIB} STATIC ${SD_LIB_SOURCES})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(MSVC)
|
||||||
|
target_compile_options(${SD_LIB} PRIVATE $<$<COMPILE_LANGUAGE:CXX>:/bigobj>)
|
||||||
|
# ggml backends can throw C++ exceptions through their C API.
|
||||||
|
target_compile_options(${SD_LIB} PRIVATE $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CXX_COMPILER_ID:MSVC>>:/EHsc->)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(APPLE)
|
||||||
|
sd_set_macos_rpaths(${SD_LIB})
|
||||||
|
endif()
|
||||||
|
|
||||||
if(SD_SYCL)
|
if(SD_SYCL)
|
||||||
message("-- Use SYCL as backend stable-diffusion")
|
message("-- Use SYCL as backend stable-diffusion")
|
||||||
set(GGML_SYCL ON)
|
set(GGML_SYCL ON)
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-narrowing -fsycl")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-narrowing -fsycl")
|
||||||
add_definitions(-DSD_USE_SYCL)
|
|
||||||
# disable fast-math on host, see:
|
# disable fast-math on host, see:
|
||||||
# https://www.intel.com/content/www/us/en/docs/cpp-compiler/developer-guide-reference/2021-10/fp-model-fp.html
|
# https://www.intel.com/content/www/us/en/docs/cpp-compiler/developer-guide-reference/2021-10/fp-model-fp.html
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
|
|
@ -162,35 +372,156 @@ set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
|
||||||
|
|
||||||
if (NOT SD_USE_SYSTEM_GGML)
|
if (NOT SD_USE_SYSTEM_GGML)
|
||||||
# see https://github.com/ggerganov/ggml/pull/682
|
# see https://github.com/ggerganov/ggml/pull/682
|
||||||
add_definitions(-DGGML_MAX_NAME=128)
|
add_definitions(-DGGML_MAX_NAME=160)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# deps
|
# deps
|
||||||
# Only add ggml if it hasn't been added yet
|
include(cmake/ggml.cmake)
|
||||||
if (NOT TARGET ggml)
|
|
||||||
if (SD_USE_SYSTEM_GGML)
|
|
||||||
find_package(ggml REQUIRED)
|
|
||||||
if (NOT ggml_FOUND)
|
|
||||||
message(FATAL_ERROR "System-installed GGML library not found.")
|
|
||||||
endif()
|
|
||||||
add_library(ggml ALIAS ggml::ggml)
|
|
||||||
else()
|
|
||||||
add_subdirectory(ggml)
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
add_subdirectory(thirdparty)
|
add_subdirectory(thirdparty)
|
||||||
|
|
||||||
target_link_libraries(${SD_LIB} PUBLIC ggml zip)
|
target_sources(${SD_LIB} PRIVATE $<TARGET_OBJECTS:zip>)
|
||||||
target_include_directories(${SD_LIB} PUBLIC . thirdparty)
|
target_link_libraries(${SD_LIB} PUBLIC ggml)
|
||||||
|
find_package(Threads REQUIRED)
|
||||||
|
target_link_libraries(${SD_LIB} PRIVATE Threads::Threads)
|
||||||
|
target_link_libraries(${SD_LIB} PRIVATE onig sd-utf8proc)
|
||||||
|
if(SD_WEBP)
|
||||||
|
target_compile_definitions(${SD_LIB} PRIVATE SD_USE_WEBP)
|
||||||
|
target_link_libraries(${SD_LIB} PRIVATE webp webpdemux)
|
||||||
|
endif()
|
||||||
|
if(SD_WEBM)
|
||||||
|
target_compile_definitions(${SD_LIB} PRIVATE SD_USE_WEBM)
|
||||||
|
target_link_libraries(${SD_LIB} PRIVATE webm)
|
||||||
|
endif()
|
||||||
|
if (SD_CUDA)
|
||||||
|
find_package(CUDAToolkit REQUIRED)
|
||||||
|
# Keep the driver stub on downstream link lines when no driver is installed.
|
||||||
|
target_link_libraries(${SD_LIB} PUBLIC CUDA::cuda_driver)
|
||||||
|
set_property(SOURCE src/core/ggml_extend_backend.cpp APPEND PROPERTY COMPILE_DEFINITIONS SD_USE_CUDA)
|
||||||
|
if (NOT SD_USE_UPSTREAM_GGML)
|
||||||
|
include(cmake/cutlass.cmake)
|
||||||
|
if (TARGET ggml-cuda)
|
||||||
|
# ggml resolves CUDA architectures in a child directory scope.
|
||||||
|
get_target_property(CMAKE_CUDA_ARCHITECTURES ggml-cuda CUDA_ARCHITECTURES)
|
||||||
|
endif()
|
||||||
|
enable_language(CUDA)
|
||||||
|
set_target_properties(${SD_LIB} PROPERTIES
|
||||||
|
CUDA_STANDARD 17
|
||||||
|
CUDA_STANDARD_REQUIRED ON
|
||||||
|
CUDA_ARCHITECTURES "${CMAKE_CUDA_ARCHITECTURES}")
|
||||||
|
if (SD_CUDA_CUTLASS_PATH)
|
||||||
|
target_sources(${SD_LIB} PRIVATE src/core/cuda/cute_attention.cu src/core/cuda/i8_projection.cu src/core/cuda/i8_gated_residual.cu src/core/cuda/i8_gemm.cu src/core/cuda/bf16_gemm.cu)
|
||||||
|
set_source_files_properties(src/core/cuda/cute_attention.cu src/core/cuda/i8_projection.cu src/core/cuda/i8_gated_residual.cu src/core/cuda/i8_gemm.cu src/core/cuda/bf16_gemm.cu PROPERTIES
|
||||||
|
INCLUDE_DIRECTORIES "${SD_CUDA_CUTLASS_PATH}/include"
|
||||||
|
COMPILE_OPTIONS "--use_fast_math;--extended-lambda;--expt-relaxed-constexpr")
|
||||||
|
if (MSVC)
|
||||||
|
set_property(SOURCE src/core/cuda/cute_attention.cu src/core/cuda/i8_projection.cu src/core/cuda/i8_gated_residual.cu src/core/cuda/i8_gemm.cu src/core/cuda/bf16_gemm.cu APPEND PROPERTY COMPILE_OPTIONS -Xcompiler=/Zc:preprocessor,/Zc:__cplusplus)
|
||||||
|
endif()
|
||||||
|
if (GGML_CUDA_FORCE_CUBLAS)
|
||||||
|
set_property(SOURCE src/core/cuda/i8_projection.cu src/core/cuda/i8_gated_residual.cu src/core/cuda/i8_gemm.cu src/core/cuda/bf16_gemm.cu APPEND PROPERTY COMPILE_DEFINITIONS SD_CUDA_FORCE_CUBLAS)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
set(SD_BACKEND_REGISTRATIONS)
|
||||||
|
if (SD_METAL AND NOT SD_USE_UPSTREAM_GGML)
|
||||||
|
add_subdirectory(src/core/metal)
|
||||||
|
target_link_libraries(${SD_LIB} PRIVATE "-framework Foundation" "-framework Metal")
|
||||||
|
list(APPEND SD_BACKEND_REGISTRATIONS sd_ggml_register_metal_i8)
|
||||||
|
endif()
|
||||||
|
if (NOT SD_USE_UPSTREAM_GGML AND (SD_CUDA OR SD_HIPBLAS OR SD_MUSA))
|
||||||
|
if(SD_HIPBLAS)
|
||||||
|
include(cmake/hip.cmake)
|
||||||
|
endif()
|
||||||
|
add_subdirectory(src/core/cuda)
|
||||||
|
foreach(VENDOR CUDA HIP MUSA)
|
||||||
|
if(SD_${VENDOR} OR (VENDOR STREQUAL "HIP" AND SD_HIPBLAS))
|
||||||
|
string(TOLOWER "${VENDOR}" NAMESPACE)
|
||||||
|
list(APPEND SD_BACKEND_REGISTRATIONS "sd_${NAMESPACE}::register_extensions")
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
endif()
|
||||||
|
if (SD_VULKAN AND NOT SD_USE_UPSTREAM_GGML)
|
||||||
|
add_subdirectory(src/core/vulkan)
|
||||||
|
list(APPEND SD_BACKEND_REGISTRATIONS sd_ggml_register_vulkan_rope sd_ggml_register_vulkan_i8 sd_ggml_register_vulkan_modulate sd_ggml_register_vulkan_rms_affine)
|
||||||
|
endif()
|
||||||
|
if(SD_BACKEND_REGISTRATIONS)
|
||||||
|
string(REPLACE ";" ",\n " SD_BACKEND_REGISTRATIONS "${SD_BACKEND_REGISTRATIONS}")
|
||||||
|
configure_file(cmake/backend_extensions.h.in generated/sd_backend_extensions.h @ONLY)
|
||||||
|
set_property(SOURCE src/core/ggml_extensions.cpp APPEND PROPERTY INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}/generated")
|
||||||
|
set_property(SOURCE src/core/ggml_extensions.cpp APPEND PROPERTY COMPILE_DEFINITIONS SD_BACKEND_EXTENSIONS)
|
||||||
|
endif()
|
||||||
|
if (SD_HIPBLAS)
|
||||||
|
find_package(hip REQUIRED CONFIG HINTS "$ENV{ROCM_PATH}" /opt/rocm)
|
||||||
|
target_link_libraries(${SD_LIB} PRIVATE hip::host)
|
||||||
|
set_property(SOURCE src/core/ggml_extend_backend.cpp APPEND PROPERTY COMPILE_DEFINITIONS SD_USE_HIP)
|
||||||
|
if (GGML_HIP_MMQ_MFMA)
|
||||||
|
set_property(SOURCE src/core/ggml_extend_backend.cpp APPEND PROPERTY COMPILE_DEFINITIONS SD_HIP_MFMA)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
target_include_directories(${SD_LIB} PUBLIC include)
|
||||||
|
target_include_directories(${SD_LIB} PRIVATE src src/core "${CMAKE_CURRENT_BINARY_DIR}/generated")
|
||||||
|
target_include_directories(${SD_LIB} PUBLIC thirdparty)
|
||||||
target_compile_features(${SD_LIB} PUBLIC c_std_11 cxx_std_17)
|
target_compile_features(${SD_LIB} PUBLIC c_std_11 cxx_std_17)
|
||||||
|
set_target_properties(${SD_LIB} PROPERTIES
|
||||||
|
CXX_VISIBILITY_PRESET hidden
|
||||||
|
VISIBILITY_INLINES_HIDDEN ON)
|
||||||
|
|
||||||
|
|
||||||
if (SD_BUILD_EXAMPLES)
|
if (SD_BUILD_EXAMPLES)
|
||||||
add_subdirectory(examples)
|
add_subdirectory(examples)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(SD_PUBLIC_HEADERS stable-diffusion.h)
|
|
||||||
set_target_properties(${SD_LIB} PROPERTIES PUBLIC_HEADER "${SD_PUBLIC_HEADERS}")
|
|
||||||
|
|
||||||
install(TARGETS ${SD_LIB} LIBRARY PUBLIC_HEADER)
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# install
|
||||||
|
#
|
||||||
|
|
||||||
|
include(CMakePackageConfigHelpers)
|
||||||
|
include(GNUInstallDirs)
|
||||||
|
|
||||||
|
set(SD_INSTALL_VERSION "${SDCPP_BUILD_VERSION}")
|
||||||
|
set(SD_INSTALL_COMMIT "${SDCPP_BUILD_COMMIT}")
|
||||||
|
set(SD_SHARED_LIB ${SD_BUILD_SHARED_LIBS})
|
||||||
|
|
||||||
|
set(SD_INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_INCLUDEDIR} CACHE PATH "Location of header files")
|
||||||
|
set(SD_LIB_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR} CACHE PATH "Location of library files")
|
||||||
|
set(SD_BIN_INSTALL_DIR ${CMAKE_INSTALL_BINDIR} CACHE PATH "Location of binary files")
|
||||||
|
|
||||||
|
set_target_properties(${SD_LIB}
|
||||||
|
PROPERTIES
|
||||||
|
PUBLIC_HEADER "${CMAKE_CURRENT_SOURCE_DIR}/include/stable-diffusion.h")
|
||||||
|
|
||||||
|
|
||||||
|
install(TARGETS ${SD_LIB}
|
||||||
|
ARCHIVE
|
||||||
|
LIBRARY
|
||||||
|
RUNTIME
|
||||||
|
PUBLIC_HEADER)
|
||||||
|
|
||||||
|
|
||||||
|
configure_package_config_file(
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/cmake/stable-diffusion-config.cmake.in
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/stable-diffusion-config.cmake
|
||||||
|
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/stable-diffusion
|
||||||
|
PATH_VARS SD_INCLUDE_INSTALL_DIR
|
||||||
|
SD_LIB_INSTALL_DIR
|
||||||
|
SD_BIN_INSTALL_DIR )
|
||||||
|
|
||||||
|
write_basic_package_version_file(
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/stable-diffusion-version.cmake
|
||||||
|
VERSION ${SD_INSTALL_VERSION}
|
||||||
|
COMPATIBILITY SameMajorVersion)
|
||||||
|
|
||||||
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/stable-diffusion-config.cmake
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/stable-diffusion-version.cmake
|
||||||
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/stable-diffusion)
|
||||||
|
|
||||||
|
configure_file(cmake/stable-diffusion.pc.in
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/stable-diffusion.pc"
|
||||||
|
@ONLY)
|
||||||
|
|
||||||
|
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/stable-diffusion.pc"
|
||||||
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
|
||||||
|
|
|
||||||
179
CONTRIBUTING.md
Normal file
|
|
@ -0,0 +1,179 @@
|
||||||
|
# Contributing
|
||||||
|
|
||||||
|
This document collects general contribution conventions for this repository.
|
||||||
|
|
||||||
|
## Before You Start
|
||||||
|
|
||||||
|
Before opening a PR, please search existing PRs to avoid duplicating ongoing work.
|
||||||
|
|
||||||
|
For large-scale refactors or changes with broad impact, please open an issue first to discuss the approach before submitting a PR.
|
||||||
|
|
||||||
|
If you want to update a third-party dependency, please open an issue first instead of submitting a direct PR. See [Dependency Updates](#dependency-updates) for details.
|
||||||
|
|
||||||
|
## Pull Requests
|
||||||
|
|
||||||
|
When contributing from a fork, use a fork under your personal GitHub account and enable **Allow edits from maintainers**. This lets maintainers make follow-up fixes directly on the PR branch.
|
||||||
|
|
||||||
|
PRs from organization-owned forks are automatically closed when opened or reopened because GitHub does not support this maintainer-edit option for those forks. Submit the changes from a personal fork instead. See [GitHub's documentation](https://docs.github.com/en/pull-requests/how-tos/work-with-forks/allowing-changes-to-a-pull-request-branch-created-from-a-fork).
|
||||||
|
|
||||||
|
Keep each PR focused on one clear change. Large or overly complex PRs are harder to review and may not be merged.
|
||||||
|
|
||||||
|
Do not include test code or test scripts in commits or PRs. Keep them local and report verification results in the PR description.
|
||||||
|
|
||||||
|
Follow Conventional Commit-style subjects seen in history: `feat:`, `fix:`, `refactor:`, `ci:`, `docs:`, `chore:`. Keep subjects imperative and scoped.
|
||||||
|
|
||||||
|
PRs should include:
|
||||||
|
|
||||||
|
- What changed and why (short problem/solution summary).
|
||||||
|
- Verification evidence when applicable (commands and key outputs).
|
||||||
|
- Linked issue/PR context when applicable.
|
||||||
|
- Screenshots or sample outputs for UI/visual behavior changes.
|
||||||
|
|
||||||
|
## Documentation
|
||||||
|
|
||||||
|
Write model and component usage guides in `docs/models/` for users. Focus on
|
||||||
|
supported weights, setup, runnable commands, parameter meanings, output behavior,
|
||||||
|
and practical limits such as memory requirements. Include technical details only
|
||||||
|
when they help users choose settings or troubleshoot a problem.
|
||||||
|
|
||||||
|
Put shared usage workflows and configuration in `docs/guides/`, and internal
|
||||||
|
implementation details and development conventions in `docs/development/`.
|
||||||
|
Keep build, Docker, and troubleshooting guides at the root of `docs/`.
|
||||||
|
Link new documentation from [the documentation index](docs/README.md) or
|
||||||
|
[the model index](docs/models/README.md), as appropriate. Keep supported model
|
||||||
|
entries and their guide links in the project README.
|
||||||
|
|
||||||
|
Use **DGL** for the language name in headings, prose, link text, UI labels,
|
||||||
|
comments, logs, and diagnostics. Preserve literal spellings in commands, files,
|
||||||
|
paths, and protocol or metadata fields, such as `-M dgl`, `.dgl`, `docs/dgl/`,
|
||||||
|
and the metadata key `dgl`. Code identifiers follow their existing naming style,
|
||||||
|
such as `sd_dgl_run`, `sd::dgl`, `SD_DGL_VALUE_TENSOR`, and `DglWorkspace`.
|
||||||
|
|
||||||
|
### Model Documentation
|
||||||
|
|
||||||
|
Every new model or component integration must include a user guide in
|
||||||
|
`docs/models/` in the same PR. For a variant or new task of an existing family,
|
||||||
|
update that family's guide instead of creating a duplicate page. Add new guides
|
||||||
|
to the model index, and update the supported-model entries and guide links in
|
||||||
|
the project README when adding a model family or capability.
|
||||||
|
|
||||||
|
Model guides should use the model name as their single top-level heading and
|
||||||
|
start with a short description of supported tasks and compatibility requirements.
|
||||||
|
`Model files` and `Usage` are required. Use the following sections in order,
|
||||||
|
omitting other sections when they have no content:
|
||||||
|
|
||||||
|
- `Supported variants` when variants need a separate comparison.
|
||||||
|
- `Model files`, with component, weights/downloads, CLI option, and requirement
|
||||||
|
columns. Include tokenizers, projectors, connectors, downloads, conversion, and
|
||||||
|
required preprocessing.
|
||||||
|
- `Usage`, with `Web UI`, `DGL`, and `Legacy CLI` subsections in that order
|
||||||
|
where applicable. Group DGL scripts in a task table with descriptive links;
|
||||||
|
put shared run instructions below the table. Link to the
|
||||||
|
server's shared Web UI guide and list compatible recipes/components. Group
|
||||||
|
complete CLI examples by task or variant within this section; do not add a
|
||||||
|
separate `Quick start` or `Examples` section. Keep API usage in its own
|
||||||
|
subsection when needed.
|
||||||
|
- `Options` for model-specific settings.
|
||||||
|
- `Notes and limitations` for input/output constraints, memory requirements,
|
||||||
|
and unsupported functionality.
|
||||||
|
|
||||||
|
Follow the [model example conventions](docs/models/README.md#example-conventions)
|
||||||
|
for working directories and shell syntax. Provide Windows PowerShell and
|
||||||
|
Linux/macOS forms of executable examples, using `.\bin\Release\sd-cli.exe` and
|
||||||
|
`./bin/sd-cli` respectively from the build directory. Use the corresponding
|
||||||
|
server paths for Web UI startup. Keep backend-specific examples clearly labeled.
|
||||||
|
Use multiline commands with mode and
|
||||||
|
model components first, followed by inputs/prompts, sampling settings, dimensions,
|
||||||
|
other model options, memory/backend options, and output/seed settings. Preserve
|
||||||
|
checkpoint-specific values when reorganizing existing examples. Keep example
|
||||||
|
images next to their commands, and update links when section anchors change.
|
||||||
|
Keep shared Web UI operating instructions in `examples/server/README.md` and
|
||||||
|
link to them from model guides. Document shared settings by linking to
|
||||||
|
`docs/guides/`. Only describe Web UI
|
||||||
|
recipes and capabilities that already exist; documentation cleanup alone is not
|
||||||
|
a reason to add or change a built-in recipe.
|
||||||
|
|
||||||
|
Before submitting, check download links, relative links, command paths, CLI
|
||||||
|
options, and any recipe/component mappings against the implementation. Report
|
||||||
|
which examples were actually run and which were only inspected in the PR's
|
||||||
|
verification notes.
|
||||||
|
|
||||||
|
Keep tensor layouts, internal class names, kernel implementation details,
|
||||||
|
algorithm derivations, and development history out of usage guides. Keep task-specific
|
||||||
|
profiling logs, numerical comparison procedures, and test artifacts local, and
|
||||||
|
summarize relevant verification results in the PR description.
|
||||||
|
|
||||||
|
## Application and UI Listings
|
||||||
|
|
||||||
|
The [applications and UIs list](docs/ecosystem.md#applications-and-uis) only
|
||||||
|
includes open-source projects that use `stable-diffusion.cpp` as a backend.
|
||||||
|
Do not submit PRs to add closed-source applications or UIs.
|
||||||
|
|
||||||
|
## Server Recipes
|
||||||
|
|
||||||
|
Before adding or changing a built-in server recipe, read and follow the
|
||||||
|
[built-in recipe policy](examples/server/recipes/README.md). The policy governs
|
||||||
|
native editing, community editing LoRAs, distinct task checkpoints, external
|
||||||
|
adapters, native components and layer-count variants. Do not add recipes solely
|
||||||
|
for style or acceleration LoRAs, separately stored native components, or added
|
||||||
|
or removed model layers. Explain the task, component compatibility or capability
|
||||||
|
difference that justifies a new recipe, and verify its required components,
|
||||||
|
feature declarations and embedded API representation.
|
||||||
|
|
||||||
|
## Code Style
|
||||||
|
|
||||||
|
Format code according to the repository style before submitting changes.
|
||||||
|
|
||||||
|
Formatting follows `.clang-format` (Chromium base, 4-space indent, no tabs). Run `scripts/format-code.sh` or `scripts/format-code.ps1` before opening a PR. Keep C++ standard at C++17-compatible patterns used in this repo.
|
||||||
|
|
||||||
|
Naming conventions:
|
||||||
|
|
||||||
|
- Use `PascalCase` for class/struct/type names.
|
||||||
|
- In `PascalCase` names, preserve common abbreviations in uppercase, for example `SD`, `API`, `HTTP`, `JSON`, `RGB`, `VAE`, `TAE`, `LoRA`, and `WebP`.
|
||||||
|
- Use `snake_case` for functions, methods, variables, and file names unless an existing API requires a different style.
|
||||||
|
- Use a trailing underscore for private data member names, for example `hidden_size_` or `tokenizer_`.
|
||||||
|
- Use `.hpp` for model headers under `src/model/`, including new model headers. Do not rename these headers to `.h`. Use `.h` for other C and C++ header files.
|
||||||
|
- Use macro-based header include guards instead of `#pragma once`.
|
||||||
|
- Format header include guards as `__SD_{PATH}__`, where `{PATH}` is the header path in uppercase snake case without the file extension. For example, `src/sample.h` should use `__SD_SAMPLE_H__`.
|
||||||
|
- Do not introduce anonymous namespaces in new or modified code; prefer `static` file-local functions/variables or an explicit named namespace when scoping is needed.
|
||||||
|
- In `class`/`struct` definitions, place data members before member functions unless an existing type already clearly follows a different pattern.
|
||||||
|
|
||||||
|
Some older code in the project may not fully follow the current conventions. Please do not submit PRs that only rewrite existing code to match style rules.
|
||||||
|
|
||||||
|
When adding or modifying model implementations, follow the
|
||||||
|
[model config and weight detection conventions](docs/development/model_config.md).
|
||||||
|
|
||||||
|
## Tokenizer Data
|
||||||
|
|
||||||
|
New model integrations must use an external `tokenizer.json` by default. Do not
|
||||||
|
embed new vocabularies or merge tables solely for less widely used models;
|
||||||
|
these tables increase the binary size for every user.
|
||||||
|
|
||||||
|
The embedded-data allowlist is CLIP, T5/UMT5, Qwen 2/3, Mistral, and Gemma 3/4.
|
||||||
|
Models may reuse an existing embedded tokenizer when its vocabulary and behavior
|
||||||
|
match their text encoder. Gemma 2 and GPT-OSS require external JSON files.
|
||||||
|
|
||||||
|
Adding to this allowlist requires maintainer approval, supported by the model's
|
||||||
|
usage, reuse across models, and measured binary-size cost. Document the matching
|
||||||
|
JSON and CLI option for models that require an external tokenizer, and fail
|
||||||
|
initialization clearly when it is missing.
|
||||||
|
|
||||||
|
## AI-Assisted Contributions
|
||||||
|
|
||||||
|
AI tools may be used to assist development, but contributors are responsible for the quality and correctness of the submitted code.
|
||||||
|
|
||||||
|
If any part of a contribution was generated with AI assistance, the contributor must perform a thorough human review before submitting the PR and understand every changed line.
|
||||||
|
|
||||||
|
Do not list AI tools as co-authors. The human contributor is the sole responsible author of the submitted code.
|
||||||
|
|
||||||
|
Please do not submit AI-generated code that you do not understand, and do not include meaningless experiments, temporary test code, or unrelated generated output in a PR.
|
||||||
|
|
||||||
|
## Dependency Updates
|
||||||
|
|
||||||
|
Do not submit PRs that update `ggml`. `ggml` updates are performed only after local validation by the maintainer.
|
||||||
|
|
||||||
|
Other third-party dependencies are not updated unless necessary. If you want to update a dependency, please open an issue first instead of submitting a direct PR.
|
||||||
|
|
||||||
|
## Security & Configuration
|
||||||
|
|
||||||
|
Do not commit model weights, secrets, or local absolute paths. Keep large binaries out of git unless intentionally tracked release assets.
|
||||||
23
Dockerfile
|
|
@ -1,23 +0,0 @@
|
||||||
ARG UBUNTU_VERSION=24.04
|
|
||||||
|
|
||||||
FROM ubuntu:$UBUNTU_VERSION AS build
|
|
||||||
|
|
||||||
RUN apt-get update && apt-get install -y --no-install-recommends build-essential git cmake
|
|
||||||
|
|
||||||
WORKDIR /sd.cpp
|
|
||||||
|
|
||||||
COPY . .
|
|
||||||
|
|
||||||
RUN cmake . -B ./build
|
|
||||||
RUN cmake --build ./build --config Release --parallel
|
|
||||||
|
|
||||||
FROM ubuntu:$UBUNTU_VERSION AS runtime
|
|
||||||
|
|
||||||
RUN apt-get update && \
|
|
||||||
apt-get install --yes --no-install-recommends libgomp1 && \
|
|
||||||
apt-get clean
|
|
||||||
|
|
||||||
COPY --from=build /sd.cpp/build/bin/sd-cli /sd-cli
|
|
||||||
COPY --from=build /sd.cpp/build/bin/sd-server /sd-server
|
|
||||||
|
|
||||||
ENTRYPOINT [ "/sd-cli" ]
|
|
||||||
|
|
@ -1,24 +0,0 @@
|
||||||
ARG MUSA_VERSION=rc4.2.0
|
|
||||||
ARG UBUNTU_VERSION=22.04
|
|
||||||
|
|
||||||
FROM mthreads/musa:${MUSA_VERSION}-devel-ubuntu${UBUNTU_VERSION}-amd64 as build
|
|
||||||
|
|
||||||
RUN apt-get update && apt-get install -y ccache cmake git
|
|
||||||
|
|
||||||
WORKDIR /sd.cpp
|
|
||||||
|
|
||||||
COPY . .
|
|
||||||
|
|
||||||
RUN mkdir build && cd build && \
|
|
||||||
cmake .. -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ \
|
|
||||||
-DCMAKE_C_FLAGS="${CMAKE_C_FLAGS} -fopenmp -I/usr/lib/llvm-14/lib/clang/14.0.0/include -L/usr/lib/llvm-14/lib" \
|
|
||||||
-DCMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS} -fopenmp -I/usr/lib/llvm-14/lib/clang/14.0.0/include -L/usr/lib/llvm-14/lib" \
|
|
||||||
-DSD_MUSA=ON -DCMAKE_BUILD_TYPE=Release && \
|
|
||||||
cmake --build . --config Release
|
|
||||||
|
|
||||||
FROM mthreads/musa:${MUSA_VERSION}-runtime-ubuntu${UBUNTU_VERSION}-amd64 as runtime
|
|
||||||
|
|
||||||
COPY --from=build /sd.cpp/build/bin/sd-cli /sd-cli
|
|
||||||
COPY --from=build /sd.cpp/build/bin/sd-server /sd-server
|
|
||||||
|
|
||||||
ENTRYPOINT [ "/sd-cli" ]
|
|
||||||
|
|
@ -1,20 +0,0 @@
|
||||||
ARG SYCL_VERSION=2025.1.0-0
|
|
||||||
|
|
||||||
FROM intel/oneapi-basekit:${SYCL_VERSION}-devel-ubuntu24.04 AS build
|
|
||||||
|
|
||||||
RUN apt-get update && apt-get install -y cmake
|
|
||||||
|
|
||||||
WORKDIR /sd.cpp
|
|
||||||
|
|
||||||
COPY . .
|
|
||||||
|
|
||||||
RUN mkdir build && cd build && \
|
|
||||||
cmake .. -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx -DSD_SYCL=ON -DCMAKE_BUILD_TYPE=Release && \
|
|
||||||
cmake --build . --config Release -j$(nproc)
|
|
||||||
|
|
||||||
FROM intel/oneapi-basekit:${SYCL_VERSION}-devel-ubuntu24.04 AS runtime
|
|
||||||
|
|
||||||
COPY --from=build /sd.cpp/build/bin/sd-cli /sd-cli
|
|
||||||
COPY --from=build /sd.cpp/build/bin/sd-server /sd-server
|
|
||||||
|
|
||||||
ENTRYPOINT [ "/sd-cli" ]
|
|
||||||
|
|
@ -1,23 +0,0 @@
|
||||||
ARG UBUNTU_VERSION=24.04
|
|
||||||
|
|
||||||
FROM ubuntu:$UBUNTU_VERSION AS build
|
|
||||||
|
|
||||||
RUN apt-get update && apt-get install -y --no-install-recommends build-essential git cmake libvulkan-dev glslc
|
|
||||||
|
|
||||||
WORKDIR /sd.cpp
|
|
||||||
|
|
||||||
COPY . .
|
|
||||||
|
|
||||||
RUN cmake . -B ./build -DSD_VULKAN=ON
|
|
||||||
RUN cmake --build ./build --config Release --parallel
|
|
||||||
|
|
||||||
FROM ubuntu:$UBUNTU_VERSION AS runtime
|
|
||||||
|
|
||||||
RUN apt-get update && \
|
|
||||||
apt-get install --yes --no-install-recommends libgomp1 libvulkan1 mesa-vulkan-drivers && \
|
|
||||||
apt-get clean
|
|
||||||
|
|
||||||
COPY --from=build /sd.cpp/build/bin/sd-cli /sd-cli
|
|
||||||
COPY --from=build /sd.cpp/build/bin/sd-server /sd-server
|
|
||||||
|
|
||||||
ENTRYPOINT [ "/sd-cli" ]
|
|
||||||
264
README.md
|
|
@ -15,52 +15,95 @@ API and command-line option may change frequently.***
|
||||||
|
|
||||||
## 🔥Important News
|
## 🔥Important News
|
||||||
|
|
||||||
|
* **2026/11/11** 🚀 stable-diffusion.cpp adds **Day-0 support for MiniMax-H3-Image**
|
||||||
|
* **2026/10/16** 🚀 stable-diffusion.cpp adds **Day-0 support for MOSS-Image-Base / MOSS-Image-SFT**
|
||||||
|
* **2026/10/16** 🚀 stable-diffusion.cpp adds **Day-0 support for FLUX.3 Image Klein / Klein Base**
|
||||||
|
* **2026/09/20** 🚀 stable-diffusion.cpp adds **Day-0 support for Qwen-Image-2.1**
|
||||||
|
* **2026/08/20** 🚀 stable-diffusion.cpp now supports **LTX-2.5**
|
||||||
|
* **2026/08/04** 🚀 stable-diffusion.cpp adds **Day-1 support for MiniMax-H3**
|
||||||
|
* **2026/06/25** 🚀 stable-diffusion.cpp now supports **Krea2**
|
||||||
|
* **2026/06/04** 🚀 stable-diffusion.cpp now supports **Ideogram4**
|
||||||
|
* **2026/05/31** 🚀 stable-diffusion.cpp now supports **PiD**
|
||||||
|
* **2026/05/27** 🚀 stable-diffusion.cpp now supports **Lens**
|
||||||
|
* **2026/05/17** 🚀 stable-diffusion.cpp now supports **LTX-2.3**
|
||||||
|
* **2026/04/11** 🚀 stable-diffusion.cpp now uses a brand-new embedded web UI.
|
||||||
|
* **2026/01/18** 🚀 stable-diffusion.cpp now supports **FLUX.2-klein**
|
||||||
* **2025/12/01** 🚀 stable-diffusion.cpp now supports **Z-Image**
|
* **2025/12/01** 🚀 stable-diffusion.cpp now supports **Z-Image**
|
||||||
👉 Details: [PR #1020](https://github.com/leejet/stable-diffusion.cpp/pull/1020)
|
|
||||||
|
|
||||||
* **2025/11/30** 🚀 stable-diffusion.cpp now supports **FLUX.2-dev**
|
* **2025/11/30** 🚀 stable-diffusion.cpp now supports **FLUX.2-dev**
|
||||||
👉 Details: [PR #1016](https://github.com/leejet/stable-diffusion.cpp/pull/1016)
|
|
||||||
|
|
||||||
* **2025/10/13** 🚀 stable-diffusion.cpp now supports **Qwen-Image-Edit / Qwen-Image-Edit 2509**
|
* **2025/10/13** 🚀 stable-diffusion.cpp now supports **Qwen-Image-Edit / Qwen-Image-Edit 2509**
|
||||||
👉 Details: [PR #877](https://github.com/leejet/stable-diffusion.cpp/pull/877)
|
|
||||||
|
|
||||||
* **2025/10/12** 🚀 stable-diffusion.cpp now supports **Qwen-Image**
|
* **2025/10/12** 🚀 stable-diffusion.cpp now supports **Qwen-Image**
|
||||||
👉 Details: [PR #851](https://github.com/leejet/stable-diffusion.cpp/pull/851)
|
|
||||||
|
|
||||||
* **2025/09/14** 🚀 stable-diffusion.cpp now supports **Wan2.1 Vace**
|
* **2025/09/14** 🚀 stable-diffusion.cpp now supports **Wan2.1 Vace**
|
||||||
👉 Details: [PR #819](https://github.com/leejet/stable-diffusion.cpp/pull/819)
|
|
||||||
|
|
||||||
* **2025/09/06** 🚀 stable-diffusion.cpp now supports **Wan2.1 / Wan2.2**
|
* **2025/09/06** 🚀 stable-diffusion.cpp now supports **Wan2.1 / Wan2.2**
|
||||||
👉 Details: [PR #778](https://github.com/leejet/stable-diffusion.cpp/pull/778)
|
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
- Plain C/C++ implementation based on [ggml](https://github.com/ggml-org/ggml), working in the same way as [llama.cpp](https://github.com/ggml-org/llama.cpp)
|
- Plain C/C++ implementation based on [ggml](https://github.com/ggml-org/ggml), working in the same way as [llama.cpp](https://github.com/ggml-org/llama.cpp)
|
||||||
- Super lightweight and without external dependencies
|
- Super lightweight and without external dependencies
|
||||||
|
- Built-in [Web UI](./examples/server/README.md) for image and video generation
|
||||||
- Supported models
|
- Supported models
|
||||||
- Image Models
|
- Image Models
|
||||||
- SD1.x, SD2.x, [SD-Turbo](https://huggingface.co/stabilityai/sd-turbo)
|
- [SD1.x, SD2.x, SD-Turbo](./docs/models/sd.md)
|
||||||
- SDXL, [SDXL-Turbo](https://huggingface.co/stabilityai/sdxl-turbo)
|
- [SDXL, SDXL-Turbo](./docs/models/sd.md)
|
||||||
- [Some SD1.x and SDXL distilled models](./docs/distilled_sd.md)
|
- [Some SD1.x and SDXL distilled models](./docs/models/distilled_sd.md)
|
||||||
- [SD3/SD3.5](./docs/sd3.md)
|
- [SD3/SD3.5](./docs/models/sd3.md)
|
||||||
- [FlUX.1-dev/FlUX.1-schnell](./docs/flux.md)
|
- [FLUX.1-dev/FLUX.1-schnell](./docs/models/flux.md)
|
||||||
- [FLUX.2-dev](./docs/flux2.md)
|
- [FLUX.2-dev/FLUX.2-klein](./docs/models/flux2.md)
|
||||||
- [Chroma](./docs/chroma.md)
|
- [FLUX.3 Image Klein / Klein Base](./docs/models/flux3.md)
|
||||||
- [Chroma1-Radiance](./docs/chroma_radiance.md)
|
- [MOSS-Image-Base / MOSS-Image-SFT](./docs/models/moss_image.md)
|
||||||
- [Qwen Image](./docs/qwen_image.md)
|
- [Fibo 2.0 Dev](./docs/models/fibo2.md)
|
||||||
- [Z-Image](./docs/z_image.md)
|
- [Lens](./docs/models/lens.md)
|
||||||
- [Ovis-Image](./docs/ovis_image.md)
|
- [Chroma](./docs/models/chroma.md)
|
||||||
- Image Edit Models
|
- [Chroma1-Radiance](./docs/models/chroma_radiance.md)
|
||||||
- [FLUX.1-Kontext-dev](./docs/kontext.md)
|
- [Qwen Image](./docs/models/qwen_image.md)
|
||||||
- [Qwen Image Edit series](./docs/qwen_image_edit.md)
|
- [Qwen Image 2.1](./docs/models/qwen_image_2.1.md)
|
||||||
|
- [PiD](./docs/models/pid.md)
|
||||||
|
- [LongCat Image](./docs/models/longcat_image.md)
|
||||||
|
- [Z-Image](./docs/models/z_image.md), including [DGL ControlNet](./docs/models/z_image.md#controlnet)
|
||||||
|
- [Z-Image L2P](./docs/models/z_image_l2p.md)
|
||||||
|
- [MiniT2I](./docs/models/minit2i.md)
|
||||||
|
- [P-H3-Image](./docs/models/p_h3_image.md)
|
||||||
|
- [MiniMax-H3-Image](./docs/models/minimax_h3_image.md)
|
||||||
|
- [SenseNova U1.5](./docs/models/sensenova_u1.md)
|
||||||
|
- [Ovis-Image](./docs/models/ovis_image.md)
|
||||||
|
- [Anima](./docs/models/anima.md)
|
||||||
|
- [ERNIE-Image](./docs/models/ernie_image.md)
|
||||||
|
- [Boogu Image](./docs/models/boogu_image.md)
|
||||||
|
- [Krea2](./docs/models/krea2.md)
|
||||||
|
- [Mage-Flow](./docs/models/mage_flow.md)
|
||||||
|
- [SeFi-Image](./docs/models/sefi_image.md)
|
||||||
|
- [HiDream-O1-Image](./docs/models/hidream_o1_image.md)
|
||||||
|
- [Ideogram4](./docs/models/ideogram4.md)
|
||||||
|
- [LLaDA-Image](./docs/models/llada_image.md)
|
||||||
|
- [Ming-Image Design](./docs/models/ming_image.md)
|
||||||
|
- [PixArt](./docs/models/pixart.md)
|
||||||
|
- [Iris-3B](./docs/models/iris.md)
|
||||||
|
- [Image Edit Models](./docs/guides/edit.md)
|
||||||
|
- [FLUX.1-Kontext-dev](./docs/models/kontext.md)
|
||||||
|
- [Qwen Image Edit series](./docs/models/qwen_image_edit.md)
|
||||||
|
- [LongCat Image Edit](./docs/models/longcat_image.md)
|
||||||
|
- [Boogu Image Edit](./docs/models/boogu_image.md)
|
||||||
|
- [Mage-Flow-Edit](./docs/models/mage_flow.md#image-editing)
|
||||||
|
- [LLaDA-Image Edit](./docs/models/llada_image.md#image-editing)
|
||||||
|
- [Fibo 2.0 Dev / Edit Turbo](./docs/models/fibo2.md#fibo-20-edit-turbo)
|
||||||
|
- [MOSS-Image Edit](./docs/models/moss_image.md#moss-image-edit)
|
||||||
- Video Models
|
- Video Models
|
||||||
- [Wan2.1/Wan2.2](./docs/wan.md)
|
- [Wan2.1/Wan2.2](./docs/models/wan.md)
|
||||||
- [PhotoMaker](https://github.com/TencentARC/PhotoMaker) support.
|
- [MiniMax-H3](./docs/models/minimax_h3.md)
|
||||||
|
- [LTX-2.3/LTX-2.5](./docs/models/ltx2.md)
|
||||||
|
- [HunyuanVideo 1.5](./docs/models/hunyuan_video.md)
|
||||||
|
- [LingBot-Video](./docs/models/lingbot_video.md)
|
||||||
|
- Video Upscale Models
|
||||||
|
- [RelayVSR](./docs/models/relay_vsr.md)
|
||||||
|
- [SeedVR2](./docs/models/seedvr2.md)
|
||||||
|
- [PhotoMaker](./docs/models/photo_maker.md) support.
|
||||||
|
- [IP-Adapter](./docs/models/ip_adapter.md) support (SD 1.5 and SDXL, including Plus)
|
||||||
- Control Net support with SD 1.5
|
- Control Net support with SD 1.5
|
||||||
|
- [ADetailer](./docs/models/adetailer.md)
|
||||||
- LoRA support, same as [stable-diffusion-webui](https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Features#lora)
|
- LoRA support, same as [stable-diffusion-webui](https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Features#lora)
|
||||||
|
- [Textual inversion embeddings](./docs/embeddings.md) for SD 1.x/2.x/SDXL via `--embd-dir` and `<embedding:...>` tags
|
||||||
- Latent Consistency Models support (LCM/LCM-LoRA)
|
- Latent Consistency Models support (LCM/LCM-LoRA)
|
||||||
- Faster and memory efficient latent decoding with [TAESD](https://github.com/madebyollin/taesd)
|
- Faster and memory efficient latent decoding with [TAESD](./docs/models/taesd.md)
|
||||||
- Upscale images generated with [ESRGAN](https://github.com/xinntao/Real-ESRGAN)
|
- Upscale images generated with [ESRGAN](./docs/models/esrgan.md)
|
||||||
- Supported backends
|
- Supported backends
|
||||||
- CPU (AVX, AVX2 and AVX512 support for x86 architectures)
|
- CPU (AVX, AVX2 and AVX512 support for x86 architectures)
|
||||||
- CUDA
|
- CUDA
|
||||||
|
|
@ -69,9 +112,10 @@ API and command-line option may change frequently.***
|
||||||
- OpenCL
|
- OpenCL
|
||||||
- SYCL
|
- SYCL
|
||||||
- Supported weight formats
|
- Supported weight formats
|
||||||
- Pytorch checkpoint (`.ckpt` or `.pth`)
|
- Pytorch checkpoint (`.ckpt` or `.pth` or `.pt`)
|
||||||
- Safetensors (`./safetensors`)
|
- Safetensors (`.safetensors`)
|
||||||
- GGUF (`.gguf`)
|
- GGUF (`.gguf`)
|
||||||
|
- Convert mode supports converting model weights to `.gguf` or `.safetensors`
|
||||||
- Supported platforms
|
- Supported platforms
|
||||||
- Linux
|
- Linux
|
||||||
- Mac OS
|
- Mac OS
|
||||||
|
|
@ -81,15 +125,7 @@ API and command-line option may change frequently.***
|
||||||
- Negative prompt
|
- Negative prompt
|
||||||
- [stable-diffusion-webui](https://github.com/AUTOMATIC1111/stable-diffusion-webui) style tokenizer (not all the features, only token weighting for now)
|
- [stable-diffusion-webui](https://github.com/AUTOMATIC1111/stable-diffusion-webui) style tokenizer (not all the features, only token weighting for now)
|
||||||
- VAE tiling processing for reduce memory usage
|
- VAE tiling processing for reduce memory usage
|
||||||
- Sampling method
|
- Support for a wide range of [sampling methods and schedulers](./docs/guides/sampling.md)
|
||||||
- `Euler A`
|
|
||||||
- `Euler`
|
|
||||||
- `Heun`
|
|
||||||
- `DPM2`
|
|
||||||
- `DPM++ 2M`
|
|
||||||
- [`DPM++ 2M v2`](https://github.com/AUTOMATIC1111/stable-diffusion-webui/discussions/8457)
|
|
||||||
- `DPM++ 2S a`
|
|
||||||
- [`LCM`](https://github.com/AUTOMATIC1111/stable-diffusion-webui/issues/13952)
|
|
||||||
- Cross-platform reproducibility
|
- Cross-platform reproducibility
|
||||||
- `--rng cuda`, default, consistent with the `stable-diffusion-webui GPU RNG`
|
- `--rng cuda`, default, consistent with the `stable-diffusion-webui GPU RNG`
|
||||||
- `--rng cpu`, consistent with the `comfyui RNG`
|
- `--rng cpu`, consistent with the `comfyui RNG`
|
||||||
|
|
@ -97,100 +133,96 @@ API and command-line option may change frequently.***
|
||||||
|
|
||||||
## Quick Start
|
## Quick Start
|
||||||
|
|
||||||
### Get the sd executable
|
### Get the executables
|
||||||
|
|
||||||
- Download pre-built binaries from the [releases page](https://github.com/leejet/stable-diffusion.cpp/releases)
|
- Download and extract pre-built binaries from the [releases page](https://github.com/leejet/stable-diffusion.cpp/releases)
|
||||||
- Or build from source by following the [build guide](./docs/build.md)
|
- Or build from source by following the [build guide](./docs/build.md)
|
||||||
|
|
||||||
|
The executable examples below run from the build directory (`cd build` from
|
||||||
|
the repository root). Windows examples use the Visual Studio Release path;
|
||||||
|
adjust the executable path for other build configurations or extracted archives.
|
||||||
|
Model files stay under the repository's `models/` directory.
|
||||||
|
|
||||||
### Download model weights
|
### Download model weights
|
||||||
|
|
||||||
- download weights(.ckpt or .safetensors or .gguf). For example
|
Choose a model from the [model guides](./docs/models/README.md) and download its
|
||||||
- Stable Diffusion v1.5 from https://huggingface.co/stable-diffusion-v1-5/stable-diffusion-v1-5
|
weights and required components. For a simple example, save Stable Diffusion 1.5
|
||||||
|
under `models/checkpoints/`:
|
||||||
|
|
||||||
```sh
|
**Windows (PowerShell)**
|
||||||
curl -L -O https://huggingface.co/runwayml/stable-diffusion-v1-5/resolve/main/v1-5-pruned-emaonly.safetensors
|
|
||||||
```
|
|
||||||
|
|
||||||
### Generate an image with just one command
|
```powershell
|
||||||
|
New-Item -ItemType Directory -Force ..\models\checkpoints | Out-Null
|
||||||
```sh
|
curl.exe -L -o ..\models\checkpoints\v1-5-pruned-emaonly.safetensors https://huggingface.co/stable-diffusion-v1-5/stable-diffusion-v1-5/resolve/main/v1-5-pruned-emaonly.safetensors
|
||||||
./bin/sd-cli -m ../models/v1-5-pruned-emaonly.safetensors -p "a lovely cat"
|
|
||||||
```
|
```
|
||||||
|
|
||||||
***For detailed command-line arguments, check out [cli doc](./examples/cli/README.md).***
|
**Linux/macOS**
|
||||||
|
|
||||||
|
```sh
|
||||||
|
mkdir -p ../models/checkpoints
|
||||||
|
curl -L -o ../models/checkpoints/v1-5-pruned-emaonly.safetensors https://huggingface.co/stable-diffusion-v1-5/stable-diffusion-v1-5/resolve/main/v1-5-pruned-emaonly.safetensors
|
||||||
|
```
|
||||||
|
|
||||||
|
### Option 1: Web UI
|
||||||
|
|
||||||
|
Start the server:
|
||||||
|
|
||||||
|
**Windows (PowerShell)**
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
.\bin\Release\sd-server.exe --model-dir ..\models
|
||||||
|
```
|
||||||
|
|
||||||
|
**Linux/macOS**
|
||||||
|
|
||||||
|
```sh
|
||||||
|
./bin/sd-server --model-dir ../models
|
||||||
|
```
|
||||||
|
|
||||||
|
Open <http://127.0.0.1:1234/>, choose **SD 1.x** in **Recipe**, select the
|
||||||
|
checkpoint, and click **Load models**. Enter a prompt and click **Generate**.
|
||||||
|
See the [Web UI guide](./examples/server/README.md#web-ui) for the full workflow.
|
||||||
|
|
||||||
|
### Option 2: CLI
|
||||||
|
|
||||||
|
Generate an image with one command:
|
||||||
|
|
||||||
|
**Windows (PowerShell)**
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
.\bin\Release\sd-cli.exe -m ..\models\checkpoints\v1-5-pruned-emaonly.safetensors -p "a lovely cat"
|
||||||
|
```
|
||||||
|
|
||||||
|
**Linux/macOS**
|
||||||
|
|
||||||
|
```sh
|
||||||
|
./bin/sd-cli -m ../models/checkpoints/v1-5-pruned-emaonly.safetensors -p "a lovely cat"
|
||||||
|
```
|
||||||
|
|
||||||
|
Run `.\bin\Release\sd-cli.exe --help` on Windows or `./bin/sd-cli --help` on
|
||||||
|
Linux/macOS for all command-line options. See the
|
||||||
|
[CLI guide](./examples/cli/README.md) for additional usage notes.
|
||||||
|
|
||||||
## Performance
|
## Performance
|
||||||
|
|
||||||
If you want to improve performance or reduce VRAM/RAM usage, please refer to [performance guide](./docs/performance.md).
|
If you want to improve performance or reduce VRAM/RAM usage, please refer to [performance guide](./docs/guides/performance.md).
|
||||||
|
For runtime and parameter backend placement, see the [backend selection guide](./docs/guides/backend.md).
|
||||||
|
|
||||||
## More Guides
|
## Documentation
|
||||||
|
|
||||||
- [SD1.x/SD2.x/SDXL](./docs/sd.md)
|
Browse the [documentation index](./docs/README.md) or jump to a topic:
|
||||||
- [SD3/SD3.5](./docs/sd3.md)
|
|
||||||
- [FlUX.1-dev/FlUX.1-schnell](./docs/flux.md)
|
|
||||||
- [FLUX.2-dev](./docs/flux2.md)
|
|
||||||
- [FLUX.1-Kontext-dev](./docs/kontext.md)
|
|
||||||
- [Chroma](./docs/chroma.md)
|
|
||||||
- [🔥Qwen Image](./docs/qwen_image.md)
|
|
||||||
- [🔥Qwen Image Edit series](./docs/qwen_image_edit.md)
|
|
||||||
- [🔥Wan2.1/Wan2.2](./docs/wan.md)
|
|
||||||
- [🔥Z-Image](./docs/z_image.md)
|
|
||||||
- [Ovis-Image](./docs/ovis_image.md)
|
|
||||||
- [LoRA](./docs/lora.md)
|
|
||||||
- [LCM/LCM-LoRA](./docs/lcm.md)
|
|
||||||
- [Using PhotoMaker to personalize image generation](./docs/photo_maker.md)
|
|
||||||
- [Using ESRGAN to upscale results](./docs/esrgan.md)
|
|
||||||
- [Using TAESD to faster decoding](./docs/taesd.md)
|
|
||||||
- [Docker](./docs/docker.md)
|
|
||||||
- [Quantization and GGUF](./docs/quantization_and_gguf.md)
|
|
||||||
- [Inference acceleration via caching](./docs/caching.md)
|
|
||||||
|
|
||||||
## Bindings
|
- [Getting started: build, Docker, CLI, and server](./docs/README.md#get-started)
|
||||||
|
- [Models and components](./docs/models/README.md)
|
||||||
These projects wrap `stable-diffusion.cpp` for easier use in other languages/frameworks.
|
- [Generation and inputs](./docs/README.md#generation-and-inputs)
|
||||||
|
- [DGL generation scripts](./docs/dgl.md)
|
||||||
* Golang (non-cgo): [seasonjs/stable-diffusion](https://github.com/seasonjs/stable-diffusion)
|
- [Devices and performance](./docs/README.md#devices-and-performance)
|
||||||
* Golang (cgo): [Binozo/GoStableDiffusion](https://github.com/Binozo/GoStableDiffusion)
|
- [Weights and quantization](./docs/README.md#weights-and-quantization)
|
||||||
* C#: [DarthAffe/StableDiffusion.NET](https://github.com/DarthAffe/StableDiffusion.NET)
|
- [Troubleshooting](./docs/troubleshooting.md)
|
||||||
* Python: [william-murray1204/stable-diffusion-cpp-python](https://github.com/william-murray1204/stable-diffusion-cpp-python)
|
- [Development and contributing](./docs/README.md#development)
|
||||||
* Rust: [newfla/diffusion-rs](https://github.com/newfla/diffusion-rs)
|
|
||||||
* Flutter/Dart: [rmatif/Local-Diffusion](https://github.com/rmatif/Local-Diffusion)
|
|
||||||
|
|
||||||
## UIs
|
|
||||||
|
|
||||||
These projects use `stable-diffusion.cpp` as a backend for their image generation.
|
|
||||||
|
|
||||||
- [Jellybox](https://jellybox.com)
|
|
||||||
- [Stable Diffusion GUI](https://github.com/fszontagh/sd.cpp.gui.wx)
|
|
||||||
- [Stable Diffusion CLI-GUI](https://github.com/piallai/stable-diffusion.cpp)
|
|
||||||
- [Local Diffusion](https://github.com/rmatif/Local-Diffusion)
|
|
||||||
- [sd.cpp-webui](https://github.com/daniandtheweb/sd.cpp-webui)
|
|
||||||
- [LocalAI](https://github.com/mudler/LocalAI)
|
|
||||||
- [Neural-Pixel](https://github.com/Luiz-Alcantara/Neural-Pixel)
|
|
||||||
- [KoboldCpp](https://github.com/LostRuins/koboldcpp)
|
|
||||||
|
|
||||||
## Contributors
|
## Contributors
|
||||||
|
|
||||||
Thank you to all the people who have already contributed to stable-diffusion.cpp!
|
Thank you to all the people who have already contributed to stable-diffusion.cpp!
|
||||||
|
|
||||||
[](https://github.com/leejet/stable-diffusion.cpp/graphs/contributors)
|
[](https://github.com/leejet/stable-diffusion.cpp/graphs/contributors)
|
||||||
|
|
||||||
## Star History
|
|
||||||
|
|
||||||
[](https://star-history.com/#leejet/stable-diffusion.cpp&Date)
|
|
||||||
|
|
||||||
## References
|
|
||||||
|
|
||||||
- [ggml](https://github.com/ggml-org/ggml)
|
|
||||||
- [diffusers](https://github.com/huggingface/diffusers)
|
|
||||||
- [stable-diffusion](https://github.com/CompVis/stable-diffusion)
|
|
||||||
- [sd3-ref](https://github.com/Stability-AI/sd3-ref)
|
|
||||||
- [stable-diffusion-stability-ai](https://github.com/Stability-AI/stablediffusion)
|
|
||||||
- [stable-diffusion-webui](https://github.com/AUTOMATIC1111/stable-diffusion-webui)
|
|
||||||
- [ComfyUI](https://github.com/comfyanonymous/ComfyUI)
|
|
||||||
- [k-diffusion](https://github.com/crowsonkb/k-diffusion)
|
|
||||||
- [latent-consistency-model](https://github.com/luosiallen/latent-consistency-model)
|
|
||||||
- [generative-models](https://github.com/Stability-AI/generative-models/)
|
|
||||||
- [PhotoMaker](https://github.com/TencentARC/PhotoMaker)
|
|
||||||
- [Wan2.1](https://github.com/Wan-Video/Wan2.1)
|
|
||||||
- [Wan2.2](https://github.com/Wan-Video/Wan2.2)
|
|
||||||
|
|
|
||||||
BIN
assets/anima/example.png
Normal file
|
After Width: | Height: | Size: 230 KiB |
BIN
assets/animatediff/img2video_demo.gif
Normal file
|
After Width: | Height: | Size: 1.7 MiB |
BIN
assets/animatediff/v2_coast.gif
Normal file
|
After Width: | Height: | Size: 1.4 MiB |
BIN
assets/animatediff/v2_house.gif
Normal file
|
After Width: | Height: | Size: 1.8 MiB |
BIN
assets/animatediff/v2_man.gif
Normal file
|
After Width: | Height: | Size: 1.6 MiB |
BIN
assets/animatediff/v2_rabbit.gif
Normal file
|
After Width: | Height: | Size: 1,002 KiB |
BIN
assets/animatediff/v3_coast.gif
Normal file
|
After Width: | Height: | Size: 1.1 MiB |
BIN
assets/animatediff/v3_house.gif
Normal file
|
After Width: | Height: | Size: 1.8 MiB |
BIN
assets/animatediff/v3_man.gif
Normal file
|
After Width: | Height: | Size: 1.8 MiB |
BIN
assets/animatediff/v3_rabbit.gif
Normal file
|
After Width: | Height: | Size: 1.2 MiB |
BIN
assets/animatediff/v3_rabbit_domain_lora.gif
Normal file
|
After Width: | Height: | Size: 1.4 MiB |
BIN
assets/boogu/edit_example.png
Normal file
|
After Width: | Height: | Size: 477 KiB |
BIN
assets/boogu/example.png
Normal file
|
After Width: | Height: | Size: 489 KiB |
BIN
assets/ernie_image/example.png
Normal file
|
After Width: | Height: | Size: 595 KiB |
BIN
assets/ernie_image/turbo_example.png
Normal file
|
After Width: | Height: | Size: 562 KiB |
BIN
assets/fibo2/dev_edit.png
Normal file
|
After Width: | Height: | Size: 500 KiB |
BIN
assets/fibo2/t2i.png
Normal file
|
After Width: | Height: | Size: 501 KiB |
BIN
assets/flux2/flux2-klein-4b-edit.png
Normal file
|
After Width: | Height: | Size: 510 KiB |
BIN
assets/flux2/flux2-klein-4b.png
Normal file
|
After Width: | Height: | Size: 455 KiB |
BIN
assets/flux2/flux2-klein-9b-edit.png
Normal file
|
After Width: | Height: | Size: 511 KiB |
BIN
assets/flux2/flux2-klein-9b.png
Normal file
|
After Width: | Height: | Size: 491 KiB |
BIN
assets/flux2/flux2-klein-base-4b.png
Normal file
|
After Width: | Height: | Size: 464 KiB |
BIN
assets/flux2/flux2-klein-base-9b.png
Normal file
|
After Width: | Height: | Size: 552 KiB |
BIN
assets/flux3/flux3-image-klein-base.png
Normal file
|
After Width: | Height: | Size: 232 KiB |
BIN
assets/flux3/flux3-image-klein-edit.png
Normal file
|
After Width: | Height: | Size: 488 KiB |
BIN
assets/flux3/flux3-image-klein.png
Normal file
|
After Width: | Height: | Size: 611 KiB |
BIN
assets/hidream-o1/dev_example.png
Normal file
|
After Width: | Height: | Size: 1.2 MiB |
BIN
assets/huanyuan_video/hy1.5_t2v.mp4
Normal file
BIN
assets/hunyuan_video/hy1.5_t2v.mp4
Normal file
BIN
assets/ideogram4/example.png
Normal file
|
After Width: | Height: | Size: 2.5 MiB |
BIN
assets/iris/example.png
Normal file
|
After Width: | Height: | Size: 1.4 MiB |
BIN
assets/krea2/example.png
Normal file
|
After Width: | Height: | Size: 289 KiB |
BIN
assets/lens/example.png
Normal file
|
After Width: | Height: | Size: 630 KiB |
BIN
assets/lens/turbo_example.png
Normal file
|
After Width: | Height: | Size: 555 KiB |
BIN
assets/llada_image/edit_example.png
Normal file
|
After Width: | Height: | Size: 478 KiB |
BIN
assets/llada_image/example.png
Normal file
|
After Width: | Height: | Size: 437 KiB |
BIN
assets/longcat/example.png
Normal file
|
After Width: | Height: | Size: 423 KiB |
BIN
assets/ltx2/flf2v.webm
Normal file
BIN
assets/ltx2/hires_i2v.webm
Normal file
BIN
assets/ltx2/i2v.webm
Normal file
BIN
assets/ltx2/t2v.webm
Normal file
BIN
assets/mage_flow/edit_example.png
Normal file
|
After Width: | Height: | Size: 466 KiB |
BIN
assets/mage_flow/example.png
Normal file
|
After Width: | Height: | Size: 399 KiB |
BIN
assets/minimax-h3/i2av.mp4
Normal file
BIN
assets/minimax-h3/r2av.mp4
Normal file
BIN
assets/minimax-h3/t2av.mp4
Normal file
BIN
assets/moss/sft.png
Normal file
|
After Width: | Height: | Size: 2.1 MiB |
BIN
assets/pid/example.png
Normal file
|
After Width: | Height: | Size: 9 MiB |
BIN
assets/qwen/qwen-image-2.1-alpha-in1.png
Normal file
|
After Width: | Height: | Size: 399 KiB |
BIN
assets/qwen/qwen-image-2.1-alpha-out1.png
Normal file
|
After Width: | Height: | Size: 2 MiB |
BIN
assets/qwen/qwen-image-2.1-alpha-out2.png
Normal file
|
After Width: | Height: | Size: 1.1 MiB |
BIN
assets/qwen/qwen_image_2.1.png
Normal file
|
After Width: | Height: | Size: 634 KiB |
BIN
assets/sefi_image/example.png
Normal file
|
After Width: | Height: | Size: 1.7 MiB |
BIN
assets/wan/Wan2.2_A14B_vace_r2v.mp4
Normal file
BIN
assets/z_image/base_bf16.png
Normal file
|
After Width: | Height: | Size: 870 KiB |
17
cmake/backend_extensions.h.in
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
#ifndef __SD_BACKEND_EXTENSIONS_H__
|
||||||
|
#define __SD_BACKEND_EXTENSIONS_H__
|
||||||
|
|
||||||
|
#include "core/cuda/registration.h"
|
||||||
|
|
||||||
|
void sd_ggml_register_metal_i8(ggml_backend_dev_t device);
|
||||||
|
|
||||||
|
void sd_ggml_register_vulkan_rope(ggml_backend_dev_t device);
|
||||||
|
void sd_ggml_register_vulkan_i8(ggml_backend_dev_t device);
|
||||||
|
void sd_ggml_register_vulkan_rms_affine(ggml_backend_dev_t device);
|
||||||
|
void sd_ggml_register_vulkan_modulate(ggml_backend_dev_t device);
|
||||||
|
|
||||||
|
static void (*const sd_backend_extensions[])(ggml_backend_dev_t) = {
|
||||||
|
@SD_BACKEND_REGISTRATIONS@
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
20
cmake/cutlass.cmake
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
set(sd_cutlass_default "${PROJECT_SOURCE_DIR}/thirdparty/cutlass")
|
||||||
|
if(NOT DEFINED SD_CUDA_CUTLASS_PATH AND DEFINED GGML_CUDA_CUTLASS_PATH)
|
||||||
|
get_filename_component(sd_old_cutlass_default "${SD_GGML_SOURCE_DIR}/src/ggml-cuda/vendors/cutlass" ABSOLUTE)
|
||||||
|
if(NOT GGML_CUDA_CUTLASS_PATH STREQUAL sd_old_cutlass_default)
|
||||||
|
set(sd_cutlass_default "${GGML_CUDA_CUTLASS_PATH}")
|
||||||
|
endif()
|
||||||
|
message(STATUS "Migrating GGML_CUDA_CUTLASS_PATH to SD_CUDA_CUTLASS_PATH")
|
||||||
|
endif()
|
||||||
|
set(SD_CUDA_CUTLASS_PATH "${sd_cutlass_default}" CACHE PATH "sd: CUTLASS source directory for INT8 GEMM and CuTe attention, empty to disable")
|
||||||
|
unset(GGML_CUDA_CUTLASS_PATH CACHE)
|
||||||
|
if(SD_CUDA_CUTLASS_PATH)
|
||||||
|
if(NOT EXISTS "${SD_CUDA_CUTLASS_PATH}/include/cutlass/gemm/kernel/default_gemm_universal_with_visitor.h" OR
|
||||||
|
NOT EXISTS "${SD_CUDA_CUTLASS_PATH}/include/cute/tensor.hpp")
|
||||||
|
message(FATAL_ERROR
|
||||||
|
"CUTLASS headers not found at ${SD_CUDA_CUTLASS_PATH}. "
|
||||||
|
"Run git submodule update --init --recursive from the sd.cpp repository root, "
|
||||||
|
"set SD_CUDA_CUTLASS_PATH to a CUTLASS source tree (tested with 3.9.2), "
|
||||||
|
"or set SD_CUDA_CUTLASS_PATH to an empty string to disable CUTLASS.")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
3
cmake/embed_spirv.cmake
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
file(READ "${INPUT}" SPIRV HEX)
|
||||||
|
string(REGEX REPLACE "(..)(..)(..)(..)" "0x\\4\\3\\2\\1," SPIRV_WORDS "${SPIRV}")
|
||||||
|
file(WRITE "${OUTPUT}" "#include <cstdint>\nnamespace sd_vulkan_shaders {\nstatic const uint32_t ${NAME}[] = {${SPIRV_WORDS}};\n}\n")
|
||||||
29
cmake/ggml.cmake
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
if(NOT TARGET ggml AND NOT TARGET ggml::ggml)
|
||||||
|
if(SD_USE_SYSTEM_GGML)
|
||||||
|
find_package(ggml REQUIRED)
|
||||||
|
else()
|
||||||
|
add_subdirectory("${SD_GGML_SOURCE_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/ggml")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
if(NOT TARGET ggml)
|
||||||
|
add_library(ggml ALIAS ggml::ggml)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(SD_USE_UPSTREAM_GGML)
|
||||||
|
get_target_property(sd_ggml_imported ggml IMPORTED)
|
||||||
|
if(sd_ggml_imported)
|
||||||
|
set(sd_ggml_private_include "${SD_GGML_SOURCE_DIR}/src")
|
||||||
|
else()
|
||||||
|
get_target_property(sd_ggml_private_include ggml SOURCE_DIR)
|
||||||
|
endif()
|
||||||
|
if(NOT EXISTS "${sd_ggml_private_include}/ggml-impl.h")
|
||||||
|
message(FATAL_ERROR "Set SD_GGML_SOURCE_DIR to the source tree matching the selected ggml library (ggml-impl.h is required).")
|
||||||
|
endif()
|
||||||
|
target_include_directories(${SD_LIB} PRIVATE "${sd_ggml_private_include}")
|
||||||
|
set_property(TARGET ${SD_LIB} PROPERTY SD_GGML_PRIVATE_INCLUDE_DIR "${sd_ggml_private_include}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(SD_USE_UPSTREAM_GGML)
|
||||||
|
target_compile_definitions(${SD_LIB} PUBLIC SD_USE_UPSTREAM_GGML)
|
||||||
|
message(WARNING "Using upstream GGML: INT8 tensorwise/convrot is disabled and FP8 weights are converted to F16 at load time. Some operators may be unsupported and performance may be lower than with patched GGML.")
|
||||||
|
endif()
|
||||||
12
cmake/hip.cmake
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
if(NOT WIN32 AND NOT CMAKE_CXX_COMPILER MATCHES "hipcc")
|
||||||
|
if(NOT CMAKE_HIP_ARCHITECTURES)
|
||||||
|
if(GPU_TARGETS)
|
||||||
|
set(CMAKE_HIP_ARCHITECTURES ${GPU_TARGETS})
|
||||||
|
elseif(AMDGPU_TARGETS)
|
||||||
|
set(CMAKE_HIP_ARCHITECTURES ${AMDGPU_TARGETS})
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
# HIP objects are linked by the parent target, so initialize its link rules here.
|
||||||
|
enable_language(HIP)
|
||||||
|
set_property(TARGET ${SD_LIB} PROPERTY HIP_ARCHITECTURES "${CMAKE_HIP_ARCHITECTURES}")
|
||||||
|
endif()
|
||||||
45
cmake/stable-diffusion-config.cmake.in
Normal file
|
|
@ -0,0 +1,45 @@
|
||||||
|
set(SD_VERSION "@SD_INSTALL_VERSION@")
|
||||||
|
set(SD_BUILD_COMMIT "@SD_INSTALL_COMMIT@")
|
||||||
|
set(SD_SHARED_LIB @SD_SHARED_LIB@)
|
||||||
|
|
||||||
|
@PACKAGE_INIT@
|
||||||
|
|
||||||
|
set_and_check(SD_INCLUDE_DIR "@PACKAGE_SD_INCLUDE_INSTALL_DIR@")
|
||||||
|
set_and_check(SD_LIB_DIR "@PACKAGE_SD_LIB_INSTALL_DIR@")
|
||||||
|
set(SD_BIN_DIR "@PACKAGE_SD_BIN_INSTALL_DIR@")
|
||||||
|
|
||||||
|
include(CMakeFindDependencyMacro)
|
||||||
|
find_dependency(ggml REQUIRED HINTS "${SD_LIB_DIR}/cmake")
|
||||||
|
find_dependency(Threads REQUIRED)
|
||||||
|
if(@SD_CUDA@)
|
||||||
|
find_dependency(CUDAToolkit REQUIRED)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT TARGET stable-diffusion)
|
||||||
|
find_library(stable-diffusion_LIBRARY stable-diffusion
|
||||||
|
REQUIRED
|
||||||
|
HINTS "${SD_LIB_DIR}"
|
||||||
|
NO_CMAKE_FIND_ROOT_PATH
|
||||||
|
)
|
||||||
|
|
||||||
|
add_library(stable-diffusion UNKNOWN IMPORTED)
|
||||||
|
set_target_properties(stable-diffusion
|
||||||
|
PROPERTIES
|
||||||
|
INTERFACE_INCLUDE_DIRECTORIES "${SD_INCLUDE_DIR}"
|
||||||
|
INTERFACE_LINK_LIBRARIES "ggml::ggml;Threads::Threads"
|
||||||
|
IMPORTED_LINK_INTERFACE_LANGUAGES "CXX"
|
||||||
|
IMPORTED_LOCATION "${stable-diffusion_LIBRARY}"
|
||||||
|
INTERFACE_COMPILE_FEATURES "c_std_11;cxx_std_17"
|
||||||
|
POSITION_INDEPENDENT_CODE ON)
|
||||||
|
|
||||||
|
if(@SD_CUDA@)
|
||||||
|
set_property(TARGET stable-diffusion APPEND PROPERTY INTERFACE_LINK_LIBRARIES CUDA::cuda_driver)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(SD_SHARED_LIB)
|
||||||
|
target_compile_definitions(stable-diffusion
|
||||||
|
INTERFACE SD_BUILD_SHARED_LIB)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
check_required_components(stable-diffusion)
|
||||||
11
cmake/stable-diffusion.pc.in
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
prefix=@CMAKE_INSTALL_PREFIX@
|
||||||
|
exec_prefix=${prefix}
|
||||||
|
libdir=@CMAKE_INSTALL_FULL_LIBDIR@
|
||||||
|
includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@
|
||||||
|
|
||||||
|
Name: stable-diffusion
|
||||||
|
Description: Diffusion model(SD,Flux,Wan,Qwen Image,Z-Image,...) inference in pure C/C++
|
||||||
|
Version: @SDCPP_BUILD_VERSION@
|
||||||
|
Libs: -L${libdir} -lstable-diffusion
|
||||||
|
Libs.private: -lggml -lggml-base @CMAKE_THREAD_LIBS_INIT@
|
||||||
|
Cflags: -I${includedir}
|
||||||
1897
conditioner.hpp
466
control.hpp
|
|
@ -1,466 +0,0 @@
|
||||||
#ifndef __CONTROL_HPP__
|
|
||||||
#define __CONTROL_HPP__
|
|
||||||
|
|
||||||
#include "common.hpp"
|
|
||||||
#include "ggml_extend.hpp"
|
|
||||||
#include "model.h"
|
|
||||||
|
|
||||||
#define CONTROL_NET_GRAPH_SIZE 1536
|
|
||||||
|
|
||||||
/*
|
|
||||||
=================================== ControlNet ===================================
|
|
||||||
Reference: https://github.com/comfyanonymous/ComfyUI/blob/master/comfy/cldm/cldm.py
|
|
||||||
|
|
||||||
*/
|
|
||||||
class ControlNetBlock : public GGMLBlock {
|
|
||||||
protected:
|
|
||||||
SDVersion version = VERSION_SD1;
|
|
||||||
// network hparams
|
|
||||||
int in_channels = 4;
|
|
||||||
int out_channels = 4;
|
|
||||||
int hint_channels = 3;
|
|
||||||
int num_res_blocks = 2;
|
|
||||||
std::vector<int> attention_resolutions = {4, 2, 1};
|
|
||||||
std::vector<int> channel_mult = {1, 2, 4, 4};
|
|
||||||
std::vector<int> transformer_depth = {1, 1, 1, 1};
|
|
||||||
int time_embed_dim = 1280; // model_channels*4
|
|
||||||
int num_heads = 8;
|
|
||||||
int num_head_channels = -1; // channels // num_heads
|
|
||||||
int context_dim = 768; // 1024 for VERSION_SD2, 2048 for VERSION_SDXL
|
|
||||||
bool use_linear_projection = false;
|
|
||||||
|
|
||||||
public:
|
|
||||||
int model_channels = 320;
|
|
||||||
int adm_in_channels = 2816; // only for VERSION_SDXL
|
|
||||||
|
|
||||||
ControlNetBlock(SDVersion version = VERSION_SD1)
|
|
||||||
: version(version) {
|
|
||||||
if (sd_version_is_sd2(version)) {
|
|
||||||
context_dim = 1024;
|
|
||||||
num_head_channels = 64;
|
|
||||||
num_heads = -1;
|
|
||||||
} else if (sd_version_is_sdxl(version)) {
|
|
||||||
context_dim = 2048;
|
|
||||||
attention_resolutions = {4, 2};
|
|
||||||
channel_mult = {1, 2, 4};
|
|
||||||
transformer_depth = {1, 2, 10};
|
|
||||||
num_head_channels = 64;
|
|
||||||
num_heads = -1;
|
|
||||||
} else if (version == VERSION_SVD) {
|
|
||||||
in_channels = 8;
|
|
||||||
out_channels = 4;
|
|
||||||
context_dim = 1024;
|
|
||||||
adm_in_channels = 768;
|
|
||||||
num_head_channels = 64;
|
|
||||||
num_heads = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
blocks["time_embed.0"] = std::shared_ptr<GGMLBlock>(new Linear(model_channels, time_embed_dim));
|
|
||||||
// time_embed_1 is nn.SiLU()
|
|
||||||
blocks["time_embed.2"] = std::shared_ptr<GGMLBlock>(new Linear(time_embed_dim, time_embed_dim));
|
|
||||||
|
|
||||||
if (sd_version_is_sdxl(version) || version == VERSION_SVD) {
|
|
||||||
blocks["label_emb.0.0"] = std::shared_ptr<GGMLBlock>(new Linear(adm_in_channels, time_embed_dim));
|
|
||||||
// label_emb_1 is nn.SiLU()
|
|
||||||
blocks["label_emb.0.2"] = std::shared_ptr<GGMLBlock>(new Linear(time_embed_dim, time_embed_dim));
|
|
||||||
}
|
|
||||||
|
|
||||||
// input_blocks
|
|
||||||
blocks["input_blocks.0.0"] = std::shared_ptr<GGMLBlock>(new Conv2d(in_channels, model_channels, {3, 3}, {1, 1}, {1, 1}));
|
|
||||||
|
|
||||||
std::vector<int> input_block_chans;
|
|
||||||
input_block_chans.push_back(model_channels);
|
|
||||||
int ch = model_channels;
|
|
||||||
int input_block_idx = 0;
|
|
||||||
int ds = 1;
|
|
||||||
|
|
||||||
auto get_resblock = [&](int64_t channels, int64_t emb_channels, int64_t out_channels) -> ResBlock* {
|
|
||||||
return new ResBlock(channels, emb_channels, out_channels);
|
|
||||||
};
|
|
||||||
|
|
||||||
auto get_attention_layer = [&](int64_t in_channels,
|
|
||||||
int64_t n_head,
|
|
||||||
int64_t d_head,
|
|
||||||
int64_t depth,
|
|
||||||
int64_t context_dim) -> SpatialTransformer* {
|
|
||||||
return new SpatialTransformer(in_channels, n_head, d_head, depth, context_dim, use_linear_projection);
|
|
||||||
};
|
|
||||||
|
|
||||||
auto make_zero_conv = [&](int64_t channels) {
|
|
||||||
return new Conv2d(channels, channels, {1, 1});
|
|
||||||
};
|
|
||||||
|
|
||||||
blocks["zero_convs.0.0"] = std::shared_ptr<GGMLBlock>(make_zero_conv(model_channels));
|
|
||||||
|
|
||||||
blocks["input_hint_block.0"] = std::shared_ptr<GGMLBlock>(new Conv2d(hint_channels, 16, {3, 3}, {1, 1}, {1, 1}));
|
|
||||||
// nn.SiLU()
|
|
||||||
blocks["input_hint_block.2"] = std::shared_ptr<GGMLBlock>(new Conv2d(16, 16, {3, 3}, {1, 1}, {1, 1}));
|
|
||||||
// nn.SiLU()
|
|
||||||
blocks["input_hint_block.4"] = std::shared_ptr<GGMLBlock>(new Conv2d(16, 32, {3, 3}, {2, 2}, {1, 1}));
|
|
||||||
// nn.SiLU()
|
|
||||||
blocks["input_hint_block.6"] = std::shared_ptr<GGMLBlock>(new Conv2d(32, 32, {3, 3}, {1, 1}, {1, 1}));
|
|
||||||
// nn.SiLU()
|
|
||||||
blocks["input_hint_block.8"] = std::shared_ptr<GGMLBlock>(new Conv2d(32, 96, {3, 3}, {2, 2}, {1, 1}));
|
|
||||||
// nn.SiLU()
|
|
||||||
blocks["input_hint_block.10"] = std::shared_ptr<GGMLBlock>(new Conv2d(96, 96, {3, 3}, {1, 1}, {1, 1}));
|
|
||||||
// nn.SiLU()
|
|
||||||
blocks["input_hint_block.12"] = std::shared_ptr<GGMLBlock>(new Conv2d(96, 256, {3, 3}, {2, 2}, {1, 1}));
|
|
||||||
// nn.SiLU()
|
|
||||||
blocks["input_hint_block.14"] = std::shared_ptr<GGMLBlock>(new Conv2d(256, model_channels, {3, 3}, {1, 1}, {1, 1}));
|
|
||||||
|
|
||||||
size_t len_mults = channel_mult.size();
|
|
||||||
for (int i = 0; i < len_mults; i++) {
|
|
||||||
int mult = channel_mult[i];
|
|
||||||
for (int j = 0; j < num_res_blocks; j++) {
|
|
||||||
input_block_idx += 1;
|
|
||||||
std::string name = "input_blocks." + std::to_string(input_block_idx) + ".0";
|
|
||||||
blocks[name] = std::shared_ptr<GGMLBlock>(get_resblock(ch, time_embed_dim, mult * model_channels));
|
|
||||||
|
|
||||||
ch = mult * model_channels;
|
|
||||||
if (std::find(attention_resolutions.begin(), attention_resolutions.end(), ds) != attention_resolutions.end()) {
|
|
||||||
int n_head = num_heads;
|
|
||||||
int d_head = ch / num_heads;
|
|
||||||
if (num_head_channels != -1) {
|
|
||||||
d_head = num_head_channels;
|
|
||||||
n_head = ch / d_head;
|
|
||||||
}
|
|
||||||
std::string name = "input_blocks." + std::to_string(input_block_idx) + ".1";
|
|
||||||
blocks[name] = std::shared_ptr<GGMLBlock>(get_attention_layer(ch,
|
|
||||||
n_head,
|
|
||||||
d_head,
|
|
||||||
transformer_depth[i],
|
|
||||||
context_dim));
|
|
||||||
}
|
|
||||||
blocks["zero_convs." + std::to_string(input_block_idx) + ".0"] = std::shared_ptr<GGMLBlock>(make_zero_conv(ch));
|
|
||||||
input_block_chans.push_back(ch);
|
|
||||||
}
|
|
||||||
if (i != len_mults - 1) {
|
|
||||||
input_block_idx += 1;
|
|
||||||
std::string name = "input_blocks." + std::to_string(input_block_idx) + ".0";
|
|
||||||
blocks[name] = std::shared_ptr<GGMLBlock>(new DownSampleBlock(ch, ch));
|
|
||||||
|
|
||||||
blocks["zero_convs." + std::to_string(input_block_idx) + ".0"] = std::shared_ptr<GGMLBlock>(make_zero_conv(ch));
|
|
||||||
|
|
||||||
input_block_chans.push_back(ch);
|
|
||||||
ds *= 2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// middle blocks
|
|
||||||
int n_head = num_heads;
|
|
||||||
int d_head = ch / num_heads;
|
|
||||||
if (num_head_channels != -1) {
|
|
||||||
d_head = num_head_channels;
|
|
||||||
n_head = ch / d_head;
|
|
||||||
}
|
|
||||||
blocks["middle_block.0"] = std::shared_ptr<GGMLBlock>(get_resblock(ch, time_embed_dim, ch));
|
|
||||||
blocks["middle_block.1"] = std::shared_ptr<GGMLBlock>(get_attention_layer(ch,
|
|
||||||
n_head,
|
|
||||||
d_head,
|
|
||||||
transformer_depth[transformer_depth.size() - 1],
|
|
||||||
context_dim));
|
|
||||||
blocks["middle_block.2"] = std::shared_ptr<GGMLBlock>(get_resblock(ch, time_embed_dim, ch));
|
|
||||||
|
|
||||||
// middle_block_out
|
|
||||||
blocks["middle_block_out.0"] = std::shared_ptr<GGMLBlock>(make_zero_conv(ch));
|
|
||||||
}
|
|
||||||
|
|
||||||
struct ggml_tensor* resblock_forward(std::string name,
|
|
||||||
GGMLRunnerContext* ctx,
|
|
||||||
struct ggml_tensor* x,
|
|
||||||
struct ggml_tensor* emb) {
|
|
||||||
auto block = std::dynamic_pointer_cast<ResBlock>(blocks[name]);
|
|
||||||
return block->forward(ctx, x, emb);
|
|
||||||
}
|
|
||||||
|
|
||||||
struct ggml_tensor* attention_layer_forward(std::string name,
|
|
||||||
GGMLRunnerContext* ctx,
|
|
||||||
struct ggml_tensor* x,
|
|
||||||
struct ggml_tensor* context) {
|
|
||||||
auto block = std::dynamic_pointer_cast<SpatialTransformer>(blocks[name]);
|
|
||||||
return block->forward(ctx, x, context);
|
|
||||||
}
|
|
||||||
|
|
||||||
struct ggml_tensor* input_hint_block_forward(GGMLRunnerContext* ctx,
|
|
||||||
struct ggml_tensor* hint,
|
|
||||||
struct ggml_tensor* emb,
|
|
||||||
struct ggml_tensor* context) {
|
|
||||||
int num_input_blocks = 15;
|
|
||||||
auto h = hint;
|
|
||||||
for (int i = 0; i < num_input_blocks; i++) {
|
|
||||||
if (i % 2 == 0) {
|
|
||||||
auto block = std::dynamic_pointer_cast<Conv2d>(blocks["input_hint_block." + std::to_string(i)]);
|
|
||||||
|
|
||||||
h = block->forward(ctx, h);
|
|
||||||
} else {
|
|
||||||
h = ggml_silu_inplace(ctx->ggml_ctx, h);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return h;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<struct ggml_tensor*> forward(GGMLRunnerContext* ctx,
|
|
||||||
struct ggml_tensor* x,
|
|
||||||
struct ggml_tensor* hint,
|
|
||||||
struct ggml_tensor* guided_hint,
|
|
||||||
struct ggml_tensor* timesteps,
|
|
||||||
struct ggml_tensor* context,
|
|
||||||
struct ggml_tensor* y = nullptr) {
|
|
||||||
// x: [N, in_channels, h, w] or [N, in_channels/2, h, w]
|
|
||||||
// timesteps: [N,]
|
|
||||||
// context: [N, max_position, hidden_size] or [1, max_position, hidden_size]. for example, [N, 77, 768]
|
|
||||||
// y: [N, adm_in_channels] or [1, adm_in_channels]
|
|
||||||
if (context != nullptr) {
|
|
||||||
if (context->ne[2] != x->ne[3]) {
|
|
||||||
context = ggml_repeat(ctx->ggml_ctx, context, ggml_new_tensor_3d(ctx->ggml_ctx, GGML_TYPE_F32, context->ne[0], context->ne[1], x->ne[3]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (y != nullptr) {
|
|
||||||
if (y->ne[1] != x->ne[3]) {
|
|
||||||
y = ggml_repeat(ctx->ggml_ctx, y, ggml_new_tensor_2d(ctx->ggml_ctx, GGML_TYPE_F32, y->ne[0], x->ne[3]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
auto time_embed_0 = std::dynamic_pointer_cast<Linear>(blocks["time_embed.0"]);
|
|
||||||
auto time_embed_2 = std::dynamic_pointer_cast<Linear>(blocks["time_embed.2"]);
|
|
||||||
auto input_blocks_0_0 = std::dynamic_pointer_cast<Conv2d>(blocks["input_blocks.0.0"]);
|
|
||||||
auto zero_convs_0 = std::dynamic_pointer_cast<Conv2d>(blocks["zero_convs.0.0"]);
|
|
||||||
|
|
||||||
auto middle_block_out = std::dynamic_pointer_cast<Conv2d>(blocks["middle_block_out.0"]);
|
|
||||||
|
|
||||||
auto t_emb = ggml_ext_timestep_embedding(ctx->ggml_ctx, timesteps, model_channels); // [N, model_channels]
|
|
||||||
|
|
||||||
auto emb = time_embed_0->forward(ctx, t_emb);
|
|
||||||
emb = ggml_silu_inplace(ctx->ggml_ctx, emb);
|
|
||||||
emb = time_embed_2->forward(ctx, emb); // [N, time_embed_dim]
|
|
||||||
|
|
||||||
// SDXL/SVD
|
|
||||||
if (y != nullptr) {
|
|
||||||
auto label_embed_0 = std::dynamic_pointer_cast<Linear>(blocks["label_emb.0.0"]);
|
|
||||||
auto label_embed_2 = std::dynamic_pointer_cast<Linear>(blocks["label_emb.0.2"]);
|
|
||||||
|
|
||||||
auto label_emb = label_embed_0->forward(ctx, y);
|
|
||||||
label_emb = ggml_silu_inplace(ctx->ggml_ctx, label_emb);
|
|
||||||
label_emb = label_embed_2->forward(ctx, label_emb); // [N, time_embed_dim]
|
|
||||||
|
|
||||||
emb = ggml_add(ctx->ggml_ctx, emb, label_emb); // [N, time_embed_dim]
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<struct ggml_tensor*> outs;
|
|
||||||
|
|
||||||
if (guided_hint == nullptr) {
|
|
||||||
guided_hint = input_hint_block_forward(ctx, hint, emb, context);
|
|
||||||
}
|
|
||||||
outs.push_back(guided_hint);
|
|
||||||
|
|
||||||
// input_blocks
|
|
||||||
|
|
||||||
// input block 0
|
|
||||||
auto h = input_blocks_0_0->forward(ctx, x);
|
|
||||||
h = ggml_add(ctx->ggml_ctx, h, guided_hint);
|
|
||||||
outs.push_back(zero_convs_0->forward(ctx, h));
|
|
||||||
|
|
||||||
// input block 1-11
|
|
||||||
size_t len_mults = channel_mult.size();
|
|
||||||
int input_block_idx = 0;
|
|
||||||
int ds = 1;
|
|
||||||
for (int i = 0; i < len_mults; i++) {
|
|
||||||
int mult = channel_mult[i];
|
|
||||||
for (int j = 0; j < num_res_blocks; j++) {
|
|
||||||
input_block_idx += 1;
|
|
||||||
std::string name = "input_blocks." + std::to_string(input_block_idx) + ".0";
|
|
||||||
h = resblock_forward(name, ctx, h, emb); // [N, mult*model_channels, h, w]
|
|
||||||
if (std::find(attention_resolutions.begin(), attention_resolutions.end(), ds) != attention_resolutions.end()) {
|
|
||||||
std::string name = "input_blocks." + std::to_string(input_block_idx) + ".1";
|
|
||||||
h = attention_layer_forward(name, ctx, h, context); // [N, mult*model_channels, h, w]
|
|
||||||
}
|
|
||||||
|
|
||||||
auto zero_conv = std::dynamic_pointer_cast<Conv2d>(blocks["zero_convs." + std::to_string(input_block_idx) + ".0"]);
|
|
||||||
|
|
||||||
outs.push_back(zero_conv->forward(ctx, h));
|
|
||||||
}
|
|
||||||
if (i != len_mults - 1) {
|
|
||||||
ds *= 2;
|
|
||||||
input_block_idx += 1;
|
|
||||||
|
|
||||||
std::string name = "input_blocks." + std::to_string(input_block_idx) + ".0";
|
|
||||||
auto block = std::dynamic_pointer_cast<DownSampleBlock>(blocks[name]);
|
|
||||||
|
|
||||||
h = block->forward(ctx, h); // [N, mult*model_channels, h/(2^(i+1)), w/(2^(i+1))]
|
|
||||||
|
|
||||||
auto zero_conv = std::dynamic_pointer_cast<Conv2d>(blocks["zero_convs." + std::to_string(input_block_idx) + ".0"]);
|
|
||||||
|
|
||||||
outs.push_back(zero_conv->forward(ctx, h));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// [N, 4*model_channels, h/8, w/8]
|
|
||||||
|
|
||||||
// middle_block
|
|
||||||
h = resblock_forward("middle_block.0", ctx, h, emb); // [N, 4*model_channels, h/8, w/8]
|
|
||||||
h = attention_layer_forward("middle_block.1", ctx, h, context); // [N, 4*model_channels, h/8, w/8]
|
|
||||||
h = resblock_forward("middle_block.2", ctx, h, emb); // [N, 4*model_channels, h/8, w/8]
|
|
||||||
|
|
||||||
// out
|
|
||||||
outs.push_back(middle_block_out->forward(ctx, h));
|
|
||||||
return outs;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ControlNet : public GGMLRunner {
|
|
||||||
SDVersion version = VERSION_SD1;
|
|
||||||
ControlNetBlock control_net;
|
|
||||||
|
|
||||||
ggml_backend_buffer_t control_buffer = nullptr; // keep control output tensors in backend memory
|
|
||||||
ggml_context* control_ctx = nullptr;
|
|
||||||
std::vector<struct ggml_tensor*> controls; // (12 input block outputs, 1 middle block output) SD 1.5
|
|
||||||
struct ggml_tensor* guided_hint = nullptr; // guided_hint cache, for faster inference
|
|
||||||
bool guided_hint_cached = false;
|
|
||||||
|
|
||||||
ControlNet(ggml_backend_t backend,
|
|
||||||
bool offload_params_to_cpu,
|
|
||||||
const String2TensorStorage& tensor_storage_map = {},
|
|
||||||
SDVersion version = VERSION_SD1)
|
|
||||||
: GGMLRunner(backend, offload_params_to_cpu), control_net(version) {
|
|
||||||
control_net.init(params_ctx, tensor_storage_map, "");
|
|
||||||
}
|
|
||||||
|
|
||||||
~ControlNet() override {
|
|
||||||
free_control_ctx();
|
|
||||||
}
|
|
||||||
|
|
||||||
void alloc_control_ctx(std::vector<struct ggml_tensor*> outs) {
|
|
||||||
struct ggml_init_params params;
|
|
||||||
params.mem_size = static_cast<size_t>(outs.size() * ggml_tensor_overhead()) + 1024 * 1024;
|
|
||||||
params.mem_buffer = nullptr;
|
|
||||||
params.no_alloc = true;
|
|
||||||
control_ctx = ggml_init(params);
|
|
||||||
|
|
||||||
controls.resize(outs.size() - 1);
|
|
||||||
|
|
||||||
size_t control_buffer_size = 0;
|
|
||||||
|
|
||||||
guided_hint = ggml_dup_tensor(control_ctx, outs[0]);
|
|
||||||
control_buffer_size += ggml_nbytes(guided_hint);
|
|
||||||
|
|
||||||
for (int i = 0; i < outs.size() - 1; i++) {
|
|
||||||
controls[i] = ggml_dup_tensor(control_ctx, outs[i + 1]);
|
|
||||||
control_buffer_size += ggml_nbytes(controls[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
control_buffer = ggml_backend_alloc_ctx_tensors(control_ctx, runtime_backend);
|
|
||||||
|
|
||||||
LOG_DEBUG("control buffer size %.2fMB", control_buffer_size * 1.f / 1024.f / 1024.f);
|
|
||||||
}
|
|
||||||
|
|
||||||
void free_control_ctx() {
|
|
||||||
if (control_buffer != nullptr) {
|
|
||||||
ggml_backend_buffer_free(control_buffer);
|
|
||||||
control_buffer = nullptr;
|
|
||||||
}
|
|
||||||
if (control_ctx != nullptr) {
|
|
||||||
ggml_free(control_ctx);
|
|
||||||
control_ctx = nullptr;
|
|
||||||
}
|
|
||||||
guided_hint = nullptr;
|
|
||||||
guided_hint_cached = false;
|
|
||||||
controls.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string get_desc() override {
|
|
||||||
return "control_net";
|
|
||||||
}
|
|
||||||
|
|
||||||
void get_param_tensors(std::map<std::string, struct ggml_tensor*>& tensors, const std::string prefix) {
|
|
||||||
control_net.get_param_tensors(tensors, prefix);
|
|
||||||
}
|
|
||||||
|
|
||||||
struct ggml_cgraph* build_graph(struct ggml_tensor* x,
|
|
||||||
struct ggml_tensor* hint,
|
|
||||||
struct ggml_tensor* timesteps,
|
|
||||||
struct ggml_tensor* context,
|
|
||||||
struct ggml_tensor* y = nullptr) {
|
|
||||||
struct ggml_cgraph* gf = new_graph_custom(CONTROL_NET_GRAPH_SIZE);
|
|
||||||
|
|
||||||
x = to_backend(x);
|
|
||||||
if (guided_hint_cached) {
|
|
||||||
hint = nullptr;
|
|
||||||
} else {
|
|
||||||
hint = to_backend(hint);
|
|
||||||
}
|
|
||||||
context = to_backend(context);
|
|
||||||
y = to_backend(y);
|
|
||||||
timesteps = to_backend(timesteps);
|
|
||||||
|
|
||||||
auto runner_ctx = get_context();
|
|
||||||
|
|
||||||
auto outs = control_net.forward(&runner_ctx,
|
|
||||||
x,
|
|
||||||
hint,
|
|
||||||
guided_hint_cached ? guided_hint : nullptr,
|
|
||||||
timesteps,
|
|
||||||
context,
|
|
||||||
y);
|
|
||||||
|
|
||||||
if (control_ctx == nullptr) {
|
|
||||||
alloc_control_ctx(outs);
|
|
||||||
}
|
|
||||||
|
|
||||||
ggml_build_forward_expand(gf, ggml_cpy(compute_ctx, outs[0], guided_hint));
|
|
||||||
for (int i = 0; i < outs.size() - 1; i++) {
|
|
||||||
ggml_build_forward_expand(gf, ggml_cpy(compute_ctx, outs[i + 1], controls[i]));
|
|
||||||
}
|
|
||||||
|
|
||||||
return gf;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool compute(int n_threads,
|
|
||||||
struct ggml_tensor* x,
|
|
||||||
struct ggml_tensor* hint,
|
|
||||||
struct ggml_tensor* timesteps,
|
|
||||||
struct ggml_tensor* context,
|
|
||||||
struct ggml_tensor* y,
|
|
||||||
struct ggml_tensor** output = nullptr,
|
|
||||||
struct ggml_context* output_ctx = nullptr) {
|
|
||||||
// x: [N, in_channels, h, w]
|
|
||||||
// timesteps: [N, ]
|
|
||||||
// context: [N, max_position, hidden_size]([N, 77, 768]) or [1, max_position, hidden_size]
|
|
||||||
// y: [N, adm_in_channels] or [1, adm_in_channels]
|
|
||||||
auto get_graph = [&]() -> struct ggml_cgraph* {
|
|
||||||
return build_graph(x, hint, timesteps, context, y);
|
|
||||||
};
|
|
||||||
|
|
||||||
bool res = GGMLRunner::compute(get_graph, n_threads, false, output, output_ctx);
|
|
||||||
if (res) {
|
|
||||||
// cache guided_hint
|
|
||||||
guided_hint_cached = true;
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool load_from_file(const std::string& file_path, int n_threads) {
|
|
||||||
LOG_INFO("loading control net from '%s'", file_path.c_str());
|
|
||||||
alloc_params_buffer();
|
|
||||||
std::map<std::string, ggml_tensor*> tensors;
|
|
||||||
control_net.get_param_tensors(tensors);
|
|
||||||
std::set<std::string> ignore_tensors;
|
|
||||||
|
|
||||||
ModelLoader model_loader;
|
|
||||||
if (!model_loader.init_from_file_and_convert_name(file_path)) {
|
|
||||||
LOG_ERROR("init control net model loader from file failed: '%s'", file_path.c_str());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool success = model_loader.load_tensors(tensors, ignore_tensors, n_threads);
|
|
||||||
|
|
||||||
if (!success) {
|
|
||||||
LOG_ERROR("load control net tensors from model loader failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
LOG_INFO("control net model loaded");
|
|
||||||
return success;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // __CONTROL_HPP__
|
|
||||||
1645
denoiser.hpp
0
dgl/.gitkeep
Normal file
|
|
@ -1,450 +0,0 @@
|
||||||
#ifndef __DIFFUSION_MODEL_H__
|
|
||||||
#define __DIFFUSION_MODEL_H__
|
|
||||||
|
|
||||||
#include "flux.hpp"
|
|
||||||
#include "mmdit.hpp"
|
|
||||||
#include "qwen_image.hpp"
|
|
||||||
#include "unet.hpp"
|
|
||||||
#include "wan.hpp"
|
|
||||||
#include "z_image.hpp"
|
|
||||||
|
|
||||||
struct DiffusionParams {
|
|
||||||
struct ggml_tensor* x = nullptr;
|
|
||||||
struct ggml_tensor* timesteps = nullptr;
|
|
||||||
struct ggml_tensor* context = nullptr;
|
|
||||||
struct ggml_tensor* c_concat = nullptr;
|
|
||||||
struct ggml_tensor* y = nullptr;
|
|
||||||
struct ggml_tensor* guidance = nullptr;
|
|
||||||
std::vector<ggml_tensor*> ref_latents = {};
|
|
||||||
bool increase_ref_index = false;
|
|
||||||
int num_video_frames = -1;
|
|
||||||
std::vector<struct ggml_tensor*> controls = {};
|
|
||||||
float control_strength = 0.f;
|
|
||||||
struct ggml_tensor* vace_context = nullptr;
|
|
||||||
float vace_strength = 1.f;
|
|
||||||
std::vector<int> skip_layers = {};
|
|
||||||
};
|
|
||||||
|
|
||||||
struct DiffusionModel {
|
|
||||||
virtual std::string get_desc() = 0;
|
|
||||||
virtual bool compute(int n_threads,
|
|
||||||
DiffusionParams diffusion_params,
|
|
||||||
struct ggml_tensor** output = nullptr,
|
|
||||||
struct ggml_context* output_ctx = nullptr) = 0;
|
|
||||||
virtual void alloc_params_buffer() = 0;
|
|
||||||
virtual void free_params_buffer() = 0;
|
|
||||||
virtual void free_compute_buffer() = 0;
|
|
||||||
virtual void get_param_tensors(std::map<std::string, struct ggml_tensor*>& tensors) = 0;
|
|
||||||
virtual size_t get_params_buffer_size() = 0;
|
|
||||||
virtual void set_weight_adapter(const std::shared_ptr<WeightAdapter>& adapter){};
|
|
||||||
virtual int64_t get_adm_in_channels() = 0;
|
|
||||||
virtual void set_flash_attn_enabled(bool enabled) = 0;
|
|
||||||
virtual void set_circular_axes(bool circular_x, bool circular_y) = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct UNetModel : public DiffusionModel {
|
|
||||||
UNetModelRunner unet;
|
|
||||||
|
|
||||||
UNetModel(ggml_backend_t backend,
|
|
||||||
bool offload_params_to_cpu,
|
|
||||||
const String2TensorStorage& tensor_storage_map = {},
|
|
||||||
SDVersion version = VERSION_SD1)
|
|
||||||
: unet(backend, offload_params_to_cpu, tensor_storage_map, "model.diffusion_model", version) {
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string get_desc() override {
|
|
||||||
return unet.get_desc();
|
|
||||||
}
|
|
||||||
|
|
||||||
void alloc_params_buffer() override {
|
|
||||||
unet.alloc_params_buffer();
|
|
||||||
}
|
|
||||||
|
|
||||||
void free_params_buffer() override {
|
|
||||||
unet.free_params_buffer();
|
|
||||||
}
|
|
||||||
|
|
||||||
void free_compute_buffer() override {
|
|
||||||
unet.free_compute_buffer();
|
|
||||||
}
|
|
||||||
|
|
||||||
void get_param_tensors(std::map<std::string, struct ggml_tensor*>& tensors) override {
|
|
||||||
unet.get_param_tensors(tensors, "model.diffusion_model");
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t get_params_buffer_size() override {
|
|
||||||
return unet.get_params_buffer_size();
|
|
||||||
}
|
|
||||||
|
|
||||||
void set_weight_adapter(const std::shared_ptr<WeightAdapter>& adapter) override {
|
|
||||||
unet.set_weight_adapter(adapter);
|
|
||||||
}
|
|
||||||
|
|
||||||
int64_t get_adm_in_channels() override {
|
|
||||||
return unet.unet.adm_in_channels;
|
|
||||||
}
|
|
||||||
|
|
||||||
void set_flash_attn_enabled(bool enabled) {
|
|
||||||
unet.set_flash_attention_enabled(enabled);
|
|
||||||
}
|
|
||||||
|
|
||||||
void set_circular_axes(bool circular_x, bool circular_y) override {
|
|
||||||
unet.set_circular_axes(circular_x, circular_y);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool compute(int n_threads,
|
|
||||||
DiffusionParams diffusion_params,
|
|
||||||
struct ggml_tensor** output = nullptr,
|
|
||||||
struct ggml_context* output_ctx = nullptr) override {
|
|
||||||
return unet.compute(n_threads,
|
|
||||||
diffusion_params.x,
|
|
||||||
diffusion_params.timesteps,
|
|
||||||
diffusion_params.context,
|
|
||||||
diffusion_params.c_concat,
|
|
||||||
diffusion_params.y,
|
|
||||||
diffusion_params.num_video_frames,
|
|
||||||
diffusion_params.controls,
|
|
||||||
diffusion_params.control_strength, output, output_ctx);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
struct MMDiTModel : public DiffusionModel {
|
|
||||||
MMDiTRunner mmdit;
|
|
||||||
|
|
||||||
MMDiTModel(ggml_backend_t backend,
|
|
||||||
bool offload_params_to_cpu,
|
|
||||||
const String2TensorStorage& tensor_storage_map = {})
|
|
||||||
: mmdit(backend, offload_params_to_cpu, tensor_storage_map, "model.diffusion_model") {
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string get_desc() override {
|
|
||||||
return mmdit.get_desc();
|
|
||||||
}
|
|
||||||
|
|
||||||
void alloc_params_buffer() override {
|
|
||||||
mmdit.alloc_params_buffer();
|
|
||||||
}
|
|
||||||
|
|
||||||
void free_params_buffer() override {
|
|
||||||
mmdit.free_params_buffer();
|
|
||||||
}
|
|
||||||
|
|
||||||
void free_compute_buffer() override {
|
|
||||||
mmdit.free_compute_buffer();
|
|
||||||
}
|
|
||||||
|
|
||||||
void get_param_tensors(std::map<std::string, struct ggml_tensor*>& tensors) override {
|
|
||||||
mmdit.get_param_tensors(tensors, "model.diffusion_model");
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t get_params_buffer_size() override {
|
|
||||||
return mmdit.get_params_buffer_size();
|
|
||||||
}
|
|
||||||
|
|
||||||
void set_weight_adapter(const std::shared_ptr<WeightAdapter>& adapter) override {
|
|
||||||
mmdit.set_weight_adapter(adapter);
|
|
||||||
}
|
|
||||||
|
|
||||||
int64_t get_adm_in_channels() override {
|
|
||||||
return 768 + 1280;
|
|
||||||
}
|
|
||||||
|
|
||||||
void set_flash_attn_enabled(bool enabled) {
|
|
||||||
mmdit.set_flash_attention_enabled(enabled);
|
|
||||||
}
|
|
||||||
|
|
||||||
void set_circular_axes(bool circular_x, bool circular_y) override {
|
|
||||||
mmdit.set_circular_axes(circular_x, circular_y);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool compute(int n_threads,
|
|
||||||
DiffusionParams diffusion_params,
|
|
||||||
struct ggml_tensor** output = nullptr,
|
|
||||||
struct ggml_context* output_ctx = nullptr) override {
|
|
||||||
return mmdit.compute(n_threads,
|
|
||||||
diffusion_params.x,
|
|
||||||
diffusion_params.timesteps,
|
|
||||||
diffusion_params.context,
|
|
||||||
diffusion_params.y,
|
|
||||||
output,
|
|
||||||
output_ctx,
|
|
||||||
diffusion_params.skip_layers);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
struct FluxModel : public DiffusionModel {
|
|
||||||
Flux::FluxRunner flux;
|
|
||||||
|
|
||||||
FluxModel(ggml_backend_t backend,
|
|
||||||
bool offload_params_to_cpu,
|
|
||||||
const String2TensorStorage& tensor_storage_map = {},
|
|
||||||
SDVersion version = VERSION_FLUX,
|
|
||||||
bool use_mask = false)
|
|
||||||
: flux(backend, offload_params_to_cpu, tensor_storage_map, "model.diffusion_model", version, use_mask) {
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string get_desc() override {
|
|
||||||
return flux.get_desc();
|
|
||||||
}
|
|
||||||
|
|
||||||
void alloc_params_buffer() override {
|
|
||||||
flux.alloc_params_buffer();
|
|
||||||
}
|
|
||||||
|
|
||||||
void free_params_buffer() override {
|
|
||||||
flux.free_params_buffer();
|
|
||||||
}
|
|
||||||
|
|
||||||
void free_compute_buffer() override {
|
|
||||||
flux.free_compute_buffer();
|
|
||||||
}
|
|
||||||
|
|
||||||
void get_param_tensors(std::map<std::string, struct ggml_tensor*>& tensors) override {
|
|
||||||
flux.get_param_tensors(tensors, "model.diffusion_model");
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t get_params_buffer_size() override {
|
|
||||||
return flux.get_params_buffer_size();
|
|
||||||
}
|
|
||||||
|
|
||||||
void set_weight_adapter(const std::shared_ptr<WeightAdapter>& adapter) override {
|
|
||||||
flux.set_weight_adapter(adapter);
|
|
||||||
}
|
|
||||||
|
|
||||||
int64_t get_adm_in_channels() override {
|
|
||||||
return 768;
|
|
||||||
}
|
|
||||||
|
|
||||||
void set_flash_attn_enabled(bool enabled) {
|
|
||||||
flux.set_flash_attention_enabled(enabled);
|
|
||||||
}
|
|
||||||
|
|
||||||
void set_circular_axes(bool circular_x, bool circular_y) override {
|
|
||||||
flux.set_circular_axes(circular_x, circular_y);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool compute(int n_threads,
|
|
||||||
DiffusionParams diffusion_params,
|
|
||||||
struct ggml_tensor** output = nullptr,
|
|
||||||
struct ggml_context* output_ctx = nullptr) override {
|
|
||||||
return flux.compute(n_threads,
|
|
||||||
diffusion_params.x,
|
|
||||||
diffusion_params.timesteps,
|
|
||||||
diffusion_params.context,
|
|
||||||
diffusion_params.c_concat,
|
|
||||||
diffusion_params.y,
|
|
||||||
diffusion_params.guidance,
|
|
||||||
diffusion_params.ref_latents,
|
|
||||||
diffusion_params.increase_ref_index,
|
|
||||||
output,
|
|
||||||
output_ctx,
|
|
||||||
diffusion_params.skip_layers);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
struct WanModel : public DiffusionModel {
|
|
||||||
std::string prefix;
|
|
||||||
WAN::WanRunner wan;
|
|
||||||
|
|
||||||
WanModel(ggml_backend_t backend,
|
|
||||||
bool offload_params_to_cpu,
|
|
||||||
const String2TensorStorage& tensor_storage_map = {},
|
|
||||||
const std::string prefix = "model.diffusion_model",
|
|
||||||
SDVersion version = VERSION_WAN2)
|
|
||||||
: prefix(prefix), wan(backend, offload_params_to_cpu, tensor_storage_map, prefix, version) {
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string get_desc() override {
|
|
||||||
return wan.get_desc();
|
|
||||||
}
|
|
||||||
|
|
||||||
void alloc_params_buffer() override {
|
|
||||||
wan.alloc_params_buffer();
|
|
||||||
}
|
|
||||||
|
|
||||||
void free_params_buffer() override {
|
|
||||||
wan.free_params_buffer();
|
|
||||||
}
|
|
||||||
|
|
||||||
void free_compute_buffer() override {
|
|
||||||
wan.free_compute_buffer();
|
|
||||||
}
|
|
||||||
|
|
||||||
void get_param_tensors(std::map<std::string, struct ggml_tensor*>& tensors) override {
|
|
||||||
wan.get_param_tensors(tensors, prefix);
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t get_params_buffer_size() override {
|
|
||||||
return wan.get_params_buffer_size();
|
|
||||||
}
|
|
||||||
|
|
||||||
void set_weight_adapter(const std::shared_ptr<WeightAdapter>& adapter) override {
|
|
||||||
wan.set_weight_adapter(adapter);
|
|
||||||
}
|
|
||||||
|
|
||||||
int64_t get_adm_in_channels() override {
|
|
||||||
return 768;
|
|
||||||
}
|
|
||||||
|
|
||||||
void set_flash_attn_enabled(bool enabled) {
|
|
||||||
wan.set_flash_attention_enabled(enabled);
|
|
||||||
}
|
|
||||||
|
|
||||||
void set_circular_axes(bool circular_x, bool circular_y) override {
|
|
||||||
wan.set_circular_axes(circular_x, circular_y);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool compute(int n_threads,
|
|
||||||
DiffusionParams diffusion_params,
|
|
||||||
struct ggml_tensor** output = nullptr,
|
|
||||||
struct ggml_context* output_ctx = nullptr) override {
|
|
||||||
return wan.compute(n_threads,
|
|
||||||
diffusion_params.x,
|
|
||||||
diffusion_params.timesteps,
|
|
||||||
diffusion_params.context,
|
|
||||||
diffusion_params.y,
|
|
||||||
diffusion_params.c_concat,
|
|
||||||
nullptr,
|
|
||||||
diffusion_params.vace_context,
|
|
||||||
diffusion_params.vace_strength,
|
|
||||||
output,
|
|
||||||
output_ctx);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
struct QwenImageModel : public DiffusionModel {
|
|
||||||
std::string prefix;
|
|
||||||
Qwen::QwenImageRunner qwen_image;
|
|
||||||
|
|
||||||
QwenImageModel(ggml_backend_t backend,
|
|
||||||
bool offload_params_to_cpu,
|
|
||||||
const String2TensorStorage& tensor_storage_map = {},
|
|
||||||
const std::string prefix = "model.diffusion_model",
|
|
||||||
SDVersion version = VERSION_QWEN_IMAGE,
|
|
||||||
bool zero_cond_t = false)
|
|
||||||
: prefix(prefix), qwen_image(backend, offload_params_to_cpu, tensor_storage_map, prefix, version, zero_cond_t) {
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string get_desc() override {
|
|
||||||
return qwen_image.get_desc();
|
|
||||||
}
|
|
||||||
|
|
||||||
void alloc_params_buffer() override {
|
|
||||||
qwen_image.alloc_params_buffer();
|
|
||||||
}
|
|
||||||
|
|
||||||
void free_params_buffer() override {
|
|
||||||
qwen_image.free_params_buffer();
|
|
||||||
}
|
|
||||||
|
|
||||||
void free_compute_buffer() override {
|
|
||||||
qwen_image.free_compute_buffer();
|
|
||||||
}
|
|
||||||
|
|
||||||
void get_param_tensors(std::map<std::string, struct ggml_tensor*>& tensors) override {
|
|
||||||
qwen_image.get_param_tensors(tensors, prefix);
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t get_params_buffer_size() override {
|
|
||||||
return qwen_image.get_params_buffer_size();
|
|
||||||
}
|
|
||||||
|
|
||||||
void set_weight_adapter(const std::shared_ptr<WeightAdapter>& adapter) override {
|
|
||||||
qwen_image.set_weight_adapter(adapter);
|
|
||||||
}
|
|
||||||
|
|
||||||
int64_t get_adm_in_channels() override {
|
|
||||||
return 768;
|
|
||||||
}
|
|
||||||
|
|
||||||
void set_flash_attn_enabled(bool enabled) {
|
|
||||||
qwen_image.set_flash_attention_enabled(enabled);
|
|
||||||
}
|
|
||||||
|
|
||||||
void set_circular_axes(bool circular_x, bool circular_y) override {
|
|
||||||
qwen_image.set_circular_axes(circular_x, circular_y);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool compute(int n_threads,
|
|
||||||
DiffusionParams diffusion_params,
|
|
||||||
struct ggml_tensor** output = nullptr,
|
|
||||||
struct ggml_context* output_ctx = nullptr) override {
|
|
||||||
return qwen_image.compute(n_threads,
|
|
||||||
diffusion_params.x,
|
|
||||||
diffusion_params.timesteps,
|
|
||||||
diffusion_params.context,
|
|
||||||
diffusion_params.ref_latents,
|
|
||||||
true, // increase_ref_index
|
|
||||||
output,
|
|
||||||
output_ctx);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ZImageModel : public DiffusionModel {
|
|
||||||
std::string prefix;
|
|
||||||
ZImage::ZImageRunner z_image;
|
|
||||||
|
|
||||||
ZImageModel(ggml_backend_t backend,
|
|
||||||
bool offload_params_to_cpu,
|
|
||||||
const String2TensorStorage& tensor_storage_map = {},
|
|
||||||
const std::string prefix = "model.diffusion_model",
|
|
||||||
SDVersion version = VERSION_Z_IMAGE)
|
|
||||||
: prefix(prefix), z_image(backend, offload_params_to_cpu, tensor_storage_map, prefix, version) {
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string get_desc() override {
|
|
||||||
return z_image.get_desc();
|
|
||||||
}
|
|
||||||
|
|
||||||
void alloc_params_buffer() override {
|
|
||||||
z_image.alloc_params_buffer();
|
|
||||||
}
|
|
||||||
|
|
||||||
void free_params_buffer() override {
|
|
||||||
z_image.free_params_buffer();
|
|
||||||
}
|
|
||||||
|
|
||||||
void free_compute_buffer() override {
|
|
||||||
z_image.free_compute_buffer();
|
|
||||||
}
|
|
||||||
|
|
||||||
void get_param_tensors(std::map<std::string, struct ggml_tensor*>& tensors) override {
|
|
||||||
z_image.get_param_tensors(tensors, prefix);
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t get_params_buffer_size() override {
|
|
||||||
return z_image.get_params_buffer_size();
|
|
||||||
}
|
|
||||||
|
|
||||||
void set_weight_adapter(const std::shared_ptr<WeightAdapter>& adapter) override {
|
|
||||||
z_image.set_weight_adapter(adapter);
|
|
||||||
}
|
|
||||||
|
|
||||||
int64_t get_adm_in_channels() override {
|
|
||||||
return 768;
|
|
||||||
}
|
|
||||||
|
|
||||||
void set_flash_attn_enabled(bool enabled) {
|
|
||||||
z_image.set_flash_attention_enabled(enabled);
|
|
||||||
}
|
|
||||||
|
|
||||||
void set_circular_axes(bool circular_x, bool circular_y) override {
|
|
||||||
z_image.set_circular_axes(circular_x, circular_y);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool compute(int n_threads,
|
|
||||||
DiffusionParams diffusion_params,
|
|
||||||
struct ggml_tensor** output = nullptr,
|
|
||||||
struct ggml_context* output_ctx = nullptr) override {
|
|
||||||
return z_image.compute(n_threads,
|
|
||||||
diffusion_params.x,
|
|
||||||
diffusion_params.timesteps,
|
|
||||||
diffusion_params.context,
|
|
||||||
diffusion_params.ref_latents,
|
|
||||||
true, // increase_ref_index
|
|
||||||
output,
|
|
||||||
output_ctx);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
45
docker/Dockerfile
Normal file
|
|
@ -0,0 +1,45 @@
|
||||||
|
ARG UBUNTU_VERSION=24.04
|
||||||
|
|
||||||
|
FROM ubuntu:$UBUNTU_VERSION AS build
|
||||||
|
|
||||||
|
# sd-server embeds the web UI at build time, so the build image needs Node/pnpm.
|
||||||
|
RUN apt-get update && apt-get install -y --no-install-recommends build-essential git cmake ca-certificates curl gnupg && \
|
||||||
|
mkdir -p /etc/apt/keyrings && \
|
||||||
|
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key -o /tmp/nodesource-repo.gpg.key && \
|
||||||
|
gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg /tmp/nodesource-repo.gpg.key && \
|
||||||
|
rm /tmp/nodesource-repo.gpg.key && \
|
||||||
|
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_24.x nodistro main" > /etc/apt/sources.list.d/nodesource.list && \
|
||||||
|
apt-get update && \
|
||||||
|
apt-get install -y --no-install-recommends nodejs && \
|
||||||
|
npm install -g pnpm@10.15.1 && \
|
||||||
|
apt-get clean && \
|
||||||
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
WORKDIR /sd.cpp
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
RUN cmake . -B ./build \
|
||||||
|
-DSD_BUILD_SHARED_LIBS=ON \
|
||||||
|
-DGGML_NATIVE=OFF \
|
||||||
|
-DSD_BUILD_SHARED_GGML_LIB=ON \
|
||||||
|
-DGGML_BACKEND_DL=ON \
|
||||||
|
-DGGML_CPU_ALL_VARIANTS=ON \
|
||||||
|
-DCMAKE_BUILD_WITH_INSTALL_RPATH=ON \
|
||||||
|
-DCMAKE_INSTALL_RPATH='$ORIGIN'
|
||||||
|
RUN cmake --build ./build --config Release --parallel
|
||||||
|
|
||||||
|
FROM ubuntu:$UBUNTU_VERSION AS runtime
|
||||||
|
|
||||||
|
RUN apt-get update && \
|
||||||
|
apt-get install --yes --no-install-recommends libgomp1 && \
|
||||||
|
apt-get clean
|
||||||
|
|
||||||
|
COPY --from=build /sd.cpp/build/bin /sd.cpp/bin
|
||||||
|
RUN printf '#!/bin/sh\nexec /sd.cpp/bin/sd-cli "$@"\n' > /sd-cli && \
|
||||||
|
printf '#!/bin/sh\nexec /sd.cpp/bin/sd-server "$@"\n' > /sd-server && \
|
||||||
|
chmod +x /sd-cli /sd-server
|
||||||
|
|
||||||
|
WORKDIR /sd.cpp
|
||||||
|
|
||||||
|
ENTRYPOINT [ "/sd-cli" ]
|
||||||
76
docker/Dockerfile.cuda
Normal file
|
|
@ -0,0 +1,76 @@
|
||||||
|
# syntax=docker/dockerfile:1
|
||||||
|
|
||||||
|
ARG CUDA_VERSION=12.6.3
|
||||||
|
ARG UBUNTU_VERSION=24.04
|
||||||
|
|
||||||
|
FROM nvidia/cuda:${CUDA_VERSION}-devel-ubuntu${UBUNTU_VERSION} AS build
|
||||||
|
|
||||||
|
# sd-server embeds the web UI at build time, so the build image needs Node/pnpm.
|
||||||
|
RUN apt-get update && apt-get install -y --no-install-recommends build-essential git ccache cmake ca-certificates curl gnupg && \
|
||||||
|
mkdir -p /etc/apt/keyrings && \
|
||||||
|
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key -o /tmp/nodesource-repo.gpg.key && \
|
||||||
|
gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg /tmp/nodesource-repo.gpg.key && \
|
||||||
|
rm /tmp/nodesource-repo.gpg.key && \
|
||||||
|
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_24.x nodistro main" > /etc/apt/sources.list.d/nodesource.list && \
|
||||||
|
apt-get update && \
|
||||||
|
apt-get install -y --no-install-recommends nodejs && \
|
||||||
|
npm install -g pnpm@10.15.1 && \
|
||||||
|
apt-get clean && \
|
||||||
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
WORKDIR /sd.cpp
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
ARG CUDACXX=/usr/local/cuda/bin/nvcc
|
||||||
|
ARG CUDA_ARCHITECTURES=""
|
||||||
|
ARG GGML_CUDA_FA_ALL_QUANTS=""
|
||||||
|
ARG GGML_CUDA_ENABLE_DYNAMIC_CPU_BACKENDS=ON
|
||||||
|
|
||||||
|
ENV CCACHE_DIR=/root/.cache/ccache \
|
||||||
|
CCACHE_MAXSIZE=2G \
|
||||||
|
CCACHE_COMPILERCHECK=content
|
||||||
|
|
||||||
|
RUN set -- \
|
||||||
|
-DSD_CUDA=ON \
|
||||||
|
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
|
||||||
|
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
|
||||||
|
-DCMAKE_CUDA_COMPILER_LAUNCHER=ccache; \
|
||||||
|
if [ "${GGML_CUDA_ENABLE_DYNAMIC_CPU_BACKENDS}" = "ON" ]; then \
|
||||||
|
set -- "$@" \
|
||||||
|
-DSD_BUILD_SHARED_LIBS=ON \
|
||||||
|
-DGGML_NATIVE=OFF \
|
||||||
|
-DSD_BUILD_SHARED_GGML_LIB=ON \
|
||||||
|
-DGGML_BACKEND_DL=ON \
|
||||||
|
-DGGML_CPU_ALL_VARIANTS=ON \
|
||||||
|
-DCMAKE_BUILD_WITH_INSTALL_RPATH=ON \
|
||||||
|
"-DCMAKE_INSTALL_RPATH=\$ORIGIN"; \
|
||||||
|
fi; \
|
||||||
|
if [ -n "${CUDA_ARCHITECTURES}" ]; then \
|
||||||
|
set -- "$@" "-DCMAKE_CUDA_ARCHITECTURES=${CUDA_ARCHITECTURES}"; \
|
||||||
|
fi; \
|
||||||
|
if [ -n "${GGML_CUDA_FA_ALL_QUANTS}" ]; then \
|
||||||
|
set -- "$@" "-DGGML_CUDA_FA_ALL_QUANTS=${GGML_CUDA_FA_ALL_QUANTS}"; \
|
||||||
|
fi; \
|
||||||
|
cmake . -B ./build "$@"
|
||||||
|
RUN --mount=type=cache,target=/root/.cache/ccache \
|
||||||
|
ccache --zero-stats && \
|
||||||
|
cmake --build ./build --config Release -j$(nproc) && \
|
||||||
|
ccache --cleanup && \
|
||||||
|
ccache --show-stats
|
||||||
|
|
||||||
|
FROM nvidia/cuda:${CUDA_VERSION}-runtime-ubuntu${UBUNTU_VERSION} AS runtime
|
||||||
|
|
||||||
|
RUN apt-get update && \
|
||||||
|
apt-get install --yes --no-install-recommends libgomp1 && \
|
||||||
|
apt-get clean
|
||||||
|
|
||||||
|
COPY --from=build /sd.cpp/build/bin /sd.cpp/bin
|
||||||
|
COPY --from=build /sd.cpp/thirdparty/cutlass/LICENSE.txt /sd.cpp/bin/cutlass.txt
|
||||||
|
RUN printf '#!/bin/sh\nexec /sd.cpp/bin/sd-cli "$@"\n' > /sd-cli && \
|
||||||
|
printf '#!/bin/sh\nexec /sd.cpp/bin/sd-server "$@"\n' > /sd-server && \
|
||||||
|
chmod +x /sd-cli /sd-server
|
||||||
|
|
||||||
|
WORKDIR /sd.cpp
|
||||||
|
|
||||||
|
ENTRYPOINT [ "/sd-cli" ]
|
||||||
46
docker/Dockerfile.musa
Normal file
|
|
@ -0,0 +1,46 @@
|
||||||
|
ARG MUSA_IMAGE=registry.mthreads.com/mcconline/inference/pytorch:2.9.1.post1-py3.10-musa5.2.0-mp31-devel-ubuntu22.04-amd64
|
||||||
|
|
||||||
|
FROM ${MUSA_IMAGE} AS build
|
||||||
|
|
||||||
|
# sd-server embeds the web UI at build time, so the build image needs Node/pnpm.
|
||||||
|
RUN apt-get update && apt-get install -y --no-install-recommends ccache cmake git ca-certificates curl gnupg && \
|
||||||
|
mkdir -p /etc/apt/keyrings && \
|
||||||
|
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key -o /tmp/nodesource-repo.gpg.key && \
|
||||||
|
gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg /tmp/nodesource-repo.gpg.key && \
|
||||||
|
rm /tmp/nodesource-repo.gpg.key && \
|
||||||
|
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_24.x nodistro main" > /etc/apt/sources.list.d/nodesource.list && \
|
||||||
|
apt-get update && \
|
||||||
|
apt-get install -y --no-install-recommends nodejs && \
|
||||||
|
npm install -g pnpm@10.15.1 && \
|
||||||
|
apt-get clean && \
|
||||||
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
WORKDIR /sd.cpp
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
RUN mkdir build && cd build && \
|
||||||
|
cmake .. -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ \
|
||||||
|
-DSD_MUSA=ON \
|
||||||
|
-DMUSA_ARCHITECTURES=31 \
|
||||||
|
-DSD_BUILD_SHARED_LIBS=ON \
|
||||||
|
-DGGML_NATIVE=OFF \
|
||||||
|
-DSD_BUILD_SHARED_GGML_LIB=ON \
|
||||||
|
-DGGML_BACKEND_DL=ON \
|
||||||
|
-DGGML_CPU_ALL_VARIANTS=ON \
|
||||||
|
-DCMAKE_BUILD_WITH_INSTALL_RPATH=ON \
|
||||||
|
-DCMAKE_INSTALL_RPATH='$ORIGIN' \
|
||||||
|
-DCMAKE_BUILD_TYPE=Release && \
|
||||||
|
cmake --build . --config Release
|
||||||
|
|
||||||
|
FROM ${MUSA_IMAGE} AS runtime
|
||||||
|
|
||||||
|
COPY --from=build /sd.cpp/build/bin /sd.cpp/bin
|
||||||
|
RUN printf '#!/bin/sh\nexec /sd.cpp/bin/sd-cli "$@"\n' > /sd-cli && \
|
||||||
|
printf '#!/bin/sh\nexec /sd.cpp/bin/sd-server "$@"\n' > /sd-server && \
|
||||||
|
chmod +x /sd-cli /sd-server
|
||||||
|
|
||||||
|
WORKDIR /sd.cpp
|
||||||
|
|
||||||
|
ENTRYPOINT [ "/sd-cli" ]
|
||||||
|
CMD []
|
||||||
50
docker/Dockerfile.rocm
Normal file
|
|
@ -0,0 +1,50 @@
|
||||||
|
FROM rocm/dev-ubuntu-24.04 AS build
|
||||||
|
|
||||||
|
# sd-server embeds the web UI at build time, so the build image needs Node/pnpm.
|
||||||
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||||
|
build-essential git cmake ninja-build ccache ca-certificates curl gnupg && \
|
||||||
|
mkdir -p /etc/apt/keyrings && \
|
||||||
|
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key -o /tmp/nodesource-repo.gpg.key && \
|
||||||
|
gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg /tmp/nodesource-repo.gpg.key && \
|
||||||
|
rm /tmp/nodesource-repo.gpg.key && \
|
||||||
|
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_24.x nodistro main" > /etc/apt/sources.list.d/nodesource.list && \
|
||||||
|
apt-get update && apt-get install -y --no-install-recommends nodejs && \
|
||||||
|
npm install -g pnpm@10.15.1 && \
|
||||||
|
apt-get clean && rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
WORKDIR /sd.cpp
|
||||||
|
|
||||||
|
# ROCm's clang is not on PATH in Docker RUN shells (profile scripts are not loaded).
|
||||||
|
ENV PATH="/opt/rocm/llvm/bin:$PATH"
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
ARG AMDGPU_TARGETS=""
|
||||||
|
|
||||||
|
RUN cmake . -B ./build -G Ninja \
|
||||||
|
-DCMAKE_C_COMPILER=clang \
|
||||||
|
-DCMAKE_CXX_COMPILER=clang++ \
|
||||||
|
-DSD_HIPBLAS=ON \
|
||||||
|
-DGGML_NATIVE=OFF \
|
||||||
|
-DAMDGPU_TARGETS="${AMDGPU_TARGETS}" \
|
||||||
|
-DCMAKE_BUILD_TYPE=Release \
|
||||||
|
-DCMAKE_BUILD_WITH_INSTALL_RPATH=ON \
|
||||||
|
-DCMAKE_POSITION_INDEPENDENT_CODE=ON
|
||||||
|
RUN cmake --build ./build --config Release --parallel
|
||||||
|
|
||||||
|
FROM rocm/dev-ubuntu-24.04 AS runtime
|
||||||
|
|
||||||
|
# ROCm clang links against its own OpenMP runtime in /opt/rocm/llvm/lib,
|
||||||
|
# and the ROCm runtime libs (hipblas, rocblas, amdhip64) live in /opt/rocm/lib.
|
||||||
|
ENV LD_LIBRARY_PATH="/opt/rocm/llvm/lib:/opt/rocm/lib:$LD_LIBRARY_PATH"
|
||||||
|
|
||||||
|
RUN apt-get update && \
|
||||||
|
apt-get install --yes --no-install-recommends libgomp1 && \
|
||||||
|
apt-get clean && rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
COPY --from=build /sd.cpp/build/bin /sd.cpp/bin
|
||||||
|
RUN printf '#!/bin/sh\nexec /sd.cpp/bin/sd-cli "$@"\n' > /sd-cli && \
|
||||||
|
printf '#!/bin/sh\nexec /sd.cpp/bin/sd-server "$@"\n' > /sd-server && \
|
||||||
|
chmod +x /sd-cli /sd-server
|
||||||
|
|
||||||
|
ENTRYPOINT [ "/sd-cli" ]
|
||||||
34
docker/Dockerfile.sycl
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
# ggml SYCL hardware detection uses BMG G31/WCL architecture enums added in oneAPI 2025.3.
|
||||||
|
ARG SYCL_VERSION=2025.3.2-0
|
||||||
|
|
||||||
|
FROM intel/oneapi-basekit:${SYCL_VERSION}-devel-ubuntu24.04 AS build
|
||||||
|
|
||||||
|
# sd-server embeds the web UI at build time, so the build image needs Node/pnpm.
|
||||||
|
RUN apt-get update && apt-get install -y --no-install-recommends cmake ca-certificates curl gnupg && \
|
||||||
|
mkdir -p /etc/apt/keyrings && \
|
||||||
|
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key -o /tmp/nodesource-repo.gpg.key && \
|
||||||
|
gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg /tmp/nodesource-repo.gpg.key && \
|
||||||
|
rm /tmp/nodesource-repo.gpg.key && \
|
||||||
|
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_24.x nodistro main" > /etc/apt/sources.list.d/nodesource.list && \
|
||||||
|
apt-get update && \
|
||||||
|
apt-get install -y --no-install-recommends nodejs && \
|
||||||
|
npm install -g pnpm@10.15.1 && \
|
||||||
|
apt-get clean && \
|
||||||
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
WORKDIR /sd.cpp
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
RUN mkdir build && cd build && \
|
||||||
|
cmake .. -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx -DSD_SYCL=ON -DCMAKE_BUILD_TYPE=Release && \
|
||||||
|
cmake --build . --config Release -j$(nproc)
|
||||||
|
|
||||||
|
FROM intel/oneapi-basekit:${SYCL_VERSION}-devel-ubuntu24.04 AS runtime
|
||||||
|
|
||||||
|
COPY --from=build /sd.cpp/build/bin/sd-cli /sd-cli
|
||||||
|
COPY --from=build /sd.cpp/build/bin/sd-server /sd-server
|
||||||
|
|
||||||
|
WORKDIR /sd.cpp
|
||||||
|
|
||||||
|
ENTRYPOINT [ "/sd-cli" ]
|
||||||
46
docker/Dockerfile.vulkan
Normal file
|
|
@ -0,0 +1,46 @@
|
||||||
|
ARG UBUNTU_VERSION=24.04
|
||||||
|
|
||||||
|
FROM ubuntu:$UBUNTU_VERSION AS build
|
||||||
|
|
||||||
|
# sd-server embeds the web UI at build time, so the build image needs Node/pnpm.
|
||||||
|
RUN apt-get update && apt-get install -y --no-install-recommends build-essential git cmake libvulkan-dev glslc spirv-headers ca-certificates curl gnupg && \
|
||||||
|
mkdir -p /etc/apt/keyrings && \
|
||||||
|
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key -o /tmp/nodesource-repo.gpg.key && \
|
||||||
|
gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg /tmp/nodesource-repo.gpg.key && \
|
||||||
|
rm /tmp/nodesource-repo.gpg.key && \
|
||||||
|
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_24.x nodistro main" > /etc/apt/sources.list.d/nodesource.list && \
|
||||||
|
apt-get update && \
|
||||||
|
apt-get install -y --no-install-recommends nodejs && \
|
||||||
|
npm install -g pnpm@10.15.1 && \
|
||||||
|
apt-get clean && \
|
||||||
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
WORKDIR /sd.cpp
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
RUN cmake . -B ./build \
|
||||||
|
-DSD_VULKAN=ON \
|
||||||
|
-DSD_BUILD_SHARED_LIBS=ON \
|
||||||
|
-DGGML_NATIVE=OFF \
|
||||||
|
-DSD_BUILD_SHARED_GGML_LIB=ON \
|
||||||
|
-DGGML_BACKEND_DL=ON \
|
||||||
|
-DGGML_CPU_ALL_VARIANTS=ON \
|
||||||
|
-DCMAKE_BUILD_WITH_INSTALL_RPATH=ON \
|
||||||
|
-DCMAKE_INSTALL_RPATH='$ORIGIN'
|
||||||
|
RUN cmake --build ./build --config Release -j$(nproc)
|
||||||
|
|
||||||
|
FROM ubuntu:$UBUNTU_VERSION AS runtime
|
||||||
|
|
||||||
|
RUN apt-get update && \
|
||||||
|
apt-get install --yes --no-install-recommends libgomp1 libvulkan1 mesa-vulkan-drivers libglvnd0 libgl1 libglx0 libegl1 libgles2 && \
|
||||||
|
apt-get clean
|
||||||
|
|
||||||
|
COPY --from=build /sd.cpp/build/bin /sd.cpp/bin
|
||||||
|
RUN printf '#!/bin/sh\nexec /sd.cpp/bin/sd-cli "$@"\n' > /sd-cli && \
|
||||||
|
printf '#!/bin/sh\nexec /sd.cpp/bin/sd-server "$@"\n' > /sd-server && \
|
||||||
|
chmod +x /sd-cli /sd-server
|
||||||
|
|
||||||
|
WORKDIR /sd.cpp
|
||||||
|
|
||||||
|
ENTRYPOINT [ "/sd-cli" ]
|
||||||
52
docs/README.md
Normal file
|
|
@ -0,0 +1,52 @@
|
||||||
|
# Documentation
|
||||||
|
|
||||||
|
For the project overview and supported models, see the [project README](../README.md).
|
||||||
|
|
||||||
|
## Get started
|
||||||
|
|
||||||
|
- [Model and component guides](models/README.md): download weights and run model-specific examples.
|
||||||
|
- [Build from source](build.md)
|
||||||
|
- [Docker](docker.md)
|
||||||
|
- [CLI usage guide](../examples/cli/README.md)
|
||||||
|
- [Server setup](../examples/server/README.md)
|
||||||
|
- [Server API reference](../examples/server/api.md)
|
||||||
|
- [Community bindings, applications, and UIs](ecosystem.md)
|
||||||
|
- [Troubleshooting](troubleshooting.md)
|
||||||
|
|
||||||
|
## Generation and inputs
|
||||||
|
|
||||||
|
- [DGL generation scripts](dgl.md)
|
||||||
|
- [DGL model examples](dgl/README.md)
|
||||||
|
- [C API and migration](guides/c_api.md)
|
||||||
|
- [Sampling methods and schedulers](guides/sampling.md)
|
||||||
|
- [Image editing](guides/edit.md)
|
||||||
|
- [Images in prompts](guides/prompt_images.md)
|
||||||
|
- [Image preprocessing](guides/image_preprocessing.md)
|
||||||
|
- [Generation results and metadata](guides/generation_metadata.md)
|
||||||
|
- [JSON tokenizers](guides/tokenizers.md)
|
||||||
|
|
||||||
|
## Devices and performance
|
||||||
|
|
||||||
|
- [Backend selection and device placement](guides/backend.md)
|
||||||
|
- [Performance and memory usage](guides/performance.md)
|
||||||
|
- [Inference caching](guides/caching.md)
|
||||||
|
- [RPC](guides/rpc.md)
|
||||||
|
- [SageAttention](guides/sage_attention.md)
|
||||||
|
|
||||||
|
## Weights and quantization
|
||||||
|
|
||||||
|
- [Quantization and GGUF conversion](guides/quantization_and_gguf.md)
|
||||||
|
- [Importance matrix quantization](guides/imatrix.md)
|
||||||
|
- [INT8 and INT4 convrot weights](guides/int8_convrot.md)
|
||||||
|
|
||||||
|
## Development
|
||||||
|
|
||||||
|
- [C API internals](development/c_api.md)
|
||||||
|
- [DGL architecture](development/dgl.md)
|
||||||
|
- [Model configuration and integration conventions](development/model_config.md)
|
||||||
|
- [ggml operator extensions](development/ggml_extensions.md)
|
||||||
|
- [Backend performance probes](development/backend_probe.md)
|
||||||
|
- [Position embedding cache](development/pe_cache.md)
|
||||||
|
- [PuLID implementation and validation](development/pulid.md)
|
||||||
|
- [Qwen Image 2.1 prefix cache internals](development/qwen_image_prefix_cache.md)
|
||||||
|
- [Contribution guidelines](../CONTRIBUTING.md)
|
||||||
301
docs/build.md
|
|
@ -2,18 +2,94 @@
|
||||||
|
|
||||||
## Get the Code
|
## Get the Code
|
||||||
|
|
||||||
```
|
```shell
|
||||||
git clone --recursive https://github.com/leejet/stable-diffusion.cpp
|
git clone --recursive https://github.com/leejet/stable-diffusion.cpp
|
||||||
cd stable-diffusion.cpp
|
cd stable-diffusion.cpp
|
||||||
```
|
```
|
||||||
|
|
||||||
- If you have already cloned the repository, you can use the following command to update the repository to the latest code.
|
If you already cloned the repository without submodules, initialize them from the repository root:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
git submodule update --init --recursive
|
||||||
```
|
```
|
||||||
|
|
||||||
|
To update an existing checkout and its submodules:
|
||||||
|
|
||||||
|
```shell
|
||||||
cd stable-diffusion.cpp
|
cd stable-diffusion.cpp
|
||||||
git pull origin master
|
git pull origin master
|
||||||
git submodule init
|
git submodule update --init --recursive
|
||||||
git submodule update
|
```
|
||||||
|
|
||||||
|
## Selecting a GGML source tree
|
||||||
|
|
||||||
|
By default, sd.cpp builds the patched GGML submodule in `ggml/`. To build with
|
||||||
|
an upstream GGML checkout instead, enable `SD_USE_UPSTREAM_GGML` and set
|
||||||
|
`SD_GGML_SOURCE_DIR`:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
cmake -S . -B build-upstream -DSD_USE_UPSTREAM_GGML=ON -DSD_GGML_SOURCE_DIR=../ggml-upstream
|
||||||
|
cmake --build build-upstream --config Release
|
||||||
|
```
|
||||||
|
|
||||||
|
Upstream compatibility mode uses the selected library and matching private
|
||||||
|
headers. The patched GGML build uses public headers, including `ggml-ext.h` and
|
||||||
|
`ggml-graph.h`. Backend options such as `-DSD_CUDA=ON` apply to the selected tree
|
||||||
|
as usual.
|
||||||
|
|
||||||
|
`SD_USE_UPSTREAM_GGML` defaults to `OFF`, which enables the patched GGML
|
||||||
|
extensions. Set it to `ON` when using upstream GGML; it selects the compatibility
|
||||||
|
mode and does not download or replace the GGML source tree. Upstream mode keeps
|
||||||
|
the original FP8 safetensors handling: FP8 tensors are converted to F16 at load
|
||||||
|
time (one byte per element in the file, two in RAM and VRAM). INT8
|
||||||
|
tensorwise/convrot is disabled and its model files are rejected with an explicit
|
||||||
|
error. FP8 GGUF files, FP8 weight type requests and tensor type rules are also
|
||||||
|
rejected; no automatic conversion is performed.
|
||||||
|
|
||||||
|
Upstream GGML may lack some operators and performance optimizations provided by
|
||||||
|
the patched version. A warning is emitted during CMake configuration and when
|
||||||
|
creating an inference context. Ordinary floating-point and shared GGML
|
||||||
|
quantization types remain available, subject to backend operator support.
|
||||||
|
|
||||||
|
`SD_USE_SYSTEM_GGML=ON` instead links an installed GGML CMake package, located
|
||||||
|
with `ggml_DIR` or `CMAKE_PREFIX_PATH`. An installed patched package must include
|
||||||
|
the extension and graph APIs; its source tree is not required for private
|
||||||
|
headers. The installed library must use the same ABI settings as sd.cpp,
|
||||||
|
including `GGML_MAX_NAME`. For an upstream package, also set
|
||||||
|
`SD_USE_UPSTREAM_GGML=ON` and point `SD_GGML_SOURCE_DIR` to its matching source
|
||||||
|
tree for the compatibility layer's private headers.
|
||||||
|
|
||||||
|
## WebP and WebM Support
|
||||||
|
|
||||||
|
WebP and WebM support are enabled by default. The library links `libwebp`,
|
||||||
|
`libwebpdemux` and `libwebm` so DGL `video::load` works through the C API as
|
||||||
|
well as CLI and server. WebP input supports static images and animation;
|
||||||
|
WebM input supports this project's independent VP8 frames and PCM16 audio.
|
||||||
|
No libvpx dependency is required. See [DGL media I/O](dgl.md) for frame-rate
|
||||||
|
and codec restrictions.
|
||||||
|
|
||||||
|
The CLI and server also use `libwebp` for WebP images. CLI WebM output reuses
|
||||||
|
`libwebp` to encode each frame as VP8 before muxing with `libwebm`. System WebP
|
||||||
|
packages must provide the decoder, demuxer and muxer libraries.
|
||||||
|
|
||||||
|
DGL `video::encode` supports silent WebM and AVI with PCM16 audio. Requesting
|
||||||
|
WebM audio reports an unsupported-encoder error; use `format="avi"` to include
|
||||||
|
an audio track.
|
||||||
|
|
||||||
|
If you do not want WebP/WebM support, you can disable them at configure time:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
mkdir build && cd build
|
||||||
|
cmake .. -DSD_WEBP=OFF -DSD_WEBM=OFF
|
||||||
|
cmake --build . --config Release
|
||||||
|
```
|
||||||
|
|
||||||
|
If the submodules are not available, you can also link against system packages instead:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
mkdir build && cd build
|
||||||
|
cmake .. -DSD_USE_SYSTEM_WEBP=ON -DSD_USE_SYSTEM_WEBM=ON
|
||||||
|
cmake --build . --config Release
|
||||||
```
|
```
|
||||||
|
|
||||||
## Build (CPU only)
|
## Build (CPU only)
|
||||||
|
|
@ -36,6 +112,10 @@ cmake --build . --config Release
|
||||||
|
|
||||||
## Build with CUDA
|
## Build with CUDA
|
||||||
|
|
||||||
|
The sd.cpp SageAttention extension is included when using CUDA with patched
|
||||||
|
GGML (`SD_USE_UPSTREAM_GGML=OFF`).
|
||||||
|
See [SageAttention](guides/sage_attention.md) for GPU requirements and `--sage-attn` usage.
|
||||||
|
|
||||||
This provides GPU acceleration using NVIDIA GPU. Make sure to have the CUDA toolkit installed. You can download it from your Linux distro's package manager (e.g. `apt install nvidia-cuda-toolkit`) or from here: [CUDA Toolkit](https://developer.nvidia.com/cuda-downloads). Recommended to have at least 4 GB of VRAM.
|
This provides GPU acceleration using NVIDIA GPU. Make sure to have the CUDA toolkit installed. You can download it from your Linux distro's package manager (e.g. `apt install nvidia-cuda-toolkit`) or from here: [CUDA Toolkit](https://developer.nvidia.com/cuda-downloads). Recommended to have at least 4 GB of VRAM.
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
|
|
@ -44,31 +124,122 @@ cmake .. -DSD_CUDA=ON
|
||||||
cmake --build . --config Release
|
cmake --build . --config Release
|
||||||
```
|
```
|
||||||
|
|
||||||
## Build with HipBLAS
|
When building GGML from source, sd.cpp's CUDA extensions use the same target
|
||||||
|
architectures as GGML, including native GPU detection with `GGML_NATIVE=ON`.
|
||||||
|
To select target GPUs explicitly, pass `-DCMAKE_CUDA_ARCHITECTURES=89` (Ada),
|
||||||
|
for example, or a quoted list such as `-DCMAKE_CUDA_ARCHITECTURES="80;89"`.
|
||||||
|
|
||||||
This provides GPU acceleration using AMD GPU. Make sure to have the ROCm toolkit installed.
|
CUDA extensions use sd.cpp's `thirdparty/cutlass` submodule by default
|
||||||
To build for another GPU architecture than installed in your system, set `$GFX_NAME` manually to the desired architecture (replace first command). This is also necessary if your GPU is not officially supported by ROCm, for example you have to set `$GFX_NAME` manually to `gfx1030` for consumer RDNA2 cards.
|
for eligible INT8 GEMM and CuTe attention operations. If its headers are missing,
|
||||||
|
CMake stops with an initialization hint; it does not download them automatically.
|
||||||
|
Run `git submodule update --init --recursive` from the repository root before
|
||||||
|
configuring.
|
||||||
|
|
||||||
Windows User Refer to [docs/hipBLAS_on_Windows.md](docs%2FhipBLAS_on_Windows.md) for a comprehensive guide.
|
To build with the existing CUDA implementations without CUTLASS, configure from
|
||||||
|
the repository root with:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
cmake -S . -B build -DSD_CUDA=ON -DSD_CUDA_CUTLASS_PATH:PATH=
|
||||||
|
cmake --build build --config Release
|
||||||
|
```
|
||||||
|
|
||||||
|
Alternatively, set `SD_CUDA_CUTLASS_PATH` to another local CUTLASS source
|
||||||
|
directory (tested with 3.9.2). Existing CMake caches retain their configured path;
|
||||||
|
pass `-USD_CUDA_CUTLASS_PATH` when reconfiguring to restore the bundled default.
|
||||||
|
Existing `GGML_CUDA_CUTLASS_PATH` caches are migrated on first configuration:
|
||||||
|
the old bundled path becomes `thirdparty/cutlass`, while custom paths and an
|
||||||
|
empty disabled value are preserved. An explicitly set `SD_CUDA_CUTLASS_PATH`
|
||||||
|
takes precedence. Non-CUDA builds do not require CUTLASS.
|
||||||
|
|
||||||
|
## Build with HIPBLAS
|
||||||
|
|
||||||
|
Use `-DSD_HIPBLAS=ON` for AMD GPU acceleration through HIP and hipBLAS.
|
||||||
|
Install a compatible AMD GPU driver and the ROCm SDK, including the HIP compiler,
|
||||||
|
hipBLAS, rocBLAS, and their development files. See
|
||||||
|
[AMD's ROCm installation guide](https://rocm.docs.amd.com/en/latest/install/rocm.html)
|
||||||
|
for supported GPUs, operating systems, and installation methods.
|
||||||
|
|
||||||
|
When the hipBLASLt development package (version 1.0 or later) is available,
|
||||||
|
CMake also enables INT8 GEMM tuning. The first run of an eligible matrix shape
|
||||||
|
benchmarks the no-workspace candidates returned by hipBLASLt for the current
|
||||||
|
device, including CDNA devices, and caches the result in the process. It
|
||||||
|
selects a hipBLASLt candidate that runs successfully and beats hipBLAS, or a
|
||||||
|
working candidate if hipBLAS does not support the operation.
|
||||||
|
Set `SD_HIP_DISABLE_I8_LT=1` to use the hipBLAS GEMM path for comparison.
|
||||||
|
|
||||||
|
With a compiled wave32 WMMA kernel, the HIP flash attention path supports
|
||||||
|
head dimensions 40, 52, 64, 72, 80, 120, 128, 160, 256, and 320, including
|
||||||
|
grouped-query attention. It requires unmasked attention with at least 512
|
||||||
|
query tokens and 512 key tokens. Set `SD_HIP_DISABLE_WMMA_ATTN=1` to use
|
||||||
|
ggml's native attention path for comparison.
|
||||||
|
|
||||||
|
**Linux**
|
||||||
|
|
||||||
|
With ROCm installed, use the default CMake generator and host compilers:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
mkdir build && cd build
|
mkdir build && cd build
|
||||||
if command -v rocminfo; then export GFX_NAME=$(rocminfo | awk '/ *Name: +gfx[1-9]/ {print $2; exit}'); else echo "rocminfo missing!"; fi
|
cmake .. -DSD_HIPBLAS=ON
|
||||||
if [ -z "${GFX_NAME}" ]; then echo "Error: Couldn't detect GPU!"; else echo "Building for GPU: ${GFX_NAME}"; fi
|
|
||||||
cmake .. -G "Ninja" -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DSD_HIPBLAS=ON -DCMAKE_BUILD_TYPE=Release -DGPU_TARGETS=$GFX_NAME -DAMDGPU_TARGETS=$GFX_NAME -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON -DCMAKE_POSITION_INDEPENDENT_CODE=ON
|
|
||||||
cmake --build . --config Release
|
cmake --build . --config Release
|
||||||
```
|
```
|
||||||
|
|
||||||
|
For an SDK outside the default installation path, set `ROCM_PATH` to its root
|
||||||
|
and add `$ROCM_PATH/bin` to `PATH` before configuring. If its shared libraries
|
||||||
|
are not on the system library search path, add `$ROCM_PATH/lib` and
|
||||||
|
`$ROCM_PATH/lib64` to `LD_LIBRARY_PATH` when running the executable.
|
||||||
|
|
||||||
|
**Windows**
|
||||||
|
|
||||||
|
Follow the Windows environment setup in [Ninja](#ninja). The Windows HIP build
|
||||||
|
requires ROCm Clang with Ninja; the Visual Studio generator is not supported.
|
||||||
|
|
||||||
|
Set `HIP_PATH` to the SDK root. The HIP SDK installer normally sets this variable;
|
||||||
|
for [ROCm wheels](https://github.com/ROCm/TheRock/blob/main/RELEASES.md), run
|
||||||
|
`rocm-sdk init` and use `rocm-sdk path --root`. The build commands below cover
|
||||||
|
both the installer and wheel SDK compiler layouts.
|
||||||
|
|
||||||
|
For the wheel SDK, also set the device library path before building:
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
$env:HIP_DEVICE_LIB_PATH = "$env:HIP_PATH\lib\llvm\amdgcn\bitcode"
|
||||||
|
```
|
||||||
|
|
||||||
|
Then configure and build:
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
$env:ROCM_PATH = $env:HIP_PATH
|
||||||
|
$env:PATH = "$env:HIP_PATH\bin;$env:HIP_PATH\lib\llvm\bin;$env:PATH"
|
||||||
|
cmake -S . -B build-hip -G Ninja -DSD_HIPBLAS=ON -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_BUILD_TYPE=Release
|
||||||
|
cmake --build build-hip --config Release
|
||||||
|
```
|
||||||
|
|
||||||
|
Keep the SDK's `bin` directory on `PATH` when running `build-hip\bin\sd-cli.exe`
|
||||||
|
so its runtime DLLs can be found.
|
||||||
|
|
||||||
|
**GPU targets and verification**
|
||||||
|
|
||||||
|
CMake normally detects the installed GPU. To select a target explicitly or build
|
||||||
|
on a machine without an AMD GPU, add `-DGPU_TARGETS=gfx1100` to the configure
|
||||||
|
command (for example, for an RX 7900 XTX, XT, or GRE). For multiple targets, use a
|
||||||
|
quoted list such as `-DGPU_TARGETS="gfx1100;gfx1200"`. Check AMD's
|
||||||
|
[GPU specifications](https://rocm.docs.amd.com/en/latest/reference/gpu-specs.html)
|
||||||
|
for the correct target; the installed SDK libraries must also support it.
|
||||||
|
|
||||||
|
Use a fresh build directory when switching SDKs or compilers. Run the resulting
|
||||||
|
`sd-cli --version` to check that the executable starts without loading a model.
|
||||||
|
|
||||||
## Build with MUSA
|
## Build with MUSA
|
||||||
|
|
||||||
This provides GPU acceleration using Moore Threads GPU. Make sure to have the MUSA toolkit installed.
|
This provides GPU acceleration using Moore Threads GPUs. The configuration below follows upstream validation with MUSA SDK 5.2.0 and MTT S5000 (PH1, `mp_31`). Install that toolkit before building. Older SDKs such as 4.2 may lack the CUB headers required by the current backend.
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
mkdir build && cd build
|
mkdir build && cd build
|
||||||
cmake .. -DCMAKE_C_COMPILER=/usr/local/musa/bin/clang -DCMAKE_CXX_COMPILER=/usr/local/musa/bin/clang++ -DSD_MUSA=ON -DCMAKE_BUILD_TYPE=Release
|
cmake .. -DCMAKE_C_COMPILER=/usr/local/musa/bin/clang -DCMAKE_CXX_COMPILER=/usr/local/musa/bin/clang++ -DSD_MUSA=ON -DMUSA_ARCHITECTURES=31 -DCMAKE_BUILD_TYPE=Release
|
||||||
cmake --build . --config Release
|
cmake --build . --config Release
|
||||||
```
|
```
|
||||||
|
|
||||||
|
The MUSA Docker image uses the same SDK 5.2.0 development image as upstream for both build and runtime stages, and targets `mp_31` only. It includes the development tools and PyTorch from that base image, so it is larger than a minimal runtime image. Other GPU architectures require separate validation.
|
||||||
|
|
||||||
## Build with Metal
|
## Build with Metal
|
||||||
|
|
||||||
Using Metal makes the computation run on the GPU. Currently, there are some issues with Metal when performing operations on very large matrices, making it highly inefficient at the moment. Performance improvements are expected in the near future.
|
Using Metal makes the computation run on the GPU. Currently, there are some issues with Metal when performing operations on very large matrices, making it highly inefficient at the moment. Performance improvements are expected in the near future.
|
||||||
|
|
@ -82,6 +253,11 @@ cmake --build . --config Release
|
||||||
## Build with Vulkan
|
## Build with Vulkan
|
||||||
|
|
||||||
Install Vulkan SDK from https://www.lunarg.com/vulkan-sdk/.
|
Install Vulkan SDK from https://www.lunarg.com/vulkan-sdk/.
|
||||||
|
On Ubuntu, install the Vulkan development packages and SPIR-V headers:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
sudo apt-get install build-essential libvulkan-dev glslc spirv-headers
|
||||||
|
```
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
mkdir build && cd build
|
mkdir build && cd build
|
||||||
|
|
@ -95,10 +271,8 @@ Currently, it supports only Adreno GPUs and is primarily optimized for Q4_0 type
|
||||||
|
|
||||||
To build for Windows ARM please refers to [Windows 11 Arm64](https://github.com/ggml-org/llama.cpp/blob/master/docs/backend/OPENCL.md#windows-11-arm64)
|
To build for Windows ARM please refers to [Windows 11 Arm64](https://github.com/ggml-org/llama.cpp/blob/master/docs/backend/OPENCL.md#windows-11-arm64)
|
||||||
|
|
||||||
Building for Android:
|
For Android, prepare [Ninja](#ninja) and install the Android NDK from the
|
||||||
|
[official Android developer site](https://developer.android.com/ndk/downloads).
|
||||||
Android NDK:
|
|
||||||
Download and install the Android NDK from the [official Android developer site](https://developer.android.com/ndk/downloads).
|
|
||||||
|
|
||||||
Setup OpenCL Dependencies for NDK:
|
Setup OpenCL Dependencies for NDK:
|
||||||
|
|
||||||
|
|
@ -130,7 +304,7 @@ You need to provide OpenCL headers and the ICD loader library to your NDK sysroo
|
||||||
-DANDROID_PLATFORM=24 \
|
-DANDROID_PLATFORM=24 \
|
||||||
-DANDROID_STL=c++_shared
|
-DANDROID_STL=c++_shared
|
||||||
|
|
||||||
ninja
|
cmake --build .
|
||||||
# Replace <YOUR_NDK_PATH>
|
# Replace <YOUR_NDK_PATH>
|
||||||
# e.g., cp libOpenCL.so /path/to/android-ndk-r26c/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/aarch64-linux-android
|
# e.g., cp libOpenCL.so /path/to/android-ndk-r26c/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/aarch64-linux-android
|
||||||
sudo cp libOpenCL.so <YOUR_NDK_PATH>/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/aarch64-linux-android
|
sudo cp libOpenCL.so <YOUR_NDK_PATH>/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/aarch64-linux-android
|
||||||
|
|
@ -151,7 +325,7 @@ cmake .. -G Ninja \
|
||||||
-DGGML_OPENMP=OFF \
|
-DGGML_OPENMP=OFF \
|
||||||
-DSD_OPENCL=ON
|
-DSD_OPENCL=ON
|
||||||
|
|
||||||
ninja
|
cmake --build .
|
||||||
```
|
```
|
||||||
*(Note: Don't forget to include `LD_LIBRARY_PATH=/vendor/lib64` in your command line before running the binary)*
|
*(Note: Don't forget to include `LD_LIBRARY_PATH=/vendor/lib64` in your command line before running the binary)*
|
||||||
|
|
||||||
|
|
@ -163,6 +337,9 @@ Using SYCL makes the computation run on the Intel GPU. Please make sure you have
|
||||||
# Export relevant ENV variables
|
# Export relevant ENV variables
|
||||||
source /opt/intel/oneapi/setvars.sh
|
source /opt/intel/oneapi/setvars.sh
|
||||||
|
|
||||||
|
# Make and enter build dir
|
||||||
|
mkdir build && cd build
|
||||||
|
|
||||||
# Option 1: Use FP32 (recommended for better performance in most cases)
|
# Option 1: Use FP32 (recommended for better performance in most cases)
|
||||||
cmake .. -DSD_SYCL=ON -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx
|
cmake .. -DSD_SYCL=ON -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx
|
||||||
|
|
||||||
|
|
@ -171,3 +348,89 @@ cmake .. -DSD_SYCL=ON -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx -DGGML_SY
|
||||||
|
|
||||||
cmake --build . --config Release
|
cmake --build . --config Release
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Build tools and compiler cache
|
||||||
|
|
||||||
|
The settings in this section can be combined with the backend options in
|
||||||
|
this guide.
|
||||||
|
|
||||||
|
### Ninja
|
||||||
|
|
||||||
|
Install Ninja and make sure `ninja --version` works in your build terminal.
|
||||||
|
For native Windows builds with MSVC or ROCm Clang, install Visual Studio
|
||||||
|
2022 C++ build tools with the Windows SDK, CMake, and Ninja, then open an
|
||||||
|
x64 **Developer PowerShell for VS 2022**.
|
||||||
|
|
||||||
|
From the repository root, configure and build a Release version with:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
cmake -S . -B build-ninja -G Ninja -DCMAKE_BUILD_TYPE=Release
|
||||||
|
cmake --build build-ninja --parallel 8
|
||||||
|
```
|
||||||
|
|
||||||
|
This builds the CPU backend by default. Add backend options such as
|
||||||
|
`-DSD_CUDA=ON` or `-DSD_VULKAN=ON` to the configure command as needed.
|
||||||
|
With MSVC, you can explicitly select the compiler by adding
|
||||||
|
`-DCMAKE_C_COMPILER=cl.exe -DCMAKE_CXX_COMPILER=cl.exe`.
|
||||||
|
Adjust `--parallel 8` for your available CPU and memory resources.
|
||||||
|
|
||||||
|
Use a separate build directory when switching from another CMake generator,
|
||||||
|
such as Visual Studio. With this Ninja generator, select the build type at
|
||||||
|
configure time using `CMAKE_BUILD_TYPE`.
|
||||||
|
|
||||||
|
### ccache (optional)
|
||||||
|
|
||||||
|
Install [ccache](https://ccache.dev/download.html) and add it to `PATH`.
|
||||||
|
Check that it is available and optionally set a cache size limit:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
ccache --version
|
||||||
|
ccache --max-size=20G
|
||||||
|
```
|
||||||
|
|
||||||
|
To cache C and C++ compilation, configure with compiler launchers:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
cmake -S . -B build-ninja -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
|
||||||
|
cmake --build build-ninja --parallel 8
|
||||||
|
ccache --show-stats
|
||||||
|
```
|
||||||
|
|
||||||
|
For CUDA builds, also add `-DSD_CUDA=ON` and
|
||||||
|
`-DCMAKE_CUDA_COMPILER_LAUNCHER=ccache` to the configure command so CUDA
|
||||||
|
compilation is cached as well. Keep any other backend or compiler options
|
||||||
|
used for your build.
|
||||||
|
|
||||||
|
These [compiler launcher settings](https://cmake.org/cmake/help/latest/prop_tgt/LANG_COMPILER_LAUNCHER.html)
|
||||||
|
work with Ninja and Makefile generators. The Visual Studio generator does
|
||||||
|
not use them.
|
||||||
|
|
||||||
|
The first compilation populates the cache. After a successful build, you can
|
||||||
|
check reuse by rebuilding the same configuration with the cache intact:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
ccache --zero-stats
|
||||||
|
cmake --build build-ninja --clean-first --parallel 8
|
||||||
|
ccache --show-stats
|
||||||
|
```
|
||||||
|
|
||||||
|
Look for cache hits in the statistics. A normal incremental build with no
|
||||||
|
changed files skips compilation and does not produce new cache hits.
|
||||||
|
|
||||||
|
### MSVC compilation parallelism
|
||||||
|
|
||||||
|
MSVC builds limit parallel C/C++ compilation within each project by default.
|
||||||
|
For `n` logical processors, the limit is `n` when `n <= 2`, `n - 1` when
|
||||||
|
`3 <= n <= 8`, and `n - 2` when `n > 8`. The default is calculated when the
|
||||||
|
build directory is first configured with this setting. Override it with
|
||||||
|
`-DSD_MSVC_MP_COUNT=4`, or pass `-USD_MSVC_MP_COUNT` to recalculate it.
|
||||||
|
|
||||||
|
For Visual Studio builds, keep project-level parallelism at one to avoid
|
||||||
|
multiplying the per-project limit:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
cmake --build build --config Release --parallel 1
|
||||||
|
```
|
||||||
|
|
||||||
|
This setting controls MSVC's `/MP` option, not CUDA compiler parallelism or a
|
||||||
|
hard CPU usage limit. For Ninja job limits, see [Ninja](#ninja).
|
||||||
|
|
|
||||||
|
|
@ -1,33 +0,0 @@
|
||||||
# How to Use
|
|
||||||
|
|
||||||
You can run Chroma using stable-diffusion.cpp with a GPU that has 6GB or even 4GB of VRAM, without needing to offload to RAM.
|
|
||||||
|
|
||||||
## Download weights
|
|
||||||
|
|
||||||
- Download Chroma
|
|
||||||
- If you don't want to do the conversion yourself, download the preconverted gguf model from [silveroxides/Chroma-GGUF](https://huggingface.co/silveroxides/Chroma-GGUF)
|
|
||||||
- Otherwise, download chroma's safetensors from [lodestones/Chroma](https://huggingface.co/lodestones/Chroma)
|
|
||||||
- Download vae from https://huggingface.co/black-forest-labs/FLUX.1-dev/blob/main/ae.safetensors
|
|
||||||
- Download t5xxl from https://huggingface.co/comfyanonymous/flux_text_encoders/blob/main/t5xxl_fp16.safetensors
|
|
||||||
|
|
||||||
## Convert Chroma weights
|
|
||||||
|
|
||||||
You can download the preconverted gguf weights from [silveroxides/Chroma-GGUF](https://huggingface.co/silveroxides/Chroma-GGUF), this way you don't have to do the conversion yourself.
|
|
||||||
|
|
||||||
```
|
|
||||||
.\bin\Release\sd-cli.exe -M convert -m ..\..\ComfyUI\models\unet\chroma-unlocked-v40.safetensors -o ..\models\chroma-unlocked-v40-q8_0.gguf -v --type q8_0
|
|
||||||
```
|
|
||||||
|
|
||||||
## Run
|
|
||||||
|
|
||||||
### Example
|
|
||||||
For example:
|
|
||||||
|
|
||||||
```
|
|
||||||
.\bin\Release\sd-cli.exe --diffusion-model ..\models\chroma-unlocked-v40-q8_0.gguf --vae ..\models\ae.sft --t5xxl ..\models\t5xxl_fp16.safetensors -p "a lovely cat holding a sign says 'chroma.cpp'" --cfg-scale 4.0 --sampling-method euler -v --chroma-disable-dit-mask --clip-on-cpu
|
|
||||||
```
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,21 +0,0 @@
|
||||||
# How to Use
|
|
||||||
|
|
||||||
## Download weights
|
|
||||||
|
|
||||||
- Download Chroma1-Radiance
|
|
||||||
- safetensors: https://huggingface.co/lodestones/Chroma1-Radiance/tree/main
|
|
||||||
- gguf: https://huggingface.co/silveroxides/Chroma1-Radiance-GGUF/tree/main
|
|
||||||
|
|
||||||
- Download t5xxl
|
|
||||||
- safetensors: https://huggingface.co/comfyanonymous/flux_text_encoders/blob/main/t5xxl_fp16.safetensors
|
|
||||||
|
|
||||||
## Examples
|
|
||||||
|
|
||||||
```
|
|
||||||
.\bin\Release\sd-cli.exe --diffusion-model ..\..\ComfyUI\models\diffusion_models\Chroma1-Radiance-v0.4-Q8_0.gguf --t5xxl ..\..\ComfyUI\models\clip\t5xxl_fp16.safetensors -p "a lovely cat holding a sign says 'chroma radiance cpp'" --cfg-scale 4.0 --sampling-method euler -v
|
|
||||||
```
|
|
||||||
|
|
||||||
<img alt="Chroma1-Radiance" src="../assets/flux/chroma1-radiance.png" />
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
53
docs/development/backend_probe.md
Normal file
|
|
@ -0,0 +1,53 @@
|
||||||
|
# Adding backend performance probes
|
||||||
|
|
||||||
|
`src/core/probe/backend_probe.h` provides the shared measurement machinery. Operator
|
||||||
|
policy stays separate: `src/core/probe/flash_attn.cpp`, for example, defines attention
|
||||||
|
shapes and its CPU/CUDA/HIP/Vulkan shortcuts, then calls `sd_run_backend_probe` for unknown
|
||||||
|
configurations. `src/core/probe/conv_direct.cpp` uses metadata-only probe graphs
|
||||||
|
to check direct 2D/3D convolution support, then enables known implicit GEMM
|
||||||
|
paths on non-Vulkan backends. Vulkan compares direct convolution with im2col
|
||||||
|
using the shared measurement machinery.
|
||||||
|
|
||||||
|
For each representative shape, create a `BackendProbeCase`:
|
||||||
|
|
||||||
|
- `build(graph, candidate)` creates inputs and either the reference or candidate
|
||||||
|
graph in `graph.ctx`, registers input tensors in `graph.inputs`, and assigns
|
||||||
|
`graph.output`. Leave the output null if the requested implementation is
|
||||||
|
unavailable; do not silently benchmark its fallback as the candidate.
|
||||||
|
- By default, inputs receive deterministic F32 data, with the same seed for both
|
||||||
|
variants. Supply `initialize` for F16 convolution weights, integer inputs, or
|
||||||
|
operator-specific values. It runs after allocation, outside timed execution.
|
||||||
|
Both variants must receive equivalent logical inputs.
|
||||||
|
- Default output validation requires matching shapes and contiguous F32 outputs,
|
||||||
|
checks finiteness, and applies absolute and relative tolerances. Supply
|
||||||
|
`compare` for other output types or validation rules.
|
||||||
|
|
||||||
|
Graphs must be safe to execute repeatedly without modifying their inputs.
|
||||||
|
`BackendProbeGraph` owns its GGML context and buffer, so all return paths release
|
||||||
|
probe resources. Constructors allocate metadata only; `supported()` can also be
|
||||||
|
used before a known-architecture shortcut, without allocating device tensors.
|
||||||
|
|
||||||
|
`BackendProbeOptions` controls graph metadata capacity, warmup count, measurement
|
||||||
|
count, measured-time budget, minimum free device memory, comparison tolerances,
|
||||||
|
and minimum improvement. Warmup and allocation are excluded from timing. The
|
||||||
|
runner alternates the two variants, synchronizes the backend around execution,
|
||||||
|
and compares sums of per-case medians. The time budget is checked before each
|
||||||
|
measurement pair; it cannot interrupt an in-flight backend operation.
|
||||||
|
|
||||||
|
Only use `candidate_faster` when `completed` is true. On incomplete probes,
|
||||||
|
`error` reports why comparison failed and the timing totals may be partial.
|
||||||
|
The caller handles logging, known architecture rules, fallback policy, and
|
||||||
|
context-lifetime caching. DGL uses one `BackendProbeCache` shared by all models
|
||||||
|
in an execution context, including LoRA variants and models loaded by later
|
||||||
|
programs. It caches both enabled and disabled decisions by operation and compute
|
||||||
|
backend; CPU attention additionally keys the effective thread count. GPU results
|
||||||
|
survive changes to the context's thread count. The cache serializes first-time
|
||||||
|
probes and their decision logs. Explicit operator `on` and `off` bypass the cache.
|
||||||
|
If probe shapes or other relevant settings become variable, add them to the key.
|
||||||
|
|
||||||
|
Convolution results are cached separately for 2D and 3D, once per compute backend
|
||||||
|
in the context, just like attention results. Each probe logs its backend, decision,
|
||||||
|
and reason; mixed-device modules log when their compute devices disagree.
|
||||||
|
|
||||||
|
Module assignment parsing remains in `src/core/ggml_extend_backend.cpp`, next
|
||||||
|
to backend assignment parsing. The probe directory does not parse CLI/API options.
|
||||||
89
docs/development/c_api.md
Normal file
|
|
@ -0,0 +1,89 @@
|
||||||
|
# C API Internals
|
||||||
|
|
||||||
|
The public declarations live in [stable-diffusion.h](../../include/stable-diffusion.h).
|
||||||
|
See the [C API guide](../guides/c_api.md) for keys, value types and ownership rules.
|
||||||
|
|
||||||
|
## Internal modules
|
||||||
|
|
||||||
|
| Module | Responsibility |
|
||||||
|
| --- | --- |
|
||||||
|
| `src/api/options.h/.cpp` | Opaque options, key registration, setter validation and conversion to typed configuration. |
|
||||||
|
| `src/config.h/.cpp` | Typed configuration and the library defaults for each configuration group. |
|
||||||
|
| `src/api/tensor.h/.cpp` | Opaque tensor handles backed by `sd::Tensor<T>`, reference counting and conversion to private media views. |
|
||||||
|
| `src/core/media.h` | Private raw media views used by inference and codecs. |
|
||||||
|
| `src/api/result.h/.cpp` | Internal result storage, opaque result accessors, metadata attachment and media ownership. |
|
||||||
|
| `src/api/api.h/.cpp` | Context, generation, callback and query entry points, plus thread-local diagnostics and exception-to-status handling. |
|
||||||
|
| `src/api/generation.*` | Persistent DGL context, metadata probing, request execution, callbacks and cancellation. |
|
||||||
|
| `src/api/generation_program.*`, `generation_image.cpp`, `generation_video.cpp`, `generation_h3.cpp`, `generation_prompt.cpp` | Template selection, literal rendering and host input bindings. |
|
||||||
|
| `src/api/generation_template.*` | Embedded template parsing, variable formatting and conditional rendering. |
|
||||||
|
| `src/api/templates/` | Complete DGL execution flows and a few shared helpers. |
|
||||||
|
| `src/api/program_result.cpp` | Adaptation of DGL tensors and dictionaries to C results. |
|
||||||
|
| `src/api/generation_metadata.cpp` | Image parameter and WebUI infotext extraction through the metadata C API. |
|
||||||
|
| `src/api/image_metadata.cpp` | Container metadata reading and text/JSON reports through `sd_read_metadata()`. |
|
||||||
|
| `src/api/media_metadata.cpp`, `metadata.h` | Shared metadata encoding and C access to PNG/JPEG/XMP/AVI chunks. |
|
||||||
|
| `src/core/option_types.h/.cpp` | Internal mode enums, name lookup and parsing. |
|
||||||
|
|
||||||
|
Options are validated and converted at the API boundary. The translator renders
|
||||||
|
a concrete DGL program and binds media through `main` tensor inputs. All retained
|
||||||
|
inference entries use the same DGL compiler, execution context and model cache.
|
||||||
|
There is no separate native pipeline.
|
||||||
|
|
||||||
|
The option map alone records whether a key was supplied. Zero, false, empty
|
||||||
|
strings and explicit automatic choices remain entries until `unset` removes
|
||||||
|
them. Each conversion starts with a fresh `OptConfig`, then overlays supplied
|
||||||
|
values and validates combinations. Reusing the output configuration cannot
|
||||||
|
retain a previous request's overrides.
|
||||||
|
|
||||||
|
Fixed defaults live in the configuration constructors. Internal automatic
|
||||||
|
policies (such as model-selected sampler/scheduler and automatic eta/flow shift)
|
||||||
|
are resolved by the translator after refreshing the model metadata. Their internal
|
||||||
|
sentinel values describe an automatic policy, not the presence of an input key.
|
||||||
|
Do not infer presence by comparing a typed value against its default.
|
||||||
|
|
||||||
|
CLI/server inference inputs use `std::optional`; their option builders emit
|
||||||
|
only engaged fields. Recipe defaults fill missing startup inputs; request
|
||||||
|
fields then override the configured recipe/startup values. Explicit empty
|
||||||
|
numeric arrays replace inherited arrays, and JSON `null` clears an optional
|
||||||
|
input. Frontend-only settings such as output formats and listen ports keep
|
||||||
|
local defaults. Frontend checks cover request syntax, file inputs and server
|
||||||
|
resource policy. Parameter ranges are checked by the public setters used by the
|
||||||
|
option builders; combinations and model applicability are checked when executing.
|
||||||
|
Examples include only public library headers and do not query library defaults.
|
||||||
|
Capability defaults describe configured overrides; null means that the library
|
||||||
|
selects the value, and the executed DGL records the effective values.
|
||||||
|
|
||||||
|
Result storage owns tensors and metadata. Tensor handles contain a dtype-specific
|
||||||
|
`sd::Tensor<T>` and an atomic reference count; options retain handles rather than
|
||||||
|
copying tensor payloads. DGL outputs are adapted at the result boundary.
|
||||||
|
Internal producers with an `sd::Tensor<T>` can
|
||||||
|
move it directly into a handle. Video results keep per-frame tensors and assemble
|
||||||
|
a contiguous video tensor only when requested. Cached assembly is synchronized.
|
||||||
|
Preview tensors are independent snapshots and may be retained by callbacks.
|
||||||
|
Results retain the exact compiled DGL source. WebUI conversion and media metadata
|
||||||
|
embedding are separate from inference and never rebuild the execution program.
|
||||||
|
`src/api/generation_metadata.cpp` parses the source once to produce image
|
||||||
|
parameters and WebUI infotext together. Examples obtain this JSON through
|
||||||
|
`sd_get_generation_metadata()` without compiling or calling the DGL parser.
|
||||||
|
Container reading and metadata chunk generation also use the public C API.
|
||||||
|
Examples have no private `src` include path and retain generated DGL source
|
||||||
|
without legacy JSON conversion or LoRA path rewriting.
|
||||||
|
The translator uses an explicit `llm_path` as the text encoder's main `path`, falling back to
|
||||||
|
the checkpoint and other configured encoder paths when it is absent.
|
||||||
|
|
||||||
|
Context creation snapshots options without loading weights. Family probing is
|
||||||
|
lazy and tracks actual file dependencies. The complete request stays busy during
|
||||||
|
probing, compilation, batch gaps and execution. File permissions are checked
|
||||||
|
before probing and on every DGL resource access, including cache hits.
|
||||||
|
Generation templates load their required components as part of execution.
|
||||||
|
Capability queries read the detected family under the context lock and probe it
|
||||||
|
on demand. They leave the generation cancellation state untouched.
|
||||||
|
|
||||||
|
C++ validates inputs, resolves model defaults, prepares geometry and binds host
|
||||||
|
tensors. Templates describe complete execution flows and optional stages;
|
||||||
|
operations and models retain computation algorithms. Split templates when the
|
||||||
|
flow changes substantially, and use conditions for smaller variations. Do not
|
||||||
|
search and patch rendered source to change execution. See the
|
||||||
|
[template guide](../../src/api/templates/README.md).
|
||||||
|
|
||||||
|
These headers are private implementation details and are not installed as part
|
||||||
|
of the public C API.
|
||||||