[llama.cpp] Update third_party/llama.cpp
Categories
(Core :: Machine Learning: On Device, enhancement, P1)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox154 | --- | fixed |
People
(Reporter: vpollet, Assigned: vpollet)
References
(Blocks 3 open bugs)
Details
(Whiteboard: [aiplatform])
Attachments
(18 files)
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review |
The version of llama.cpp built and used by Firefox is quite a bit behind upstream (~3000 commits, 10 months).
Setting this as P2 because it seems like quite a lot has happened upstream. This appears to be good idea to update before committing to more work involving the llama.cpp backend.
Why it may be worth doing
This is a lot of changes to go through to determine how much of a priority this should be, so I asked Claude to analyze it to get a sense of what Firefox could gain from bumping.
Prompt
From gg-ml/llama.cpp@98e480a32ec77bc494df887da3f69e53373122a7:
Firefox uses llama.cpp to run inference on device. llama.cpp is built in tree, from a version about 3000 commits behind head here. I ran
git log d32e03f4495d3efa1c5126f53b449f1d429c5664..HEAD --onelineto get a summary of the changes that happened since, see@llama-cpp.changelog. I'm interested in the benefits Firefox would get from bumping. Firefox currently only uses the CPU backend, see@firefox-build.mozconfigfor shipped optimizations/configurations.
Claude's answer
Firefox llama.cpp Bump — CPU-Focused Benefits
Range analyzed: d32e03f4495d3efa1c5126f53b449f1d429c5664..98e480a32ec77bc494df887da3f69e53373122a7 (~3000 commits). Filtered for CPU-backend relevance on the targets shipped in firefox-build.mozconfig (x86_64-AVX2/BMI2/F16C/FMA/SSE4.2, aarch64, arm, x86, generic).
Top wins justifying the bump
- ARM64 K-quant repack GEMM/GEMV kernels (#16739, #17494, #18096, #18860, #18888, #19108, #19356, #19360) —
dotprod+i8mmvariants for q4_K/q5_K/q6_K/q8_0. Material prompt-prefill throughput on aarch64. - CPU Flash Attention — chunking (#16829), tiled FA for prefill (#19012), FA split across KV for TG (#19209), FA GEMM microkernel (#19422), and f16 FA mask (#23764) → significant speed + memory wins on the embedding path.
- AVX2 wins —
optimize avx2 q6_k(#22345),LUT for e8→f32 scales on x86(#19288),optimized x86 q1_0 dot(#21636). Direct hits on the x86_64-AVX2 path Firefox ships. - New embedding architectures — EmbeddingGemma 300m (#15798 + dense modules #16367), ModernBERT (#18330), Jina v3 (#13693), Jina v5 Nano/EuroBERT (#19826), Granite Embedding (#15641), LFM2-ColBert-350M (#18607). Highly relevant to embedding robustness work.
- Tokenizer crash fixes — segfault on repetitive input (#17786), Qwen2 regex segfault on long input (#21257), UGM XCDA bounds (#17215). Production stability.
Updated•1 month ago
|
Updated•1 month ago
|
| Assignee | ||
Updated•1 month ago
|
Updated•1 month ago
|
Updated•1 month ago
|
Updated•1 month ago
|
| Assignee | ||
Comment 1•1 month ago
|
||
Updated moz.yaml with two extra include globs as upstream refactored llama-model.cpp into multiple smaller files in src/models.
Updated cmakeparser.py to handle globs in CMakeLists.txt (introduced upstream to compile models/*.cpp).
Fixed run_parser.py needed to discard files excluded by moz.yaml.
Updated moz.build to provide src/ as an include directory during build. This was needed to compile models/*.cpp which include llama-model.h without a relative path.
Updated moz.build to export ggml/include/gguf.h as upstream now includes it in llama.h.
| Assignee | ||
Comment 2•1 month ago
|
||
This is the result of running the command:
./mach vendor third_party/llama.cpp/moz.yaml -r 74ade52741203e5c8f81eaf06a96cb1cfe15f2a3 --patch-mode=none
| Assignee | ||
Comment 3•1 month ago
|
||
Beyond the usual line-number and index shifts, this follows two upstream
file renames: llama-kv-cache-unified.cpp -> llama-kv-cache.cpp and
llama-sampling.cpp -> llama-sampler.cpp.
| Assignee | ||
Comment 4•1 month ago
|
||
Upstream split dynamic-library loading into the new ggml-backend-dl.{cpp,h},
which use std::filesystem. The patch grew to #if 0 out the fs::path-based
dl_load_library there and add the <memory>/<type_traits> includes it
otherwise pulled in transitively.
| Assignee | ||
Comment 5•1 month ago
|
||
| Assignee | ||
Comment 6•1 month ago
|
||
Upstream restructured the non-unicode regex split path: it now builds the
wstring directly from the codepoints instead of via unicode_wstring_from_utf8,
so the abort()/commented-out replacement was reapplied against the new code.
The std::wstring unicode_regex_split_stl overload was removed upstream, so
that #if 0 hunk is dropped.
| Assignee | ||
Comment 7•1 month ago
|
||
| Assignee | ||
Comment 8•1 month ago
|
||
| Assignee | ||
Comment 9•1 month ago
|
||
| Assignee | ||
Comment 10•1 month ago
|
||
| Assignee | ||
Comment 11•1 month ago
|
||
| Assignee | ||
Comment 12•1 month ago
|
||
Upstream added HAIKU to the RLIMIT_MEMLOCK guard, so sun is now
appended alongside it and the comment updated to match. Also drops a spurious
empty-file hunk the previous version of the patch carried.
| Assignee | ||
Comment 13•1 month ago
|
||
| Assignee | ||
Comment 14•1 month ago
|
||
Upstream moved threadpool parameter initialization into the new ggml-c.c, so
a hunk was added to zero-initialize the thread_create/destroy callbacks in
ggml_threadpool_params_init there, alongside the existing ggml-cpu-c.c hooks.
| Assignee | ||
Comment 15•1 month ago
|
||
| Assignee | ||
Comment 16•1 month ago
|
||
Updated•1 month ago
|
Updated•1 month ago
|
Updated•1 month ago
|
Updated•1 month ago
|
Updated•1 month ago
|
Updated•1 month ago
|
| Assignee | ||
Updated•28 days ago
|
| Assignee | ||
Comment 17•24 days ago
|
||
The metadata kv dump in llama_model_loader was measured to be very expensive (~10 milliseconds on e.g. Mac M5) for certain models.
This was not an issue prior to this bump in version of llama.cpp because we had a custom llama_model_load_from_file_handle.
Upstream added support for it so we adopted it, but our custom was skipping it.
The patch skips the dump using a pre-existing trace gate.
| Assignee | ||
Comment 18•24 days ago
|
||
This makes the exceptions declared in the redefine of catch static, avoiding construction/destruction of 4 objects.
Updated•24 days ago
|
Comment 19•21 days ago
|
||
Comment 20•20 days ago
|
||
| bugherder | ||
https://hg.mozilla.org/mozilla-central/rev/e21fd1c1613a
https://hg.mozilla.org/mozilla-central/rev/6811d1384280
https://hg.mozilla.org/mozilla-central/rev/730be2c048c3
https://hg.mozilla.org/mozilla-central/rev/25df54f4eb09
https://hg.mozilla.org/mozilla-central/rev/dd511ec11000
https://hg.mozilla.org/mozilla-central/rev/41444f8593da
https://hg.mozilla.org/mozilla-central/rev/a314f319cb2d
https://hg.mozilla.org/mozilla-central/rev/91a40b65026c
https://hg.mozilla.org/mozilla-central/rev/859880280884
https://hg.mozilla.org/mozilla-central/rev/be9857e3ee1e
https://hg.mozilla.org/mozilla-central/rev/777fb9845371
https://hg.mozilla.org/mozilla-central/rev/3bd01ffe47b0
https://hg.mozilla.org/mozilla-central/rev/596654441a06
https://hg.mozilla.org/mozilla-central/rev/9f49431b36d0
https://hg.mozilla.org/mozilla-central/rev/8fd1d6633ade
https://hg.mozilla.org/mozilla-central/rev/29b6e547608f
https://hg.mozilla.org/mozilla-central/rev/a9bb42b8f851
https://hg.mozilla.org/mozilla-central/rev/bcf9b1be5846
Description
•