benchmarks: build ggml with the tinyBLAS GEMM path (GGML_LLAMAFILE) llama.cpp enables by default - #46
Open
codspeed-hq[bot] wants to merge 1 commit into
Conversation
benchmarks/CMakeLists.txt adds ggml as a subdirectory directly, so it never sees the root llama.cpp CMakeLists.txt override that flips the default of GGML_LLAMAFILE to ON. The benchmarks were therefore built with GGML_LLAMAFILE=OFF and every ggml_compute_forward_mul_mat() call measured the per-row ggml_vec_dot() fallback instead of the tiled tinyBLAS GEMM path that real llama.cpp CPU inference takes. Mirror the same default override in the benchmark project so the benchmarked ggml matches the configuration llama.cpp itself builds with. Unsupported types and shapes (e.g. Q4_K) fall back cleanly since llamafile_sgemm() returns false.
Author
Merging this PR will regress 1 benchmark
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ❌ | WallTime | prompt_layer[f32] |
247.1 ms | 296.6 ms | -16.69% |
| ⚡ | Simulation | ffn_swiglu |
1,067.7 ms | 776.8 ms | +37.46% |
| ⚡ | Simulation | mul_mat[f32] |
346.1 ms | 258.7 ms | +33.81% |
| ⚡ | WallTime | lm_head[f16] |
60.6 ms | 52.5 ms | +15.26% |
| ⚡ | Simulation | mul_mat[q4_0] |
102 ms | 90 ms | +13.24% |
Tip
Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.
Comparing codspeed-optim-build-the-benchmarked-ggml-with-the-tinyblas-gemm-1785422569683 (d862814) with master (46819c9)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
benchmarks/CMakeLists.txtbuildsggmlstandalone viaadd_subdirectory(../ggml), so it never sees the override in the rootllama.cpp/CMakeLists.txt:Verified locally before the change:
GGML_LLAMAFILE:BOOL=OFFin the benchmarkCMakeCache.txt, andllamafile_sgemmwas absent from the benchmark binary. Everyggml_compute_forward_mul_mat()call therefore skipped the tiled tinyBLAS GEMM and fell back to the per-(row, column)ggml_vec_dot_*()loop — a path production llama.cpp CPU inference never takes.This PR mirrors the same three lines in
benchmarks/CMakeLists.txtso the benchmark build matches how llama.cpp is actually built. After the change:GGML_LLAMAFILE:BOOL=ONandllamafile_sgemmis present in the binary (checked withnm), in both thesimulationandwalltimeconfigurations.Why this is the right path to measure
mul_matdominates the benchmarked work (ggml_vec_dot_f32was 99.1% offfn_swigluand ofmul_mat[f32];ggml_vec_dot_f1675.9% oflm_head[f16]). tinyBLAS replaces the 2-loads-per-FMA dot-product loop with register-blocked tiles, cutting both instruction count and cache traffic:ffn_swiglumul_mat[f32]The change is architecture neutral — tinyBLAS ships NEON kernels as well as AVX/AVX2/AVX-512 — so the aarch64
codspeed-macrowalltime job benefits too.mul_mat[q4_k]is unchanged because tinyBLAS has no Q4_K kernel (it covers F32, BF16, F16, Q8_0, Q4_0, Q5_0, IQ4_NL);llamafile_sgemm()returnsfalseand the existing loop runs, so unsupported types and shapes are unaffected.Measured impact (CodSpeed CPU simulation, micro suite)
ffn_swiglumul_mat[f32]mul_mat[q4_0]The other 12 benchmarks are unchanged — no regressions.
Scope and caveats
benchmarks/changes.n_tokens = 1) cases are bit-identical; F32/F16 differ by ~1 ulp on a checksum due to the tile accumulation order — the same arithmetic every llama.cpp release already performs.simulationandwalltime) and executed successfully.