[GH-ISSUE #803] Perplexity ~7-10% above llama.cpp on the same GGUF (Qwen3.8-Flash-Next), also at 2K context, every version tested #360

Closed
opened 2026-11-04 01:42:17 +07:00 by bsakaguchi · 2 comments
Owner

Originally created by @mr20399 on GitHub (Oct 4, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/803

Summary

Same weights, same token ids, same scoring positions: Strata's teacher-forced perplexity is consistently ~7-10% higher
than llama.cpp's. The gap is the same on 0.1.32, 0.1.39 and the sergqwer/strata-nvfp4 fork (0.1.38-nvfp4.2), with every
expert pack we tried, and it is already present on 2048-token chunks (where QSA is exactly dense), so it looks like a
per-token numerics difference rather than QSA selection. Short exact-answer tasks still come out right; the gap shows in
perplexity.

Setup

  • RTX 5090 32 GB (driver 616.92), Intel i9-14900K (no AVX-512, AVX2 path), 96 GB DDR5-5600, Windows 11
  • Strata release binaries: upstream v0.1.32 and v0.1.39 (strata-windows-x64.zip), and sergqwer/strata-nvfp4 v0.1.38-nvfp4.2
  • Model: agentionai/Qwen3.8-Flash-Next-AP-GGUF, AP-Q4_K_XL/Qwen3.8-Flash-Next-AP-Q4_K_XL.gguf (101,142,769,536 bytes;
    experts Q4_K gate/up + IQ4_NL down, Q6_K dense, IQ4_NL PLE). Packed with tools/iq_pack.py --compat-bf16; run with
    --embd-gguf (a BF16 token embedding, because the native embedding has no Q6_K GPU dequantizer).
  • llama.cpp references: unslothai/llama.cpp mtp/qwen4exp-nextn a9e9c3c (b10909-mix) and ggml-org master f1cee99
    (includes #29751), llama-perplexity -c 8192 -b 2048 -fa on -ctk q8_0 -ctv q8_0 -ncmoe 39 -ot per_layer_token_embd=CPU

Method

  • Text: 615 KB of English markdown + Python. Token ids come from llama-tokenize on the same file, so both engines score
    identical ids.
  • llama.cpp: llama-perplexity over 8192-token chunks (second half of each chunk scored).
  • Strata: --serve with --short-read 8192 --prompt-cache 0, raw GEN 1 <ids> per chunk, STRATA_LOGPOS column 3
    (full-vocabulary log-probability of the actual next token), the same positions (4096..8190 of each chunk).
  • Engine flags: --pack <pack> --native <gguf> --resident-budget-gib 56 --embd-gguf <bf16 embd> --expert-profile data/expert-profile.bin --expert-cache auto --prefill auto --spec 4 --spec-min-p 0.5 --mtp <draft> --kv int8 --max-context 16384.

Results (chunk 1 of 8192 unless noted; lower is better)

Engine Weights Perplexity
llama.cpp b10909 AP-Q4_K_XL 4.0015
llama.cpp master f1cee99 AP-Q4_K_XL 4.0157
Strata 0.1.32 AP-Q4_K_XL 4.3871
Strata 0.1.39 AP-Q4_K_XL 4.3871
strata-nvfp4 0.1.38-nvfp4.2 AP-Q4_K_XL 4.4024
strata-nvfp4 0.1.38-nvfp4.2 nvidia/Qwen3.8-Flash-Next-NVFP4 (ModelOpt, exact BF16 HC) 4.3988
strata-nvfp4 GPTQ NVFP4 pack from the BF16 checkpoint (1/3 of the expert error) 4.3800

Over 6 chunks: llama.cpp 5.0175 (b10909) / 5.0146 (master), Strata (ModelOpt NVFP4 pack) 5.5524.

2048-token chunks (4 chunks, second half scored; QSA exactly dense):

after chunk 1 2 3 4
llama.cpp b10909, AP 7.3083 5.5979 6.3807 5.5708
Strata (fork), AP 7.6560 5.7503 6.6659 5.9605 (+7.0%)

A/B switches that did NOT move it (ModelOpt NVFP4 pack, chunk 1, baseline 4.3988; runs are deterministic)

--kv fp16 4.3850 · batched prompt path for the first 4097 tokens, then windows: 4.3920 · STRATA_ROPE_TABLE=0 4.3815 ·
--adapt-every 100000 4.3988 · --pcie-frac 1.0 (no CPU experts) 4.3975 · --pcie-frac 0 (all misses on the CPU) 4.3966 ·
STRATA_GR_V3=0 4.3966 · --gr-fp32-activations 4.3988 (no-op with --native) · upstream defaults restored in the fork
(STRATA_KV_ROT=0 STRATA_ROPE_TABLE=0 STRATA_GR_V3=0 STRATA_PREFILL_BF16X2=0 STRATA_KV_GROW=0) 4.3963 ·
--no-fused-gr: the engine exits before READY.

Notes

  • The expert weights barely matter inside Strata: a GPTQ pack with 1/3 of ModelOpt's expert error moved chunk 1 from
    4.3988 to 4.3800, and a pack with 14% of it (Q8_0 down everywhere) gave 4.4007. The gap seems to sit outside the experts.
  • docs/UNSLOTH_Q4.md reports parity with llama.cpp 3cf0325 (CPU build) on UD-Q4_K_XL (4.27 vs 4.29 after a 16K prompt).
    We cannot reproduce that kind of agreement on AP-Q4_K_XL with GPU llama.cpp builds. The AVX2 CPU path is not the
    cause (pcie-frac 0 / 1 give the same result).
  • Happy to run any diagnostic build or dump you suggest.
Originally created by @mr20399 on GitHub (Oct 4, 2026). Original GitHub issue: https://github.com/Niko1221/Strata/issues/803 ## Summary Same weights, same token ids, same scoring positions: Strata's teacher-forced perplexity is consistently ~7-10% higher than llama.cpp's. The gap is the same on 0.1.32, 0.1.39 and the sergqwer/strata-nvfp4 fork (0.1.38-nvfp4.2), with every expert pack we tried, and it is already present on 2048-token chunks (where QSA is exactly dense), so it looks like a per-token numerics difference rather than QSA selection. Short exact-answer tasks still come out right; the gap shows in perplexity. ## Setup - RTX 5090 32 GB (driver 616.92), Intel i9-14900K (no AVX-512, AVX2 path), 96 GB DDR5-5600, Windows 11 - Strata release binaries: upstream v0.1.32 and v0.1.39 (`strata-windows-x64.zip`), and sergqwer/strata-nvfp4 v0.1.38-nvfp4.2 - Model: `agentionai/Qwen3.8-Flash-Next-AP-GGUF`, `AP-Q4_K_XL/Qwen3.8-Flash-Next-AP-Q4_K_XL.gguf` (101,142,769,536 bytes; experts Q4_K gate/up + IQ4_NL down, Q6_K dense, IQ4_NL PLE). Packed with `tools/iq_pack.py --compat-bf16`; run with `--embd-gguf` (a BF16 token embedding, because the native embedding has no Q6_K GPU dequantizer). - llama.cpp references: unslothai/llama.cpp `mtp/qwen4exp-nextn` a9e9c3c (b10909-mix) and ggml-org master f1cee99 (includes #29751), `llama-perplexity -c 8192 -b 2048 -fa on -ctk q8_0 -ctv q8_0 -ncmoe 39 -ot per_layer_token_embd=CPU` ## Method - Text: 615 KB of English markdown + Python. Token ids come from `llama-tokenize` on the same file, so both engines score identical ids. - llama.cpp: `llama-perplexity` over 8192-token chunks (second half of each chunk scored). - Strata: `--serve` with `--short-read 8192 --prompt-cache 0`, raw `GEN 1 <ids>` per chunk, `STRATA_LOGPOS` column 3 (full-vocabulary log-probability of the actual next token), the same positions (4096..8190 of each chunk). - Engine flags: `--pack <pack> --native <gguf> --resident-budget-gib 56 --embd-gguf <bf16 embd> --expert-profile data/expert-profile.bin --expert-cache auto --prefill auto --spec 4 --spec-min-p 0.5 --mtp <draft> --kv int8 --max-context 16384`. ## Results (chunk 1 of 8192 unless noted; lower is better) | Engine | Weights | Perplexity | |---|---|---| | llama.cpp b10909 | AP-Q4_K_XL | 4.0015 | | llama.cpp master f1cee99 | AP-Q4_K_XL | 4.0157 | | Strata 0.1.32 | AP-Q4_K_XL | 4.3871 | | Strata 0.1.39 | AP-Q4_K_XL | 4.3871 | | strata-nvfp4 0.1.38-nvfp4.2 | AP-Q4_K_XL | 4.4024 | | strata-nvfp4 0.1.38-nvfp4.2 | nvidia/Qwen3.8-Flash-Next-NVFP4 (ModelOpt, exact BF16 HC) | 4.3988 | | strata-nvfp4 | GPTQ NVFP4 pack from the BF16 checkpoint (1/3 of the expert error) | 4.3800 | Over 6 chunks: llama.cpp 5.0175 (b10909) / 5.0146 (master), Strata (ModelOpt NVFP4 pack) 5.5524. 2048-token chunks (4 chunks, second half scored; QSA exactly dense): | | after chunk 1 | 2 | 3 | 4 | |---|---|---|---|---| | llama.cpp b10909, AP | 7.3083 | 5.5979 | 6.3807 | 5.5708 | | Strata (fork), AP | 7.6560 | 5.7503 | 6.6659 | 5.9605 (+7.0%) | ## A/B switches that did NOT move it (ModelOpt NVFP4 pack, chunk 1, baseline 4.3988; runs are deterministic) `--kv fp16` 4.3850 · batched prompt path for the first 4097 tokens, then windows: 4.3920 · `STRATA_ROPE_TABLE=0` 4.3815 · `--adapt-every 100000` 4.3988 · `--pcie-frac 1.0` (no CPU experts) 4.3975 · `--pcie-frac 0` (all misses on the CPU) 4.3966 · `STRATA_GR_V3=0` 4.3966 · `--gr-fp32-activations` 4.3988 (no-op with `--native`) · upstream defaults restored in the fork (`STRATA_KV_ROT=0 STRATA_ROPE_TABLE=0 STRATA_GR_V3=0 STRATA_PREFILL_BF16X2=0 STRATA_KV_GROW=0`) 4.3963 · `--no-fused-gr`: the engine exits before READY. ## Notes - The expert weights barely matter inside Strata: a GPTQ pack with 1/3 of ModelOpt's expert error moved chunk 1 from 4.3988 to 4.3800, and a pack with 14% of it (Q8_0 down everywhere) gave 4.4007. The gap seems to sit outside the experts. - docs/UNSLOTH_Q4.md reports parity with llama.cpp 3cf0325 (CPU build) on UD-Q4_K_XL (4.27 vs 4.29 after a 16K prompt). We cannot reproduce that kind of agreement on AP-Q4_K_XL with GPU llama.cpp builds. The AVX2 CPU path is not the cause (pcie-frac 0 / 1 give the same result). - Happy to run any diagnostic build or dump you suggest.
Author
Owner

@clapbr commented on GitHub (Oct 4, 2026):

I was worried at first but I measured mine vs llama ROCm and isnt even close to this huge gap (−0.008%). My setup is so different from yours though (AMD, iq3_s).

<!-- gh-comment-id:5985477355 --> @clapbr commented on GitHub (Oct 4, 2026): I was worried at first but I measured mine vs llama ROCm and isnt even close to this huge gap (−0.008%). My setup is so different from yours though (AMD, iq3_s).
Author
Owner

@mr20399 commented on GitHub (Oct 5, 2026):

@clapbr thank you, you were right, and your measurement is what led us to the cause. Your near-zero gap made us re-check our test text: our ppl-text.txt had Windows CRLF line endings (it was written in text mode on Windows). On an LF copy of the same text, Strata matches llama.cpp on our NVIDIA box too, just like on your AMD setup. The only real bug left is a narrow one: Strata scores the CRLF line-break tokens badly. So the gap in this issue's title is a test-text artifact, not a general accuracy problem.

Details

LF copy of the same text, re-tokenized with llama-tokenize:

6 × 8192 chunks, LF text, second half scored Perplexity
llama.cpp b10909, AP-Q4_K_XL 5.0196
strata-nvfp4 fork, nvidia NVFP4 (ModelOpt) 5.0190
strata-nvfp4 fork, ISTA-DASLab GSQ-RCO IQ3_S 5.0048

Same IQ3_S GGUF, chunks 1 / 2:

LF text CRLF text
llama.cpp 4.0664 / 4.4580 4.0656 / 4.4501
Strata 4.0683 / 4.4692 4.4955 / 5.2962

The remaining bug: Strata gives the CRLF line-break tokens far too little probability, while llama.cpp scores them normally on the same ids. In the Qwen3.8 vocab these are \r\n (317), \r\n\r\n (845) and \r\n\r\n\r\n (8301). Every other token scores the same as llama.cpp; the whole gap sits on those tokens (mean NLL ≈ 3.25 on them, vs ≈ 0.39 for \n (198) on the LF copy). We see it on 0.1.32, 0.1.39 and the fork, with the AP-Q4_K_XL, NVFP4 and IQ3_S packs, and with --pcie-frac 0 and 1.0, so it is not the weights or the CPU path. As far as we can tell the PLE n-gram hashing matches llama.cpp's code, so we have not found where it comes from.

Practical impact is small, because the rest of the text scores normally. But on Windows, CRLF reaches the model easily (files read from disk, tool output, text written in text mode), and any perplexity measured on such text looks ~10-19% worse than it really is. That is what happened to us.

Workaround we use for now: normalize \r\n to \n in the server's chat-template render (ChatTemplate.render() in serve/frontend.py, .replace("\r\n", "\n")) before tokenizing. Our agent restores each file's own line endings when it writes, so nothing is lost.

Happy to run a diagnostic build for the CRLF tokens.

<!-- gh-comment-id:5999033434 --> @mr20399 commented on GitHub (Oct 5, 2026): @clapbr thank you, you were right, and your measurement is what led us to the cause. Your near-zero gap made us re-check our test text: our `ppl-text.txt` had Windows CRLF line endings (it was written in text mode on Windows). On an LF copy of the same text, Strata matches llama.cpp on our NVIDIA box too, just like on your AMD setup. The only real bug left is a narrow one: Strata scores the CRLF line-break tokens badly. So the gap in this issue's title is a test-text artifact, not a general accuracy problem. **Details** LF copy of the same text, re-tokenized with `llama-tokenize`: | 6 × 8192 chunks, LF text, second half scored | Perplexity | |---|---| | llama.cpp b10909, AP-Q4_K_XL | 5.0196 | | strata-nvfp4 fork, nvidia NVFP4 (ModelOpt) | 5.0190 | | strata-nvfp4 fork, ISTA-DASLab GSQ-RCO IQ3_S | 5.0048 | Same IQ3_S GGUF, chunks 1 / 2: | | LF text | CRLF text | |---|---|---| | llama.cpp | 4.0664 / 4.4580 | 4.0656 / 4.4501 | | Strata | 4.0683 / 4.4692 | 4.4955 / 5.2962 | The remaining bug: **Strata gives the CRLF line-break tokens far too little probability**, while llama.cpp scores them normally on the same ids. In the Qwen3.8 vocab these are `\r\n` (317), `\r\n\r\n` (845) and `\r\n\r\n\r\n` (8301). Every other token scores the same as llama.cpp; the whole gap sits on those tokens (mean NLL ≈ 3.25 on them, vs ≈ 0.39 for `\n` (198) on the LF copy). We see it on 0.1.32, 0.1.39 and the fork, with the AP-Q4_K_XL, NVFP4 and IQ3_S packs, and with `--pcie-frac 0` and `1.0`, so it is not the weights or the CPU path. As far as we can tell the PLE n-gram hashing matches llama.cpp's code, so we have not found where it comes from. Practical impact is small, because the rest of the text scores normally. But on Windows, CRLF reaches the model easily (files read from disk, tool output, text written in text mode), and any perplexity measured on such text looks ~10-19% worse than it really is. That is what happened to us. Workaround we use for now: normalize `\r\n` to `\n` in the server's chat-template render (`ChatTemplate.render()` in `serve/frontend.py`, `.replace("\r\n", "\n")`) before tokenizing. Our agent restores each file's own line endings when it writes, so nothing is lost. Happy to run a diagnostic build for the CRLF tokens.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#360
No description provided.