logoalt Hacker News

jcodertoday at 10:04 AM7 repliesview on HN

> All requests to an LLM are idempotent, for every API call you need to send it the entire conversation history

A more appropriate term is “stateless”. LLM responses are certainly not idempotent, as they are not even deterministic.


Replies

msdztoday at 10:56 AM

Which is why big labs have been working hard on making their harness not be stateless any longer:

https://earendil.com/posts/session-portability/

“Just take the session thread to another provider” might not be feasible anymore soon-ish.

show 3 replies
jpgvmtoday at 12:32 PM

They can be deterministic. We did this at Groq, if you sent a request with exactly the same input token, seed and temperature value you would get precisely the same result every time.

This is harder to do on other architectures that themselves aren't fully deterministic though.

show 2 replies
jcodertoday at 6:25 PM

I appreciate the replies on the determinism point and I’ve learned some new things here. In any case I probably should not have tagged that on, as my main point was to share that the sort of property that parent is talking about (whether true for all LLMs/providers/harnesses or not) is statelessness, not idempotency.

qeternitytoday at 12:00 PM

LLMs are, in theory, deterministic. Sampling is not intrinsic to LLMs.

Greedy decoding a single batch in most libraries will give you mostly deterministic outputs. Higher batch sizes can increase variance.

But all of this is down to CUDA and/or kernel implementation issues.

show 1 reply
DavidHaerertoday at 11:01 AM

According to [1] there is - unfortunately - increasingly more state in LLM sessions.

1: https://earendil.com/posts/session-portability

SkyBelowtoday at 2:54 PM

>LLM responses are certainly not idempotent, as they are not even deterministic.

Isn't that more due to an optimization and not how the LLM itself runs?

Like a MoE LLM run on a single input should give the same output each time. But this is inefficient, as any given token is hitting 1 (or maybe 2 or 3) experts at a time, meaning all the other experts are doing absolutely nothing. So you upgrade it to take in multiple requests. But then any given expert can become a bottleneck, so when too many requests need a given expert, some of them are routed to a second or third best expert instead. Within the context of any single request, this looks like non-determinism, but it is still deterministic when considering the full batch.

For everyday users and everyday use cases, that is enough to treat it as non-deterministic (the harness might also send in unique data like current time which means one can never have the exact same request twice), but when talking about LLMs more theoretically, I think we need to consider they can still be ran deterministically even if that isn't as optimized.

Similar with temperature. 0 means deterministic, but anything higher with a seeded value is deterministic. If anything, temperature is us purposefully adding non-determinism to agents because they were too deterministic.

show 1 reply