Skip to main content
KM

My LLM Correctness Tool Had Correctness Bugs. Here's What It Says Now.

13 min read
quantizationmlxvllminferenceinfer-check

Update, November 2026: This post replaces the version I published in March 2026. That version reported results from an early build of infer-check with bugs in generation, scoring, and its stress test, and most of its conclusions didn't survive the fixes. If you read the original, the short version is that 4-bit quantization is safer than I said, and backends agree less exactly than I said, but for mostly benign reasons.

In March I wrote that every benchmark for LLM inference engines measures tokens per second, and almost none measure whether the tokens are correct. I still think that's true. I built infer-check to test for it, ran it on Llama-3.1-8B and Qwen3.5-4B on Apple Silicon, and published what I found: 4-bit quantization badly damaged reasoning and numerics, a newer architecture degraded at the same rate as a dense model, and vllm-mlx matched mlx-lm token for token, even under load.

Then I kept working on the tool, and learned that a correctness tool needs its own correctness testing. Nearly every number in that post came from code measuring something other than what I thought it measured. This post explains what was wrong, how infer-check measures things now, and what the corrected tool finds on three models: Llama-3.1-8B-Instruct, Qwen3.5-9B, and Gemma 4 12B.

What was wrong

Generation was broken. The MLX backend looped over mlx-lm's low-level generate_step instead of using stream_generate. That loop never stopped at the end-of-message token, so outputs ran on into invented extra conversation turns. It also capped every output at 256 tokens regardless of the requested limit, decoded one token at a time (mangling multi-byte characters), and gave chat-templated prompts a second BOS token. Two models with slightly different weights invent different extra turns, so this alone inflated divergence.

"Severe" didn't mean wrong. infer-check classified each output by its text similarity to the baseline, and I treated "severe" (similarity below 0.5) as a correctness failure. It isn't one. Two outputs that take different routes to the same right answer score as severe. My March headline, that 70% of Llama's reasoning prompts degraded severely at 4-bit, was a statement about wording.

The KL divergence wasn't a KL divergence. The old metric was computed from the log-probabilities of the chosen tokens only, and it kept comparing positions after the two generations had diverged, when the models were predicting continuations of different text. Combined with a tiny floor for missing tokens, it produced values around 19 nats per token for 4-bit vs. bf16, which means nothing.

The flip rate guessed. For prompts without an answer key, a "flip" was decided by heuristics that pulled the last number or a yes/no out of each output. On outputs cut off at the token limit, that last number comes from unfinished reasoning.

The stress test couldn't see batching. It sent concurrent requests but never varied what each prompt was batched with, which is how batching actually changes outputs. "100% consistency under load" said more about the test than about the server.

I got an architecture wrong. I described Qwen3.5-4B as a Mixture-of-Experts model and built a finding around MoE degrading at the same rate as dense models. The small Qwen3.5 models are dense: they mix Gated DeltaNet linear attention with full attention, but every parameter is active on every token. That comparison was never a comparison.

How infer-check measures now

The biggest change is that it grades answers instead of comparing text. Prompts can carry an answer key, and the package now bundles the 1,319-problem GSM8K test split, all keyed. Each graded prompt asks the model to end with a Final answer: line, and the grader parses it exactly, with fractions as exact rationals and no rounding of large integers. Two configurations are compared as a paired table: prompts both got right, regressions (baseline right, test wrong), improvements, and both wrong. An exact McNemar test on the discordant pairs says whether the difference is more than chance. A test model that runs out of tokens where the baseline finished counts as wrong, because that's usually a repetition loop.

Drift in the model's predictions is measured with teacher-forced KL: both models score the baseline's exact tokens, so every position compares predictions made from identical context. Alongside it, top-1 agreement is the fraction of positions where both models' most likely next token is the same. HTTP servers can't score arbitrary tokens, so for them infer-check falls back to an approximate prefix KL over the positions where both generations still share context, and labels it as such.

For cross-backend comparisons, exact text match turned out to be the wrong test, so diff now checks whether each divergence is a near-tie: whether each side's chosen token is in the other's top-K at the first point where they differ, the same check vLLM uses in its own correctness tests. And stress now runs each prompt alone, then sends it together with randomly drawn other prompts and compares the two outputs token for token.

Finally, the tool has positive controls: a script that deliberately damages a model, by quantizing further or injecting noise into its logits, and checks that KL and top-1 disagreement rise with the damage and that zero damage gives a KL of exactly zero. If a correctness metric can't see damage you put there on purpose, it can't be trusted to see anything else.

The setup

All runs use greedy decoding with a 1,024-token limit on Apple Silicon. Quantization sweeps use the first 50 GSM8K problems with bf16 as the baseline. The 8-bit and 4-bit Llama and Gemma models are mlx-community's conversions; the Qwen models and the 3-bit and 2-bit Gemma models I converted locally with mlx_lm.convert. Cross-backend and stress tests use the 100-prompt reasoning suite, which has no answer keys, so those results are about agreement between backends, not about right answers.

Fifty prompts is a small sample, and that matters. With 50 paired prompts, McNemar only flags a difference when regressions clearly outnumber improvements, so a real drop of a few points can easily look like noise. I'll point out where that limits the conclusions.

Finding 1: Text similarity overstates quantization damage

Here's each model at 4-bit against its own bf16 baseline:

Model"Severe" text divergenceAccuracy (bf16 → 4-bit)Regressions / improvementsMcNemar p
Llama-3.1-8B-Instruct35/5090% → 80%6 / 10.125
Qwen3.5-9B33/5096% → 98%0 / 11.0
Gemma 4 12B28/5098% → 96%1 / 01.0

Llama's 35 of 50 "severe" outputs is the same number I reported in March, even after the generation fixes. By text, 4-bit Llama looks badly broken. By answers, it regressed on 6 problems and improved on 1. Qwen3.5-9B had 33 "severe" outputs and zero regressions; it got one more problem right at 4-bit than at bf16.

Greedy decoding explains the gap. Once a quantized model picks a different token, which at 4-bit happens at about 4% of positions for all three models, everything after it is a different continuation: different wording, different intermediate steps, and often the same final answer. Text similarity measures how far apart the two paths drifted, not whether they arrived at the same place.

None of this means 4-bit is free. Llama dropped from 90% to 80%, and a 6-to-1 split is suggestive even though p = 0.125 isn't significant at this sample size. What the data doesn't support is the March framing, where most 4-bit reasoning outputs were "broken."

Finding 2: The cliff is at 3-bit, and it looks like runaway generation

To see where quantization actually breaks, I swept Qwen3.5-9B and Gemma 4 12B down to 2-bit. Llama only went down to 4-bit.

ModelLevelMean KL (nats/token)Top-1 agreementAccuracyRegressions / improvements
Qwen3.5-9Bbf16 (self-check)0100%96%0 / 0
8-bit0.000599.6%96%0 / 0
4-bit0.03796.2%98%0 / 1
3-bit0.18990.7%76%11 / 1
2-bit3.2236.7%0%48 / 0
Gemma 4 12Bbf16 (self-check)0100%98%0 / 0
8-bit0.000699.5%98%0 / 0
4-bit0.05495.8%96%1 / 0
3-bit0.48385.4%4%47 / 0
2-bit26.60.01%0%49 / 0
Llama-3.1-8Bbf16 (self-check)0100%90%0 / 0
8-bit0.000399.4%86%2 / 0
4-bit0.02596.1%80%6 / 1

These sweeps double as positive controls. KL rises and top-1 agreement falls at every step down in precision, and each self-check reproduces all 50 baseline outputs with a KL of exactly zero. Beyond that, three things stand out.

8-bit is indistinguishable from bf16 on these runs. KL is under 0.001 nats per token, top-1 agreement is above 99%, and accuracy doesn't move for Qwen or Gemma. Llama's 8-bit lost 2 problems, which is well within noise.

4-bit shows real drift, but no significant accuracy loss. KL rises by nearly two orders of magnitude over 8-bit, to between 0.025 and 0.054 nats per token. Oddly, Llama has the lowest 4-bit KL of the three and the largest accuracy drop. With 50 prompts I wouldn't read much into that, but it's a reminder that mean KL and task accuracy aren't interchangeable.

3-bit is where both models break, and they break by not stopping. infer-check marks the degradation cliff as the first level with a statistically significant accuracy loss, and for both models it's 3-bit. Qwen3.5-9B fell from 96% to 76%, with 11 regressions against 1 improvement (p = 0.006). Gemma 4 12B fell off a much steeper edge, from 98% to 4%: 47 of its 50 outputs hit the token limit, and every one of them ends in a repetition loop. Most of Qwen's 3-bit truncations, by contrast, were long, meandering reasoning that never reached an answer. At 2-bit both models are gone.

Gemma's 3-bit row also shows a limit of teacher-forced KL. A KL of 0.48 and 85% top-1 agreement look degraded but not catastrophic, yet accuracy collapsed. Teacher forcing measures one prediction at a time on the baseline's text, so it can't see errors compound the way they do when the model generates on its own and feeds its mistakes back in.

That failure mode matters for anyone serving low-bit models. A model that loops usually won't hand you a confidently wrong number; it will burn the whole token budget and return nothing usable. That's cheap to catch in production if you watch finish reasons, and easy to miss if you only check accuracy on the outputs that finished.

Finding 3: Servers don't match in-process mlx-lm exactly, and that's mostly fine

In March I reported that vllm-mlx produced output identical to mlx-lm on 80 of 80 prompts. With the generation bug fixed, on the 100-prompt reasoning suite, the match for Llama-3.1-8B at 4-bit is 74 of 100, plus 8 more that differ only in leading or trailing whitespace (vllm-mlx drops a final space token when it hits the length limit).

That looks like a regression in the serving layer until you ask what kind of divergence it is. vllm-mlx doesn't return log-probabilities, so I can't say more about it. mlx_lm.server does, which lets infer-check check every divergence for a near-tie:

Model (4-bit)ServerIdentical outputsDivergences that were near-ties
Llama-3.1-8Bvllm-mlx74/100 (82 ignoring whitespace)unknown (no log-probs)
Llama-3.1-8Bmlx_lm.server81/10019 of 19
Qwen3.5-9Bmlx_lm.server30/10070 of 70
Gemma 4 12Bmlx_lm.server23/10077 of 77

Every divergence I could inspect, 166 across three models, was a near-tie. Where prefix KL was available, it was about 0.01 nats per token. That's the signature of a numerically different but correct computation: a batched or cached decode, a different kernel, a different order of floating-point operations. When two candidate tokens are nearly tied, a rounding difference picks the other one, and greedy decoding carries that choice through the rest of the output. Qwen and Gemma match less often partly because they're verbose: 92 of Qwen's 100 baseline outputs ran to the token limit, so each comparison had more positions where a near-tie could occur.

So the March conclusion, that serving with vllm-mlx won't change your outputs, was wrong. The corrected one is narrower: servers change text often, but where I could check, never in a way that points to a bug. Exact text match can't tell those two situations apart. A near-tie check can.

One more lesson came out of this section. An earlier version of the HTTP backend prepended an empty system message to chat requests. On Qwen and Gemma, whose chat templates render a system turn, the server saw 5 more prompt tokens than the in-process model, and only 6 and 4 of 100 outputs matched. I was comparing two different prompts. diff now checks that both sides report the same prompt length and won't give a near-tie verdict when they don't. If you build anything like this, check that first.

Finding 4: Batching changes outputs

The old stress test reported 100% consistency, but it never varied what each prompt shared a batch with. The new one runs each prompt alone, then sends it alongside randomly drawn other prompts and compares token for token. On vllm-mlx with Llama-3.1-8B at 4-bit, using 20 reasoning prompts:

Requests in flightIdentical to solo run
1 (reference)20/20
215/20
414/20
814/20
1613/20

There were no errors at any level, but 25 to 35% of outputs changed once they shared a batch. A separate run on mlx_lm.server isolates the cause: with its default batching, 8 of 24 outputs changed at 4 in flight; with batching turned off, 2 did.

This is the batch-invariance problem. Some kernels reduce in a different order depending on batch size and composition, so the same prompt gets slightly different logits depending on what it's scheduled with, and a near-tie can flip. In the changed outputs I read, the batched run usually took a different route to the same conclusion, sometimes the same wrong one. Asked whether 7919 is prime, the solo run and the batched run both decided it isn't, each citing a different divisor that doesn't actually divide it. (7919 is prime.)

The reasoning suite has no answer keys, so this doesn't tell me how often batching turns a right answer into a wrong one. Running stress on GSM8K is the obvious next experiment.

What holds up

In-process mlx-lm is deterministic as far as these runs can show: every sweep's bf16 self-check reproduced all 50 outputs exactly, with a KL of exactly zero, for all three models. The 20-run determinism test from March predates the generation fix and I haven't rerun it, so I'm only claiming what the self-checks show.

The motivation holds up too. The cross-backend comparisons I surveyed in March measure throughput, and I still haven't found a general-purpose tool that checks whether two engines give the same answers. What changed is my sense of how easy it is to get the measurement itself wrong.

Revised takeaways

Don't judge quantization by text similarity. Grade answers against keys, use hundreds of prompts rather than dozens, and report paired regressions, not only accuracy.

8-bit looked lossless on every model here. 4-bit showed measurable drift and no significant accuracy loss at n = 50, which is a weaker statement than "safe." 3-bit broke both models I tested.

Watch finish reasons. Low-bit models failed by looping, not by returning wrong numbers.

Expect servers and batching to change text. Before calling a divergence a bug, check that both sides saw the same prompt and whether the divergence is a near-tie.

Try it

infer-check is on PyPI and GitHub, with documentation that explains every metric above.

pip install "infer-check[mlx]"

# Grade two quantizations against GSM8K answer keys
infer-check compare \
  mlx-community/Llama-3.1-8B-Instruct-4bit \
  mlx-community/Llama-3.1-8B-Instruct-8bit \
  --prompts gsm8k

# Sweep down from bf16 and find the degradation cliff
infer-check sweep \
  --models "bf16=mlx-community/Meta-Llama-3.1-8B-Instruct-bf16,\
            8bit=mlx-community/Meta-Llama-3.1-8B-Instruct-8bit,\
            4bit=mlx-community/Meta-Llama-3.1-8B-Instruct-4bit" \
  --backend mlx-lm --prompts gsm8k --num-prompts 200

# In-process mlx-lm vs. a local server, with near-tie checks
infer-check diff \
  --model mlx-community/Meta-Llama-3.1-8B-Instruct-4bit \
  --backends "mlx-lm,openai-compat" \
  --base-urls ",http://127.0.0.1:8080" \
  --prompts reasoning

# Does batching change outputs?
infer-check stress \
  --model mlx-community/Meta-Llama-3.1-8B-Instruct-4bit \
  --backend openai-compat --base-url http://127.0.0.1:8080 \
  --prompts reasoning --num-prompts 24 --concurrency 1,4,8

# Shareable HTML report from any results directory
infer-check report ./results/ --format html

What's next

The biggest gap is sample size: the next runs should use the full 1,319-problem GSM8K set, which has enough power to detect a drop of a few points. After that, the roadmap is teacher-forced scoring over HTTP using vLLM's prompt_logprobs, so server comparisons get exact KL instead of the prefix approximation; CUDA backends for vLLM and SGLang; and a CI mode with pass/fail exit codes for catching regressions when an engine or model is upgraded.

The question I started with was whether the tokens are correct. The better question turned out to be whether your measurement of correctness is. I'd rather publish that lesson than leave the March numbers up.