Deep Dive: Optimizing LLM inference

  Рет қаралды 18,580

Julien Simon

Julien Simon

4 ай бұрын

Open-source LLMs are great for conversational applications, but they can be difficult to scale in production and deliver latency and throughput that are incompatible with your cost-performance objectives.
In this video, we zoom in on optimizing LLM inference, and study key mechanisms that help reduce latency and increase throughput: the KV cache, continuous batching, and speculative decoding, including the state-of-the-art Medusa approach.
⭐️⭐️⭐️ Don't forget to subscribe to be notified of future videos. Follow me on Medium at / julsimon or Substack at julsimon.substack.com. ⭐️⭐️⭐️
01:15 Decoder-only inference
06:05 The KV cache
11:15 Continuous batching
16:17 Speculative decoding
25:28 Speculative decoding: small off-the-shelf model
26:40 Speculative decoding: n-grams
30:25 Speculative decoding: Medusa

Пікірлер: 16
@jiegong529
@jiegong529 2 күн бұрын
Thanks so much for the crystal clear explanations! You understand them so well and it's even more amazing how you show them in bullet points and graphs to make your audience understand as well!
@billykotsos4642
@billykotsos4642 7 күн бұрын
very informative as always !
@cybermanaudiobooks3231
@cybermanaudiobooks3231 4 ай бұрын
Thanks Julien. Your recent series of videos have been top quality. A future video, you might consider making, is one about the different prompts required when fine-tuning. Why does llama2 differ from mistral? left-padding for some, right-padding for others; how does trl help simplify things? what is the history of this? what is chatml? guanaco? etc.., To get a solid foundation in navigating this area would be a helpful video to say the least!
@juliensimonfr
@juliensimonfr 4 ай бұрын
Hi Cyberman, thank you for the kind words. I have a bit of an inference obsession at the moment, but I'll come back to training and fine-tuning after that. Your suggestions sound good, I'll add them to the list :)
@RoyAAD
@RoyAAD 2 ай бұрын
Very interesting. Can we batch 1 image of the LLM? Or we need multiple copies of it loaded in the gpu in order to batch? And how can we estimate the throughput? Say if I have a 70B model on 2 A100?
@juliensimonfr
@juliensimonfr 2 ай бұрын
This works even on a single GPU. Here's the paper if you want to dive deeper: www.usenix.org/conference/osdi22/presentation/yu. Regarding benchmarks, I suggest you run your own to find the right latency/throughput trade-off for your application. This should help: www.databricks.com/blog/llm-inference-performance-engineering-best-practices
@RoyAAD
@RoyAAD 2 ай бұрын
@@juliensimonfr Thanks. Do you have a link that explains how to calculate the feasability for an LLM?
@bibiworm
@bibiworm Ай бұрын
Would you mind sharing the slides please Sir? Thank you!
@justwest
@justwest 3 ай бұрын
how does the big LLM handle the "predicted" tokens? I mean, how does it check whether these are good or not?
@juliensimonfr
@juliensimonfr 3 ай бұрын
Detailed explanation in huggingface.co/blog/assisted-generation. In a nutshell, you can run a forward pass with the large model on a speculative sequence and retrieve the logits (i.e. the probabilities) for the next token at each position in the sequence. If a speculative token does have the highest logit, then it's the token the large model would have generated.
@justwest
@justwest 3 ай бұрын
@@juliensimonfr thx a lot (for the vids in general also, of course). I think I am still missing a point here. why do you get the logits *at each position in the sequence*? isnt the ouput of the model just probabilities for the *next* token? If I would want to have this *at each position*, wouldnt I have to forward pass multiple times? thx!
@rbrowne4255
@rbrowne4255 3 ай бұрын
Thanks for the video great job!!! in terms of Speculative decoding, can you provide any additional feedback on its impact on GPU performance/memory? i.e kv-cache usage or overall GPU memory resources
@juliensimonfr
@juliensimonfr 3 ай бұрын
The only overhead is the assistant model, which can share layers with the large model . For example, see huggingface.co/blog/whisper-speculative-decoding, which says that there's only 8% of RAM overhead.
@user-kd2st5vc5t
@user-kd2st5vc5t Ай бұрын
很快就讲清楚了,好厉害!爱来自瓷器。
@Gerald-xg3rq
@Gerald-xg3rq 2 ай бұрын
hi great video! how to set WAITING_SERVED_RATIO, MAX_BATCH_SIZE, MAX_BATCH_TOTAL_TOKENS, MAX_BATCH_PREFILL_TOKENS etc. for highest throughput? looking at llama2-7b-chat and llama3-8b-instruct with nvidia A10.
@juliensimonfr
@juliensimonfr 2 ай бұрын
Hi, the doc is available at huggingface.co/docs/text-generation-inference/en/basic_tutorials/launcher. I would increase batch size and measure.
Deep dive: model merging
47:26
Julien Simon
Рет қаралды 6 М.
Khó thế mà cũng làm được || How did the police do that? #shorts
01:00
THEY made a RAINBOW M&M 🤩😳 LeoNata family #shorts
00:49
LeoNata Family
Рет қаралды 33 МЛН
I wish every AI Engineer could watch this.
33:49
1littlecoder
Рет қаралды 65 М.
Enabling Cost-Efficient LLM Serving with Ray Serve
30:28
Anyscale
Рет қаралды 4,4 М.
Fast LLM Serving with vLLM and PagedAttention
32:07
Anyscale
Рет қаралды 19 М.
How a Transformer works at inference vs training time
49:53
Niels Rogge
Рет қаралды 49 М.
Developing an LLM: Building, Training, Finetuning
58:46
Sebastian Raschka
Рет қаралды 18 М.
Speculative Decoding Explained
37:34
Trelis Research
Рет қаралды 3,2 М.
Samsung Galaxy 🔥 #shorts  #trending #youtubeshorts  #shortvideo ujjawal4u
0:10
Ujjawal4u. 120k Views . 4 hours ago
Рет қаралды 3,3 МЛН
Урна с айфонами!
0:30
По ту сторону Гугла
Рет қаралды 8 МЛН
Mastering Picture Editing: Zoom Tools Tutorial
0:52
Photoo Edit
Рет қаралды 505 М.
КРУТОЙ ТЕЛЕФОН
0:16
KINO KAIF
Рет қаралды 4,8 МЛН