Answers for LLM inference engineers

vLLM batch invariance: what still breaks determinism, and how to test your endpoint

VLLM_BATCH_INVARIANT=1 makes a dense model on one GPU reproducible at temperature 0. It does not yet cover everything people run in production. As of November 2026, vLLM issues report divergence with the flag set for MLA models under chunked prefill (still open). Divergence for fused MoE experts with online FP8 (fixed in v0.33.0), AWQ models in compiled mode (fixed in v0.32.0) and tensor parallelism combined with sequence parallelism (turned off under the flag from v0.31.0) was reported and fixed. Speculative decoding is outside the guarantee, and two newer model families refuse to start with the flag. The table below lists each case with its issue number. The tool underneath checks your own endpoint from the outside: it varies load, batch composition and prefix-cache state, and can compare two servers token by token.

Published 2026-11-10 · Status table as of 2026-11-12 · Updated 2026-11-11 (browser access on vLLM v0.32 and later) · Corrected 2026-11-12 (MoE FP8, AWQ and sequence-parallel rows: fixes released in v0.31–v0.33) · Corrected 2026-12-05 (tool 1.0.1: llama.cpp logprobs) · Tool version 1.0.1

Corrected on 2026-12-05: detcheck 1.0.0 did not read the logprobs that llama.cpp's llama-server returns on /v1/completions (a choices[0].logprobs.content[] list, the shape other servers use for chat). It fell back to comparing text, so it could print NO_DIVERGENCE_OBSERVED for a server whose logprobs do move. 1.0.1 (script and browser tool) reads both shapes on both endpoints, and says so when logprobs were requested but none it can read came back. Checked on CPU with llama-server b12997 and a small Q4_K_M test model (--completions --runs 16 --concurrency 1,8 --max-tokens 128): started without -np (four slots sharing one KV cache, kv_unified = 'true' in the log), 1.0.0 printed NO_DIVERGENCE_OBSERVED with compare=text, and 1.0.1 printed LOGPROB_DRIFT (max |Δlogprob| 4.2e-07 under load, 1.3e-02 in mixed traffic, 2.7e-02 cold versus warm). Started with -np 4 (kv_unified = 'false'), the load and mixed probes showed no drift at all (NO_DIVERGENCE_OBSERVED with --probes load,mixed); with all probes, the cache probe still showed 3.6e-07, so the verdict was LOGPROB_DRIFT for “cache warm-vs-cold” only. These are CPU results; the GPU build was not tested. See llama.cpp: set -np.

Where does batch invariance hold on vLLM, and where does it break?

Each row cites the public report it comes from. "Reported" means a user measured it on the version shown; it may be fixed on a later version, which is the reason to test your own build.

ConfigurationWith VLLM_BATCH_INVARIANT=1EvidenceProbe
Dense model, one GPU, bf16, on the validated list (Qwen3, Llama 3.1/3.2, Mistral-7B, Phi, Gemma 2 and others)HoldsvLLM docs, Batch Invariance; CI tests. NVIDIA compute capability 8.0+, AMD Instinct, or Intel XPU with TRITON_ATTN.load
Tensor parallel, no sequence parallelismHolds with a conditionTP=4 bitwise clean in #56370. Docs: all-reduce sizes must be a multiple of 16 bytes, which every validated model satisfies.load, mixed
Tensor parallel + sequence parallelism or async TP (enable_sp, fuse_gemm_comms)Broke on v0.29.0; turned off under the flag from v0.31.0#56370: Qwen3-1.7B, TP=4, batch 1 vs 64: greedy output changed for 17 of 64 prompts. Issue closed; PR #56377 (first in v0.31.0) turns sequence parallelism and async TP off when the flag is set and adds a TP regression test.load
Pipeline parallelNo statementNot mentioned in the docs or the tracking issue #27433. Data parallel is declared out of scope there.load, mixed
MoE with experts quantized online to FP8 (--quantization fp8, Triton fused-MoE)Fixed in v0.33.0 (broke without warning before)#57016: granite-3.1-1b-a400m, Qwen1.5-MoE-A2.7B, DeepSeek-V2-Lite on RTX 4090, H100 and RTX 5090 (v0.27.1 and main). Output depends on the content of the other requests in the batch. A block-scaled FP8 checkpoint (Qwen3-30B-A3B-FP8) passed.mixed, cache
MoE with MXFP4 experts on Blackwell (DeepSeek-V4-Flash)Refuses to start#53436: NotImplementedError: No MXFP4 MoE backend supports the deployment configuration.–
Sparse MLA (GLM-5.3)Refuses to start; not invariant when forced#65278 (open, 2026-11-03): with the refusal bypassed, 32 of 32 prompts differ between batch 1 and batch N. Root cause not established.load
MLA with TRITON_MLA under chunked prefill (DeepSeek-V2-Lite, DeepSeek-V3.1)Breaks#60007 (open, fix PR #60122 open): splitting one prompt's prefill into chunks moves logprobs by about 1e-3 and flips a token by decode step 9. FLASHINFER_MLA is not supported at all (#27433).mixed, ab
Speculative decoding (draft model, n-gram, MTP, EAGLE)Not coveredListed as an unchecked item in #27433 (feature request #52522). #54506: the verify pass over k+1 tokens and plain one-token decode are not guaranteed to produce the same bits. The vLLM docs promise losslessness only up to floating-point precision. To tell a near-tie flip from a bug: Is speculative decoding lossless?ab
Prefix cachingMostly holdsWithout the flag, a warm (cached) request and a cold one differ: up to 4.6e-2 in logprob on H100 in #40896; with the flag, bit exact in that test. The flag disables prefix caching on FLASHINFER and TRITON_MLA. No CI test covers cold versus warm (#27433), and the MoE and AWQ rows here failed on it.cache
AWQ weights in the default compiled mode (Qwen3-8B-AWQ, sm8x)Fixed in v0.32.0 (broke on v0.27.1 and v0.29.0)#59086 (opened 2026-09-28): a co-batched request flips the greedy token at position 4; --enforce-eager is clean. Closed 2026-10-20: no longer reproduces after PR #52231, which also overrides the aten::mm.out/addmm.out calls the compiler emits (first in v0.32.0). PR #60479 (GPTQ layers, which ran Marlin under the flag) is merged on main but not in v0.33.0.mixed, cache
Many co-resident sequences (about 44 or more)Fixed in v0.27.0#51187: on v0.26.0 logprobs changed between repeats of the same workload; RMSNorm fix #48391.load
Embedding and pooling modelsReported not invariantUser report in #27433; the only workaround given is --max-num-seqs 1.–

Cost of the flag: a contributor measured about 30% lower throughput on an RTX 4090 D and 35% on an H20 in compiled mode (comment in #27433). The docs give no figure. It has not been measured for this page.

Test your own endpoint

The test is black-box: it only needs the OpenAI-compatible API, so it works the same way whether the server runs TP, an MoE model or speculative decoding. Requests go straight from this page to the URL you enter.

A network error means the server does not accept cross-origin requests from this page, or it is a plain http:// host other than localhost (browsers block that from an HTTPS page). vLLM v0.31 and earlier accept any origin by default; v0.32.0 and later refuse cross-origin requests unless the server is started with --allowed-origins '["https://erimaki-kobo.github.io"]'. llama.cpp accepts any origin by default. Otherwise use the command-line script, which has no such limits.

What do the four probes measure?

ProbeWhat it sendsWhat a difference means
baselineThe prompt N times, one request at a time. The most common output becomes the reference.Not reproducible even alone: shared endpoint, mixed replicas, or non-greedy decoding.
loadThe same prompt N times at each higher concurrency level.The result depends on batch size.
mixedThe same prompt N times, interleaved with three times as many other prompts of six different lengths.The result depends on what else is in the batch, not only how much. This is the case behind the MoE FP8 and AWQ reports.
cacheA prompt with a random session id, so its prefix cannot be cached, sent once cold and twice more warm. Eight such prompts.A cache hit takes a different numeric path than a full prefill.
abFour prompts (the default, a two-character one, a repetitive one and a long one) twice on each of two endpoints.The two deployments are not interchangeable: speculative decoding on versus off, TP 1 versus TP 4, eval server versus production, old version versus new.

Every comparison is made on tokens and, when the server returns them, on the logprob of each generated token. Identical tokens with different logprobs is a finding: the numerics already vary, and the text has not changed only because no near-tie was hit. Several of the issues above were first seen that way.

How do I read the verdict?

No divergence observed
Every completion matched the baseline in tokens and logprobs. That is evidence, not proof. In the Thinking Machines experiment the first 102 tokens of 1,000 completions were identical, so use long outputs and your real peak concurrency before relying on a clean result.
Logprob drift
Tokens matched but logprobs moved in at least one probe. The server is not invariant under that condition. Expect token flips on other prompts or longer outputs.
Token divergence
The generated text changed in the probes listed. The report shows the earliest split and the logprob gap between the top two candidates there. A gap of a few thousandths of a nat is a near-tie tipped by rounding. A large gap points at something structural, such as a different quantization scale or a different kernel.
Nondeterministic at baseline
Outputs differ for identical sequential requests. Fix or explain this first; the other probes cannot be interpreted until the baseline is stable.

Run it from the command line or in CI

detcheck.py is the same test as one Python file with no dependencies (standard library, Python 3.8+). Exit status is 0 when nothing diverged, 1 when tokens diverged, 3 when only logprobs drifted and 2 when it could not run, so it can gate a deployment.

curl -O https://erimaki-kobo.github.io/en/llm-determinism-test/detcheck.py

# all probes against a local server, model auto-detected
python detcheck.py --base-url http://localhost:8000/v1

# is the server with speculative decoding equivalent to the one without?
python detcheck.py --base-url http://localhost:8000/v1 --against http://localhost:8001/v1

# more thorough, with a JSON report
python detcheck.py --base-url http://localhost:8000/v1 --runs 64 \
  --concurrency 1,8,32,64 --max-tokens 500 --json report.json

Report format (from a mock server built to flip one near-tied token when different prompts share a batch; not a measurement of a real engine):

probe                    ok  err  unique  differ  shared prefix  max |dlogp|
baseline c=1             24    0       1       0              -            0  identical
load c=8                 24    0       1       0              -            0  identical
mixed c=8                24    0       2       7       8 tokens            0  TOKENS DIFFER
cache warm-vs-cold        8    0       1       0              -            0  identical

VERDICT: TOKEN_DIVERGENCE
Generated tokens changed in: mixed c=8.
Earliest divergence (mixed c=8): the first 8 tokens are identical, then:
  reference: ' Queens, New York.'
  other:     ' New York City.'
  reference top-2 there: ' Queens' (-0.6921) vs ' New' (-0.6942); gap 0.0021 nats

llama.cpp: why -np matters

Started without -np, llama-server (b12997) creates four slots that share one KV cache, and in our CPU test the logprobs of a request moved with the other requests running beside it. With -np set explicitly the cache is per slot and the drift went away. The startup log shows which mode you have: kv_unified = 'true' or 'false'. Use -np 1 if one client uses the server, or -np N for N concurrent requests, and test with --completions:

llama-server -m model.gguf -np 4 --port 8080
python detcheck.py --base-url http://localhost:8080/v1 --completions --max-tokens 128

Measured on CPU only, with a 5M-parameter test model in Q4_K_M; numbers and the effect on a GPU build can differ. Which kernel produces the difference was not investigated.

Why does the same prompt give different outputs at temperature 0?

Temperature 0 makes token selection deterministic, not the logits. Floating-point addition is not associative, and GPU kernels for matrix multiplication, normalization and attention choose their reduction strategy from the tensor shape. The shape depends on the batch, and the server builds batches from whatever is in flight. Same request, different batch, slightly different logits. At a near-tie the argmax flips, and from that token on the two generations are different texts.

Thinking Machines Lab measured this in September 2025: 1,000 completions of one prompt at temperature 0 on Qwen3-235B produced 80 distinct outputs, with the first 102 tokens identical in all of them. With batch-invariant kernels for RMSNorm, matrix multiplication and attention, all 1,000 were identical. vLLM shipped that idea as VLLM_BATCH_INVARIANT=1.

Batch size is only one axis. The reports in the table add four more: the content of the neighbours (one activation scale shared by a whole batch), cache state (one-token prefill versus full prefill), how a prompt is chunked, and how many tokens the model verifies at once under speculative decoding. A fixed seed helps with none of them: at temperature 0 there is no sampling left for it to control.

How do I make inference deterministic?

  1. Turn the flag on: VLLM_BATCH_INVARIANT=1 vllm serve <model>. For an online server this is the only supported route; VLLM_ENABLE_V1_MULTIPROCESSING=0 applies to offline use. The feature is in beta, and reproducibility is promised only on the same hardware and the same vLLM version.
  2. Check your configuration against the table. If you run MLA with chunked prefill, online FP8 on an MoE model before v0.33.0, AWQ in compiled mode before v0.32.0, or sequence parallelism before v0.31.0, the flag alone was not enough on the versions reported.
  3. Run the probes before and after. A clean dense-model result does not transfer to your MoE or TP deployment.
  4. Treat speculative decoding as a different deployment. Run the A/B probe against a server without it. If the outputs differ, evals taken on one do not describe the other.
  5. If you cannot get invariance (hosted API, unsupported model): compare outputs semantically instead of byte for byte, cache responses you need to replay, and report evals as a mean over several runs.

Other engines: SGLang has --enable-deterministic-inference, which was bit exact in the cold-versus-warm test in #40896; the LLM-42 paper measured its overhead at up to 56%. A server that processes one request at a time has no batch to vary and should pass the load and mixed probes.

What can this test not tell you?

Related tools

Questions

Does temperature 0 guarantee the same output every time?

No. Temperature 0 means the server picks the highest-scoring token. The scores can change by tiny amounts when the batch, the cache state or the decoding path changes, and a tiny change at a near-tie picks a different token.

Is VLLM_BATCH_INVARIANT=1 enough to make vLLM deterministic?

For a validated dense model on one supported GPU, yes, on the same hardware and vLLM version. As of November 2026 it is not enough for speculative decoding or MLA models under chunked prefill. It was not enough for MoE experts quantized online to FP8 before v0.33.0 or AWQ models in compiled mode before v0.32.0, and some newer models refuse to start with the flag.

Does speculative decoding change the output at temperature 0?

It can. The algorithm is lossless in exact arithmetic, but the verify pass processes several tokens at once while plain decoding processes one, and vLLM does not guarantee the two produce identical bits (issue #54506). Compare a server with speculative decoding against one without, using the A/B probe.

Why does the first request after a restart differ from later identical requests?

Prefix caching. The first request computes the whole prompt; later ones reuse cached keys and values and compute only the tail, which is a different numeric path. Disabling prefix caching or enabling batch-invariant mode removed the difference in the reports cited above.

How many requests do I need?

Start with the defaults: 32 per level and 200 tokens. If that is clean, raise max_tokens to 500 or 1,000 and set the top concurrency level to your real peak. Longer outputs matter more than more requests, because every generated token is another chance to hit a near-tie.

Does this page see my API key or prompts?

No. The page is static. Requests go from your browser directly to the base URL you enter, and nothing is stored or sent anywhere else.

Sources