LLMs
Determinism and reproducibility
Why the same prompt at temperature 0 can still give different answers.
What it is and why it exists
Production inference batches your request with others; floating-point arithmetic on GPUs isn’t associative, and batch composition changes the order of operations, so logits differ slightly and greedy decoding can diverge. Model updates behind an alias change outputs too.
Quick prototype
Rerun and hope.
In production, at scale
Pin dated model versions, store prompts, parameters and outputs for every call, run evals several times and report variance, and design tests around properties (schema valid, contains the right ID) instead of exact strings.
Vendors and tools
| seed parameters | Best-effort reproducibility where offered |
|---|---|
| Recorded fixtures (VCR-style) | Replay stored responses in tests |
How it fails
- Golden tests comparing exact strings
- Silent behaviour changes when an unpinned alias moves
What the interviewer asks next
How do you test code that calls an LLM?
Mock or replay recorded responses for unit tests, assert on properties not exact text, and keep a separate eval suite that runs the real model and tracks scores over time.