frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Open in hackernews

Defeating Nondeterminism in LLM Inference

https://thinkingmachines.ai/blog/defeating-nondeterminism-in-llm-inference/
106•jxmorris12•3h ago

Comments

measurablefunc•2h ago
I think this means that the results might also be non-deterministic across hardware revisions b/c I don't think they verified that the kernels will work the same on different GPU & TPU versions b/c how do they know that the compiler will not re-order the operations behind their back?
TimorousBestie•2h ago
Ensuring the same floating-point algorithm workload behaves exactly the same on two distinct workstations is a heck of a lot of work that almost no one is willing to pay for.
measurablefunc•2h ago
Not only that but heterogeneous clusters (inevitable at a large enough scale) will also have non-deterministic outputs. So it's great that they wrote kernels to make the forward pass deterministic but getting rid of it entirely at data center scale would mean that they'd also have to do this type of work across cluster nodes as well to maintain "cluster" invariance & not just batch invariance.
reliabilityguy•2h ago
> will not re-order the operations behind their back?

Valid point. Floating point summation is not always commutative.

AlotOfReading•2h ago
You can prevent reordering with sufficient amounts of compiler abuse.

With revisions, you're trying to ensure a consistent floating point environment where the operations used are deterministic, and used in the same order with the same inputs. The best way to do that is to use operations that adhere to a mostly deterministic standard like IEEE-754.

saagarjha•2h ago
Yes, there’s usually no guarantee on how different hardware does operations (for example, even if the hardware is correctly rounding intermediate results, different hardware may use different tile sizes). The reproducibility here is for runs on the same machine.

Compilers can also reorder operations but in practice this is rarely an issue because kernels typically synchronize frequently and this limits the ability for compilers to reorder things. This isn’t to say it doesn’t happen, but even if it does happen it’s likely because the compiler changed because the code they generate is generally run-to-run identical.

lrvick•2h ago
Job one is have every bit of software involved also be deterministic, which stagex takes care of.

I had no problem getting deterministic LLM outputs when I experimented with this 6 months ago.

Run two of these with the same prompts and same seed and you get the same results.

Obviously in GPU clusters with different hardware things get more complicated.

https://git.distrust.co/public/llmshell

saagarjha•2h ago
What’s stagex?
spindump8930•2h ago
That's not what this is about.

"I had no problem getting deterministic LLM outputs when I experimented with this 6 months ago" looks like you're using llama-cpp in that repo. This is about vllm serving many requests at once, at long sequence lengths.

> As it turns out, our request’s output does depend on the parallel user requests. Not because we’re somehow leaking information across batches — instead, it’s because our forward pass lacks “batch invariance”, causing our request’s output to depend on the batch size of our forward pass.

Your situation isn't really comparable.

lsy•2h ago
Fixing "theoretical" nondeterminism for a totally closed individual input-output pair doesn't solve the two "practical" nondeterminism problems, where the exact same input gives different results given different preceding context, and where a slightly transformed input doesn't give a correctly transformed result.

Until those are addressed, closed-system nondeterminism doesn't really help except in cases where a lookup table would do just as well. You can't use "correct" unit tests or evaluation sets to prove anything about inputs you haven't tested.

saagarjha•2h ago
This is really useful in reproducing bugs.
kazinator•9m ago
[delayed]
mg•2h ago
I really hope we will get deterministic LLMs in the future. Even if it causes slightly slower response times.

Nondeterminism is what currently keeps me from working with other developers.

As I wrote in "Prompt Coding" [1], these days I am not looking for good code. I am looking for prompts that create good code. But how do you share prompts among developers when they produce different code every time? You cannot simply state "Here, I found a prompt that makes gpt-5-2025-08-07 output a solution with all the desired attributes".

Similar with images. At the moment, for most image models, you cannot outsource the task of writing prompts that create the desired images. Because most image models will not create the same image when given the same prompt and parameters.

[1]: https://www.gibney.org/prompt_coding

khimaros•44m ago
i tried to create a makefile driven workflow based on this idea and ended up with https://github.com/khimaros/enc -- it suffers from the issues you raised

i'm hoping that it becomes more useful as models improve and become more reliable at producing working code (though determinism would be great for improving prompts).

p1necone•9m ago
Surely if you end up relying on a given prompt to produce the exact same code every time you should instead just check that code into source control the first time you generate it?

A deterministic LLM isn't going to behave appreciably differently from a non deterministic one if your input or context varies by even a tiny bit (pun intended) each time.

TNDnow•1h ago
Who needs a working product when you can spend all day designing the most WEWORK looking website and slap some pseud slop on it. It's like crypto "startups" but it's not even fun.
cubefox•1h ago
His solution still relies on greedy (temperature 0) sampling, which is probably not optimal for model performance on various tasks. For example, Gemini 2.5 uses temperature 1 by default. But deterministic inference with temperature >0 can still be achieved by using pseudorandom sampling with a fixed seed.
mynameismon•1h ago
The point of the blog is that even at "supposed" deterministic generative sampling, non-determinism creeps in. This in turn has disastrous effects in very real experiments.
cubefox•59m ago
My point is that greedy sampling is not just not sufficient but also not necessary for deterministic inference.
red2awn•58m ago
Conceptually setting temperature to be >0 doesn't actually introduce any non-determinism. If your sampler is seeded then it will always choose the same next token. Higher temperature only flattens the logit distribution.
jll29•1h ago
Sometimes, the reason for non-determinism is implementation-specific. For instance, in GPT-2's source code (I haven't checked other model versions), setting the temperature in the GUI does not lead to a value of 0 but "epsilon" (a very small value larger than 0), to avoid a division by zero error in the code, which makes sense.

For many applications, non-determinism implies "useless". This has been a long standing issue with LDA topic models. In particular in the legal, financial and regulatory domains, if a method is not deterministic, it may be illegal to use it or it may lead to follow-on requirements that one does not want (e.g. all screens shown to humans must be preserved to be able to go back and reconstruct what exactly happened to a particular user in a particular second).

eldenring•1h ago
Very impressive! I guess this still wouldn't affect their original example

> For example, you might observe that asking ChatGPT the same question multiple times provides different results.

even with 0.0 temperature due to MOE models routing at a batch level, and you're very unlikely to get a deterministic batch.

> Not because we’re somehow leaking information across batches — instead, it’s because our forward pass lacks “batch invariance”, causing our request’s output to depend on the batch size of our forward pass.

The router also leaks batch-level information across sequences.

boroboro4•59m ago
> even with 0.0 temperature due to MOE models routing at a batch level, and you're very unlikely to get a deterministic batch.

I don’t think this is correct - MoE routing happens at per token basis. It can be non deterministic and batch related if you try to balance out your experts load in a batch but that’s performance optimization (just like all of the blogpost) and not the way models are trained to work.

eldenring•22m ago
Ah interesting, good point. So I guess expert-choice routing leaks across the batch. Now I'm not sure.
syntaxing•1h ago
Super interesting. For those unaware, this is the company Mira Murati (OpenAI previous CTO) started
jasonjmcghee•1h ago
I love high quality blog post style research discussion - Anthropic has been leading the charge with this recently and it's great to see it spreading. OpenAI was also doing this during all the RL research days.
nowittyusername•1h ago
I am baffled that I still run against these statement years after LLM's have been around. LLM's are deterministic and always have been. The reason people are having issues with them is because they are basing their assumptions on api based experiments. Like my man, how can you be making these statements when you haven't done the due diligence of running the LLM on your own hardware with all of the variables locked down and accounted for? If you do just that it would become obviously clear that they are deterministic and most of the time the reason you see the non deterministic behavior is because you have not controlled for a variable. Usually prompt caching, batch processing or some other obvious variable. Now this is related to within same system deterministic behavior. You might get different answers when running on a different gpu, but at least for same systems the behavior is 100% identical if you account for all server startup flags and properly account for things like prompt cashing, slot contamination etc...
tossandthrow•1h ago
The article literally justifies This in the second paragraph.
nowittyusername•58m ago
I suppose I have issues with the way "determinism" is used in the title of this article. It can mean different things to different people and in my mind stating that "Defeating Nondeterminism in LLM Inference" frames it as an actual issue with LLM inference. But its not, its an issue with LLM inference when you start using large scale inference with more complex parts such as systems which use multi gpu inference systems or batching processes and other mechanisms. It is not an issue when using an LLM without those more complex parts. Stating it this way muddies the signal and gives a false sense that this is a fundamental issue with architecture, where its an issue of the systems at scale...
golol•1h ago
Hold on a second. A transformer produces deterministically a probability distribution over the token alphabet from the context. Then one samples from this distribution. This is random and meant to be random.
oasisaimlessly•1h ago
It's possible to deterministically sample from a probability distribution. For example, just seed your RNG with a constant, or with the SHA256 hash of the context.
golol•26m ago
Well yes, you can "hack" the pseudorandom number generator, but... that's not really the point when talking about determinism in LLMs is it? I mean the mathematical idea of the standard LLM is certainly truly random.
nowittyusername•12m ago
The sampling process isn't random. If you sample with identical sampling parameters and identical values for said parameters, you will always get same results. You only start getting "non deterministic" behavior when you start using more complex systems outside the scope of your control like multi gpu systems and batch processing. One llm sampled with cash prompting off and and batch processing off will always generate same results if all values are same.
Voloskaya•1h ago
I suggest you look up the name of the main author of TFA before assuming they don’t know what they are talking about.

This is literally one of the most knowledgeable person on the topic. I think you are the one that hasn’t peeled enough layers to connect with what they are saying.

threeducks•21m ago
It should also be noted that PyTorch has a page about reproducibility: https://docs.pytorch.org/docs/stable/notes/randomness.html

TL;DR

Seed your PRNGs and call torch.use_deterministic_algorithms(True) to get the deterministic kernels. They may be slightly slower, but in practice, you probably will not notice.

Note that results will still differ between different drivers and GPUs. It would be great if NVIDIA tried harder in that regard.

htrp•11m ago
We know what thinking machines does yet?
sudohalt•10m ago
cool project but if this is what you are producing with $2 billion funding, i doubt you will survive. This is the type of article a grad student would write over a weekend.

ChatGPT Developer Mode: Full MCP client access

https://platform.openai.com/docs/guides/developer-mode
269•meetpateltech•4h ago•137 comments

Show HN: Term.everything – Run any GUI app in the terminal

https://github.com/mmulet/term.everything
462•mmulet•1d ago•64 comments

Defeating Nondeterminism in LLM Inference

https://thinkingmachines.ai/blog/defeating-nondeterminism-in-llm-inference/
106•jxmorris12•3h ago•36 comments

The HackberryPi CM5 handheld computer

https://github.com/ZitaoTech/HackberryPiCM5
97•kristianpaul•2d ago•26 comments

Show HN: Haystack – Review pull requests like you wrote them yourself

https://haystackeditor.com
31•akshaysg•2h ago•11 comments

Launch HN: Recall.ai (YC W20) – API for meeting recordings and transcripts

35•davidgu•4h ago•18 comments

OrioleDB Patent: now freely available to the Postgres community

https://supabase.com/blog/orioledb-patent-free
319•tosh•9h ago•109 comments

I didn't bring my son to a museum to look at screens

https://sethpurcell.com/writing/screens-in-museums/
554•arch_deluxe•4h ago•216 comments

Dotter: Dotfile manager and templater written in Rust

https://github.com/SuperCuber/dotter
17•nateb2022•1h ago•3 comments

UGMM-NN: Univariate Gaussian Mixture Model Neural Network

https://arxiv.org/abs/2509.07569
12•zakeria•1h ago•2 comments

Harvey Mudd Miniature Machine

https://www.cs.hmc.edu/~cs5grad/cs5/hmmm/documentation/documentation.html
23•nill0•2d ago•7 comments

'Clearest sign' yet of ancient life on Mars

https://www.nature.com/articles/s41586-025-09413-0
48•stevenjgarner•1h ago•5 comments

Bild AI (YC W25) Is Hiring

https://www.ycombinator.com/companies/bild-ai/jobs/m2ilR5L-founding-engineer-applied-ai
1•rooppal•3h ago

Jiratui – A Textual UI for interacting with Atlassian Jira from your shell

https://jiratui.sh/
69•gjvc•6h ago•22 comments

The origin story of merge queues

https://mergify.com/blog/the-origin-story-of-merge-queues
59•jd__•4h ago•18 comments

Clojure's Solutions to the Expression Problem

https://www.infoq.com/presentations/Clojure-Expression-Problem/
7•adityaathalye•3d ago•0 comments

Show HN: TailGuard – Bridge your WireGuard router into Tailscale via a container

https://github.com/juhovh/tailguard
70•juhovh•17h ago•21 comments

Kerberoasting

https://blog.cryptographyengineering.com/2025/09/10/kerberoasting/
125•feross•8h ago•42 comments

Zoox robotaxi launches in Las Vegas

https://zoox.com/journal/las-vegas
133•krschultz•5h ago•174 comments

Anthropic Services Down

https://status.anthropic.com/incidents/k6gkm2b8cjk9
140•rob•4h ago•68 comments

TikTok has turned culture into a feedback loop of impulse and machine learning

https://www.thenexus.media/tiktok-won-now-everything-is-60-seconds/
215•natalie3p•4h ago•165 comments

Insufficiently sanitized data allows unauthenticated access to FreePBX Admin

https://labs.watchtowr.com/you-already-have-our-personal-data-take-our-phone-calls-too-freepbx-cv...
38•Tiberium•2h ago•6 comments

Distributing your own scripts via Homebrew

https://justin.searls.co/posts/how-to-distribute-your-own-scripts-via-homebrew/
47•ingve•2d ago•7 comments

We can’t circumvent the work needed to train our minds

https://zettelkasten.de/posts/the-scam-called-you-dont-have-to-remember-anything/
280•maksimur•6h ago•136 comments

Tarsnap is cozy

https://til.andrew-quinn.me/posts/tarsnap-is-cozy/
70•hiAndrewQuinn•8h ago•53 comments

Semantic Line Breaks (2017)

https://sembr.org
63•Bogdanp•3d ago•44 comments

Delphi 13 Florence Released

https://blogs.embarcadero.com/announcing-the-availability-of-rad-studio-13-florence/
44•andsoitis•2h ago•19 comments

Rayhunter: IMSI Catchers We Have Found So Far

https://www.eff.org/deeplinks/2025/09/rayhunter-what-we-have-found-so-far
44•cooperq•1h ago•3 comments

Things you can do with a debugger but not with print debugging

https://mahesh-hegde.github.io/posts/what_debugger_can/
169•never_inline•3d ago•178 comments

Charlie Kirk shot at event in Utah

https://www.nbcnews.com/news/us-news/live-blog/live-updates-shooting-charlie-kirk-event-utah-rcna...
168•david927•1h ago•259 comments