← Lab
sortpoison
confirmedupstream bugC++ · CPUInference & servingJuly 13, 2026
the question
Do llama.cpp's top_k, top_p, and min_p truncation samplers stay order-invariant under a stale sorted=true flag, and is that stale state reachable through the public sampler API?
what came out
No. Exhaustively over n! permutations with sorted forced true, top_p yields up to 11 distinct survivor sets, min_p 8, top_k 10, all wrong, while typical stays sound. logit_bias reorders logits without resetting sorted=false, so the public chain top_k to logit_bias to top_p keeps {0,1,2,3} where {3} is correct. The stock default chain is safe.
method & receipts
- Result: confirmed
- Pre-registered — the prediction was written down and committed before the run.
- Reproducible — one script re-runs the whole thing from scratch.
- Tested — a correctness/benchmark suite ships alongside the code.
→ read the code and re-run it
github.com/v-code01/sortpoison