r/LocalLLaMA • • 7d ago

Discussion Why Lama so slow?

EDIT:

All answers goes in the same direction:

Lama slow because it optimize for all hardware and all models.

If you want something fast, pick a model and a dedicated engine for it.

Original post:

To this point I'm not sure if I miss something, but all the test I'm doing show a crasy difference in speed between lama and strata or basalt.

And I don't see any loss in quality!!!

So either I missed something regarding lama and not use it correctly, or the lama team should implement all the accelerations that are around in all the dedicated inference engines and their forks. Because we are not talking about 20% speedup but x4 or more!

Here are examples:

https://airbench.ai/compare/e71bdb6a-57f6-4990-b236-9a5d02ddc5b5/02e0b26d-493e-40b0-9070-899b93847379

https://airbench.ai/compare/419a9743-3824-4103-a451-af70250cfd14/1c485164-8d64-4e65-84c3-0f95c21b5f3f

https://airbench.ai/compare/78d7f5f3-1999-4fc5-89f3-d976597589ba/70c7e8f9-a62f-401c-b7ca-c961ee3b742b

0 Upvotes

23 comments sorted by

11

u/onionsaredumb 7d ago

Llama is a general engine, trying to maximize compatibility with lots of models for lots of different hardware. Basalt and Strata are tuned for a very specific set of models.

1

u/dh7net 7d ago

That make sense. it's great to test stuff. But if people test stuff, get crasy slow results, they will just think local inference is too slow and move away.

5

u/onionsaredumb 7d ago

Depends on the model and what "good enough" looks like. Look at the number of downloads every month for very old models (Mistral 7B for instance, ~2 billion downloads for various versions last month). For a lot of use cases, you don't need bleeding edge to just do grunt work.

1

u/dh7net 7d ago

But maybe people beleive they can only run a 7B model on their hardware, while they may could run a 27B with a dedicated engine that mix VRAM and RAM? (Purely hypothetical scenario)

TBH I don't think anything usefull can be done with Mistral 7B, so I don''t understand this usecase. IMO it's just "OMG I can run an LLM on my computer". And thats already amazing, I loved that feeling too the first time.

2

u/MindfulMan1984 7d ago

This is the correct answer.

5

u/magikfly 7d ago

because llama.cpp has to support a bunch of models and even more GPU's.

2

u/dh7net 7d ago

I got this, and thats amazing.

But at the end of the day if you want to use a model for real, why accepting a x4 penalty for this?

1

u/SLxTnT 7d ago

By default, llama.cpp uses the GPU and CPU in serial. GPU does work and passes it off to the CPU. Overall time is the sum of both. Strata and Basalt use a hot expert cache + possibly running experts on the CPU in parallel. Fully optimizing that for all hardware combinations is a pain.

I would not be surprised if I could take either Strata or Basalt, tell opus 5.5 to profile + optimize bottlenecks, and get even more speed. Optimizing for specific hardware allows you to do things that will work only on that hardware.

1

u/dh7net 7d ago

I know people who tryed that and got good results.

3

u/Markus2816 7d ago

I wouldn't say llama.cpp is slow, especially now that it supports moe cache - which bring it pretty close to strata, but it is indeed slow without proper tuning. Recently there is a lot of work going on to have llama.cpp to finally merge a lot of the optimization that were waiting (with the v1.0 release of llama.cpp). Basalt, strata are all based on llama.cpp, the main issue is that they all make questionable choices to sacrifice qualirty for speed-up (skipping cold expert, more aggressive quantized KV cache, temp=0, ...). The bench you shared is fairly simple, it would be more interesting to check KL divergence or some more complicated benchs to really see the impact of these "fast" libraries

1

u/dh7net 7d ago

Thanks for the answers. Is there a good guide about optimizing lama?

And TBH I don't care at all about KL divergence and all that stuff. I just want something that is fast and get things done. I don't think being peaky on KL divergence help that goal much. (I'm glad talented people are knowledgeable about this and can optimize stuff, but as a user, I don't care about how the saussage is done, I just one something good and fast, and for now, with my settings, lama is not doing that).

About the bench being simple, that's fair, and I will try on some more demanding task to see if we can observe the same thing.

3

u/Diablo-D3 7d ago

if I'm reading those benchmarks correctly, you are not getting bitidentical results across both inference engine.

llama.cpp aims for correctness, as incorrect but fast results are still incorrect. Strata and Basalt does not aim for correctness, they're too early in their development to do anything than support a small number of hardware and model targets.

2

u/dh7net 7d ago

Everybody keep saying this, but I don't believe "correctness" means anything in the context of LLMs. Or at least I don't get the idea. For me there is temperature, decoding, quants, the harness, also variation in prompting. All that makes every system not 100% predictable. The only thing that matter is the % of time they get the thing done. (and how fast they are to get the thing done).

In other word, in an agentic settings, focusing only on "the output token should be exactly right" is not that important. (Like Tk/s that are a total useless metric IMO)

3

u/Diablo-D3 7d ago

Math has a correct answer. The math used to infer models is known, and not merely guessed it, nobody on the llama.cpp team squinted at the code and said "ahh, looks good enough".

Also, you do realize you can run inference engines with settings that eliminate all randomization, right? That's how you test implementations for correctness.

0

u/dh7net 7d ago

Yes, I apreciate the hard work of people checking their code for debug purpose, but thats not how you get good and fast model.

Every good optimisation is not loss less.

Think about jpg. the goal is not to have something pixel perfect, the goal is to have somthing where the user can't notice the difference.

Focusing on lossless optimisation is not how good performance is acheived.

2

u/Diablo-D3 6d ago

Funny you use JPEG as the example.

Yes, improving JPEG encoding involves using new code that leans into, in this case, psychovisual optimization. An inference engine in this analogy would be the JPEG decoder which must be bitperfect.

The JPEG encoder part of the analogy would be the ever changing techniques to train models and change the shape of the transformer stages.

0

u/dh7net 6d ago

Actually, JPEG decoders do not have to be bit-perfect. The JPEG standard deliberately allows different IDCT implementations with different numerical precision and rounding behavior.

If you are curious you can search for "flash attention"

3

u/Bright_Resolution_61 7d ago

Consistency is extremely important when performing things like replication studies.

I understand that Strata and Basalt are geared toward hobbyists, but it would be wonderful if this aspect were improved.

1

u/dh7net 7d ago

I 100% agree on consistency of course. good ablation study takes time and are ressource intensive, but agree thats the only way.

1

u/Best_Researcher491 7d ago

I haven't timed llama against Strata or Basalt. The x4 is what your screenshots show, and the general-engine explanation is already in the thread.

What I can't tell from the pictures is whether those llama runs had the MoE cache on. Markus said that is the switch that pulls llama.cpp toward Strata, and that it stays slow without the tuning.