build.yml 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311
  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/**', '**/CMakeLists.txt', '**/Makefile', '**/*.h', '**/*.hpp', '**/*.c', '**/*.cpp', '**/*.cu', '**/*.swift', '**/*.m']
  13. pull_request:
  14. types: [opened, synchronize, reopened]
  15. paths: ['**/CMakeLists.txt', '**/Makefile', '**/*.h', '**/*.hpp', '**/*.c', '**/*.cpp', '**/*.cu', '**/*.swift', '**/*.m']
  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 -DLLAMA_METAL_EMBED_LIBRARY=ON -DLLAMA_CURL=ON ..
  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-latest
  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. mkdir build
  92. cd build
  93. # Metal is disabled due to intermittent failures with Github runners not having a GPU:
  94. # https://github.com/ggerganov/llama.cpp/actions/runs/8635935781/job/23674807267#step:5:2313
  95. cmake -DLLAMA_FATAL_WARNINGS=ON -DLLAMA_METAL=OFF -DLLAMA_CURL=ON ..
  96. cmake --build . --config Release -j $(sysctl -n hw.logicalcpu)
  97. - name: Test
  98. id: cmake_test
  99. run: |
  100. cd build
  101. ctest -L main --verbose --timeout 900
  102. - name: Determine tag name
  103. id: tag
  104. shell: bash
  105. run: |
  106. BUILD_NUMBER="$(git rev-list --count HEAD)"
  107. SHORT_HASH="$(git rev-parse --short=7 HEAD)"
  108. if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
  109. echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
  110. else
  111. SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
  112. echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
  113. fi
  114. - name: Pack artifacts
  115. id: pack_artifacts
  116. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  117. run: |
  118. cp LICENSE ./build/bin/
  119. zip -r llama-${{ steps.tag.outputs.name }}-bin-macos-x64.zip ./build/bin/*
  120. - name: Upload artifacts
  121. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  122. uses: actions/upload-artifact@v4
  123. with:
  124. path: llama-${{ steps.tag.outputs.name }}-bin-macos-x64.zip
  125. name: llama-bin-macos-x64.zip
  126. ubuntu-focal-make:
  127. runs-on: ubuntu-20.04
  128. env:
  129. LLAMA_NODE_AVAILABLE: true
  130. LLAMA_PYTHON_AVAILABLE: true
  131. steps:
  132. - name: Clone
  133. id: checkout
  134. uses: actions/checkout@v4
  135. - name: Dependencies
  136. id: depends
  137. run: |
  138. sudo apt-get update
  139. sudo apt-get install build-essential gcc-8
  140. - uses: actions/setup-node@v4
  141. with:
  142. node-version: "20"
  143. - uses: actions/setup-python@v5
  144. with:
  145. python-version: "3.11"
  146. - name: Build
  147. id: make_build
  148. env:
  149. LLAMA_FATAL_WARNINGS: 1
  150. run: |
  151. CC=gcc-8 make -j $(nproc)
  152. - name: Test
  153. id: make_test
  154. run: |
  155. CC=gcc-8 make tests -j $(nproc)
  156. make test -j $(nproc)
  157. ubuntu-focal-make-curl:
  158. runs-on: ubuntu-20.04
  159. steps:
  160. - name: Clone
  161. id: checkout
  162. uses: actions/checkout@v4
  163. - name: Dependencies
  164. id: depends
  165. run: |
  166. sudo apt-get update
  167. sudo apt-get install build-essential gcc-8 libcurl4-openssl-dev
  168. - name: Build
  169. id: make_build
  170. env:
  171. LLAMA_FATAL_WARNINGS: 1
  172. LLAMA_CURL: 1
  173. run: |
  174. CC=gcc-8 make -j $(nproc)
  175. ubuntu-latest-cmake:
  176. runs-on: ubuntu-latest
  177. steps:
  178. - name: Clone
  179. id: checkout
  180. uses: actions/checkout@v4
  181. with:
  182. fetch-depth: 0
  183. - name: Dependencies
  184. id: depends
  185. run: |
  186. sudo apt-get update
  187. sudo apt-get install build-essential libcurl4-openssl-dev
  188. - name: Build
  189. id: cmake_build
  190. run: |
  191. mkdir build
  192. cd build
  193. cmake .. -DLLAMA_FATAL_WARNINGS=ON -DLLAMA_CURL=ON
  194. cmake --build . --config Release -j $(nproc)
  195. - name: Test
  196. id: cmake_test
  197. run: |
  198. cd build
  199. ctest -L 'main|curl' --verbose --timeout 900
  200. - name: Test llama2c conversion
  201. id: llama2c_test
  202. run: |
  203. cd build
  204. echo "Fetch tokenizer"
  205. wget https://huggingface.co/karpathy/tinyllamas/resolve/main/stories260K/tok512.bin
  206. echo "Fetch llama2c model"
  207. wget https://huggingface.co/karpathy/tinyllamas/resolve/main/stories260K/stories260K.bin
  208. ./bin/convert-llama2c-to-ggml --copy-vocab-from-model ./tok512.bin --llama2c-model stories260K.bin --llama2c-output-model stories260K.gguf
  209. ./bin/main -m stories260K.gguf -p "One day, Lily met a Shoggoth" -n 500 -c 256
  210. - name: Determine tag name
  211. id: tag
  212. shell: bash
  213. run: |
  214. BUILD_NUMBER="$(git rev-list --count HEAD)"
  215. SHORT_HASH="$(git rev-parse --short=7 HEAD)"
  216. if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
  217. echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
  218. else
  219. SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
  220. echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
  221. fi
  222. - name: Pack artifacts
  223. id: pack_artifacts
  224. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  225. run: |
  226. cp LICENSE ./build/bin/
  227. zip -r llama-${{ steps.tag.outputs.name }}-bin-ubuntu-x64.zip ./build/bin/*
  228. - name: Upload artifacts
  229. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  230. uses: actions/upload-artifact@v4
  231. with:
  232. path: llama-${{ steps.tag.outputs.name }}-bin-ubuntu-x64.zip
  233. name: llama-bin-ubuntu-x64.zip
  234. ubuntu-latest-cmake-sanitizer:
  235. runs-on: ubuntu-latest
  236. continue-on-error: true
  237. strategy:
  238. matrix:
  239. sanitizer: [ADDRESS, THREAD, UNDEFINED]
  240. build_type: [Debug, Release]
  241. steps:
  242. - name: Clone
  243. id: checkout
  244. uses: actions/checkout@v4
  245. - name: Dependencies
  246. id: depends
  247. run: |
  248. sudo apt-get update
  249. sudo apt-get install build-essential
  250. - name: Build
  251. id: cmake_build
  252. if: ${{ matrix.sanitizer != 'THREAD' }}
  253. run: |
  254. mkdir build
  255. cd build
  256. cmake .. -DLLAMA_FATAL_WARNINGS=ON -DLLAMA_SANITIZE_${{ matrix.sanitizer }}=ON -DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
  257. cmake --build . --config ${{ matrix.build_type }} -j $(nproc)
  258. - name: Build (no OpenMP)
  259. id: cmake_build_no_openmp
  260. if: ${{ matrix.sanitizer == 'THREAD' }}
  261. run: |
  262. mkdir build
  263. cd build
  264. cmake .. -DLLAMA_FATAL_WARNINGS=ON -DLLAMA_SANITIZE_${{ matrix.sanitizer }}=ON -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DLLAMA_OPENMP=OFF
  265. cmake --build . --config ${{ matrix.build_type }} -j $(nproc)
  266. - name: Test
  267. id: cmake_test
  268. run: |
  269. cd build
  270. ctest -L main --verbose --timeout 900
  271. ubuntu-latest-cmake-rpc:
  272. runs-on: ubuntu-latest
  273. continue-on-error: true
  274. steps:
  275. - name: Clone
  276. id: checkout
  277. uses: actions/checkout@v4
  278. - name: Dependencies
  279. id: depends
  280. run: |
  281. sudo apt-get update
  282. sudo apt-get install build-essential
  283. - name: Build
  284. id: cmake_build
  285. run: |
  286. mkdir build
  287. cd build
  288. cmake -DLLAMA_RPC=ON ..
  289. cmake --build . --config Release -j $(nproc)
  290. - name: Test
  291. id: cmake_test
  292. run: |
  293. cd build
  294. ctest -L main --verbose
  295. ubuntu-22-cmake-vulkan:
  296. runs-on: ubuntu-22.04
  297. steps:
  298. - name: Clone
  299. id: checkout
  300. uses: actions/checkout@v4
  301. - name: Dependencies
  302. id: depends
  303. run: |
  304. sudo apt-get update
  305. sudo apt-get install build-essential libvulkan-dev
  306. - name: Build
  307. id: cmake_build
  308. run: |
  309. mkdir build
  310. cd build
  311. cmake -DLLAMA_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" -DLLAMA_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 -DLLAMA_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 -DLLAMA_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 -DLLAMA_SYCL=ON -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx -DLLAMA_SYCL_F16=ON ..
  400. cmake --build . --config Release -j $(nproc)
  401. # TODO: build with LLAMA_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. LLAMA_NO_METAL=1 make -j $(sysctl -n hw.logicalcpu)
  421. - name: Test
  422. id: make_test
  423. run: |
  424. LLAMA_NO_METAL=1 make tests -j $(sysctl -n hw.logicalcpu)
  425. LLAMA_NO_METAL=1 make test -j $(sysctl -n hw.logicalcpu)
  426. # TODO: build with LLAMA_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 -DLLAMA_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. -DLLAMA_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. cmake --build . --config Release -j $(sysctl -n hw.logicalcpu)
  479. macOS-latest-cmake-tvos:
  480. runs-on: macos-latest
  481. steps:
  482. - name: Clone
  483. id: checkout
  484. uses: actions/checkout@v1
  485. - name: Dependencies
  486. id: depends
  487. continue-on-error: true
  488. run: |
  489. brew update
  490. - name: Build
  491. id: cmake_build
  492. run: |
  493. sysctl -a
  494. mkdir build
  495. cd build
  496. cmake -G Xcode .. \
  497. -DLLAMA_METAL_EMBED_LIBRARY=ON \
  498. -DLLAMA_BUILD_EXAMPLES=OFF \
  499. -DLLAMA_BUILD_TESTS=OFF \
  500. -DLLAMA_BUILD_SERVER=OFF \
  501. -DCMAKE_SYSTEM_NAME=tvOS \
  502. -DCMAKE_OSX_DEPLOYMENT_TARGET=14.0
  503. cmake --build . --config Release -j $(sysctl -n hw.logicalcpu)
  504. macOS-latest-swift:
  505. runs-on: macos-latest
  506. strategy:
  507. matrix:
  508. destination: ['generic/platform=macOS', 'generic/platform=iOS', 'generic/platform=tvOS']
  509. steps:
  510. - name: Clone
  511. id: checkout
  512. uses: actions/checkout@v1
  513. - name: Dependencies
  514. id: depends
  515. continue-on-error: true
  516. run: |
  517. brew update
  518. - name: xcodebuild for swift package
  519. id: xcodebuild
  520. run: |
  521. xcodebuild -scheme llama -destination "${{ matrix.destination }}"
  522. - name: Build Swift Example
  523. id: make_build_swift_example
  524. run: |
  525. make swift
  526. windows-msys2:
  527. runs-on: windows-latest
  528. strategy:
  529. fail-fast: false
  530. matrix:
  531. include:
  532. - { sys: UCRT64, env: ucrt-x86_64, build: Release }
  533. - { sys: CLANG64, env: clang-x86_64, build: Release }
  534. steps:
  535. - name: Clone
  536. uses: actions/checkout@v4
  537. - name: Setup ${{ matrix.sys }}
  538. uses: msys2/setup-msys2@v2
  539. with:
  540. update: true
  541. msystem: ${{matrix.sys}}
  542. install: >-
  543. base-devel
  544. mingw-w64-${{matrix.env}}-toolchain
  545. mingw-w64-${{matrix.env}}-cmake
  546. mingw-w64-${{matrix.env}}-openblas
  547. - name: Build using make
  548. shell: msys2 {0}
  549. run: |
  550. make -j $(nproc)
  551. - name: Clean after building using make
  552. shell: msys2 {0}
  553. run: |
  554. make clean
  555. - name: Build using make w/ OpenBLAS
  556. shell: msys2 {0}
  557. run: |
  558. make LLAMA_OPENBLAS=1 -j $(nproc)
  559. - name: Build using CMake
  560. shell: msys2 {0}
  561. run: |
  562. cmake -B build
  563. cmake --build build --config ${{ matrix.build }} -j $(nproc)
  564. - name: Clean after building using CMake
  565. shell: msys2 {0}
  566. run: |
  567. rm -rf build
  568. - name: Build using CMake w/ OpenBLAS
  569. shell: msys2 {0}
  570. run: |
  571. cmake -B build -DLLAMA_BLAS=ON -DLLAMA_BLAS_VENDOR=OpenBLAS
  572. cmake --build build --config ${{ matrix.build }} -j $(nproc)
  573. windows-latest-cmake:
  574. runs-on: windows-latest
  575. env:
  576. OPENBLAS_VERSION: 0.3.23
  577. SDE_VERSION: 9.33.0-2024-01-07
  578. VULKAN_VERSION: 1.3.261.1
  579. strategy:
  580. matrix:
  581. include:
  582. - build: 'rpc-x64'
  583. defines: '-DLLAMA_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DLLAMA_RPC=ON -DBUILD_SHARED_LIBS=ON'
  584. - build: 'noavx-x64'
  585. defines: '-DLLAMA_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DLLAMA_AVX=OFF -DLLAMA_AVX2=OFF -DLLAMA_FMA=OFF -DBUILD_SHARED_LIBS=ON'
  586. - build: 'avx2-x64'
  587. defines: '-DLLAMA_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DBUILD_SHARED_LIBS=ON'
  588. - build: 'avx-x64'
  589. defines: '-DLLAMA_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DLLAMA_AVX2=OFF -DBUILD_SHARED_LIBS=ON'
  590. - build: 'avx512-x64'
  591. defines: '-DLLAMA_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DLLAMA_AVX512=ON -DBUILD_SHARED_LIBS=ON'
  592. - build: 'openblas-x64'
  593. defines: '-DLLAMA_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DLLAMA_BLAS=ON -DBUILD_SHARED_LIBS=ON -DLLAMA_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: '-DLLAMA_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DLLAMA_KOMPUTE=ON -DKOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK=ON -DBUILD_SHARED_LIBS=ON'
  596. - build: 'vulkan-x64'
  597. defines: '-DLLAMA_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DLLAMA_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 -DLLAMA_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 -DLLAMA_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 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. & $sde -future -- ctest -L main -C Release --verbose --timeout 900
  678. - name: Determine tag name
  679. id: tag
  680. shell: bash
  681. run: |
  682. BUILD_NUMBER="$(git rev-list --count HEAD)"
  683. SHORT_HASH="$(git rev-parse --short=7 HEAD)"
  684. if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
  685. echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
  686. else
  687. SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
  688. echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
  689. fi
  690. - name: Pack artifacts
  691. id: pack_artifacts
  692. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  693. run: |
  694. Copy-Item LICENSE .\build\bin\Release\llama.cpp.txt
  695. 7z a llama-${{ steps.tag.outputs.name }}-bin-win-${{ matrix.build }}.zip .\build\bin\Release\*
  696. - name: Upload artifacts
  697. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  698. uses: actions/upload-artifact@v4
  699. with:
  700. path: llama-${{ steps.tag.outputs.name }}-bin-win-${{ matrix.build }}.zip
  701. name: llama-bin-win-${{ matrix.build }}.zip
  702. windows-latest-cmake-cuda:
  703. runs-on: windows-latest
  704. strategy:
  705. matrix:
  706. cuda: ['12.2.0', '11.7.1']
  707. build: ['cuda']
  708. steps:
  709. - name: Clone
  710. id: checkout
  711. uses: actions/checkout@v4
  712. with:
  713. fetch-depth: 0
  714. - uses: Jimver/cuda-toolkit@v0.2.11
  715. id: cuda-toolkit
  716. with:
  717. cuda: ${{ matrix.cuda }}
  718. method: 'network'
  719. sub-packages: '["nvcc", "cudart", "cublas", "cublas_dev", "thrust", "visual_studio_integration"]'
  720. - name: Build
  721. id: cmake_build
  722. run: |
  723. mkdir build
  724. cd build
  725. cmake .. -DLLAMA_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DLLAMA_CUDA=ON -DBUILD_SHARED_LIBS=ON
  726. cmake --build . --config Release -j ${env:NUMBER_OF_PROCESSORS}
  727. - name: Determine tag name
  728. id: tag
  729. shell: bash
  730. run: |
  731. BUILD_NUMBER="$(git rev-list --count HEAD)"
  732. SHORT_HASH="$(git rev-parse --short=7 HEAD)"
  733. if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
  734. echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
  735. else
  736. SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
  737. echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
  738. fi
  739. - name: Pack artifacts
  740. id: pack_artifacts
  741. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  742. run: |
  743. 7z a llama-${{ steps.tag.outputs.name }}-bin-win-${{ matrix.build }}-cu${{ matrix.cuda }}-x64.zip .\build\bin\Release\*
  744. - name: Upload artifacts
  745. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  746. uses: actions/upload-artifact@v4
  747. with:
  748. path: llama-${{ steps.tag.outputs.name }}-bin-win-${{ matrix.build }}-cu${{ matrix.cuda }}-x64.zip
  749. name: llama-bin-win-cu${{ matrix.cuda }}-x64.zip
  750. - name: Copy and pack Cuda runtime
  751. run: |
  752. echo "Cuda install location: ${{steps.cuda-toolkit.outputs.CUDA_PATH}}"
  753. $dst='.\build\bin\cudart\'
  754. robocopy "${{steps.cuda-toolkit.outputs.CUDA_PATH}}\bin" $dst cudart64_*.dll cublas64_*.dll cublasLt64_*.dll
  755. 7z a cudart-llama-bin-win-cu${{ matrix.cuda }}-x64.zip $dst\*
  756. - name: Upload Cuda runtime
  757. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  758. uses: actions/upload-artifact@v4
  759. with:
  760. path: cudart-llama-bin-win-cu${{ matrix.cuda }}-x64.zip
  761. name: cudart-llama-bin-win-cu${{ matrix.cuda }}-x64.zip
  762. windows-latest-cmake-sycl:
  763. runs-on: windows-latest
  764. defaults:
  765. run:
  766. shell: bash
  767. env:
  768. 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
  769. WINDOWS_DPCPP_MKL: intel.oneapi.win.cpp-dpcpp-common:intel.oneapi.win.mkl.devel
  770. ONEAPI_ROOT: "C:/Program Files (x86)/Intel/oneAPI"
  771. steps:
  772. - name: Clone
  773. id: checkout
  774. uses: actions/checkout@v4
  775. with:
  776. fetch-depth: 0
  777. - name: Install
  778. run: scripts/install-oneapi.bat $WINDOWS_BASEKIT_URL $WINDOWS_DPCPP_MKL
  779. - name: Build
  780. id: cmake_build
  781. run: examples/sycl/win-build-sycl.bat
  782. - name: Determine tag name
  783. id: tag
  784. shell: bash
  785. run: |
  786. BUILD_NUMBER="$(git rev-list --count HEAD)"
  787. SHORT_HASH="$(git rev-parse --short=7 HEAD)"
  788. if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
  789. echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
  790. else
  791. SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
  792. echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
  793. fi
  794. - name: Pack artifacts
  795. id: pack_artifacts
  796. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  797. run: |
  798. echo "cp oneAPI running time dll files in ${{ env.ONEAPI_ROOT }} to ./build/bin"
  799. cp "${{ env.ONEAPI_ROOT }}/mkl/latest/bin/mkl_sycl_blas.4.dll" ./build/bin
  800. cp "${{ env.ONEAPI_ROOT }}/mkl/latest/bin/mkl_core.2.dll" ./build/bin
  801. cp "${{ env.ONEAPI_ROOT }}/mkl/latest/bin/mkl_tbb_thread.2.dll" ./build/bin
  802. cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/pi_win_proxy_loader.dll" ./build/bin
  803. cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/pi_level_zero.dll" ./build/bin
  804. cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/sycl7.dll" ./build/bin
  805. cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/svml_dispmd.dll" ./build/bin
  806. cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/libmmd.dll" ./build/bin
  807. echo "cp oneAPI running time dll files to ./build/bin done"
  808. 7z a llama-${{ steps.tag.outputs.name }}-bin-win-sycl-x64.zip ./build/bin/*
  809. - name: Upload artifacts
  810. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  811. uses: actions/upload-artifact@v4
  812. with:
  813. path: llama-${{ steps.tag.outputs.name }}-bin-win-sycl-x64.zip
  814. name: llama-bin-win-sycl-x64.zip
  815. windows-latest-cmake-hip:
  816. runs-on: windows-latest
  817. steps:
  818. - name: Clone
  819. id: checkout
  820. uses: actions/checkout@v3
  821. - name: Install
  822. id: depends
  823. run: |
  824. $ErrorActionPreference = "Stop"
  825. write-host "Downloading AMD HIP SDK Installer"
  826. 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"
  827. write-host "Installing AMD HIP SDK"
  828. Start-Process "${env:RUNNER_TEMP}\rocm-install.exe" -ArgumentList '-install' -NoNewWindow -Wait
  829. write-host "Completed AMD HIP SDK installation"
  830. - name: Verify ROCm
  831. id: verify
  832. run: |
  833. & 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' --version
  834. - name: Build
  835. id: cmake_build
  836. run: |
  837. $env:HIP_PATH=$(Resolve-Path 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' | split-path | split-path)
  838. $env:CMAKE_PREFIX_PATH="${env:HIP_PATH}"
  839. 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" -DLLAMA_HIPBLAS=ON
  840. cmake --build build --config Release
  841. ios-xcode-build:
  842. runs-on: macos-latest
  843. steps:
  844. - name: Checkout code
  845. uses: actions/checkout@v4
  846. - name: Build Xcode project
  847. 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
  848. android-build:
  849. runs-on: ubuntu-latest
  850. steps:
  851. - name: Clone
  852. uses: actions/checkout@v4
  853. - name: Set up JDK
  854. uses: actions/setup-java@v3
  855. with:
  856. java-version: 17
  857. distribution: zulu
  858. - name: Setup Android SDK
  859. uses: android-actions/setup-android@v3
  860. with:
  861. log-accepted-android-sdk-licenses: false
  862. - name: Build
  863. run: |
  864. cd examples/llama.android
  865. ./gradlew build --no-daemon
  866. # freeBSD-latest:
  867. # runs-on: macos-12
  868. # steps:
  869. # - name: Clone
  870. # uses: actions/checkout@v4
  871. #
  872. # - name: Build
  873. # uses: cross-platform-actions/action@v0.19.0
  874. # with:
  875. # operating_system: freebsd
  876. # version: '13.2'
  877. # hypervisor: 'qemu'
  878. # run: |
  879. # sudo pkg update
  880. # sudo pkg install -y gmake automake autoconf pkgconf llvm15 openblas
  881. # gmake CC=/usr/local/bin/clang15 CXX=/usr/local/bin/clang++15 -j `sysctl -n hw.ncpu`
  882. release:
  883. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  884. runs-on: ubuntu-latest
  885. needs:
  886. - ubuntu-focal-make
  887. - ubuntu-latest-cmake
  888. - macOS-latest-make
  889. - macOS-latest-cmake
  890. - windows-latest-cmake
  891. - windows-latest-cmake-cuda
  892. - macOS-latest-cmake-arm64
  893. - macOS-latest-cmake-x64
  894. steps:
  895. - name: Clone
  896. id: checkout
  897. uses: actions/checkout@v4
  898. with:
  899. fetch-depth: 0
  900. - name: Determine tag name
  901. id: tag
  902. shell: bash
  903. run: |
  904. BUILD_NUMBER="$(git rev-list --count HEAD)"
  905. SHORT_HASH="$(git rev-parse --short=7 HEAD)"
  906. if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
  907. echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
  908. else
  909. SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
  910. echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
  911. fi
  912. - name: Download artifacts
  913. id: download-artifact
  914. uses: actions/download-artifact@v4
  915. with:
  916. path: ./artifact
  917. - name: Move artifacts
  918. id: move_artifacts
  919. run: mkdir -p ./artifact/release && mv ./artifact/*/*.zip ./artifact/release
  920. - name: Create release
  921. id: create_release
  922. uses: anzz1/action-create-release@v1
  923. env:
  924. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  925. with:
  926. tag_name: ${{ steps.tag.outputs.name }}
  927. - name: Upload release
  928. id: upload_release
  929. uses: actions/github-script@v3
  930. with:
  931. github-token: ${{secrets.GITHUB_TOKEN}}
  932. script: |
  933. const path = require('path');
  934. const fs = require('fs');
  935. const release_id = '${{ steps.create_release.outputs.id }}';
  936. for (let file of await fs.readdirSync('./artifact/release')) {
  937. if (path.extname(file) === '.zip') {
  938. console.log('uploadReleaseAsset', file);
  939. await github.repos.uploadReleaseAsset({
  940. owner: context.repo.owner,
  941. repo: context.repo.repo,
  942. release_id: release_id,
  943. name: file,
  944. data: await fs.readFileSync(`./artifact/release/${file}`)
  945. });
  946. }
  947. }
  948. # ubuntu-latest-gcc:
  949. # runs-on: ubuntu-latest
  950. #
  951. # strategy:
  952. # matrix:
  953. # build: [Debug, Release]
  954. #
  955. # steps:
  956. # - name: Clone
  957. # uses: actions/checkout@v4
  958. #
  959. # - name: Dependencies
  960. # run: |
  961. # sudo apt-get update
  962. # sudo apt-get install build-essential
  963. # sudo apt-get install cmake
  964. #
  965. # - name: Configure
  966. # run: cmake . -DCMAKE_BUILD_TYPE=${{ matrix.build }}
  967. #
  968. # - name: Build
  969. # run: |
  970. # make
  971. #
  972. # ubuntu-latest-clang:
  973. # runs-on: ubuntu-latest
  974. #
  975. # strategy:
  976. # matrix:
  977. # build: [Debug, Release]
  978. #
  979. # steps:
  980. # - name: Clone
  981. # uses: actions/checkout@v4
  982. #
  983. # - name: Dependencies
  984. # run: |
  985. # sudo apt-get update
  986. # sudo apt-get install build-essential
  987. # sudo apt-get install cmake
  988. #
  989. # - name: Configure
  990. # run: cmake . -DCMAKE_BUILD_TYPE=${{ matrix.build }} -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang
  991. #
  992. # - name: Build
  993. # run: |
  994. # make
  995. #
  996. # ubuntu-latest-gcc-sanitized:
  997. # runs-on: ubuntu-latest
  998. #
  999. # strategy:
  1000. # matrix:
  1001. # sanitizer: [ADDRESS, THREAD, UNDEFINED]
  1002. #
  1003. # steps:
  1004. # - name: Clone
  1005. # uses: actions/checkout@v4
  1006. #
  1007. # - name: Dependencies
  1008. # run: |
  1009. # sudo apt-get update
  1010. # sudo apt-get install build-essential
  1011. # sudo apt-get install cmake
  1012. #
  1013. # - name: Configure
  1014. # run: cmake . -DCMAKE_BUILD_TYPE=Debug -DLLAMA_SANITIZE_${{ matrix.sanitizer }}=ON
  1015. #
  1016. # - name: Build
  1017. # run: |
  1018. # make
  1019. #
  1020. # windows:
  1021. # runs-on: windows-latest
  1022. #
  1023. # strategy:
  1024. # matrix:
  1025. # build: [Release]
  1026. # arch: [Win32, x64]
  1027. # include:
  1028. # - arch: Win32
  1029. # s2arc: x86
  1030. # - arch: x64
  1031. # s2arc: x64
  1032. #
  1033. # steps:
  1034. # - name: Clone
  1035. # uses: actions/checkout@v4
  1036. #
  1037. # - name: Add msbuild to PATH
  1038. # uses: microsoft/setup-msbuild@v1
  1039. #
  1040. # - name: Configure
  1041. # run: >
  1042. # cmake -S . -B ./build -A ${{ matrix.arch }}
  1043. # -DCMAKE_BUILD_TYPE=${{ matrix.build }}
  1044. #
  1045. # - name: Build
  1046. # run: |
  1047. # cd ./build
  1048. # msbuild ALL_BUILD.vcxproj -t:build -p:configuration=${{ matrix.build }} -p:platform=${{ matrix.arch }}
  1049. #
  1050. # - name: Upload binaries
  1051. # uses: actions/upload-artifact@v4
  1052. # with:
  1053. # name: llama-bin-${{ matrix.arch }}
  1054. # path: build/bin/${{ matrix.build }}
  1055. #
  1056. # windows-blas:
  1057. # runs-on: windows-latest
  1058. #
  1059. # strategy:
  1060. # matrix:
  1061. # build: [Release]
  1062. # arch: [Win32, x64]
  1063. # blas: [ON]
  1064. # include:
  1065. # - arch: Win32
  1066. # obzip: https://github.com/xianyi/OpenBLAS/releases/download/v0.3.21/OpenBLAS-0.3.21-x86.zip
  1067. # s2arc: x86
  1068. # - arch: x64
  1069. # obzip: https://github.com/xianyi/OpenBLAS/releases/download/v0.3.21/OpenBLAS-0.3.21-x64.zip
  1070. # s2arc: x64
  1071. #
  1072. # steps:
  1073. # - name: Clone
  1074. # uses: actions/checkout@v4
  1075. #
  1076. # - name: Add msbuild to PATH
  1077. # uses: microsoft/setup-msbuild@v1
  1078. #
  1079. # - name: Fetch OpenBLAS
  1080. # if: matrix.blas == 'ON'
  1081. # run: |
  1082. # C:/msys64/usr/bin/wget.exe -qO blas.zip ${{ matrix.obzip }}
  1083. # 7z x blas.zip -oblas -y
  1084. # copy blas/include/cblas.h .
  1085. # copy blas/include/openblas_config.h .
  1086. # echo "blasdir=$env:GITHUB_WORKSPACE/blas" >> $env:GITHUB_ENV
  1087. #
  1088. # - name: Configure
  1089. # run: >
  1090. # cmake -S . -B ./build -A ${{ matrix.arch }}
  1091. # -DCMAKE_BUILD_TYPE=${{ matrix.build }}
  1092. # -DLLAMA_SUPPORT_OPENBLAS=${{ matrix.blas }}
  1093. # -DCMAKE_LIBRARY_PATH="$env:blasdir/lib"
  1094. #
  1095. # - name: Build
  1096. # run: |
  1097. # cd ./build
  1098. # msbuild ALL_BUILD.vcxproj -t:build -p:configuration=${{ matrix.build }} -p:platform=${{ matrix.arch }}
  1099. #
  1100. # - name: Copy libopenblas.dll
  1101. # if: matrix.blas == 'ON'
  1102. # run: copy "$env:blasdir/bin/libopenblas.dll" build/bin/${{ matrix.build }}
  1103. #
  1104. # - name: Upload binaries
  1105. # if: matrix.blas == 'ON'
  1106. # uses: actions/upload-artifact@v4
  1107. # with:
  1108. # name: llama-blas-bin-${{ matrix.arch }}
  1109. # path: build/bin/${{ matrix.build }}
  1110. #
  1111. # emscripten:
  1112. # runs-on: ubuntu-latest
  1113. #
  1114. # strategy:
  1115. # matrix:
  1116. # build: [Release]
  1117. #
  1118. # steps:
  1119. # - name: Clone
  1120. # uses: actions/checkout@v4
  1121. #
  1122. # - name: Dependencies
  1123. # run: |
  1124. # wget -q https://github.com/emscripten-core/emsdk/archive/master.tar.gz
  1125. # tar -xvf master.tar.gz
  1126. # emsdk-master/emsdk update
  1127. # emsdk-master/emsdk install latest
  1128. # emsdk-master/emsdk activate latest
  1129. #
  1130. # - name: Configure
  1131. # run: echo "tmp"
  1132. #
  1133. # - name: Build
  1134. # run: |
  1135. # pushd emsdk-master
  1136. # source ./emsdk_env.sh
  1137. # popd
  1138. # emcmake cmake . -DCMAKE_BUILD_TYPE=${{ matrix.build }}
  1139. # make