1
0

build.yml 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314
  1. name: CI
  2. on:
  3. workflow_dispatch: # allows manual triggering
  4. inputs:
  5. create_release:
  6. description: 'Create new release'
  7. required: true
  8. type: boolean
  9. push:
  10. branches:
  11. - master
  12. paths: ['.github/workflows/build.yml', '**/CMakeLists.txt', '**/Makefile', '**/*.h', '**/*.hpp', '**/*.c', '**/*.cpp', '**/*.cu', '**/*.cuh', '**/*.swift', '**/*.m', '**/*.metal']
  13. pull_request:
  14. types: [opened, synchronize, reopened]
  15. paths: ['.github/workflows/build.yml', '**/CMakeLists.txt', '**/Makefile', '**/*.h', '**/*.hpp', '**/*.c', '**/*.cpp', '**/*.cu', '**/*.cuh', '**/*.swift', '**/*.m', '**/*.metal']
  16. concurrency:
  17. group: ${{ github.workflow }}-${{ github.head_ref && github.ref || github.run_id }}
  18. cancel-in-progress: true
  19. env:
  20. BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
  21. GGML_NLOOP: 3
  22. GGML_N_THREADS: 1
  23. jobs:
  24. macOS-latest-cmake-arm64:
  25. runs-on: macos-14
  26. steps:
  27. - name: Clone
  28. id: checkout
  29. uses: actions/checkout@v4
  30. with:
  31. fetch-depth: 0
  32. - name: Dependencies
  33. id: depends
  34. continue-on-error: true
  35. run: |
  36. brew update
  37. - name: Build
  38. id: cmake_build
  39. run: |
  40. sysctl -a
  41. mkdir build
  42. cd build
  43. cmake -DLLAMA_FATAL_WARNINGS=ON -DGGML_METAL_EMBED_LIBRARY=ON -DLLAMA_CURL=ON -DGGML_RPC=ON -DBUILD_SHARED_LIBS=OFF ..
  44. cmake --build . --config Release -j $(sysctl -n hw.logicalcpu)
  45. - name: Test
  46. id: cmake_test
  47. run: |
  48. cd build
  49. ctest -L 'main|curl' --verbose --timeout 900
  50. - name: Determine tag name
  51. id: tag
  52. shell: bash
  53. run: |
  54. BUILD_NUMBER="$(git rev-list --count HEAD)"
  55. SHORT_HASH="$(git rev-parse --short=7 HEAD)"
  56. if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
  57. echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
  58. else
  59. SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
  60. echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
  61. fi
  62. - name: Pack artifacts
  63. id: pack_artifacts
  64. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  65. run: |
  66. cp LICENSE ./build/bin/
  67. zip -r llama-${{ steps.tag.outputs.name }}-bin-macos-arm64.zip ./build/bin/*
  68. - name: Upload artifacts
  69. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  70. uses: actions/upload-artifact@v4
  71. with:
  72. path: llama-${{ steps.tag.outputs.name }}-bin-macos-arm64.zip
  73. name: llama-bin-macos-arm64.zip
  74. macOS-latest-cmake-x64:
  75. runs-on: macos-12
  76. steps:
  77. - name: Clone
  78. id: checkout
  79. uses: actions/checkout@v4
  80. with:
  81. fetch-depth: 0
  82. - name: Dependencies
  83. id: depends
  84. continue-on-error: true
  85. run: |
  86. brew update
  87. - name: Build
  88. id: cmake_build
  89. run: |
  90. sysctl -a
  91. # Metal is disabled due to intermittent failures with Github runners not having a GPU:
  92. # https://github.com/ggerganov/llama.cpp/actions/runs/8635935781/job/23674807267#step:5:2313
  93. cmake -B build -DLLAMA_FATAL_WARNINGS=ON -DGGML_METAL=OFF -DLLAMA_CURL=ON -DGGML_RPC=ON -DBUILD_SHARED_LIBS=OFF
  94. cmake --build build --config Release -j $(sysctl -n hw.logicalcpu)
  95. - name: Test
  96. id: cmake_test
  97. run: |
  98. cd build
  99. ctest -L main --verbose --timeout 900
  100. - name: Determine tag name
  101. id: tag
  102. shell: bash
  103. run: |
  104. BUILD_NUMBER="$(git rev-list --count HEAD)"
  105. SHORT_HASH="$(git rev-parse --short=7 HEAD)"
  106. if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
  107. echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
  108. else
  109. SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
  110. echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
  111. fi
  112. - name: Pack artifacts
  113. id: pack_artifacts
  114. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  115. run: |
  116. cp LICENSE ./build/bin/
  117. zip -r llama-${{ steps.tag.outputs.name }}-bin-macos-x64.zip ./build/bin/*
  118. - name: Upload artifacts
  119. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  120. uses: actions/upload-artifact@v4
  121. with:
  122. path: llama-${{ steps.tag.outputs.name }}-bin-macos-x64.zip
  123. name: llama-bin-macos-x64.zip
  124. ubuntu-focal-make:
  125. runs-on: ubuntu-20.04
  126. env:
  127. LLAMA_NODE_AVAILABLE: true
  128. LLAMA_PYTHON_AVAILABLE: true
  129. steps:
  130. - name: Clone
  131. id: checkout
  132. uses: actions/checkout@v4
  133. - name: Dependencies
  134. id: depends
  135. run: |
  136. sudo apt-get update
  137. sudo apt-get install build-essential gcc-8
  138. - uses: actions/setup-node@v4
  139. with:
  140. node-version: "20"
  141. - uses: actions/setup-python@v5
  142. with:
  143. python-version: "3.11"
  144. - name: Build
  145. id: make_build
  146. env:
  147. LLAMA_FATAL_WARNINGS: 1
  148. run: |
  149. CC=gcc-8 make -j $(nproc)
  150. - name: Test
  151. id: make_test
  152. run: |
  153. CC=gcc-8 make tests -j $(nproc)
  154. make test -j $(nproc)
  155. ubuntu-focal-make-curl:
  156. runs-on: ubuntu-20.04
  157. steps:
  158. - name: Clone
  159. id: checkout
  160. uses: actions/checkout@v4
  161. - name: Dependencies
  162. id: depends
  163. run: |
  164. sudo apt-get update
  165. sudo apt-get install build-essential gcc-8 libcurl4-openssl-dev
  166. - name: Build
  167. id: make_build
  168. env:
  169. LLAMA_FATAL_WARNINGS: 1
  170. LLAMA_CURL: 1
  171. run: |
  172. CC=gcc-8 make -j $(nproc)
  173. ubuntu-latest-cmake:
  174. runs-on: ubuntu-latest
  175. steps:
  176. - name: Clone
  177. id: checkout
  178. uses: actions/checkout@v4
  179. with:
  180. fetch-depth: 0
  181. - name: Dependencies
  182. id: depends
  183. run: |
  184. sudo apt-get update
  185. sudo apt-get install build-essential libcurl4-openssl-dev
  186. - name: Build
  187. id: cmake_build
  188. run: |
  189. mkdir build
  190. cd build
  191. cmake .. -DLLAMA_FATAL_WARNINGS=ON -DLLAMA_CURL=ON -DGGML_RPC=ON -DBUILD_SHARED_LIBS=OFF
  192. cmake --build . --config Release -j $(nproc)
  193. - name: Test
  194. id: cmake_test
  195. run: |
  196. cd build
  197. ctest -L 'main|curl' --verbose --timeout 900
  198. - name: Test llama2c conversion
  199. id: llama2c_test
  200. run: |
  201. cd build
  202. echo "Fetch tokenizer"
  203. wget https://huggingface.co/karpathy/tinyllamas/resolve/main/stories260K/tok512.bin
  204. echo "Fetch llama2c model"
  205. wget https://huggingface.co/karpathy/tinyllamas/resolve/main/stories260K/stories260K.bin
  206. ./bin/llama-convert-llama2c-to-ggml --copy-vocab-from-model ./tok512.bin --llama2c-model stories260K.bin --llama2c-output-model stories260K.gguf
  207. ./bin/llama-cli -m stories260K.gguf -p "One day, Lily met a Shoggoth" -n 500 -c 256
  208. - name: Determine tag name
  209. id: tag
  210. shell: bash
  211. run: |
  212. BUILD_NUMBER="$(git rev-list --count HEAD)"
  213. SHORT_HASH="$(git rev-parse --short=7 HEAD)"
  214. if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
  215. echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
  216. else
  217. SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
  218. echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
  219. fi
  220. - name: Pack artifacts
  221. id: pack_artifacts
  222. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  223. run: |
  224. cp LICENSE ./build/bin/
  225. zip -r llama-${{ steps.tag.outputs.name }}-bin-ubuntu-x64.zip ./build/bin/*
  226. - name: Upload artifacts
  227. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  228. uses: actions/upload-artifact@v4
  229. with:
  230. path: llama-${{ steps.tag.outputs.name }}-bin-ubuntu-x64.zip
  231. name: llama-bin-ubuntu-x64.zip
  232. ubuntu-latest-cmake-sanitizer:
  233. runs-on: ubuntu-latest
  234. continue-on-error: true
  235. strategy:
  236. matrix:
  237. sanitizer: [ADDRESS, THREAD, UNDEFINED]
  238. build_type: [Debug, Release]
  239. steps:
  240. - name: Clone
  241. id: checkout
  242. uses: actions/checkout@v4
  243. - name: Dependencies
  244. id: depends
  245. run: |
  246. sudo apt-get update
  247. sudo apt-get install build-essential
  248. - name: Build
  249. id: cmake_build
  250. if: ${{ matrix.sanitizer != 'THREAD' }}
  251. run: |
  252. mkdir build
  253. cd build
  254. cmake .. -DLLAMA_FATAL_WARNINGS=ON -DLLAMA_SANITIZE_${{ matrix.sanitizer }}=ON -DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
  255. cmake --build . --config ${{ matrix.build_type }} -j $(nproc)
  256. - name: Build (no OpenMP)
  257. id: cmake_build_no_openmp
  258. if: ${{ matrix.sanitizer == 'THREAD' }}
  259. run: |
  260. mkdir build
  261. cd build
  262. cmake .. -DLLAMA_FATAL_WARNINGS=ON -DLLAMA_SANITIZE_${{ matrix.sanitizer }}=ON -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DGGML_OPENMP=OFF
  263. cmake --build . --config ${{ matrix.build_type }} -j $(nproc)
  264. - name: Test
  265. id: cmake_test
  266. run: |
  267. cd build
  268. ctest -L main --verbose --timeout 900
  269. ubuntu-latest-cmake-rpc:
  270. runs-on: ubuntu-latest
  271. continue-on-error: true
  272. steps:
  273. - name: Clone
  274. id: checkout
  275. uses: actions/checkout@v4
  276. - name: Dependencies
  277. id: depends
  278. run: |
  279. sudo apt-get update
  280. sudo apt-get install build-essential
  281. - name: Build
  282. id: cmake_build
  283. run: |
  284. mkdir build
  285. cd build
  286. cmake -DGGML_RPC=ON ..
  287. cmake --build . --config Release -j $(nproc)
  288. - name: Test
  289. id: cmake_test
  290. run: |
  291. cd build
  292. ctest -L main --verbose
  293. ubuntu-22-cmake-vulkan:
  294. runs-on: ubuntu-22.04
  295. steps:
  296. - name: Clone
  297. id: checkout
  298. uses: actions/checkout@v4
  299. - name: Dependencies
  300. id: depends
  301. run: |
  302. wget -qO - https://packages.lunarg.com/lunarg-signing-key-pub.asc | sudo apt-key add -
  303. sudo wget -qO /etc/apt/sources.list.d/lunarg-vulkan-jammy.list https://packages.lunarg.com/vulkan/lunarg-vulkan-jammy.list
  304. sudo apt-get update -y
  305. sudo apt-get install -y build-essential vulkan-sdk
  306. - name: Build
  307. id: cmake_build
  308. run: |
  309. mkdir build
  310. cd build
  311. cmake -DGGML_VULKAN=ON ..
  312. cmake --build . --config Release -j $(nproc)
  313. ubuntu-22-cmake-hip:
  314. runs-on: ubuntu-22.04
  315. container: rocm/dev-ubuntu-22.04:6.0.2
  316. steps:
  317. - name: Clone
  318. id: checkout
  319. uses: actions/checkout@v3
  320. - name: Dependencies
  321. id: depends
  322. run: |
  323. sudo apt-get update
  324. sudo apt-get install -y build-essential git cmake rocblas-dev hipblas-dev
  325. - name: Build with native CMake HIP support
  326. id: cmake_build
  327. run: |
  328. cmake -B build -S . -DCMAKE_HIP_COMPILER="$(hipconfig -l)/clang" -DGGML_HIPBLAS=ON
  329. cmake --build build --config Release -j $(nproc)
  330. - name: Build with legacy HIP support
  331. id: cmake_build_legacy_hip
  332. run: |
  333. cmake -B build2 -S . -DCMAKE_C_COMPILER=hipcc -DCMAKE_CXX_COMPILER=hipcc -DGGML_HIPBLAS=ON
  334. cmake --build build2 --config Release -j $(nproc)
  335. ubuntu-22-cmake-sycl:
  336. runs-on: ubuntu-22.04
  337. continue-on-error: true
  338. steps:
  339. - uses: actions/checkout@v2
  340. - name: add oneAPI to apt
  341. shell: bash
  342. run: |
  343. cd /tmp
  344. wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
  345. sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
  346. rm GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
  347. sudo add-apt-repository "deb https://apt.repos.intel.com/oneapi all main"
  348. - name: install oneAPI dpcpp compiler
  349. shell: bash
  350. run: |
  351. sudo apt update
  352. sudo apt install intel-oneapi-compiler-dpcpp-cpp
  353. - name: install oneAPI MKL library
  354. shell: bash
  355. run: |
  356. sudo apt install intel-oneapi-mkl-devel
  357. - name: Clone
  358. id: checkout
  359. uses: actions/checkout@v4
  360. - name: Build
  361. id: cmake_build
  362. run: |
  363. source /opt/intel/oneapi/setvars.sh
  364. mkdir build
  365. cd build
  366. cmake -DGGML_SYCL=ON -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx ..
  367. cmake --build . --config Release -j $(nproc)
  368. ubuntu-22-cmake-sycl-fp16:
  369. runs-on: ubuntu-22.04
  370. continue-on-error: true
  371. steps:
  372. - uses: actions/checkout@v2
  373. - name: add oneAPI to apt
  374. shell: bash
  375. run: |
  376. cd /tmp
  377. wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
  378. sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
  379. rm GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
  380. sudo add-apt-repository "deb https://apt.repos.intel.com/oneapi all main"
  381. - name: install oneAPI dpcpp compiler
  382. shell: bash
  383. run: |
  384. sudo apt update
  385. sudo apt install intel-oneapi-compiler-dpcpp-cpp
  386. - name: install oneAPI MKL library
  387. shell: bash
  388. run: |
  389. sudo apt install intel-oneapi-mkl-devel
  390. - name: Clone
  391. id: checkout
  392. uses: actions/checkout@v4
  393. - name: Build
  394. id: cmake_build
  395. run: |
  396. source /opt/intel/oneapi/setvars.sh
  397. mkdir build
  398. cd build
  399. cmake -DGGML_SYCL=ON -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx -DGGML_SYCL_F16=ON ..
  400. cmake --build . --config Release -j $(nproc)
  401. # TODO: build with GGML_NO_METAL because test-backend-ops fail on "Apple Paravirtual device" and I don't know
  402. # how to debug it.
  403. # ref: https://github.com/ggerganov/llama.cpp/actions/runs/7131777249/job/19420981052#step:5:1124
  404. macOS-latest-make:
  405. runs-on: macos-latest
  406. steps:
  407. - name: Clone
  408. id: checkout
  409. uses: actions/checkout@v4
  410. - name: Dependencies
  411. id: depends
  412. continue-on-error: true
  413. run: |
  414. brew update
  415. - name: Build
  416. id: make_build
  417. env:
  418. LLAMA_FATAL_WARNINGS: 1
  419. run: |
  420. GGML_NO_METAL=1 make -j $(sysctl -n hw.logicalcpu)
  421. - name: Test
  422. id: make_test
  423. run: |
  424. GGML_NO_METAL=1 make tests -j $(sysctl -n hw.logicalcpu)
  425. GGML_NO_METAL=1 make test -j $(sysctl -n hw.logicalcpu)
  426. # TODO: build with GGML_METAL=OFF because test-backend-ops fail on "Apple Paravirtual device" and I don't know
  427. # how to debug it.
  428. # ref: https://github.com/ggerganov/llama.cpp/actions/runs/7132125951/job/19422043567?pr=4359#step:5:6584
  429. # would be great if we fix these
  430. macOS-latest-cmake:
  431. runs-on: macos-latest
  432. steps:
  433. - name: Clone
  434. id: checkout
  435. uses: actions/checkout@v4
  436. - name: Dependencies
  437. id: depends
  438. continue-on-error: true
  439. run: |
  440. brew update
  441. - name: Build
  442. id: cmake_build
  443. run: |
  444. sysctl -a
  445. mkdir build
  446. cd build
  447. cmake -DLLAMA_FATAL_WARNINGS=ON -DGGML_METAL=OFF ..
  448. cmake --build . --config Release -j $(sysctl -n hw.logicalcpu)
  449. - name: Test
  450. id: cmake_test
  451. run: |
  452. cd build
  453. ctest -L main --verbose --timeout 900
  454. macOS-latest-cmake-ios:
  455. runs-on: macos-latest
  456. steps:
  457. - name: Clone
  458. id: checkout
  459. uses: actions/checkout@v1
  460. - name: Dependencies
  461. id: depends
  462. continue-on-error: true
  463. run: |
  464. brew update
  465. - name: Build
  466. id: cmake_build
  467. run: |
  468. sysctl -a
  469. mkdir build
  470. cd build
  471. cmake -G Xcode .. \
  472. -DGGML_METAL_EMBED_LIBRARY=ON \
  473. -DLLAMA_BUILD_EXAMPLES=OFF \
  474. -DLLAMA_BUILD_TESTS=OFF \
  475. -DLLAMA_BUILD_SERVER=OFF \
  476. -DCMAKE_SYSTEM_NAME=iOS \
  477. -DCMAKE_OSX_DEPLOYMENT_TARGET=14.0 \
  478. -DCMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM=ggml
  479. cmake --build . --config Release -j $(sysctl -n hw.logicalcpu) -- CODE_SIGNING_ALLOWED=NO
  480. macOS-latest-cmake-tvos:
  481. runs-on: macos-latest
  482. steps:
  483. - name: Clone
  484. id: checkout
  485. uses: actions/checkout@v1
  486. - name: Dependencies
  487. id: depends
  488. continue-on-error: true
  489. run: |
  490. brew update
  491. - name: Build
  492. id: cmake_build
  493. run: |
  494. sysctl -a
  495. mkdir build
  496. cd build
  497. cmake -G Xcode .. \
  498. -DGGML_METAL_EMBED_LIBRARY=ON \
  499. -DLLAMA_BUILD_EXAMPLES=OFF \
  500. -DLLAMA_BUILD_TESTS=OFF \
  501. -DLLAMA_BUILD_SERVER=OFF \
  502. -DCMAKE_SYSTEM_NAME=tvOS \
  503. -DCMAKE_OSX_DEPLOYMENT_TARGET=14.0 \
  504. -DCMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM=ggml
  505. cmake --build . --config Release -j $(sysctl -n hw.logicalcpu) -- CODE_SIGNING_ALLOWED=NO
  506. macOS-latest-swift:
  507. runs-on: macos-latest
  508. strategy:
  509. matrix:
  510. destination: ['generic/platform=macOS', 'generic/platform=iOS', 'generic/platform=tvOS']
  511. steps:
  512. - name: Clone
  513. id: checkout
  514. uses: actions/checkout@v1
  515. - name: Dependencies
  516. id: depends
  517. continue-on-error: true
  518. run: |
  519. brew update
  520. - name: xcodebuild for swift package
  521. id: xcodebuild
  522. run: |
  523. xcodebuild -scheme llama -destination "${{ matrix.destination }}"
  524. - name: Build Swift Example
  525. id: make_build_swift_example
  526. run: |
  527. make swift
  528. windows-msys2:
  529. runs-on: windows-latest
  530. strategy:
  531. fail-fast: false
  532. matrix:
  533. include:
  534. - { sys: UCRT64, env: ucrt-x86_64, build: Release }
  535. - { sys: CLANG64, env: clang-x86_64, build: Release }
  536. steps:
  537. - name: Clone
  538. uses: actions/checkout@v4
  539. - name: Setup ${{ matrix.sys }}
  540. uses: msys2/setup-msys2@v2
  541. with:
  542. update: true
  543. msystem: ${{matrix.sys}}
  544. install: >-
  545. base-devel
  546. mingw-w64-${{matrix.env}}-toolchain
  547. mingw-w64-${{matrix.env}}-cmake
  548. mingw-w64-${{matrix.env}}-openblas
  549. - name: Build using make
  550. shell: msys2 {0}
  551. run: |
  552. make -j $(nproc)
  553. - name: Clean after building using make
  554. shell: msys2 {0}
  555. run: |
  556. make clean
  557. - name: Build using make w/ OpenBLAS
  558. shell: msys2 {0}
  559. run: |
  560. make GGML_OPENBLAS=1 -j $(nproc)
  561. - name: Build using CMake
  562. shell: msys2 {0}
  563. run: |
  564. cmake -B build
  565. cmake --build build --config ${{ matrix.build }} -j $(nproc)
  566. - name: Clean after building using CMake
  567. shell: msys2 {0}
  568. run: |
  569. rm -rf build
  570. - name: Build using CMake w/ OpenBLAS
  571. shell: msys2 {0}
  572. run: |
  573. cmake -B build -DGGML_BLAS=ON -DGGML_BLAS_VENDOR=OpenBLAS
  574. cmake --build build --config ${{ matrix.build }} -j $(nproc)
  575. windows-latest-cmake:
  576. runs-on: windows-2019
  577. env:
  578. OPENBLAS_VERSION: 0.3.23
  579. SDE_VERSION: 9.33.0-2024-01-07
  580. VULKAN_VERSION: 1.3.261.1
  581. strategy:
  582. matrix:
  583. include:
  584. - build: 'noavx-x64'
  585. defines: '-DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DGGML_RPC=ON -DGGML_AVX=OFF -DGGML_AVX2=OFF -DGGML_FMA=OFF -DBUILD_SHARED_LIBS=ON'
  586. - build: 'avx2-x64'
  587. defines: '-DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DGGML_RPC=ON -DBUILD_SHARED_LIBS=ON'
  588. - build: 'avx-x64'
  589. defines: '-DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DGGML_RPC=ON -DGGML_AVX2=OFF -DBUILD_SHARED_LIBS=ON'
  590. - build: 'avx512-x64'
  591. defines: '-DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DGGML_RPC=ON -DGGML_AVX512=ON -DBUILD_SHARED_LIBS=ON'
  592. - build: 'openblas-x64'
  593. defines: '-DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DGGML_RPC=ON -DGGML_BLAS=ON -DBUILD_SHARED_LIBS=ON -DGGML_BLAS_VENDOR=OpenBLAS -DBLAS_INCLUDE_DIRS="$env:RUNNER_TEMP/openblas/include" -DBLAS_LIBRARIES="$env:RUNNER_TEMP/openblas/lib/openblas.lib"'
  594. - build: 'kompute-x64'
  595. defines: '-DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DGGML_RPC=ON -DGGML_KOMPUTE=ON -DKOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK=ON -DBUILD_SHARED_LIBS=ON'
  596. - build: 'vulkan-x64'
  597. defines: '-DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DGGML_RPC=ON -DGGML_VULKAN=ON -DBUILD_SHARED_LIBS=ON'
  598. - build: 'llvm-arm64'
  599. defines: '-G "Ninja Multi-Config" -D CMAKE_TOOLCHAIN_FILE=cmake/arm64-windows-llvm.cmake -DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DBUILD_SHARED_LIBS=ON'
  600. - build: 'msvc-arm64'
  601. defines: '-G "Ninja Multi-Config" -D CMAKE_TOOLCHAIN_FILE=cmake/arm64-windows-msvc.cmake -DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DBUILD_SHARED_LIBS=ON'
  602. steps:
  603. - name: Clone
  604. id: checkout
  605. uses: actions/checkout@v4
  606. with:
  607. fetch-depth: 0
  608. - name: Clone Kompute submodule
  609. id: clone_kompute
  610. if: ${{ matrix.build == 'kompute-x64' }}
  611. run: |
  612. git submodule update --init ggml/src/kompute
  613. - name: Download OpenBLAS
  614. id: get_openblas
  615. if: ${{ matrix.build == 'openblas-x64' }}
  616. run: |
  617. curl.exe -o $env:RUNNER_TEMP/openblas.zip -L "https://github.com/xianyi/OpenBLAS/releases/download/v${env:OPENBLAS_VERSION}/OpenBLAS-${env:OPENBLAS_VERSION}-x64.zip"
  618. curl.exe -o $env:RUNNER_TEMP/OpenBLAS.LICENSE.txt -L "https://github.com/xianyi/OpenBLAS/raw/v${env:OPENBLAS_VERSION}/LICENSE"
  619. mkdir $env:RUNNER_TEMP/openblas
  620. tar.exe -xvf $env:RUNNER_TEMP/openblas.zip -C $env:RUNNER_TEMP/openblas
  621. $vcdir = $(vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath)
  622. $msvc = $(join-path $vcdir $('VC\Tools\MSVC\'+$(gc -raw $(join-path $vcdir 'VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.txt')).Trim()))
  623. $lib = $(join-path $msvc 'bin\Hostx64\x64\lib.exe')
  624. & $lib /machine:x64 "/def:${env:RUNNER_TEMP}/openblas/lib/libopenblas.def" "/out:${env:RUNNER_TEMP}/openblas/lib/openblas.lib" /name:openblas.dll
  625. - name: Install Vulkan SDK
  626. id: get_vulkan
  627. if: ${{ matrix.build == 'kompute-x64' || matrix.build == 'vulkan-x64' }}
  628. run: |
  629. curl.exe -o $env:RUNNER_TEMP/VulkanSDK-Installer.exe -L "https://sdk.lunarg.com/sdk/download/${env:VULKAN_VERSION}/windows/VulkanSDK-${env:VULKAN_VERSION}-Installer.exe"
  630. & "$env:RUNNER_TEMP\VulkanSDK-Installer.exe" --accept-licenses --default-answer --confirm-command install
  631. Add-Content $env:GITHUB_ENV "VULKAN_SDK=C:\VulkanSDK\${env:VULKAN_VERSION}"
  632. Add-Content $env:GITHUB_PATH "C:\VulkanSDK\${env:VULKAN_VERSION}\bin"
  633. - name: Install Ninja
  634. id: install_ninja
  635. run: |
  636. choco install ninja
  637. - name: Build
  638. id: cmake_build
  639. run: |
  640. cmake -S . -B build ${{ matrix.defines }}
  641. cmake --build build --config Release -j ${env:NUMBER_OF_PROCESSORS}
  642. - name: Add libopenblas.dll
  643. id: add_libopenblas_dll
  644. if: ${{ matrix.build == 'openblas-x64' }}
  645. run: |
  646. cp $env:RUNNER_TEMP/openblas/bin/libopenblas.dll ./build/bin/Release/openblas.dll
  647. cp $env:RUNNER_TEMP/OpenBLAS.LICENSE.txt ./build/bin/Release/OpenBLAS-${env:OPENBLAS_VERSION}.txt
  648. - name: Check AVX512F support
  649. id: check_avx512f
  650. if: ${{ matrix.build == 'avx512-x64' }}
  651. continue-on-error: true
  652. run: |
  653. cd build
  654. $vcdir = $(vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath)
  655. $msvc = $(join-path $vcdir $('VC\Tools\MSVC\'+$(gc -raw $(join-path $vcdir 'VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.txt')).Trim()))
  656. $cl = $(join-path $msvc 'bin\Hostx64\x64\cl.exe')
  657. echo 'int main(void){unsigned int a[4];__cpuid(a,7);return !(a[1]&65536);}' >> avx512f.c
  658. & $cl /O2 /GS- /kernel avx512f.c /link /nodefaultlib /entry:main
  659. .\avx512f.exe && echo "AVX512F: YES" && ( echo HAS_AVX512F=1 >> $env:GITHUB_ENV ) || echo "AVX512F: NO"
  660. - name: Test
  661. id: cmake_test
  662. # not all machines have native AVX-512
  663. if: ${{ matrix.build != 'msvc-arm64' && matrix.build != 'llvm-arm64' && matrix.build != 'kompute-x64' && matrix.build != 'vulkan-x64' && (matrix.build != 'avx512-x64' || env.HAS_AVX512F == '1') }}
  664. run: |
  665. cd build
  666. ctest -L main -C Release --verbose --timeout 900
  667. - name: Test (Intel SDE)
  668. id: cmake_test_sde
  669. if: ${{ matrix.build == 'avx512-x64' && env.HAS_AVX512F == '0' }} # use Intel SDE for AVX-512 emulation
  670. run: |
  671. curl.exe -o $env:RUNNER_TEMP/sde.tar.xz -L "https://downloadmirror.intel.com/813591/sde-external-${env:SDE_VERSION}-win.tar.xz"
  672. # for some weird reason windows tar doesn't like sde tar.xz
  673. 7z x "-o${env:RUNNER_TEMP}" $env:RUNNER_TEMP/sde.tar.xz
  674. 7z x "-o${env:RUNNER_TEMP}" $env:RUNNER_TEMP/sde.tar
  675. $sde = $(join-path $env:RUNNER_TEMP sde-external-${env:SDE_VERSION}-win/sde.exe)
  676. cd build
  677. $env:LLAMA_SKIP_TESTS_SLOW_ON_EMULATOR = 1
  678. & $sde -future -- ctest -L main -C Release --verbose --timeout 900
  679. - name: Determine tag name
  680. id: tag
  681. shell: bash
  682. run: |
  683. BUILD_NUMBER="$(git rev-list --count HEAD)"
  684. SHORT_HASH="$(git rev-parse --short=7 HEAD)"
  685. if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
  686. echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
  687. else
  688. SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
  689. echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
  690. fi
  691. - name: Pack artifacts
  692. id: pack_artifacts
  693. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  694. run: |
  695. Copy-Item LICENSE .\build\bin\Release\llama.cpp.txt
  696. 7z a llama-${{ steps.tag.outputs.name }}-bin-win-${{ matrix.build }}.zip .\build\bin\Release\*
  697. - name: Upload artifacts
  698. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  699. uses: actions/upload-artifact@v4
  700. with:
  701. path: llama-${{ steps.tag.outputs.name }}-bin-win-${{ matrix.build }}.zip
  702. name: llama-bin-win-${{ matrix.build }}.zip
  703. windows-latest-cmake-cuda:
  704. runs-on: windows-2019
  705. strategy:
  706. matrix:
  707. cuda: ['12.2.0', '11.7.1']
  708. build: ['cuda']
  709. steps:
  710. - name: Clone
  711. id: checkout
  712. uses: actions/checkout@v4
  713. with:
  714. fetch-depth: 0
  715. - name: Install CUDA toolkit
  716. id: cuda-toolkit
  717. uses: Jimver/cuda-toolkit@v0.2.15
  718. with:
  719. cuda: ${{ matrix.cuda }}
  720. method: 'network'
  721. sub-packages: '["nvcc", "cudart", "cublas", "cublas_dev", "thrust", "visual_studio_integration"]'
  722. - name: Build
  723. id: cmake_build
  724. run: |
  725. mkdir build
  726. cd build
  727. cmake .. -DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DGGML_CUDA=ON -DBUILD_SHARED_LIBS=ON -DGGML_RPC=ON
  728. cmake --build . --config Release -j $((${env:NUMBER_OF_PROCESSORS} - 1)) -t ggml
  729. cmake --build . --config Release -j ${env:NUMBER_OF_PROCESSORS}
  730. - name: Determine tag name
  731. id: tag
  732. shell: bash
  733. run: |
  734. BUILD_NUMBER="$(git rev-list --count HEAD)"
  735. SHORT_HASH="$(git rev-parse --short=7 HEAD)"
  736. if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
  737. echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
  738. else
  739. SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
  740. echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
  741. fi
  742. - name: Pack artifacts
  743. id: pack_artifacts
  744. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  745. run: |
  746. 7z a llama-${{ steps.tag.outputs.name }}-bin-win-${{ matrix.build }}-cu${{ matrix.cuda }}-x64.zip .\build\bin\Release\*
  747. - name: Upload artifacts
  748. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  749. uses: actions/upload-artifact@v4
  750. with:
  751. path: llama-${{ steps.tag.outputs.name }}-bin-win-${{ matrix.build }}-cu${{ matrix.cuda }}-x64.zip
  752. name: llama-bin-win-cu${{ matrix.cuda }}-x64.zip
  753. - name: Copy and pack Cuda runtime
  754. run: |
  755. echo "Cuda install location: ${{steps.cuda-toolkit.outputs.CUDA_PATH}}"
  756. $dst='.\build\bin\cudart\'
  757. robocopy "${{steps.cuda-toolkit.outputs.CUDA_PATH}}\bin" $dst cudart64_*.dll cublas64_*.dll cublasLt64_*.dll
  758. 7z a cudart-llama-bin-win-cu${{ matrix.cuda }}-x64.zip $dst\*
  759. - name: Upload Cuda runtime
  760. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  761. uses: actions/upload-artifact@v4
  762. with:
  763. path: cudart-llama-bin-win-cu${{ matrix.cuda }}-x64.zip
  764. name: cudart-llama-bin-win-cu${{ matrix.cuda }}-x64.zip
  765. windows-latest-cmake-sycl:
  766. runs-on: windows-latest
  767. defaults:
  768. run:
  769. shell: bash
  770. env:
  771. WINDOWS_BASEKIT_URL: https://registrationcenter-download.intel.com/akdlm/IRC_NAS/7dff44ba-e3af-4448-841c-0d616c8da6e7/w_BaseKit_p_2024.1.0.595_offline.exe
  772. WINDOWS_DPCPP_MKL: intel.oneapi.win.cpp-dpcpp-common:intel.oneapi.win.mkl.devel
  773. ONEAPI_ROOT: "C:/Program Files (x86)/Intel/oneAPI"
  774. steps:
  775. - name: Clone
  776. id: checkout
  777. uses: actions/checkout@v4
  778. with:
  779. fetch-depth: 0
  780. - name: Install
  781. run: scripts/install-oneapi.bat $WINDOWS_BASEKIT_URL $WINDOWS_DPCPP_MKL
  782. - name: Build
  783. id: cmake_build
  784. run: examples/sycl/win-build-sycl.bat
  785. - name: Determine tag name
  786. id: tag
  787. shell: bash
  788. run: |
  789. BUILD_NUMBER="$(git rev-list --count HEAD)"
  790. SHORT_HASH="$(git rev-parse --short=7 HEAD)"
  791. if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
  792. echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
  793. else
  794. SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
  795. echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
  796. fi
  797. - name: Pack artifacts
  798. id: pack_artifacts
  799. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  800. run: |
  801. echo "cp oneAPI running time dll files in ${{ env.ONEAPI_ROOT }} to ./build/bin"
  802. cp "${{ env.ONEAPI_ROOT }}/mkl/latest/bin/mkl_sycl_blas.4.dll" ./build/bin
  803. cp "${{ env.ONEAPI_ROOT }}/mkl/latest/bin/mkl_core.2.dll" ./build/bin
  804. cp "${{ env.ONEAPI_ROOT }}/mkl/latest/bin/mkl_tbb_thread.2.dll" ./build/bin
  805. cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/pi_win_proxy_loader.dll" ./build/bin
  806. cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/pi_level_zero.dll" ./build/bin
  807. cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/sycl7.dll" ./build/bin
  808. cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/svml_dispmd.dll" ./build/bin
  809. cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/libmmd.dll" ./build/bin
  810. echo "cp oneAPI running time dll files to ./build/bin done"
  811. 7z a llama-${{ steps.tag.outputs.name }}-bin-win-sycl-x64.zip ./build/bin/*
  812. - name: Upload artifacts
  813. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  814. uses: actions/upload-artifact@v4
  815. with:
  816. path: llama-${{ steps.tag.outputs.name }}-bin-win-sycl-x64.zip
  817. name: llama-bin-win-sycl-x64.zip
  818. windows-latest-cmake-hip:
  819. runs-on: windows-latest
  820. steps:
  821. - name: Clone
  822. id: checkout
  823. uses: actions/checkout@v3
  824. - name: Install
  825. id: depends
  826. run: |
  827. $ErrorActionPreference = "Stop"
  828. write-host "Downloading AMD HIP SDK Installer"
  829. Invoke-WebRequest -Uri "https://download.amd.com/developer/eula/rocm-hub/AMD-Software-PRO-Edition-23.Q4-WinSvr2022-For-HIP.exe" -OutFile "${env:RUNNER_TEMP}\rocm-install.exe"
  830. write-host "Installing AMD HIP SDK"
  831. Start-Process "${env:RUNNER_TEMP}\rocm-install.exe" -ArgumentList '-install' -NoNewWindow -Wait
  832. write-host "Completed AMD HIP SDK installation"
  833. - name: Verify ROCm
  834. id: verify
  835. run: |
  836. & 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' --version
  837. - name: Build
  838. id: cmake_build
  839. run: |
  840. $env:HIP_PATH=$(Resolve-Path 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' | split-path | split-path)
  841. $env:CMAKE_PREFIX_PATH="${env:HIP_PATH}"
  842. cmake -G "Unix Makefiles" -B build -S . -DCMAKE_C_COMPILER="${env:HIP_PATH}\bin\clang.exe" -DCMAKE_CXX_COMPILER="${env:HIP_PATH}\bin\clang++.exe" -DGGML_HIPBLAS=ON
  843. cmake --build build --config Release
  844. ios-xcode-build:
  845. runs-on: macos-latest
  846. steps:
  847. - name: Checkout code
  848. uses: actions/checkout@v4
  849. - name: Build Xcode project
  850. run: xcodebuild -project examples/llama.swiftui/llama.swiftui.xcodeproj -scheme llama.swiftui -sdk iphoneos CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY= -destination 'generic/platform=iOS' build
  851. android-build:
  852. runs-on: ubuntu-latest
  853. steps:
  854. - name: Clone
  855. uses: actions/checkout@v4
  856. - name: Set up JDK
  857. uses: actions/setup-java@v3
  858. with:
  859. java-version: 17
  860. distribution: zulu
  861. - name: Setup Android SDK
  862. uses: android-actions/setup-android@v3
  863. with:
  864. log-accepted-android-sdk-licenses: false
  865. - name: Build
  866. run: |
  867. cd examples/llama.android
  868. ./gradlew build --no-daemon
  869. # freeBSD-latest:
  870. # runs-on: macos-12
  871. # steps:
  872. # - name: Clone
  873. # uses: actions/checkout@v4
  874. #
  875. # - name: Build
  876. # uses: cross-platform-actions/action@v0.19.0
  877. # with:
  878. # operating_system: freebsd
  879. # version: '13.2'
  880. # hypervisor: 'qemu'
  881. # run: |
  882. # sudo pkg update
  883. # sudo pkg install -y gmake automake autoconf pkgconf llvm15 openblas
  884. # gmake CC=/usr/local/bin/clang15 CXX=/usr/local/bin/clang++15 -j `sysctl -n hw.ncpu`
  885. release:
  886. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  887. runs-on: ubuntu-latest
  888. needs:
  889. - ubuntu-focal-make
  890. - ubuntu-latest-cmake
  891. - macOS-latest-make
  892. - macOS-latest-cmake
  893. - windows-latest-cmake
  894. - windows-latest-cmake-cuda
  895. - macOS-latest-cmake-arm64
  896. - macOS-latest-cmake-x64
  897. steps:
  898. - name: Clone
  899. id: checkout
  900. uses: actions/checkout@v4
  901. with:
  902. fetch-depth: 0
  903. - name: Determine tag name
  904. id: tag
  905. shell: bash
  906. run: |
  907. BUILD_NUMBER="$(git rev-list --count HEAD)"
  908. SHORT_HASH="$(git rev-parse --short=7 HEAD)"
  909. if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
  910. echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
  911. else
  912. SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
  913. echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
  914. fi
  915. - name: Download artifacts
  916. id: download-artifact
  917. uses: actions/download-artifact@v4
  918. with:
  919. path: ./artifact
  920. - name: Move artifacts
  921. id: move_artifacts
  922. run: mkdir -p ./artifact/release && mv ./artifact/*/*.zip ./artifact/release
  923. - name: Create release
  924. id: create_release
  925. uses: anzz1/action-create-release@v1
  926. env:
  927. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  928. with:
  929. tag_name: ${{ steps.tag.outputs.name }}
  930. - name: Upload release
  931. id: upload_release
  932. uses: actions/github-script@v3
  933. with:
  934. github-token: ${{secrets.GITHUB_TOKEN}}
  935. script: |
  936. const path = require('path');
  937. const fs = require('fs');
  938. const release_id = '${{ steps.create_release.outputs.id }}';
  939. for (let file of await fs.readdirSync('./artifact/release')) {
  940. if (path.extname(file) === '.zip') {
  941. console.log('uploadReleaseAsset', file);
  942. await github.repos.uploadReleaseAsset({
  943. owner: context.repo.owner,
  944. repo: context.repo.repo,
  945. release_id: release_id,
  946. name: file,
  947. data: await fs.readFileSync(`./artifact/release/${file}`)
  948. });
  949. }
  950. }
  951. # ubuntu-latest-gcc:
  952. # runs-on: ubuntu-latest
  953. #
  954. # strategy:
  955. # matrix:
  956. # build: [Debug, Release]
  957. #
  958. # steps:
  959. # - name: Clone
  960. # uses: actions/checkout@v4
  961. #
  962. # - name: Dependencies
  963. # run: |
  964. # sudo apt-get update
  965. # sudo apt-get install build-essential
  966. # sudo apt-get install cmake
  967. #
  968. # - name: Configure
  969. # run: cmake . -DCMAKE_BUILD_TYPE=${{ matrix.build }}
  970. #
  971. # - name: Build
  972. # run: |
  973. # make
  974. #
  975. # ubuntu-latest-clang:
  976. # runs-on: ubuntu-latest
  977. #
  978. # strategy:
  979. # matrix:
  980. # build: [Debug, Release]
  981. #
  982. # steps:
  983. # - name: Clone
  984. # uses: actions/checkout@v4
  985. #
  986. # - name: Dependencies
  987. # run: |
  988. # sudo apt-get update
  989. # sudo apt-get install build-essential
  990. # sudo apt-get install cmake
  991. #
  992. # - name: Configure
  993. # run: cmake . -DCMAKE_BUILD_TYPE=${{ matrix.build }} -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang
  994. #
  995. # - name: Build
  996. # run: |
  997. # make
  998. #
  999. # ubuntu-latest-gcc-sanitized:
  1000. # runs-on: ubuntu-latest
  1001. #
  1002. # strategy:
  1003. # matrix:
  1004. # sanitizer: [ADDRESS, THREAD, UNDEFINED]
  1005. #
  1006. # steps:
  1007. # - name: Clone
  1008. # uses: actions/checkout@v4
  1009. #
  1010. # - name: Dependencies
  1011. # run: |
  1012. # sudo apt-get update
  1013. # sudo apt-get install build-essential
  1014. # sudo apt-get install cmake
  1015. #
  1016. # - name: Configure
  1017. # run: cmake . -DCMAKE_BUILD_TYPE=Debug -DLLAMA_SANITIZE_${{ matrix.sanitizer }}=ON
  1018. #
  1019. # - name: Build
  1020. # run: |
  1021. # make
  1022. #
  1023. # windows:
  1024. # runs-on: windows-latest
  1025. #
  1026. # strategy:
  1027. # matrix:
  1028. # build: [Release]
  1029. # arch: [Win32, x64]
  1030. # include:
  1031. # - arch: Win32
  1032. # s2arc: x86
  1033. # - arch: x64
  1034. # s2arc: x64
  1035. #
  1036. # steps:
  1037. # - name: Clone
  1038. # uses: actions/checkout@v4
  1039. #
  1040. # - name: Add msbuild to PATH
  1041. # uses: microsoft/setup-msbuild@v1
  1042. #
  1043. # - name: Configure
  1044. # run: >
  1045. # cmake -S . -B ./build -A ${{ matrix.arch }}
  1046. # -DCMAKE_BUILD_TYPE=${{ matrix.build }}
  1047. #
  1048. # - name: Build
  1049. # run: |
  1050. # cd ./build
  1051. # msbuild ALL_BUILD.vcxproj -t:build -p:configuration=${{ matrix.build }} -p:platform=${{ matrix.arch }}
  1052. #
  1053. # - name: Upload binaries
  1054. # uses: actions/upload-artifact@v4
  1055. # with:
  1056. # name: llama-bin-${{ matrix.arch }}
  1057. # path: build/bin/${{ matrix.build }}
  1058. #
  1059. # windows-blas:
  1060. # runs-on: windows-latest
  1061. #
  1062. # strategy:
  1063. # matrix:
  1064. # build: [Release]
  1065. # arch: [Win32, x64]
  1066. # blas: [ON]
  1067. # include:
  1068. # - arch: Win32
  1069. # obzip: https://github.com/xianyi/OpenBLAS/releases/download/v0.3.21/OpenBLAS-0.3.21-x86.zip
  1070. # s2arc: x86
  1071. # - arch: x64
  1072. # obzip: https://github.com/xianyi/OpenBLAS/releases/download/v0.3.21/OpenBLAS-0.3.21-x64.zip
  1073. # s2arc: x64
  1074. #
  1075. # steps:
  1076. # - name: Clone
  1077. # uses: actions/checkout@v4
  1078. #
  1079. # - name: Add msbuild to PATH
  1080. # uses: microsoft/setup-msbuild@v1
  1081. #
  1082. # - name: Fetch OpenBLAS
  1083. # if: matrix.blas == 'ON'
  1084. # run: |
  1085. # C:/msys64/usr/bin/wget.exe -qO blas.zip ${{ matrix.obzip }}
  1086. # 7z x blas.zip -oblas -y
  1087. # copy blas/include/cblas.h .
  1088. # copy blas/include/openblas_config.h .
  1089. # echo "blasdir=$env:GITHUB_WORKSPACE/blas" >> $env:GITHUB_ENV
  1090. #
  1091. # - name: Configure
  1092. # run: >
  1093. # cmake -S . -B ./build -A ${{ matrix.arch }}
  1094. # -DCMAKE_BUILD_TYPE=${{ matrix.build }}
  1095. # -DLLAMA_SUPPORT_OPENBLAS=${{ matrix.blas }}
  1096. # -DCMAKE_LIBRARY_PATH="$env:blasdir/lib"
  1097. #
  1098. # - name: Build
  1099. # run: |
  1100. # cd ./build
  1101. # msbuild ALL_BUILD.vcxproj -t:build -p:configuration=${{ matrix.build }} -p:platform=${{ matrix.arch }}
  1102. #
  1103. # - name: Copy libopenblas.dll
  1104. # if: matrix.blas == 'ON'
  1105. # run: copy "$env:blasdir/bin/libopenblas.dll" build/bin/${{ matrix.build }}
  1106. #
  1107. # - name: Upload binaries
  1108. # if: matrix.blas == 'ON'
  1109. # uses: actions/upload-artifact@v4
  1110. # with:
  1111. # name: llama-blas-bin-${{ matrix.arch }}
  1112. # path: build/bin/${{ matrix.build }}
  1113. #
  1114. # emscripten:
  1115. # runs-on: ubuntu-latest
  1116. #
  1117. # strategy:
  1118. # matrix:
  1119. # build: [Release]
  1120. #
  1121. # steps:
  1122. # - name: Clone
  1123. # uses: actions/checkout@v4
  1124. #
  1125. # - name: Dependencies
  1126. # run: |
  1127. # wget -q https://github.com/emscripten-core/emsdk/archive/master.tar.gz
  1128. # tar -xvf master.tar.gz
  1129. # emsdk-master/emsdk update
  1130. # emsdk-master/emsdk install latest
  1131. # emsdk-master/emsdk activate latest
  1132. #
  1133. # - name: Configure
  1134. # run: echo "tmp"
  1135. #
  1136. # - name: Build
  1137. # run: |
  1138. # pushd emsdk-master
  1139. # source ./emsdk_env.sh
  1140. # popd
  1141. # emcmake cmake . -DCMAKE_BUILD_TYPE=${{ matrix.build }}
  1142. # make