BerryLM-OS-GGUF

BerryLM-OS quantized to GGUF for llama.cpp: Q6_K and Q4_K_M, and the DFlash2 draft model for faster generation with speculative decoding.

These files need llama.cpp with BerryLM support. It is proposed in the pull request ggml-org/llama.cpp#30234, which is not merged yet. Until it is merged, official llama.cpp releases, Ollama, LM Studio and other applications built on llama.cpp do not load these files; build llama.cpp from the pull request as shown below.

Files

file size KL divergence to BF16 (en / ru) top-1 agreement with BF16 (en / ru)
BerryLM-OS-Q6_K.gguf 14.1 GiB 0.0062 / 0.0055 96.6 % / 97.4 %
BerryLM-OS-Q4_K_M.gguf 10.5 GiB 0.0301 / 0.0238 92.5 % / 94.7 %

Measured with llama-perplexity from #30234 on CUDA against the BF16 GGUF of the same weights: en = wikitext-2 test (context 512, 147 900 scored tokens), ru = the first 50 windows of 4096 tokens from 75 Russian Wikipedia articles (102 350 scored tokens). The quants use no importance matrix. Q6_K is practically lossless; Q4_K_M loses a little.

BerryLM-OS-DFlash2-BF16.gguf (784 MiB) is the draft model for speculative decoding, see Faster generation with the draft model. It works with either file.

Build llama.cpp from the pull request

git clone https://github.com/ggml-org/llama.cpp
cd llama.cpp
git fetch origin pull/30234/head:berrylm
git checkout berrylm
cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build -j --target llama-cli llama-server

For an NVIDIA GPU add -DGGML_CUDA=ON to the first cmake line; Metal on macOS is enabled by default. On macOS build in your home directory, not under /tmp.

Download

pip install -U huggingface_hub
hf download rwb-ai/BerryLM-OS-GGUF BerryLM-OS-Q6_K.gguf --local-dir .

Run

./build/bin/llama-server -m BerryLM-OS-Q6_K.gguf -ngl 99 -c 32768 --no-reasoning-preserve --port 8080

The chat UI is at http://127.0.0.1:8080 and the OpenAI-compatible API at http://127.0.0.1:8080/v1; the server returns the reasoning separately from the answer (reasoning_content). A chat in the terminal:

./build/bin/llama-cli -m BerryLM-OS-Q6_K.gguf -ngl 99 -c 16384 --no-reasoning-preserve
  • Always pass -c. Without it llama.cpp starts from the full 256k context (262 144 tokens), about 5 GiB of KV cache, and shrinks it only if memory runs out; 16k takes about 0.3 GiB, 32k about 0.6 GiB.
  • The sampling defaults for thinking mode are stored in the files: temperature 0.8, top_k 20, top_p 0.95, min_p 0, no penalties. No flags are needed, and the model does not need repetition or presence penalties.
  • Thinking is on by default. Turn it off per request with "chat_template_kwargs": {"enable_thinking": false}, for the whole server with --chat-template-kwargs '{"enable_thinking": false}', or in llama-cli with --reasoning off. For direct answers the recommended sampling is temperature 0.7, top_p 0.8, top_k 20: add --temp 0.7 --top-p 0.8, or send "temperature": 0.7, "top_p": 0.8 with the request.
  • --no-reasoning-preserve keeps earlier reasoning out of the conversation history, as the model's chat template does.
  • Tool calling works through llama-server: pass tools in an OpenAI-style request, and the calls come back parsed in tool_calls.

Memory. The file and the context must fit: in GPU memory with -ngl 99, in RAM without it. On Apple silicon the GPU gets part of the unified memory (17.8 GiB on a 24 GB Mac). On a 24 GB Apple M5 Mac with the default GPU limit both files load fully on the GPU; Q6_K with -c 32768 used 15.2 GiB and processed a 26.7k-token prompt. Q4_K_M on a 16 GB Mac was not tested: with an 8k context it needs about 11 GiB of GPU memory, close to the default limit there; raising the limit (sudo sysctl iogpu.wired_limit_mb=12288) gives headroom.

Faster generation with the draft model

BerryLM-OS-DFlash2 proposes 7 tokens at a time and BerryLM-OS checks them in one pass (DFlash2 speculative decoding). Every emitted token is verified by BerryLM-OS, so the output distribution does not change; generation gets faster. Load it next to either file with -md:

hf download rwb-ai/BerryLM-OS-GGUF BerryLM-OS-DFlash2-BF16.gguf --local-dir .
./build/bin/llama-server -m BerryLM-OS-Q6_K.gguf -md BerryLM-OS-DFlash2-BF16.gguf -ngl 99 -ngld 99 \
  -c 32768 --no-reasoning-preserve --port 8080 \
  --spec-type draft-dflash --spec-draft-n-max 7 --spec-draft-n-min 0 --spec-draft-p-min 0 \
  --spec-draft-sampling probabilistic

--spec-draft-n-max must be 7. The draft model adds about 0.8 GiB of memory. τ below is the number of tokens emitted per BerryLM-OS verification step (1 + accepted draft tokens), averaged over requests.

Speedup of llama-server with the drafter GGUF over llama-server alone with the same BerryLM-OS GGUF, 1 request at a time, probabilistic drafting. Mean of three repetitions.

task Q6_K Q4_K_M
GSM8K 1.77× 1.86×
HumanEval 1.83× 1.95×
MATH-500 1.91× 2.05×
MBPP 1.65× 1.73×
MT-Bench 1.51× 1.61×

τ is 4.49–5.66 and within ±0.1 of vLLM's on the same requests for every file: quantization of BerryLM-OS does not lower the acceptance.

Measured on CUDA, one GPU: 32 requests per task from GSM8K, HumanEval, MATH-500, MBPP and MT-Bench (first turn only), thinking on, up to 4096 new tokens, temperature 0.8, top-p 0.95, top-k 20, context 17408, all layers on the GPU. On an Apple M5 (Metal, 24 GB) a short check with Q4_K_M (24 requests, temperature 0, 384 new tokens) gave the same τ as on CUDA (5.23 vs 5.26) and 1.63× the decoding speed (75 vs 46 tokens per second).

Validation

The checks below use the llama.cpp code from #30234. The full-model checks use these files; the exactness check and the architecture tests use small random-weight models instead.

Implementation against the reference. The llama.cpp graph was compared with the HF transformers implementation:

check setup result
exactness 18 random-weight models covering the architecture variants, F32 GGUF on CPU vs HF fp32, 4 374 tokens mean KL ≤ 1.5e-11, top-1 identical except one exact tie
full model Q4_K_M on Metal (Apple M5) vs HF fp32 logits, 6 English/Russian texts, 290 tokens mean KL 0.034, top-1 96.9 %, in line with Q4_K_M quantization error

Perplexity on wikitext-2 test (scripts/get-wikitext-2.sh, context 512, all 580 chunks):

file CUDA Apple M5 (Metal)
BF16 (not hosted) 8.7534 ± 0.0575 –
Q6_K 8.7543 ± 0.0576 8.7481 ± 0.0576
Q4_K_M 8.9496 ± 0.0586 8.9417 ± 0.0585

Tokenizer. The embedded tokenizer gives the same tokens as the original one on the 46 llama.cpp tokenizer test strings, 1 015 edge and random cases and about 1.4 million generated texts (NFC input, see Limitations).

Runtime. The llama.cpp architecture tests (test-llama-archs, state save/load and rollback) pass on Metal and CUDA, the graph fusion check on Metal. llama-server was checked with thinking on and off and with a tool call.

Limitations

  • The original tokenizer applies NFC Unicode normalization; the llama.cpp tokenizer does not yet (planned as a follow-up to #30234). Text already in NFC, which is most text, tokenizes identically. Text with decomposed characters, such as a letter followed by a combining accent, can tokenize differently; normalize such input to NFC first.
  • The model declares a 256k context. The quality measurements above use contexts up to 4096 tokens; a 26.7k-token prompt was run with a 32k context, and longer contexts were not tried in llama.cpp.

License

Released under the Apache License 2.0, see LICENSE.

Downloads last month
38
GGUF
Model size
0.4B params
Architecture
dflash
Hardware compatibility
Log In to add your hardware

4-bit

6-bit

16-bit

Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for rwb-ai/BerryLM-OS-GGUF

Quantized
(2)
this model