Model and Inference EngineeringEnd-to-end serving and modalitiesStaff
What does a sampling seed guarantee when a model moves between inference engines?
By Amit Kumar3 min readWorked answer includedReviewed 28 Sept 2026
The question
Interview question
A model moves to another inference engine with apparently identical weights, prompt, temperature, top-p and seed, but sampled text changes. Explain what the seed controls, isolate distribution changes from random-number scheduling changes, and propose the provenance and tests required for any reproducibility promise.
Draft your approach first
Take a few minutes before you read the answer. Name the constraint that matters most, the failure you are designing for and how you would know it worked.
Reveal the worked answerWorked answer
A seed initializes a particular random-number path. It is not a cross-engine contract for which random numbers are drawn, how they are assigned to requests, or how candidate tokens are filtered. Different samplers may consume draws in another order, use different RNG algorithms or apply temperature and top-p with slightly different numerical kernels. A batched server may also schedule requests differently. vLLM's sampling parameters define a seed alongside temperature and filtering options, but that does not promise byte-identical output to another engine. More importantly, the model first produces logits, raw next-token scores converted into probabilities by the sampler. If those scores differ before any random draw, blaming the random generator misses the earlier fault.
A pseudo-random number generator, or PRNG, is a deterministic state machine that produces a sequence of values from its initial seed. Imagine the sequence starts 0.2, 0.8, 0.4. A server assigning its first draw to request A and its second to B gives A 0.2. A different batch order can give A 0.8 instead. A request-local generator avoids that particular interference, but different generator algorithms, candidate ordering or draw counts can still map the same seed to different sampled tokens.
I would separate the stages. Compare exact token IDs, chat template, position IDs, masks and model revision. Run a fixed prompt at greedy temperature to compare prefill logits and the first next-token choice, recognizing that even greedy behavior can flip on a near tie under different numerical layouts. Then capture a few steps of processed logits, top-k/top-p candidate sets, renormalized probabilities and sampled token for the same requests. Confirm how each engine interprets zero temperature, minimum probabilities, stop tokens and any hidden default. An API surface with the same field names can still implement different effective distributions.
If the product requires reproducible sampling, define the supported scope explicitly: engine build, kernels, device type, batch policy and request ordering. A per-request RNG state can reduce interference from other requests, but it cannot by itself align different algorithms. Persisting the seed without the sampler version is weak provenance. If the goal is quality rather than replaying exact bytes, compare distributional outcomes on a large task set, including tool correctness and refusal behavior. A text diff of two sampled answers is not a meaningful regression test by itself.
One useful diagnostic is to feed exactly the same logit vector to both sampling implementations. If the candidate set or chosen-token distribution differs, isolate the sampler. If they agree on that vector but actual serving differs, investigate the model or prompt path. The same weights and greedy decoding give different tokens on eight GPUs. Is that a bug? asks why greedy outputs differ across GPU layouts because of floating-point computation. This question holds a seed in the story and asks what the seed does and does not make deterministic in a new sampler.
Related questions
Keep practising model and inference engineering
Follow another question in this area, or search the complete library.
Get my essays on AI engineering and distributed systems by email. Subscribe to ArchCrux