mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[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
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#360
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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
strata-windows-x64.zip), and sergqwer/strata-nvfp4 v0.1.38-nvfp4.2agentionai/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).mtp/qwen4exp-nextna9e9c3c (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=CPUMethod
llama-tokenizeon the same file, so both engines scoreidentical ids.
llama-perplexityover 8192-token chunks (second half of each chunk scored).--servewith--short-read 8192 --prompt-cache 0, rawGEN 1 <ids>per chunk,STRATA_LOGPOScolumn 3(full-vocabulary log-probability of the actual next token), the same positions (4096..8190 of each chunk).
--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)
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):
A/B switches that did NOT move it (ModelOpt NVFP4 pack, chunk 1, baseline 4.3988; runs are deterministic)
--kv fp164.3850 · batched prompt path for the first 4097 tokens, then windows: 4.3920 ·STRATA_ROPE_TABLE=04.3815 ·--adapt-every 1000004.3988 ·--pcie-frac 1.0(no CPU experts) 4.3975 ·--pcie-frac 0(all misses on the CPU) 4.3966 ·STRATA_GR_V3=04.3966 ·--gr-fp32-activations4.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
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.
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).
@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).
@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.txthad 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:Same IQ3_S GGUF, chunks 1 / 2:
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 0and1.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\nto\nin the server's chat-template render (ChatTemplate.render()inserve/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.