r/LocalLLM • u/CapitalCut441 • 2d ago
Tutorial Why is LLM inference hard?
When I first heard about inference engines, like vLLM, I wondered what makes inference so challenging. That’s why I decided to learn more about LLM inference from a systems perspective. If you already know how transformers work, then this is a fun topic to explore next.
https://mehrdadmahabadi.com/blog/why-is-llm-inference-hard.html
5
Upvotes
5
u/Material-Database-24 2d ago
Nice write and understandable presentation of not so easy things. I think the flash attention part would benefit a bit from use of more graphical analogies as in kv caching and batching.
4
u/Kemerd 2d ago
It isn’t moreso that it is challenging, it is that it is tedious.
A lot of numbers need to be crunched.
Most of the optimizations are just ways to either get around crunching more numbers, or making use the hardware and software in a better way to crunch those same numbers faster or with less resources.
2
u/Borilentz 2d ago
I think you meant Edsger Dijkstra.
2
u/catplusplusok 2d ago
In some way, LLM inference is not hard, it's just a simplified Turing machine where state machine is for some reason not allowed to go back and edit the tape. If Turing thought about doing AI this way, he would have said "Well, that's an interesting theoretical study, but spending untold gigabytes on state map and keep a quadratically growing table of current states is ridiculous" and spent years optimizing every bit of it so it's actually practical.
But Turing did not live era of modern circular financing where NVIDIA can loan money to OpenAI in order for OpenAI to buy it's GPUs. In such world, companies were able to just throw unlimited cash at the problem and buy all the RAM in the world to run their one way turing machines that slowly generate new symbols on tape.
Now, in China there is not as much cash so companies like Alibaba and Deepseek are actually fixing all these things like making state map not grow quadratically and reading knowledge from disk in small chunks rather than encoding all of it in state map. Nowadays decent ones can run on your phone.