Answers for LLM inference engineers

Why do vLLM or llama.cpp logprobs differ from Transformers, and how much is normal?

Two implementations that both run float32 agree to about 1e-5 nats per token. With fp16 on one side the gap is about 1e-3 on average and 1e-2 at worst; with bf16 it is about 1e-2 on average, and single tokens can be off by 0.1 or more. Those figures come from the measurements on this page and line up with what users have reported for vLLM on GPUs.

A gap larger than the precision explains is usually a setting, not arithmetic. The two sides tokenize the prompt differently, or one returns processed logprobs and the other raw ones, or a server default applies a repetition penalty, or half precision enters through a default: vLLM loads float32 checkpoints in half precision (bf16 on Ampere and newer GPUs since v0.9.1, fp16 on older ones), and llama.cpp's flash attention casts keys and values to F16 even for an F32 model. The tables below list each cause with the version it was verified on, and lpcheck.py tells you which one you have.

Published 2026-11-11 · Corrected 2026-11-12 (vLLM's dtype default) · Measured 2026-11-11 · Verified against vLLM v0.33.0 (vLLM row rechecked on v0.34.0, 2026-11-25), SGLang v0.5.23, llama.cpp b12270 and Transformers 5.22.2 · Corrected 2026-12-05 (lpcheck 1.0.1: generations with missing logprob entries) · Tool version 1.0.1

Corrected on 2026-12-05: lpcheck 1.0.0 could report a greedy split (step G) that did not happen. llama.cpp's llama-server returns no logprob entry for a token that ends inside a UTF-8 character, such as the byte-fallback pieces of a Japanese character: forcing the four-character Japanese string for “candidate” gave 13 generated tokens (usage.completion_tokens) but 5 logprob entries, on b12997. 1.0.0 lined those entries up with the reference position by position, so every later entry was compared with the wrong token. Run against a float64 Transformers reference with a prompt containing a Japanese comment, 1.0.0 reported “earliest split: step 2”, while llama-server's own token ids (from its native /completion endpoint) matched the reference for the first 22 tokens. 1.0.1 compares the number of logprob entries with completion_tokens and leaves a generation out of step G (and out of a reference built from an endpoint) when they differ, with a note naming the prompt. Step S already requests one token at a time and skips positions with no entry. Checked with llama-server b12997 on CPU and a small test model; whether vLLM or Ollama omit entries the same way was not checked.

How much logprob difference is normal?

About 1e-6 to 1e-5 nats per token in float32, about 1e-3 in fp16 and about 1e-2 in bf16. The numbers are the absolute difference in the log-probability of the same token given the same token ids, in nats. The measured rows compare one set of weights against a float64 reference over 512 token positions (method).

Least precise sideMean99th pct.WorstWhere the number comes from
float321.5e-66.7e-61.6e-5Measured here: Transformers in float32.
fp161.8e-39.9e-30.02Measured here: Transformers in fp16. A vLLM user comparing opt-125m in fp16 on one GPU saw 2e-5 to 6.5e-3 over 28 tokens (forum #183).
bf160.0160.0790.23Measured here: Transformers in bf16. A vLLM user with a 1.5B model in bf16 reported one token at −0.668 against −0.602 and a mean relative error near 5% (forum #151).
8-bit weights (GGUF Q8_0)0.0280.220.79Measured here on a 15M-parameter model. Small models lose more to quantization than large ones, so read this as an upper range.
4-bit weights (GGUF Q4_0)0.231.21.7Same model, same caveat.

A second yardstick comes from NVIDIA's NeMo RL, which accepts a new model when the mean of exp(|Δlogprob|) between Hugging Face and vLLM stays at or below 1.05 at equal precision, and reports 1.01 to 1.04 for its own runs. On the measurements here that statistic is 1.000001 for float32, 1.002 for fp16, 1.017 for bf16 and 1.030 for Q8_0.

fp16 keeps 10 mantissa bits and bf16 keeps 7, which is why bf16 comes out about nine times worse here. Qi et al. measured the same direction in RL fine-tuning of a 1.5B model, where fp16 made the mismatch between training and inference engines roughly 24 times smaller than bf16, and vLLM's own FAQ suggests float16 over bfloat16 when stable logprobs matter.

Small gaps still change text. Against the float64 reference, float32 reproduced all 64 greedy tokens on 8 of 8 prompts, fp16 on 7 of 8 and bf16 on 1 of 8. The fp16 flips all sat where the reference's top two candidates were within 0.010 nats of each other. In bf16 the largest margin that flipped was 0.24 nats, about three times the 99th-percentile gap. So "the outputs differ at temperature 0" is not by itself evidence of a bug. A flip where the reference separates its top two tokens by much more than the noise on neighbouring tokens is.

What does "logprob" mean on each engine?

vLLM and llama.cpp return raw model log-probabilities by default. SGLang returns them after penalties and, when sampling, after temperature. Transformers gives either, depending on the field you read. Before comparing numbers, check that both sides compute the same quantity. Each row was read in the source of the version shown.

EngineReturned by defaultSwitch
vLLM v0.33.0, v0.34.0Raw. log_softmax of the model's logits, taken before penalties, logit bias, temperature and top-k/top-p. The model produces the logits in its own dtype; the softmax is taken in float32.--logprobs-mode raw_logprobs | processed_logprobs | raw_logits | processed_logits. Processed means after every processor, including temperature and top-k/top-p. The older V0 engine returned processed values.
SGLang v0.5.23Processed. Logit bias and penalties are applied to the logits first. With greedy decoding the result is log_softmax(logits); with sampling it is the log of softmax(logits / temperature).Environment variable SGLANG_RETURN_ORIGINAL_LOGPROB returns the values before temperature scaling.
llama.cpp server b12270Raw. Softmax of the logits over the whole vocabulary, without the sampler chain. The normalizing sum is accumulated in float32 (see below).Request field post_sampling_probs: true returns probabilities (not logs) after the sampler chain, in prob and top_probs.
Transformers 5.22.2model(ids).logits is raw. In generate(), output_logits=True returns raw logits and output_scores=True returns the processed scores.compute_transition_scores() works on the processed scores.

The practical consequence: a logprob from vLLM at temperature 0.7 is comparable with log_softmax(logits) from Transformers. The same request to SGLang returns log_softmax(logits / 0.7), so the reference has to divide by the temperature too.

The difference has cost real pipelines time. When ServiceNow moved an RL pipeline from vLLM 0.8.5 (V0 engine) to 0.18.1 (V1), the first fix needed to match the old training curves was logprobs-mode: processed_logprobs; turning prefix caching and async scheduling off came next, and computing the output head in float32 closed the last gap.

Which settings change logprobs before rounding does?

Tokenization, sampling defaults read from the model repo, the logprob mode, the dtype default, half-precision paths that are on by default, and the path a number was computed on. The last column is the step of lpcheck.py that exposes each one.

CauseVerified behaviourFixStep
Different tokens inA doubled or missing BOS, a chat template rendered differently, or a tokenizer that splits whitespace differently. In a test for this page, llama.cpp added BOS in front of a ChatML prompt that the Transformers chat template rendered without one. Transformers 5.22.2, building its tokenizer from a SentencePiece tokenizer.model, encoded "Hello  world" (two spaces) as [15043, 259, 11526] where SentencePiece and llama.cpp give [15043, 29871, 3186].Send token ids, not text, when testing numerics. Fix the template or the BOS flag for production.T
Sampling defaults taken from the model repoSince v0.8.0, vLLM uses repetition_penalty, temperature, top_k, top_p and min_p from the model's generation_config.json whenever the request omits them. A repetition penalty still acts at temperature 0. Transformers' generate() applies the same file; a bare forward pass does not.vllm serve --generation-config vllm, or send every sampling parameter explicitly.G
Processed against raw logprobsSee the table above.Make both sides raw, or apply the same processing to the reference.P
dtype defaultsvLLM's --dtype auto keeps fp16 and bf16 checkpoints as saved and downcasts float32 checkpoints to the first dtype the GPU supports: bf16 on compute capability 8.0 and higher (Ampere and later), fp16 on 6.x and 7.x. Up to v0.9.0 float32 checkpoints became fp16 on every GPU, and the --dtype help text still describes that. Transformers 5 loads the dtype the checkpoint was saved in; Transformers 4 loaded float32 unless told otherwise. vLLM computes the output head in the model dtype unless started with --hf-overrides '{"head_dtype": "float32"}'.For a strict test run both in float32: vllm serve --dtype float32.S
Half precision inside an F32 llama.cpp runWith flash attention on (the default, auto), llama.cpp casts K and V to F16 before attention even when the KV cache is stored as F32. The KV cache type itself defaults to F16.llama-server -fa off -ctk f32 -ctv f32S, C
Normalizer precision in llama.cppThe server normalizes with a float32 running sum over the vocabulary. Every token at a position shifts by the same constant, up to 1.0e-3 nats here, while the gaps between tokens stay accurate to 2.6e-5.Compare gaps between tokens, or subtract the shared offset. lpcheck reports the two parts separately.S
Decode path against scoring pathGenerated-token logprobs come from incremental decoding with a KV cache. Prompt logprobs come from one prefill pass; vLLM recomputes that pass and ignores the prefix cache when prompt logprobs are requested. The two paths differ by 1.4e-5 at most in float32 Transformers, 0.097 in bf16, and 0.025 on llama.cpp with default flags.Compare like with like. For RL, score with the path that produced the rollout.C
Values attached to the wrong tokenA llama-cpp-python user found per-token logprobs lined up with Transformers only after shifting by one position (issue #1983).Check alignment before reading magnitudes.S
Batch and cache effectsThe same request can return different logprobs under load or after a cache hit.See vLLM batch invariance: what still breaks determinism.–

Measured: the same weights in three implementations

The model is TinyStories 15M (stories15M.bin from llama2.c, sha256 cd590644…f49a), a 6-layer Llama-architecture model with a 32,000-token vocabulary. It is small enough to run in float64. The reference is a NumPy forward pass in float64 written from the architecture alone (np_ref.py), so it does not share code with any engine. The same weights were loaded into Transformers 5.22.2 (torch 2.15.0, CPU) and converted with llama.cpp's convert_hf_to_gguf.py for llama-server b12270 (official Linux x64 build, CPU with AVX-512, 2 threads). Eight prompts, 64 greedy tokens each, top-5 logprobs at every position, all fed as token ids.

Transformers against float64

dtypeMean99th pct.WorstMean exp(|Δ|)Top-1 agreementGreedy prompts identicalDecode vs full forward, worst
float64 (.double())2.8e-72.1e-66.6e-61.000000512 of 5128 of 81.5e-14
float321.5e-66.7e-61.6e-51.000001512 of 5128 of 81.4e-5
fp161.8e-39.9e-30.021.002509 of 5127 of 80.022
bf160.0160.0790.231.017501 of 5121 of 80.097

float64 is the model after .double(). It is not exact, because Transformers computes the rotary position angles in float32 whatever the model dtype.

llama.cpp server against float64

GGUFServer flagsMean99th pct.WorstShared offset, worstShape spread, worstTop-1 agreementGreedy prompts identicalDecode vs scoring, worst
F32-fa off -ctk f32 -ctv f321.5e-47.9e-41.0e-31.0e-32.6e-5512 of 5128 of 85.0e-6
F32default8.9e-46.4e-30.0310.0240.028512 of 5128 of 80.025
F16-fa off -ctk f32 -ctv f326.6e-43.6e-39.4e-35.5e-30.012512 of 5128 of 85.2e-6
F16default1.2e-37.7e-30.0190.0260.028511 of 5127 of 80.024
BF16-fa off -ctk f32 -ctv f327.2e-30.0470.0540.050.1510 of 5126 of 80.056
BF16default7.4e-30.0450.0840.130.13508 of 5124 of 80.036
Q8_0-fa off -ctk f32 -ctv f320.0280.220.790.370.84493 of 5121 of 80
Q8_0default0.0270.20.760.310.9497 of 5121 of 80.11
Q4_0-fa off -ctk f32 -ctv f320.231.21.72.82.8427 of 5120 of 80
Q4_0default0.231.32.12.72.7426 of 5120 of 80.014

Three things stand out.

  1. An F32 GGUF is not a float32 run by default. With default flags the F32 model lands in the same range as the F16 model. Switching attention to F32 (-fa off -ctk f32 -ctv f32) brings the shape of the distribution within 2.6e-5 of float64. Changing only the cache type has no effect, because flash attention casts K and V to F16 on its own (src/llama-graph.cpp); the two configurations gave identical numbers.
  2. What remains is a constant per position. In the all-F32 run, the whole 1.0e-3 gap is an offset shared by the five top tokens at a position. Summing the probabilities the server returned for all 32,000 tokens gave 0.99904 at one position and 1.00018 at another, the same amounts as the offsets there. The server accumulates its normalizer in a float (get_token_probabilities() in tools/server/server-common.cpp), and thousands of the terms are near or below the rounding step of the running sum. Re-adding the same terms with a float32 running sum in NumPy reproduced the offsets at three positions to three digits (−9.65e-4, −6.87e-4, +1.84e-4). Token ranking and gaps between tokens are unaffected.
  3. The engine disagrees with itself along two paths. With default flags, the logprob of a token produced during generation and the logprob of the same token when the same prefix is sent as a prompt differ by up to 0.025 nats. With attention in F32 the two paths agree to 5.0e-6. The llama.cpp README says as much about cache_prompt: logits are not guaranteed to be identical between prompt processing and token generation.

Not measured here: vLLM and SGLang (no GPU on the test machine), and models larger than 15M parameters. K-quants are missing because llama-quantize falls back from them when the hidden size (288 here) is not a multiple of 256. The rows are also available as JSON, and the viewer below shows four reports from the same setup taken against the Transformers float32 reference.

Check your own setup with lpcheck.py

lpcheck.py is one Python file. Against an endpoint it needs only the standard library; with a Hugging Face reference it needs torch and transformers. It sends token ids, so tokenization cannot leak into the numeric comparison, and it has the candidate score the reference's own continuation, so every position is compared on identical context even after greedy outputs split.

curl -O https://erimaki-kobo.github.io/en/engine-logprob-parity-check/lpcheck.py

# Transformers (float32) as the reference, a running server as the candidate
python lpcheck.py --ref-hf Qwen/Qwen3-0.6B --base-url http://localhost:8000/v1

# build the reference where the GPU is, test somewhere else
python lpcheck.py --ref-hf ./model --save-ref ref.json
python lpcheck.py --ref-file ref.json --base-url http://localhost:8080/v1 --json report.json

# two servers: old version against new, or vLLM against llama.cpp
python lpcheck.py --ref-url http://localhost:8000/v1 --base-url http://localhost:8001/v1

# no server at all: what does bf16 cost this model?
python lpcheck.py --ref-hf ./model --cand-hf ./model --cand-dtype bfloat16

Output from a real run: Transformers 5.22.2 in float32 as the reference, llama-server b12270 with default flags and the F32 GGUF of the same weights as the candidate.

lpcheck 1.0.0
reference: hf:./stories15M  dtype=float32  model=./stories15M
candidate: http://localhost:8080/v1/completions  model=stories15M-f32.gguf  api=llamacpp
prompts=8  tokens per prompt=32  top-k=5

[T] tokens in      7 of 8 prompts tokenize to the reference ids
      code      first difference at token 9: reference [1125, 13, 268, 15945, 29908, 11609] (25 tokens), candidate [1125, 13, 1678, 9995, 11609, 278] (24 tokens)
[P] meaning        returned logprobs vs temperature: unchanged | top_p: unchanged | repetition penalty: unchanged | greedy vs sampling: unchanged
      the endpoint returns raw model logprobs: sampling parameters do not change them.
[G] greedy         8 of 8 prompts give the reference tokens for all 32 steps
      while the tokens agree (256 steps): |dlogprob| mean 7.40e-04  p99 4.78e-03  max 5.08e-03
[S] same tokens    256 positions scored on identical context (stepwise)
      |dlogprob| of the reference token   mean 9.51e-04  p50 5.12e-04  p99 6.88e-03  max 1.38e-02
        offset shared by the top-5 at a position (normalizer)   mean 1.08e-03  max 1.03e-02
        spread left after removing it (shape)                  mean 3.59e-03  max 1.45e-02
      mean exp(|dlogprob|)                1.00095   (tolerance 1.050)
      top-1 agreement                     256 of 256 (100.0%); flips: 0 at near-ties, 0 with a clear reference margin
      KL(reference || candidate), top-5 + rest   mean 1.48e-06  max 1.61e-05 nats
[C] self           candidate decode path vs its stepwise path, same tokens (256 steps): mean 1.02e-03  max 8.70e-03
                   reference KV-cache decode vs full forward, same tokens (256 steps): mean 1.40e-06  max 7.35e-06

VERDICT: NOT_THE_SAME_COMPUTATION
The two sides differ before numerics come into it:
  - TOKENS_IN: the candidate turns the same prompt text into different token ids, so a text prompt is not the same input on both sides. Steps G and S send token ids, so their numbers are not affected by this.
With token ids pinned, the numbers themselves are within tolerance: mean exp(|dlogprob|) 1.00095, largest gap 1.38e-02 nats.
Scale (mean |dlogprob|, one 15M model on CPU against float64, see the page): float32 1.5e-06, fp16 1.8e-03, bf16 1.6e-02, Q8_0 2.8e-02, Q4_0 2.3e-01. Here: 9.51e-04.

report written to report.json

The run found a tokenizer difference on one prompt (step T) and nothing wrong with the numbers once ids were pinned. Exit status is 0 for identical or within tolerance, 1 for a numeric gap beyond tolerance, 3 when the two sides are not computing the same thing, and 2 when the check could not run, so it can gate an engine upgrade in CI. If production sends token ids too, add --no-tokens-check so a tokenizer difference does not fail the gate.

StepWhat it doesWhat a finding means
T tokens inTokenizes each prompt on the candidate (/tokenize; with --chat, the rendered chat prompt) and compares ids with the reference.Text prompts are not the same input. Everything after this step uses ids.
P meaningRequests one token at temperature 1 and 0.5, top_p 1 and 0.2, repetition penalty 1 and 1.5, and compares the returned top-k.If the values move, the endpoint returns processed logprobs.
G greedyGenerates from the reference's prompt ids at temperature 0.Where outputs split, and how close the reference's top two tokens were there. Also flags a token that is not the top-1 of the logprobs returned with it, the mark of a penalty or bias applied by the server.
S same tokensScores the reference's continuation on the candidate: one request with prompt_logprobs on vLLM, one request per token elsewhere.The gap on identical context, split into an offset shared by all top-k tokens at a position and the spread that is left. Also checks for unnormalized values, a temperature-like slope, a penalty on tokens already in the context, and a one-position shift.
C selfCompares the candidate's logprobs from step G with its own from step S.The candidate's noise floor. A gap to the reference of the same size is not the reference's fault.

Read a report token by token

Open a report written with --json, or one of the reports behind the tables above. Each token is shaded by its gap to the reference on a log scale; outlined tokens are top-1 flips. Nothing is uploaded.

Are my endpoint's logprobs raw or processed?

This runs step P from the browser: seven one-token requests to /completions. Requests go straight from this page to the URL you enter.

A network error means the server refused a cross-origin request or is a plain http:// host other than localhost. llama.cpp accepts any origin by default. vLLM v0.32.0 and later refuse cross-origin requests unless started with --allowed-origins '["https://erimaki-kobo.github.io"]'; v0.31 and earlier accepted them. The command-line script has no such limit.

How do I read the verdict?

IDENTICAL
Every compared logprob matched to the last printed digit. Expect this only between two instances of the same build on the same hardware.
WITHIN_TOLERANCE
Same tokens in, same meaning, mean exp(|Δlogprob|) at or below the tolerance (1.05 unless you change --max-mult-err), and every top-1 flip at a near-tie. Compare the printed mean with the table at the top to see which precision the gap corresponds to. For a float32-against-float32 check, tighten the tolerance: --max-mult-err 1.0001.
NUMERIC_GAP
The inputs and the meaning match, and the numbers still disagree by more than the tolerance, or a token flipped where the reference's margin was more than four times the 99th-percentile gap. Look at the weights first (quantization, revision, an adapter left on), then at the dtype of each side, then at the engine version.
NOT_THE_SAME_COMPUTATION
One or more of: different token ids for the same text, values that are not log-probabilities, a temperature-like slope, a penalty inside the logprobs, a token chosen at temperature 0 that is not the top-1, or a one-position shift. Each is a setting. The report still prints the numeric gap with ids pinned, so you can see whether anything is left after the setting is fixed.

How do I make two engines agree?

  1. Pin the input. Send token ids. If production sends text, fix the BOS flag and the chat template until step T passes.
  2. Neutralize the sampler. Temperature 0, repetition penalty 1, no logit bias. On vLLM start with --generation-config vllm so the model repo cannot add defaults.
  3. Make the meaning match. vLLM returns raw logprobs unless --logprobs-mode says otherwise. For SGLang at a temperature other than 1, divide the reference logits by the temperature or set SGLANG_RETURN_ORIGINAL_LOGPROB. On llama.cpp leave post_sampling_probs off. In Transformers use the logits, not the scores.
  4. Match the precision. Load both sides in the same dtype. For a strict test use float32 on both: --dtype float32 on vLLM, -fa off -ctk f32 -ctv f32 on llama.cpp.
  5. Compare the same path. Scoring-path numbers against a full forward pass, decode-path numbers against cached generation.
  6. Accept the floor. After all of that, 1e-5 in float32, 1e-2 in fp16 and 1e-1 in bf16 on single tokens are what the arithmetic leaves. Exact agreement needs the two sides to share kernels: the vLLM team reports bitwise-identical rollout and training logprobs after making the training forward pass call vLLM's own inference kernels.

What can this not tell you?

Related tools

Questions

Is it normal for vLLM logprobs to differ from Hugging Face Transformers?

Yes, within the precision of the run. Different kernels round differently, so two correct implementations of the same model do not return identical floats. In float32 the gap is around 1e-6 to 1e-5 nats per token; in fp16 around 1e-3; in bf16 around 1e-2 with occasional tokens off by 0.1 or more. A gap well beyond the row for your precision points at a setting or at different weights.

How much logprob difference is acceptable?

It depends on what you do with the numbers. For evaluation and ranking, gaps of the size your precision explains are fine, because token gaps move far less than absolute values. NVIDIA NeMo RL treats a mean exp(|difference|) up to 1.05 between Hugging Face and vLLM as acceptable at equal precision. For reinforcement learning, where a ratio of probabilities multiplies every gradient, a few tokens with large ratios matter more than the mean.

Why does vLLM give different text than Transformers at temperature 0?

Usually for one of four reasons: the prompt became different token ids (BOS, chat template); vLLM applied sampling defaults from generation_config.json, such as a repetition penalty, that your Transformers call did not; the two ran in different dtypes (vLLM runs float32 checkpoints in half precision by default: bf16 on Ampere and newer GPUs, fp16 on older ones); or the logits differ by rounding and a near-tie tipped the other way. Greedy decoding amplifies the last one: after the first different token the two texts are different continuations.

Are vLLM logprobs computed before or after temperature and top-p?

Before, by default. The V1 engine returns log_softmax of the raw logits, taken before penalties, temperature and top-k/top-p. Start the server with --logprobs-mode processed_logprobs to get the values after all processors. The older V0 engine returned processed values, which is why numbers changed for some users after upgrading.

Why are llama.cpp logprobs off by the same amount for every token at a position?

The server converts logits to probabilities with a float32 running sum over the whole vocabulary. The sum is slightly off, so every token at that position shifts by one constant: up to about 1e-3 nats in the measurement on this page. Differences between tokens at the same position are unaffected.

Does this page see my prompts, reports or API key?

No. The page is static. The report viewer reads the file in your browser, and the probe sends requests from your browser directly to the base URL you enter. Nothing is stored or sent anywhere else.

Sources