-
Notifications
You must be signed in to change notification settings - Fork 21
1165 lines (1048 loc) · 45.8 KB
/
build-gpu-wheels.yml
File metadata and controls
1165 lines (1048 loc) · 45.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
name: build-gpu-wheels
permissions:
contents: read
on:
workflow_dispatch:
inputs:
link_mode:
description: 'Linking mode'
required: true
default: 'dynamic'
type: choice
options:
- dynamic
- static
cuda_linux:
description: 'Build CUDA 12 wheels (Linux x86_64)'
required: false
default: false
type: boolean
rocm_linux:
description: 'Build ROCm wheels (Linux x86_64)'
required: false
default: false
type: boolean
sycl_linux:
description: 'Build SYCL wheels (Linux x86_64)'
required: false
default: false
type: boolean
vulkan_linux:
description: 'Build Vulkan wheels (Linux x86_64)'
required: false
default: false
type: boolean
cuda_windows:
description: 'Build CUDA 12 wheels (Windows x86_64)'
required: false
default: false
type: boolean
vulkan_windows:
description: 'Build Vulkan wheels (Windows x86_64)'
required: false
default: false
type: boolean
vulkan_macos_intel:
description: 'Build Vulkan wheels (MacOS Intel)'
required: false
default: false
type: boolean
upload_release:
description: 'Upload wheels to GitHub Release'
required: false
default: false
type: boolean
publish_index:
description: 'Publish to GitHub Pages wheel index'
required: false
default: false
type: boolean
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ inputs.link_mode }}
cancel-in-progress: true
env:
CIBW_BUILD_VERBOSITY: 1
CIBW_BUILD: "cp310-* cp311-* cp312-* cp313-* cp314-*"
CIBW_SKIP: "*-musllinux_* *-win32 *-manylinux_i686"
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: "true"
jobs:
# ---------------------------------------------------------------------------
# CUDA wheels (Linux only, CUDA 12.4)
# ---------------------------------------------------------------------------
build_cuda:
name: CUDA 12.4 - Linux x86_64 (${{ inputs.link_mode }})
if: inputs.cuda_linux
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Free disk space
run: |
sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc
df -h
- name: Cache thirdparty deps
id: cache-deps
uses: actions/cache@v5
with:
path: thirdparty/
key: deps-cuda-${{ inputs.link_mode }}-${{ hashFiles('scripts/manage.py', '.github/workflows/build-gpu-wheels.yml') }}
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.11'
- name: Install cibuildwheel
run: pip install cibuildwheel==3.4.0
- name: Set CCACHE_DIR to workspace
run: echo "CCACHE_DIR=${{ github.workspace }}/.ccache" >> "$GITHUB_ENV"
- name: ccache
uses: hendrikmuhs/[email protected]
with:
key: ccache-cuda-${{ inputs.link_mode }}
evict-old-files: 1d
- name: Build CUDA wheels
run: python -m cibuildwheel --output-dir wheelhouse
env:
CIBW_ARCHS_LINUX: x86_64
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014
CIBW_BEFORE_ALL_LINUX: >
yum install -y git yum-utils epel-release &&
yum install -y ccache &&
yum-config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/rhel7/x86_64/cuda-rhel7.repo &&
yum install -y cuda-nvcc-12-4 cuda-cudart-devel-12-4 cuda-driver-devel-12-4 libcublas-devel-12-4 &&
ln -s /usr/local/cuda-12.4 /usr/local/cuda &&
if [ -f /project/thirdparty/.deps-complete ]; then echo "=== Deps cached, skipping build ==="; exit 0; fi &&
CI_PYTHON=$(ls -d /opt/python/cp3*/bin | head -1) &&
$CI_PYTHON/pip install cmake ninja &&
PATH=/usr/local/cuda/bin:$CI_PYTHON:$PATH
CCACHE_DIR=/project/.ccache
CCACHE_DEPEND=1
CMAKE_C_COMPILER_LAUNCHER=ccache
CMAKE_CXX_COMPILER_LAUNCHER=ccache
CMAKE_CUDA_COMPILER_LAUNCHER=ccache
CMAKE_CUDA_ARCHITECTURES="75"
GGML_NATIVE=OFF GGML_CUDA=1 GGML_METAL=0
SD_USE_VENDORED_GGML=${{ inputs.link_mode == 'dynamic' && '0' || '1' }}
$CI_PYTHON/python scripts/manage.py build --all --deps-only --no-sd-examples
${{ inputs.link_mode == 'dynamic' && '--dynamic' || '' }} &&
touch /project/thirdparty/.deps-complete
CIBW_BEFORE_BUILD_LINUX: >
sed -i 's/^name = "cyllama"/name = "cyllama-cuda12"/' {project}/pyproject.toml &&
grep -q '^name = "cyllama-cuda12"' {project}/pyproject.toml || { echo "ERROR: sed rename to cyllama-cuda12 failed"; exit 1; } &&
cd {project} && python scripts/manage.py write_build_config
CIBW_ENVIRONMENT_LINUX: >
GGML_CUDA=1
GGML_METAL=0
CUDA_PATH=/usr/local/cuda
CMAKE_CUDA_ARCHITECTURES="75"
GGML_NATIVE=OFF
PATH=/usr/local/cuda/bin:$PATH
LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH
CFLAGS=-s
CXXFLAGS=-s
CCACHE_DIR=/project/.ccache
CCACHE_DEPEND=1
CMAKE_C_COMPILER_LAUNCHER=ccache
CMAKE_CXX_COMPILER_LAUNCHER=ccache
CMAKE_CUDA_COMPILER_LAUNCHER=ccache
WITH_DYLIB=${{ inputs.link_mode == 'dynamic' && '1' || '0' }}
SD_USE_VENDORED_GGML=${{ inputs.link_mode == 'dynamic' && '0' || '1' }}
CIBW_TEST_COMMAND: ""
CIBW_REPAIR_WHEEL_COMMAND_LINUX: >
test -d {project}/thirdparty/llama.cpp/dynamic || { echo "ERROR: dynamic lib dir missing: {project}/thirdparty/llama.cpp/dynamic"; exit 1; } &&
LD_LIBRARY_PATH={project}/thirdparty/llama.cpp/dynamic:$LD_LIBRARY_PATH
auditwheel repair -w {dest_dir} {wheel}
--plat manylinux_2_35_x86_64
--exclude libcuda.so.1
--exclude libcudart.so.12
--exclude libcublas.so.12
--exclude libcublasLt.so.12
--exclude libgomp.so.1
- name: List built wheels
run: ls -lah wheelhouse/
- name: Upload wheels
uses: actions/upload-artifact@v7
with:
name: wheels-cuda-linux-x86_64
path: ./wheelhouse/*.whl
# ---------------------------------------------------------------------------
# ROCm wheels (Linux only, ROCm 6.3)
# ---------------------------------------------------------------------------
build_rocm:
name: ROCm 6.3 - Linux x86_64 (${{ inputs.link_mode }})
if: inputs.rocm_linux
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Free disk space
run: |
sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc
df -h
- name: Cache thirdparty deps
id: cache-deps
uses: actions/cache@v5
with:
path: thirdparty/
key: deps-rocm-${{ inputs.link_mode }}-${{ hashFiles('scripts/manage.py', '.github/workflows/build-gpu-wheels.yml') }}
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.11'
- name: Install cibuildwheel
run: pip install cibuildwheel==3.4.0
- name: Set CCACHE_DIR to workspace
run: echo "CCACHE_DIR=${{ github.workspace }}/.ccache" >> "$GITHUB_ENV"
- name: ccache
uses: hendrikmuhs/[email protected]
with:
key: ccache-rocm-${{ inputs.link_mode }}
evict-old-files: 1d
- name: Build ROCm wheels
run: python -m cibuildwheel --output-dir wheelhouse
env:
CIBW_ARCHS_LINUX: x86_64
CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28
CIBW_BEFORE_ALL_LINUX: >
dnf install -y git epel-release &&
dnf install -y ccache &&
dnf install -y https://repo.radeon.com/amdgpu-install/6.3.3/rhel/8.10/amdgpu-install-6.3.60303-1.el8.noarch.rpm &&
dnf install -y rocm-hip-runtime-devel hipblas-devel rocblas-devel libstdc++-static &&
ls -d /opt/rocm-* | head -1 | xargs -I{} ln -sf {} /opt/rocm &&
ln -sf /usr/lib/gcc/x86_64-redhat-linux/8/libstdc++.a /opt/rocm/lib/libstdc++.a &&
if [ -f /project/thirdparty/.deps-complete ]; then echo "=== Deps cached, skipping build ==="; exit 0; fi &&
CI_PYTHON=$(ls -d /opt/python/cp3*/bin | head -1) &&
$CI_PYTHON/pip install cmake ninja &&
PATH=/opt/rocm/bin:$CI_PYTHON:$PATH
LIBRARY_PATH=/usr/lib/gcc/x86_64-redhat-linux/8:$LIBRARY_PATH
CCACHE_DIR=/project/.ccache
CCACHE_DEPEND=1
CMAKE_C_COMPILER_LAUNCHER=ccache
CMAKE_CXX_COMPILER_LAUNCHER=ccache
CMAKE_HIP_COMPILER_LAUNCHER=ccache
CMAKE_HIP_ARCHITECTURES="gfx90a;gfx942;gfx1100"
HIP_PATH=/opt/rocm
GGML_NATIVE=OFF GGML_HIP=1 GGML_METAL=0
SD_USE_VENDORED_GGML=${{ inputs.link_mode == 'dynamic' && '0' || '1' }}
$CI_PYTHON/python scripts/manage.py build --all --deps-only --no-sd-examples
${{ inputs.link_mode == 'dynamic' && '--dynamic' || '' }} &&
touch /project/thirdparty/.deps-complete
CIBW_BEFORE_BUILD_LINUX: >
sed -i 's/^name = "cyllama"/name = "cyllama-rocm"/' {project}/pyproject.toml &&
grep -q '^name = "cyllama-rocm"' {project}/pyproject.toml || { echo "ERROR: sed rename to cyllama-rocm failed"; exit 1; } &&
cd {project} && python scripts/manage.py write_build_config
CIBW_ENVIRONMENT_LINUX: >
GGML_NATIVE=OFF
GGML_HIP=1
GGML_METAL=0
HIP_PATH=/opt/rocm
CMAKE_HIP_ARCHITECTURES="gfx90a;gfx942;gfx1100"
PATH=/opt/rocm/bin:$PATH
LD_LIBRARY_PATH=/opt/rocm/lib:$LD_LIBRARY_PATH
LIBRARY_PATH=/usr/lib/gcc/x86_64-redhat-linux/8:$LIBRARY_PATH
CFLAGS=-s
CXXFLAGS=-s
CCACHE_DIR=/project/.ccache
CCACHE_DEPEND=1
CMAKE_C_COMPILER_LAUNCHER=ccache
CMAKE_CXX_COMPILER_LAUNCHER=ccache
CMAKE_HIP_COMPILER_LAUNCHER=ccache
WITH_DYLIB=${{ inputs.link_mode == 'dynamic' && '1' || '0' }}
SD_USE_VENDORED_GGML=${{ inputs.link_mode == 'dynamic' && '0' || '1' }}
CIBW_TEST_COMMAND: ""
CIBW_REPAIR_WHEEL_COMMAND_LINUX: >
test -d {project}/thirdparty/llama.cpp/dynamic || { echo "ERROR: dynamic lib dir missing: {project}/thirdparty/llama.cpp/dynamic"; exit 1; } &&
LD_LIBRARY_PATH={project}/thirdparty/llama.cpp/dynamic:$LD_LIBRARY_PATH
auditwheel repair -w {dest_dir} {wheel}
--plat manylinux_2_35_x86_64
--exclude libamdhip64.so.6
--exclude libhipblas.so.2
--exclude librocblas.so.4
--exclude libhsa-runtime64.so.1
--exclude librocsolver.so.0
--exclude libhipblaslt.so.0
--exclude libamd_comgr.so.2
--exclude librocprofiler-register.so.0
--exclude libgomp.so.1
- name: List built wheels
run: ls -lah wheelhouse/
- name: Upload wheels
uses: actions/upload-artifact@v7
with:
name: wheels-rocm-linux-x86_64
path: ./wheelhouse/*.whl
# ---------------------------------------------------------------------------
# SYCL wheels (Linux only, Intel oneAPI)
# ---------------------------------------------------------------------------
build_sycl:
name: SYCL - Linux x86_64 (${{ inputs.link_mode }})
if: inputs.sycl_linux
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Cache thirdparty deps
id: cache-deps
uses: actions/cache@v5
with:
path: thirdparty/
key: deps-sycl-${{ inputs.link_mode }}-${{ hashFiles('scripts/manage.py', '.github/workflows/build-gpu-wheels.yml') }}
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.11'
- name: Install cibuildwheel
run: pip install cibuildwheel==3.4.0
- name: Set CCACHE_DIR to workspace
run: echo "CCACHE_DIR=${{ github.workspace }}/.ccache" >> "$GITHUB_ENV"
- name: ccache
uses: hendrikmuhs/[email protected]
with:
key: ccache-sycl-${{ inputs.link_mode }}
evict-old-files: 1d
- name: Build SYCL wheels
run: python -m cibuildwheel --output-dir wheelhouse
env:
CIBW_ARCHS_LINUX: x86_64
CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28
CIBW_BEFORE_ALL_LINUX: >
dnf install -y git epel-release &&
dnf install -y ccache &&
rpm --import https://yum.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB &&
dnf config-manager --add-repo https://yum.repos.intel.com/oneapi &&
dnf install -y intel-oneapi-dpcpp-cpp-2025.3 intel-oneapi-mkl-devel-2025.3 &&
if [ -f /project/thirdparty/.deps-complete ]; then echo "=== Deps cached, skipping build ==="; exit 0; fi &&
CI_PYTHON=$(ls -d /opt/python/cp3*/bin | head -1) &&
$CI_PYTHON/pip install cmake ninja &&
source /opt/intel/oneapi/setvars.sh &&
export CC=icx CXX=icpx &&
PATH=$CI_PYTHON:$PATH
CCACHE_DIR=/project/.ccache
CMAKE_C_COMPILER_LAUNCHER=ccache
CMAKE_CXX_COMPILER_LAUNCHER=ccache
GGML_NATIVE=OFF GGML_SYCL=1 GGML_METAL=0
SD_USE_VENDORED_GGML=${{ inputs.link_mode == 'dynamic' && '0' || '1' }}
$CI_PYTHON/python scripts/manage.py build --all --deps-only --no-sd-examples
${{ inputs.link_mode == 'dynamic' && '--dynamic' || '' }} &&
touch /project/thirdparty/.deps-complete
CIBW_BEFORE_BUILD_LINUX: >
sed -i 's/^name = "cyllama"/name = "cyllama-sycl"/' {project}/pyproject.toml &&
grep -q '^name = "cyllama-sycl"' {project}/pyproject.toml || { echo "ERROR: sed rename to cyllama-sycl failed"; exit 1; } &&
cd {project} && python scripts/manage.py write_build_config
CIBW_ENVIRONMENT_LINUX: >
GGML_NATIVE=OFF
GGML_SYCL=1
GGML_METAL=0
CC=icx
CXX=icpx
PATH=/opt/intel/oneapi/compiler/latest/bin:$PATH
LD_LIBRARY_PATH=/opt/intel/oneapi/compiler/latest/lib:/opt/intel/oneapi/mkl/latest/lib:$LD_LIBRARY_PATH
CFLAGS=-s
CXXFLAGS=-s
CCACHE_DIR=/project/.ccache
CMAKE_C_COMPILER_LAUNCHER=ccache
CMAKE_CXX_COMPILER_LAUNCHER=ccache
WITH_DYLIB=${{ inputs.link_mode == 'dynamic' && '1' || '0' }}
SD_USE_VENDORED_GGML=${{ inputs.link_mode == 'dynamic' && '0' || '1' }}
CIBW_TEST_COMMAND: ""
CIBW_REPAIR_WHEEL_COMMAND_LINUX: >
test -d {project}/thirdparty/llama.cpp/dynamic || { echo "ERROR: dynamic lib dir missing: {project}/thirdparty/llama.cpp/dynamic"; exit 1; } &&
LD_LIBRARY_PATH={project}/thirdparty/llama.cpp/dynamic:$LD_LIBRARY_PATH
auditwheel repair -w {dest_dir} {wheel}
--plat manylinux_2_35_x86_64
--exclude libsycl.so.8
--exclude libOpenCL.so.1
--exclude libsvml.so
--exclude libimf.so
--exclude libintlc.so.5
--exclude libtbb.so.12
--exclude libgomp.so.1
- name: List built wheels
run: ls -lah wheelhouse/
- name: Upload wheels
uses: actions/upload-artifact@v7
with:
name: wheels-sycl-linux-x86_64
path: ./wheelhouse/*.whl
# ---------------------------------------------------------------------------
# Vulkan wheels (Linux)
# ---------------------------------------------------------------------------
build_vulkan:
name: Vulkan - Linux x86_64 (${{ inputs.link_mode }})
if: inputs.vulkan_linux
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 0
clean: true
- name: Cache thirdparty deps
id: cache-deps
uses: actions/cache@v5
with:
path: thirdparty/
key: deps-vulkan-${{ inputs.link_mode }}-${{ hashFiles('scripts/manage.py', '.github/workflows/build-gpu-wheels.yml') }}
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.11'
- name: Install cibuildwheel
run: pip install cibuildwheel==3.4.0
- name: Set CCACHE_DIR to workspace
run: echo "CCACHE_DIR=${{ github.workspace }}/.ccache" >> "$GITHUB_ENV"
- name: ccache
uses: hendrikmuhs/[email protected]
with:
key: ccache-vulkan-${{ inputs.link_mode }}
evict-old-files: 1d
- name: Build Vulkan wheels
run: python -m cibuildwheel --output-dir wheelhouse
env:
CIBW_ARCHS_LINUX: x86_64
CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28
CIBW_BEFORE_ALL_LINUX: >
dnf install -y git epel-release &&
dnf install -y ccache &&
dnf install -y vulkan-headers vulkan-loader-devel &&
if [ -f /project/thirdparty/.deps-complete ]; then echo "=== Deps cached, skipping build ==="; exit 0; fi &&
git clone --depth 1 https://github.com/google/shaderc.git /tmp/shaderc &&
cd /tmp/shaderc && python3 utils/git-sync-deps &&
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DSHADERC_SKIP_TESTS=ON -DSHADERC_SKIP_EXAMPLES=ON -DSHADERC_SKIP_COPYRIGHT_CHECK=ON &&
cmake --build build --target glslc_exe --parallel 4 &&
cp build/glslc/glslc /usr/local/bin/glslc &&
cmake -S /tmp/shaderc/third_party/spirv-headers -B /tmp/spirv-headers-build -DCMAKE_INSTALL_PREFIX=/usr/local -DSPIRV_HEADERS_SKIP_EXAMPLES=ON -DSPIRV_HEADERS_SKIP_INSTALL=OFF &&
cmake --install /tmp/spirv-headers-build &&
cd /project && rm -rf /tmp/shaderc /tmp/spirv-headers-build &&
CI_PYTHON=$(ls -d /opt/python/cp3*/bin | head -1) &&
$CI_PYTHON/pip install cmake ninja &&
PATH=$CI_PYTHON:$PATH
CCACHE_DIR=/project/.ccache
CMAKE_C_COMPILER_LAUNCHER=ccache
CMAKE_CXX_COMPILER_LAUNCHER=ccache
GGML_NATIVE=OFF GGML_VULKAN=1 GGML_METAL=0
SD_USE_VENDORED_GGML=${{ inputs.link_mode == 'dynamic' && '0' || '1' }}
$CI_PYTHON/python scripts/manage.py build --all --deps-only --no-sd-examples
${{ inputs.link_mode == 'dynamic' && '--dynamic' || '' }} &&
touch /project/thirdparty/.deps-complete
CIBW_BEFORE_BUILD_LINUX: >
sed -i 's/^name = "cyllama"/name = "cyllama-vulkan"/' {project}/pyproject.toml &&
grep -q '^name = "cyllama-vulkan"' {project}/pyproject.toml || { echo "ERROR: sed rename to cyllama-vulkan failed"; exit 1; } &&
cd {project} && python scripts/manage.py write_build_config
CIBW_ENVIRONMENT_LINUX: >
GGML_NATIVE=OFF
GGML_VULKAN=1
GGML_METAL=0
CFLAGS=-s
CXXFLAGS=-s
CCACHE_DIR=/project/.ccache
CMAKE_C_COMPILER_LAUNCHER=ccache
CMAKE_CXX_COMPILER_LAUNCHER=ccache
WITH_DYLIB=${{ inputs.link_mode == 'dynamic' && '1' || '0' }}
SD_USE_VENDORED_GGML=${{ inputs.link_mode == 'dynamic' && '0' || '1' }}
CIBW_TEST_COMMAND: ""
CIBW_REPAIR_WHEEL_COMMAND_LINUX: >
test -d {project}/thirdparty/llama.cpp/dynamic || { echo "ERROR: dynamic lib dir missing: {project}/thirdparty/llama.cpp/dynamic"; exit 1; } &&
LD_LIBRARY_PATH={project}/thirdparty/llama.cpp/dynamic:$LD_LIBRARY_PATH
auditwheel repair -w {dest_dir} {wheel}
--plat manylinux_2_35_x86_64
--exclude libvulkan.so.1
--exclude libgomp.so.1
- name: List built wheels
run: ls -lah wheelhouse/
- name: Upload wheels
uses: actions/upload-artifact@v7
with:
name: wheels-vulkan-linux-x86_64
path: ./wheelhouse/*.whl
# ---------------------------------------------------------------------------
# CUDA 12.4 - Windows (x86_64)
# Uses NVIDIA CUDA Toolkit 12.4. delvewheel handles wheel repair.
# ---------------------------------------------------------------------------
build_cuda_windows:
name: CUDA 12.4 - Windows x86_64 (${{ inputs.link_mode }})
if: inputs.cuda_windows
runs-on: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Cache thirdparty deps
id: cache-deps
uses: actions/cache@v5
with:
path: thirdparty/
key: deps-cuda-windows-${{ inputs.link_mode }}-${{ hashFiles('scripts/manage.py', '.github/workflows/build-gpu-wheels.yml') }}
- name: Install CUDA Toolkit 12.4
uses: Jimver/[email protected]
id: cuda-toolkit
with:
cuda: '12.4.0'
method: 'network'
sub-packages: '["nvcc", "cudart", "cublas", "cublas_dev", "visual_studio_integration"]'
- name: Verify CUDA installation
shell: bash
run: |
echo "CUDA_PATH=$CUDA_PATH"
nvcc --version
ls "$CUDA_PATH/lib/x64/" | head -20
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.11'
- name: Install cibuildwheel
run: pip install cibuildwheel==3.4.0
- name: Build CUDA wheels
run: python -m cibuildwheel --output-dir wheelhouse
env:
CIBW_ARCHS_WINDOWS: AMD64
CIBW_BEFORE_BUILD_WINDOWS: >
pip install delvewheel &&
python -c "import os; t=open('pyproject.toml').read(); open('pyproject.toml','w').write(t.replace('name = \"cyllama\"','name = \"cyllama-cuda12\"',1))" &&
python -c "t=open('pyproject.toml').read(); assert 'name = \"cyllama-cuda12\"' in t, 'rename failed'" &&
cd {project} &&
python scripts/manage.py build --all --deps-only --no-sd-examples
${{ inputs.link_mode == 'dynamic' && '--dynamic' || '' }} &&
python scripts/manage.py write_build_config
CIBW_ENVIRONMENT_WINDOWS: >
GGML_CUDA=1
GGML_METAL=0
GGML_NATIVE=OFF
CMAKE_CUDA_ARCHITECTURES="75"
WITH_DYLIB=${{ inputs.link_mode == 'dynamic' && '1' || '0' }}
SD_USE_VENDORED_GGML=${{ inputs.link_mode == 'dynamic' && '0' || '1' }}
CIBW_TEST_COMMAND: ""
CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: >
delvewheel repair -w {dest_dir} {wheel}
--add-path {project}\thirdparty\llama.cpp\dynamic
--add-path {project}\thirdparty\whisper.cpp\dynamic
--add-path {project}\thirdparty\stable-diffusion.cpp\dynamic
--include ggml-cuda.dll
--no-dll nvcuda.dll
--no-dll cudart64_12.dll
--no-dll cublas64_12.dll
--no-dll cublasLt64_12.dll
- name: List built wheels
shell: bash
run: ls -lah wheelhouse/
- name: Upload wheels
uses: actions/upload-artifact@v7
with:
name: wheels-cuda-windows-x86_64
path: ./wheelhouse/*.whl
# ---------------------------------------------------------------------------
# Vulkan - Windows (x86_64)
# Uses the LunarG Vulkan SDK. delvewheel handles wheel repair.
# ---------------------------------------------------------------------------
build_vulkan_windows:
name: Vulkan - Windows x86_64 (${{ inputs.link_mode }})
if: inputs.vulkan_windows
runs-on: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Cache thirdparty deps
id: cache-deps
uses: actions/cache@v5
with:
path: thirdparty/
key: deps-vulkan-windows-${{ inputs.link_mode }}-${{ hashFiles('scripts/manage.py', '.github/workflows/build-gpu-wheels.yml') }}
- name: Install Vulkan SDK
shell: pwsh
run: |
$VK_LATEST = (Invoke-RestMethod -Uri "https://vulkan.lunarg.com/sdk/latest/windows.json").windows
Write-Host "Latest Vulkan SDK: ${VK_LATEST}"
$VK_URL = "https://sdk.lunarg.com/sdk/download/${VK_LATEST}/windows/vulkan-sdk.exe"
Write-Host "Downloading Vulkan SDK from ${VK_URL}..."
Invoke-WebRequest -Uri $VK_URL -OutFile vulkan-sdk.exe
Write-Host "Installing Vulkan SDK..."
Start-Process -FilePath .\vulkan-sdk.exe -ArgumentList "--accept-licenses --default-answer --confirm-command install" -Wait -NoNewWindow
$VK_PATH = "C:\VulkanSDK\${VK_LATEST}"
Write-Host "VULKAN_SDK=${VK_PATH}"
echo "VULKAN_SDK=${VK_PATH}" >> $env:GITHUB_ENV
echo "${VK_PATH}\Bin" >> $env:GITHUB_PATH
& "${VK_PATH}\Bin\glslc.exe" --version
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.11'
- name: Install cibuildwheel
run: pip install cibuildwheel==3.4.0
- name: Build Vulkan wheels
run: python -m cibuildwheel --output-dir wheelhouse
env:
CIBW_ARCHS_WINDOWS: AMD64
CIBW_BEFORE_BUILD_WINDOWS: >
pip install delvewheel &&
python -c "import os; t=open('pyproject.toml').read(); open('pyproject.toml','w').write(t.replace('name = \"cyllama\"','name = \"cyllama-vulkan\"',1))" &&
python -c "t=open('pyproject.toml').read(); assert 'name = \"cyllama-vulkan\"' in t, 'rename failed'" &&
cd {project} &&
python scripts/manage.py build --all --deps-only --no-sd-examples
${{ inputs.link_mode == 'dynamic' && '--dynamic' || '' }} &&
python scripts/manage.py write_build_config
CIBW_ENVIRONMENT_WINDOWS: >
GGML_VULKAN=1
GGML_METAL=0
GGML_NATIVE=OFF
WITH_DYLIB=${{ inputs.link_mode == 'dynamic' && '1' || '0' }}
SD_USE_VENDORED_GGML=${{ inputs.link_mode == 'dynamic' && '0' || '1' }}
CIBW_TEST_COMMAND: ""
CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: >
delvewheel repair -w {dest_dir} {wheel}
--add-path {project}\thirdparty\llama.cpp\dynamic
--add-path {project}\thirdparty\whisper.cpp\dynamic
--add-path {project}\thirdparty\stable-diffusion.cpp\dynamic
--include ggml-vulkan.dll
- name: List built wheels
shell: bash
run: ls -lah wheelhouse/
- name: Upload wheels
uses: actions/upload-artifact@v7
with:
name: wheels-vulkan-windows-x86_64
path: ./wheelhouse/*.whl
# ---------------------------------------------------------------------------
# Vulkan - macOS Intel (x86_64)
# Uses MoltenVK (Vulkan over Metal). The Vulkan SDK provides the loader,
# headers, and glslc. delocate handles wheel repair.
# ---------------------------------------------------------------------------
build_vulkan_macos_intel:
name: Vulkan - macOS Intel x86_64 (${{ inputs.link_mode }})
if: inputs.vulkan_macos_intel
runs-on: macos-15-intel
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Cache thirdparty deps
id: cache-deps
uses: actions/cache@v5
with:
path: thirdparty/
key: deps-vulkan-macos-intel-${{ inputs.link_mode }}-${{ hashFiles('scripts/manage.py', '.github/workflows/build-gpu-wheels.yml') }}
- name: Install Vulkan SDK
run: |
brew install vulkan-headers vulkan-loader molten-vk shaderc spirv-headers
SHADERC_BIN="$(brew --prefix shaderc)/bin"
VULKAN_PREFIX="$(brew --prefix vulkan-loader)"
echo "PATH=${SHADERC_BIN}:${PATH}" >> "$GITHUB_ENV"
echo "VULKAN_SDK=${VULKAN_PREFIX}" >> "$GITHUB_ENV"
echo "CMAKE_PREFIX_PATH=$(brew --prefix vulkan-headers):$(brew --prefix vulkan-loader):$(brew --prefix molten-vk):$(brew --prefix spirv-headers)" >> "$GITHUB_ENV"
${SHADERC_BIN}/glslc --version
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.11'
- name: Install cibuildwheel
run: pip install cibuildwheel==3.4.0
- name: ccache
uses: hendrikmuhs/[email protected]
with:
key: ccache-vulkan-macos-intel-${{ inputs.link_mode }}
evict-old-files: 1d
- name: Build Vulkan wheels
run: python -m cibuildwheel --output-dir wheelhouse
env:
CIBW_ARCHS_MACOS: x86_64
CIBW_BEFORE_BUILD_MACOS: >
pip install delocate wheel &&
sed -i '' 's/^name = "cyllama"/name = "cyllama-vulkan"/' {project}/pyproject.toml &&
grep -q '^name = "cyllama-vulkan"' {project}/pyproject.toml || { echo "ERROR: sed rename to cyllama-vulkan failed"; exit 1; } &&
cd {project} &&
python scripts/manage.py build --all --deps-only --no-sd-examples
${{ inputs.link_mode == 'dynamic' && '--dynamic' || '' }} &&
python scripts/manage.py write_build_config
CIBW_ENVIRONMENT_MACOS: >
MACOSX_DEPLOYMENT_TARGET=11.0
GGML_VULKAN=1
GGML_METAL=0
GGML_NATIVE=OFF
CMAKE_C_COMPILER_LAUNCHER=ccache
CMAKE_CXX_COMPILER_LAUNCHER=ccache
WITH_DYLIB=${{ inputs.link_mode == 'dynamic' && '1' || '0' }}
SD_USE_VENDORED_GGML=${{ inputs.link_mode == 'dynamic' && '0' || '1' }}
CIBW_TEST_COMMAND: ""
CIBW_REPAIR_WHEEL_COMMAND_MACOS: >
delocate-wheel --require-archs {delocate_archs} -w {dest_dir} -v {wheel}
--exclude libvulkan
--exclude libMoltenVK &&
python {project}/scripts/manage.py fix_macos_vulkan_wheel {dest_dir}
- name: List built wheels
run: ls -lah wheelhouse/
- name: Upload wheels
uses: actions/upload-artifact@v7
with:
name: wheels-vulkan-macos-intel-x86_64
path: ./wheelhouse/*.whl
# ---------------------------------------------------------------------------
# Import smoke tests (no GPU required)
# ---------------------------------------------------------------------------
smoke_test:
name: Smoke test - ${{ matrix.backend }}
needs: [build_cuda, build_rocm, build_sycl, build_vulkan, build_cuda_windows, build_vulkan_windows, build_vulkan_macos_intel]
if: always() && !cancelled() && (needs.build_cuda.result == 'success' || needs.build_rocm.result == 'success' || needs.build_sycl.result == 'success' || needs.build_vulkan.result == 'success' || needs.build_cuda_windows.result == 'success' || needs.build_vulkan_windows.result == 'success' || needs.build_vulkan_macos_intel.result == 'success')
runs-on: ${{ matrix.runs-on }}
strategy:
fail-fast: false
matrix:
include:
- backend: cuda
runs-on: ubuntu-latest
artifact: wheels-cuda-linux-x86_64
condition: inputs.cuda_linux
- backend: rocm
runs-on: ubuntu-latest
artifact: wheels-rocm-linux-x86_64
condition: inputs.rocm_linux
- backend: sycl
runs-on: ubuntu-latest
artifact: wheels-sycl-linux-x86_64
condition: inputs.sycl_linux
- backend: vulkan
runs-on: ubuntu-latest
artifact: wheels-vulkan-linux-x86_64
condition: inputs.vulkan_linux
- backend: cuda-windows
runs-on: windows-latest
artifact: wheels-cuda-windows-x86_64
condition: inputs.cuda_windows
- backend: vulkan-windows
runs-on: windows-latest
artifact: wheels-vulkan-windows-x86_64
condition: inputs.vulkan_windows
- backend: vulkan-macos-intel
runs-on: macos-15-intel
artifact: wheels-vulkan-macos-intel-x86_64
condition: inputs.vulkan_macos_intel
steps:
- name: Check if backend was built
id: check
shell: bash
run: |
if [ "${{ matrix.condition }}" != "true" ]; then
echo "skip=true" >> "$GITHUB_OUTPUT"
else
echo "skip=false" >> "$GITHUB_OUTPUT"
fi
- uses: actions/setup-python@v6
if: steps.check.outputs.skip != 'true'
with:
python-version: "3.12"
- name: Download wheel artifacts
if: steps.check.outputs.skip != 'true'
uses: actions/download-artifact@v8
with:
name: ${{ matrix.artifact }}
path: wheels
- name: Find matching wheel
if: steps.check.outputs.skip != 'true'
id: find-wheel
shell: bash
run: |
WHEEL=$(find wheels -name "*cp312*" | head -1)
if [ -z "$WHEEL" ]; then
WHEEL=$(find wheels -name "*.whl" | head -1)
fi
echo "wheel=$WHEEL" >> "$GITHUB_OUTPUT"
echo "Found wheel: $WHEEL"
- name: Install wheel in clean venv
if: steps.check.outputs.skip != 'true'
shell: bash
run: |
python -m venv smoke-venv
if [ "$RUNNER_OS" = "Windows" ]; then
source smoke-venv/Scripts/activate
else
source smoke-venv/bin/activate
fi
pip install "${{ steps.find-wheel.outputs.wheel }}"
# -------------------------------------------------------------------
# Windows-only: link-test every bundled ggml-*.dll using the same
# LoadLibraryW(path, NULL, 0) semantics that ggml_backend_load()
# uses in C. Catches the class of bug where delvewheel-bundled
# siblings (e.g. vulkan-1-<hash>.dll) are unreachable because the
# libs dir is not on PATH — a failure mode invisible to GPU-less
# runners since `cyllama info` still exits 0 when a backend DLL
# fails to load. Independent of GPU/ICD presence.
# -------------------------------------------------------------------
- name: Smoke test - DLL link (Windows)
if: steps.check.outputs.skip != 'true' && runner.os == 'Windows'
shell: bash
run: |
source smoke-venv/Scripts/activate
python -c "
import ctypes, glob, os, site, sys
failed = []
for sp in site.getsitepackages():
for libs in glob.glob(os.path.join(sp, 'cyllama*.libs')):
for dll in sorted(glob.glob(os.path.join(libs, 'ggml-*.dll'))):
try:
ctypes.WinDLL(dll)
except OSError as e:
failed.append((dll, str(e)))
else:
print(f'OK {dll}')
if failed:
for d, e in failed:
print(f'FAIL {d}: {e}', file=sys.stderr)
sys.exit(1)
"
- name: Smoke test - imports
if: steps.check.outputs.skip != 'true'
shell: bash
run: |
if [ "$RUNNER_OS" = "Windows" ]; then
source smoke-venv/Scripts/activate
else
source smoke-venv/bin/activate
fi
python -c "
import cyllama
print(f'cyllama {cyllama.__version__} imported successfully')
# Core API imports
from cyllama import LLM, complete, chat, AsyncLLM
from cyllama import batch_generate, BatchGenerator
from cyllama import estimate_gpu_layers, estimate_memory_usage
from cyllama import GenerationConfig, Response
# Cython extension imports
from cyllama.llama import llama_cpp
print('llama_cpp extension loaded')
# Agent framework
from cyllama.agents import ReActAgent, ConstrainedAgent, ContractAgent, tool
print('agents loaded')
# Integrations
from cyllama.integrations.openai_compat import OpenAICompatibleClient
print('integrations loaded')
# Optional extensions
try:
from cyllama.whisper import whisper_cpp
print('whisper_cpp extension loaded')
except ImportError as e:
print(f'whisper_cpp not available: {e}')
try:
from cyllama.sd import stable_diffusion
print('stable_diffusion extension loaded')
except ImportError as e:
print(f'stable_diffusion not available: {e}')
# Backend info
try:
from cyllama import _backend
print(f'Backend: cuda={getattr(_backend, \"cuda\", False)}, '
f'vulkan={getattr(_backend, \"vulkan\", False)}, '
f'hip={getattr(_backend, \"hip\", False)}, '
f'sycl={getattr(_backend, \"sycl\", False)}')
except ImportError:
print('No _backend module')
print('All imports passed (${{ matrix.backend }})')
"
# -------------------------------------------------------------------
# cyllama info -- validates build_config.json is present in the wheel
# and reports which backend flags it was built with. Catches the
# class of bug behind "build_config.json missing from wheels" (0.2.10)
# and "build_config.json shipped with empty versions" (0.2.10).
# -------------------------------------------------------------------
- name: Smoke test - cyllama info
if: steps.check.outputs.skip != 'true'
shell: bash
run: |
if [ "$RUNNER_OS" = "Windows" ]; then
source smoke-venv/Scripts/activate
else
source smoke-venv/bin/activate
fi
python -m cyllama info
# -------------------------------------------------------------------
# SYCL-only: install Intel's OpenCL CPU runtime so the SYCL dispatch
# stack has a compliant device on a GPU-less runner, then run a
# 1-token decode. Exercises the full pipeline (Cython wrappers ->
# libllama -> libggml-sycl -> SYCL runtime -> OpenCL CPU device ->
# sampler -> teardown) on free hardware. Catches ABI/symbol/teardown
# regressions that bare imports miss. Best-effort: if the Intel
# runtime install fails (repo mirror issue, etc.) we log and move on
# rather than breaking the whole GPU-wheels workflow.
# -------------------------------------------------------------------
- name: Install Intel OpenCL CPU runtime
if: steps.check.outputs.skip != 'true' && matrix.backend == 'sycl'
continue-on-error: true
run: |
wget -qO - https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB \
| sudo gpg --dearmor -o /usr/share/keyrings/oneapi-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/oneapi-archive-keyring.gpg] https://apt.repos.intel.com/oneapi all main" \
| sudo tee /etc/apt/sources.list.d/oneAPI.list
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
intel-oneapi-runtime-opencl \
intel-oneapi-runtime-dpcpp-cpp
- name: Cache test model (SYCL)
if: steps.check.outputs.skip != 'true' && matrix.backend == 'sycl'
id: cache-model-sycl
uses: actions/cache@v5
with:
path: models/Llama-3.2-1B-Instruct-Q8_0.gguf
key: test-model-llama-3.2-1b-q8
- name: Download test model (SYCL)
if: steps.check.outputs.skip != 'true' && matrix.backend == 'sycl' && steps.cache-model-sycl.outputs.cache-hit != 'true'
run: |
mkdir -p models
curl -sL https://huggingface.co/unsloth/Llama-3.2-1B-Instruct-GGUF/resolve/main/Llama-3.2-1B-Instruct-Q8_0.gguf \
-o models/Llama-3.2-1B-Instruct-Q8_0.gguf
- name: Smoke test - SYCL 1-token CPU inference
if: steps.check.outputs.skip != 'true' && matrix.backend == 'sycl'
continue-on-error: true
env:
# Force the SYCL runtime onto the OpenCL CPU device the Intel
# runtime just installed (no GPU on ubuntu-latest).