bench.yml.disabled 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. # TODO: there have been some issues with the workflow, so disabling for now
  2. # https://github.com/ggml-org/llama.cpp/issues/7893
  3. #
  4. # Benchmark
  5. name: Benchmark
  6. on:
  7. workflow_dispatch:
  8. inputs:
  9. gpu-series:
  10. description: 'Azure GPU series to run with'
  11. required: true
  12. type: choice
  13. options:
  14. - Standard_NC4as_T4_v3
  15. - Standard_NC24ads_A100_v4
  16. - Standard_NC80adis_H100_v5
  17. sha:
  18. description: 'Commit SHA1 to build'
  19. required: false
  20. type: string
  21. duration:
  22. description: 'Duration of the bench'
  23. type: string
  24. default: 10m
  25. push:
  26. branches:
  27. - master
  28. paths: ['llama.cpp', 'ggml.c', 'ggml-backend.cpp', 'ggml-quants.c', '**/*.cu', 'examples/server/*.h*', 'examples/server/*.cpp']
  29. pull_request_target:
  30. types: [opened, synchronize, reopened]
  31. paths: ['llama.cpp', 'ggml.c', 'ggml-backend.cpp', 'ggml-quants.c', '**/*.cu', 'examples/server/*.h*', 'examples/server/*.cpp']
  32. schedule:
  33. - cron: '04 2 * * *'
  34. concurrency:
  35. group: ${{ github.workflow }}-${{ github.ref }}-${{ github.head_ref || github.run_id }}-${{ github.event.inputs.sha }}
  36. cancel-in-progress: true
  37. jobs:
  38. bench-server-baseline:
  39. runs-on: Standard_NC4as_T4_v3
  40. env:
  41. RUNNER_LABEL: Standard_NC4as_T4_v3 # FIXME Do not find a way to not duplicate it
  42. N_USERS: 8
  43. DURATION: 10m
  44. strategy:
  45. matrix:
  46. model: [phi-2]
  47. ftype: [q4_0, q8_0, f16]
  48. include:
  49. - model: phi-2
  50. ftype: q4_0
  51. pr_comment_enabled: "true"
  52. if: |
  53. inputs.gpu-series == 'Standard_NC4as_T4_v3'
  54. || github.event_name == 'pull_request_target'
  55. steps:
  56. - name: Clone
  57. id: checkout
  58. uses: actions/checkout@v4
  59. with:
  60. fetch-depth: 0
  61. ref: ${{ github.event.inputs.sha || github.event.pull_request.head.sha || github.sha || github.head_ref || github.ref_name }}
  62. - name: Install python env
  63. id: pipenv
  64. run: |
  65. cd examples/server/bench
  66. python3 -m venv venv
  67. source venv/bin/activate
  68. pip install -r requirements.txt
  69. - name: Prometheus
  70. id: install_prometheus
  71. run: |
  72. wget --quiet https://github.com/prometheus/prometheus/releases/download/v2.51.0/prometheus-2.51.0.linux-amd64.tar.gz
  73. tar xzf prometheus*.tar.gz --strip-components=1
  74. ./prometheus --config.file=examples/server/bench/prometheus.yml &
  75. while ! nc -z localhost 9090; do
  76. sleep 0.1
  77. done
  78. - name: Set up Go
  79. uses: actions/setup-go@v5
  80. with:
  81. go-version: '1.21'
  82. - name: Install k6 and xk6-sse
  83. id: k6_installation
  84. run: |
  85. cd examples/server/bench
  86. go install go.k6.io/xk6/cmd/xk6@latest
  87. xk6 build master \
  88. --with github.com/phymbert/xk6-sse
  89. - name: Build
  90. id: cmake_build
  91. run: |
  92. set -eux
  93. cmake -B build \
  94. -DGGML_NATIVE=OFF \
  95. -DLLAMA_BUILD_SERVER=ON \
  96. -DLLAMA_CURL=ON \
  97. -DLLAMA_CUBLAS=ON \
  98. -DCUDAToolkit_ROOT=/usr/local/cuda \
  99. -DCMAKE_CUDA_COMPILER=/usr/local/cuda/bin/nvcc \
  100. -DCMAKE_CUDA_ARCHITECTURES=75 \
  101. -DLLAMA_FATAL_WARNINGS=OFF \
  102. -DLLAMA_ALL_WARNINGS=OFF \
  103. -DCMAKE_BUILD_TYPE=Release;
  104. cmake --build build --config Release -j $(nproc) --target llama-server
  105. - name: Download the dataset
  106. id: download_dataset
  107. run: |
  108. cd examples/server/bench
  109. wget --quiet https://huggingface.co/datasets/anon8231489123/ShareGPT_Vicuna_unfiltered/resolve/main/ShareGPT_V3_unfiltered_cleaned_split.json
  110. - name: Server bench
  111. id: server_bench
  112. env:
  113. HEAD_REF: ${{ github.head_ref || github.ref_name }}
  114. run: |
  115. set -eux
  116. cd examples/server/bench
  117. source venv/bin/activate
  118. python bench.py \
  119. --runner-label ${{ env.RUNNER_LABEL }} \
  120. --name ${{ github.job }} \
  121. --branch $HEAD_REF \
  122. --commit ${{ github.event.inputs.sha || github.event.pull_request.head.sha || github.sha }} \
  123. --scenario script.js \
  124. --duration ${{ github.event.inputs.duration || env.DURATION }} \
  125. --hf-repo ggml-org/models \
  126. --hf-file ${{ matrix.model }}/ggml-model-${{ matrix.ftype }}.gguf \
  127. --model-path-prefix /models \
  128. --parallel ${{ env.N_USERS }} \
  129. -ngl 33 \
  130. --batch-size 2048 \
  131. --ubatch-size 256 \
  132. --ctx-size 16384 \
  133. --n-prompts 1000 \
  134. --max-prompt-tokens 1024 \
  135. --max-tokens 2048
  136. cat results.github.env >> $GITHUB_ENV
  137. # Remove dataset as we do not want it in the artefact
  138. rm ShareGPT_V3_unfiltered_cleaned_split.json
  139. - uses: actions/upload-artifact@v4
  140. with:
  141. name: bench-server-${{ github.job }}-${{ env.RUNNER_LABEL }}-${{ matrix.model }}-${{ matrix.ftype }}
  142. compression-level: 9
  143. path: |
  144. examples/server/bench/*.jpg
  145. examples/server/bench/*.json
  146. examples/server/bench/*.log
  147. - name: Commit status
  148. uses: Sibz/github-status-action@v1
  149. with:
  150. authToken: ${{secrets.GITHUB_TOKEN}}
  151. sha: ${{ inputs.sha || github.event.pull_request.head.sha || github.sha }}
  152. context: bench-server-${{ github.job }}-${{ env.RUNNER_LABEL }}-${{ matrix.model }}-${{ matrix.ftype }}
  153. description: |
  154. ${{ env.BENCH_RESULTS }}
  155. state: 'success'
  156. - name: Upload benchmark images
  157. uses: devicons/public-upload-to-imgur@v2.2.2
  158. continue-on-error: true # Important as it looks unstable: 503
  159. id: imgur_step
  160. with:
  161. client_id: ${{secrets.IMGUR_CLIENT_ID}}
  162. path: |
  163. examples/server/bench/prompt_tokens_seconds.jpg
  164. examples/server/bench/predicted_tokens_seconds.jpg
  165. examples/server/bench/kv_cache_usage_ratio.jpg
  166. examples/server/bench/requests_processing.jpg
  167. - name: Extract mermaid
  168. id: set_mermaid
  169. run: |
  170. set -eux
  171. cd examples/server/bench
  172. PROMPT_TOKENS_SECONDS=$(cat prompt_tokens_seconds.mermaid)
  173. echo "PROMPT_TOKENS_SECONDS<<EOF" >> $GITHUB_ENV
  174. echo "$PROMPT_TOKENS_SECONDS" >> $GITHUB_ENV
  175. echo "EOF" >> $GITHUB_ENV
  176. PREDICTED_TOKENS_SECONDS=$(cat predicted_tokens_seconds.mermaid)
  177. echo "PREDICTED_TOKENS_SECONDS<<EOF" >> $GITHUB_ENV
  178. echo "$PREDICTED_TOKENS_SECONDS" >> $GITHUB_ENV
  179. echo "EOF" >> $GITHUB_ENV
  180. KV_CACHE_USAGE_RATIO=$(cat kv_cache_usage_ratio.mermaid)
  181. echo "KV_CACHE_USAGE_RATIO<<EOF" >> $GITHUB_ENV
  182. echo "$KV_CACHE_USAGE_RATIO" >> $GITHUB_ENV
  183. echo "EOF" >> $GITHUB_ENV
  184. REQUESTS_PROCESSING=$(cat requests_processing.mermaid)
  185. echo "REQUESTS_PROCESSING<<EOF" >> $GITHUB_ENV
  186. echo "$REQUESTS_PROCESSING" >> $GITHUB_ENV
  187. echo "EOF" >> $GITHUB_ENV
  188. - name: Extract image url
  189. id: extract_image_url
  190. continue-on-error: true
  191. run: |
  192. set -eux
  193. echo "IMAGE_O=${{ fromJSON(steps.imgur_step.outputs.imgur_urls)[0] }}" >> $GITHUB_ENV
  194. echo "IMAGE_1=${{ fromJSON(steps.imgur_step.outputs.imgur_urls)[1] }}" >> $GITHUB_ENV
  195. echo "IMAGE_2=${{ fromJSON(steps.imgur_step.outputs.imgur_urls)[2] }}" >> $GITHUB_ENV
  196. echo "IMAGE_3=${{ fromJSON(steps.imgur_step.outputs.imgur_urls)[3] }}" >> $GITHUB_ENV
  197. - name: Comment PR
  198. uses: mshick/add-pr-comment@v2
  199. id: comment_pr
  200. if: ${{ github.event.pull_request != '' && matrix.pr_comment_enabled == 'true' }}
  201. with:
  202. message-id: bench-server-${{ github.job }}-${{ env.RUNNER_LABEL }}-${{ matrix.model }}-${{ matrix.ftype }}
  203. message: |
  204. <p align="center">
  205. 📈 **llama.cpp server** for _${{ github.job }}_ on _${{ env.RUNNER_LABEL }}_ for `${{ matrix.model }}`-`${{ matrix.ftype }}`: **${{ env.BENCH_ITERATIONS}} iterations** 🚀
  206. </p>
  207. <details>
  208. <summary>Expand details for performance related PR only</summary>
  209. - Concurrent users: ${{ env.N_USERS }}, duration: ${{ github.event.inputs.duration || env.DURATION }}
  210. - HTTP request : avg=${{ env.HTTP_REQ_DURATION_AVG }}ms p(95)=${{ env.HTTP_REQ_DURATION_P_95_ }}ms fails=${{ env.HTTP_REQ_FAILED_PASSES }}, finish reason: stop=${{ env.LLAMACPP_COMPLETIONS_STOP_RATE_PASSES }} truncated=${{ env.LLAMACPP_COMPLETIONS_TRUNCATED_RATE_PASSES }}
  211. - Prompt processing (pp): avg=${{ env.LLAMACPP_PROMPT_PROCESSING_SECOND_AVG }}tk/s p(95)=${{ env.LLAMACPP_PROMPT_PROCESSING_SECOND_P_95_ }}tk/s
  212. - Token generation (tg): avg=${{ env.LLAMACPP_TOKENS_SECOND_AVG }}tk/s p(95)=${{ env.LLAMACPP_TOKENS_SECOND_P_95_ }}tk/s
  213. - ${{ env.BENCH_GRAPH_XLABEL }}
  214. <p align="center">
  215. <img width="100%" height="100%" src="${{ env.IMAGE_O }}" alt="prompt_tokens_seconds" />
  216. <details>
  217. <summary>More</summary>
  218. ```mermaid
  219. ${{ env.PROMPT_TOKENS_SECONDS }}
  220. ```
  221. </details>
  222. <img width="100%" height="100%" src="${{ env.IMAGE_1 }}" alt="predicted_tokens_seconds"/>
  223. <details>
  224. <summary>More</summary>
  225. ```mermaid
  226. ${{ env.PREDICTED_TOKENS_SECONDS }}
  227. ```
  228. </details>
  229. </p>
  230. <details>
  231. <summary>Details</summary>
  232. <p align="center">
  233. <img width="100%" height="100%" src="${{ env.IMAGE_2 }}" alt="kv_cache_usage_ratio" />
  234. <details>
  235. <summary>More</summary>
  236. ```mermaid
  237. ${{ env.KV_CACHE_USAGE_RATIO }}
  238. ```
  239. </details>
  240. <img width="100%" height="100%" src="${{ env.IMAGE_3 }}" alt="requests_processing"/>
  241. <details>
  242. <summary>More</summary>
  243. ```mermaid
  244. ${{ env.REQUESTS_PROCESSING }}
  245. ```
  246. </details>
  247. </p>
  248. </details>
  249. </details>