Repository navigation
feat(gguf): serve Llama and Mistral llama-arch GGUF checkpoints - #722
Merged
Merged
Conversation
jason-fxz
force-pushed
the
feat/gguf-llama
branch
from
October 16, 2026 21:40
6d94083 to
da3bbbe
Compare
This was referenced Oct 16, 2026
This was referenced Oct 17, 2026
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.
Summary
Serves llama.cpp
llamaGGUF files on the existingllamamodel classes: Llama 3.x and the Mistral models converted before llama.cpp had amistral3arch (Mistral-7B, Mistral-Nemo, Mistral-Small-3.1/3.2, Magistral, Devstral-2507). Text only. Also fixes three GGUF tokenizer bugs that Llama 3, Mistral, DeepSeek-R1-Distill-Llama, Muse-Glimmer and MiniMax files hit.Changes
models/llama/gguf.py(new):rope_freqsdivisors. The loader sets llama3 scaling with factor = max(rope_freqs), low 1, high 4, original 8192 (every Llama 3.1–3.3 release), and refuses the file unless the result reproducesrope_freqs.attn_qkvmatrix of files converted with--fuse-qkvasqkv_proj.llama), partial rope, other rope scaling, prism files, per-tensor scales, metadata-only GGUFs, and early unsloth Mistral-Nemo conversions whose metadata gives head_dim 160 for 128-wide heads (llama.cpp rejects them too).models/llama/model.py:embed_tokenstakes the quant config, so a quantizedtoken_embdis served packed.models/gguf/tokenizer.py:add_bos_tokenkey, uses llama.cpp's default: BOS for SPM and for the BPE pre-tokenizers llama.cpp lists (llama-bpe,tekken, ...). bartowski's Llama-3.1-8B and unsloth's Llama-3.2-1B lack the key, so raw/v1/completionsprompts got no<|begin_of_text|>.<|User|>and MiniMax's tokens with spaces were cut into pieces. A token the merges build stays a normal piece (unsloth's MiniMax-M3 marks U+FFFD as control).GPT2Tokenizeradds<|endoftext|>at id = n_vocab (128256 for Llama 3, 131072 for tekken), past the embedding table.gguf/config.py,register.py,kernel/aot_models.py: register thellamaarch and claim it in the AOT model table.Tested models
RTX PRO 6000 Blackwell (sm_120),
ft serve --model-path <file>. GSM8K test problems 1–64 × 1 sample with each model's own sampling (Llama 3: temperature 0.6, top_p 0.9; Mistral-Small-3.2: 0.15; Mistral-Nemo: 0.3; Mistral-7B: 0.7). llama.cpp f2cc728 ran with top_k off and min_p 0. Also 48 staggered requests at concurrency 16.Staggered requests: no corrupted output on any file.
Results
ggml.dequantizereaches cos 0.99998 against unsloth/Llama-3.2-1B-Instruct (q, k, v, o, gate_up, down and the embedding at layers 0 and 15), and the norms are exact. Without the un-permute, q has cos 0.03. Dry load against the meta-built model matches every param of all five files (98–263). The recovered llama3 rope parameters equal the HF config (factor 32 for 3.2-1B, 8 for 3.1-8B).tokenizer.jsonfor all six files. Before, the two Llama 3 files without the key got no BOS, and<|endoftext|>encoded to 128256 / 131072. DeepSeek-R1-Distill-Llama-8B (unsloth and bartowski Q4_K_M) now equals HF on every special token and on a rendered multi-turn chat.▁after[INST]that HF does not). Every divergence is a near-tie in llama.cpp's own probabilities: both engines' picks are its top 2 (e.g. 0.495 vs 0.489).tokenizer.ggml.pre.--fuse-qkv: HF Llama-3.2-1B converted to Q8_0 with and without--fuse-qkvloads to byte-identical state dicts (98 tensors), withqkv_projread fromattn_qkv.tests/modelsandtests/tokenizerpass, except 5test_quant_configcases that also fail on main.Not covered
mistral3arch (Ministral 3, Devstral-Small-2, current Mistral Small reconversions): it needs the Llama 4 attention temperature in the mistral model.