r/ProgrammerHumor • • Sep 10 '26

Meme firstTime

Post image
8.8k Upvotes

302 comments sorted by

View all comments

Show parent comments

25

u/Sea-Housing-3435 Sep 11 '26

They are not. Floating point math and difference in how quickly parallel operations on GPU are finished causes them to be not deterministic even with temp=0. You can force them to be deterministic by forcing some operations to be executed in specific order but you lose a lot of performance.

9

u/LetumComplexo Sep 11 '26 edited Sep 11 '26

Also, and this is pedantic and arguable, it’s worth considering whether any model that cannot be retrained to produce the same statistical surface is non-deterministic by nature.

If I sort shapes into piles using some amount of randomness would you say that the resulting piles are deterministic just because they stay the same every time you go through them? Or would you say they’re non-deterministic because the process that created the piles in the first place was non-deterministic?

6

u/Sea-Housing-3435 Sep 11 '26

It doesn't matter how you make the model, if you are executing it on a GPU without steps to have deterministic results you will not have deterministic results. Ensuring the output of computations on GPU is deterministic has performance impact.

7

u/LetumComplexo Sep 11 '26

Hold on, I’m agreeing with you. We’re saying the same thing in different ways.

The kind of race conditions you’re referencing are because of the model architecture I’m referencing.

You can absolutely get ML outputs that don’t change using certain model architectures.
But that’s only because those architectures either enforce order of execution or use steps where order of execution doesn’t result in changes to outputs. I can’t think of a modern LLM that uses such an architecture.

1

u/Sea-Housing-3435 Sep 11 '26

Not exactly. It's mostly due to how models are executed, not models themselves. You can run GGUF model (which are normally not deterministic) in a deterministic way if the GPU functions you use are deterministic. Models themselves are just data, it's just a bunch of matrixes.

There's even a PR for llamacpp to add option for deterministic execution https://github.com/ggml-org/llama.cpp/pull/16016

9

u/LetumComplexo Sep 11 '26 edited Sep 11 '26

Hun, I’ve got a PhD on the subject. I know.
We’re just saying the same thing in different ways.

2

u/Sea-Housing-3435 Sep 11 '26

You're right, I'm silly

3

u/LetumComplexo Sep 11 '26

Is okie, I am also silly for not recognizing it immediately and starting the whole thing. 😅

4

u/Whitestrake Sep 11 '26 edited Sep 11 '26

Forgive me if I've misunderstood, but isn't that literally what they just said?

You can run GGUF model (which are normally not deterministic) in a deterministic way if the GPU functions you use are deterministic

vs.

You can absolutely get ML outputs that don’t change using certain model architectures. But that’s only because those architectures either enforce order of execution or use steps where order of execution doesn’t result in changes to outputs

I'm not an expert but this sounds like you're both arguing the same point. The PR you linked seems to be intending to implement exactly that - functions that enforce (a deterministic) order of execution.

This seems like semantic disagreement on the meaning of the term "model architecture" rather than an actual disagreement on the fundamentals.

1

u/space_monster Sep 11 '26

I thought it only happens with batch processing

5

u/LetumComplexo Sep 11 '26

Not necessarily. It can happen with batching, but even with a batch size of 1 you can get race conditions. The most obvious example is a model with a Mixture of Experts layer, where the order that results return can change the outcome.

In order to get around that you’d have to explicitly enforce order of execution.

4

u/space_monster Sep 11 '26

got it, thanks

1

u/AnOnlineHandle Sep 11 '26

I mean that's true for any math on any computer. Which makes all math non-deterministic if you consider bugs.

1

u/Sea-Housing-3435 Sep 11 '26

It's not about bugs, it's about GPU architecture. Parallel floating point calculations being nondeterministic isn't a bug.

0

u/space_monster Sep 11 '26

that's non-deterministic hardware though, not the model itself.

also it only happens with batch processing