Large Language Models
Lecture 16
Efficient LLM Decoding
Krishnendu Ghosh
Forward Pass through an LLM
Forward Pass through an LLM
Forward Pass through an LLM
Forward Pass through an LLM
Forward Pass through an LLM
Forward Pass through an LLM
Forward Pass through an LLM
Forward Pass through an LLM
Forward Pass through an LLM
Forward Pass through an LLM
Inference through an LLM
Inference through an LLM
Inference through an LLM
Inference through an LLM
Inference through an LLM
Inference through an LLM
Inference through an LLM
Inference through an LLM
Inference through an LLM
Inference through an LLM
Inference through an LLM
Inference through an LLM
Inference through an LLM
Inference through an LLM
Inference through an LLM
Inference through an LLM
Why we need efficient inference?
Inference through an LLM
Inference through an LLM
Inference through an LLM
Inference through an LLM
Inference through an LLM
Inference through an LLM
Inference through an LLM
Inference through an LLM
Inference through an LLM
Inference through an LLM
Inference through an LLM
Inference through an LLM
Inference through an LLM
Inference through an LLM
Inference through an LLM
Inference through an LLM
Inference through an LLM
Inference through an LLM
Inference through an LLM
Inference through an LLM
Inference through an LLM
Inference through an LLM
Inference through an LLM
Inference through an LLM
Inference through an LLM
Inference through an LLM
Inference through an LLM
Inference through an LLM
Inference through an LLM
Inference through an LLM
Inference through an LLM
Inference through an LLM
Inference through an LLM
Inference through an LLM
Inference through an LLM
Inference through an LLM
Inference through an LLM
Inference through an LLM
Inference through an LLM
Inference through an LLM
Inference through an LLM
Inference through an LLM
Inference through an LLM
Two stages of LLM inference
Inference through an LLM
Memory Usage of KV cache
Memory Usage: Example OPT-13B
Memory Usage: Example OPT-13B
Memory Management of KV Cache
Memory Management of KV Cache
Memory Management of KV Cache
Memory Management of KV Cache
Memory Management of KV Cache
Memory Management of KV Cache
Memory Management of KV Cache
Memory Management of KV Cache
Memory Management of KV Cache
Memory Layout for 13B-OPT model
on A100 (40GB)
vLLM
Efficient KV cache management
vLLM
Efficient KV cache management
KV Blocks
KV Blocks
KV Blocks
Physical vs Logical KV Blocks
Physical vs Logical KV Blocks
Physical vs Logical KV Blocks
Physical vs Logical KV Blocks
Physical vs Logical KV Blocks
Physical vs Logical KV Blocks
Physical vs Logical KV Blocks
Physical vs Logical KV Blocks
Physical vs Logical KV Blocks
Physical vs Logical KV Blocks
Physical vs Logical KV Blocks
Physical vs Logical KV Blocks
Physical vs Logical KV Blocks
Physical vs Logical KV Blocks
Physical vs Logical KV Blocks
Physical vs Logical KV Blocks
Physical vs Logical KV Blocks
Dynamic Block Mapping
Sharing KV blocks
in parallel sampling
Sharing KV blocks
in parallel sampling
Sharing KV blocks
in parallel sampling
Sharing KV blocks
in parallel sampling
Sharing KV blocks
in parallel sampling
Sharing KV blocks
in parallel sampling
Sharing KV blocks
in parallel sampling
Sharing KV blocks
in parallel sampling
Sharing KV blocks
in parallel sampling
Sharing KV blocks
in parallel sampling
Memory efficiency of vLLMs
Paged Attention
How vLLM & Paged Attention
results in efficient inference?
HuggingFace vs TGI (2023)
System Architecture and
Implementation
Flash Attention - Recap
Flash Attention - Recap
Flash Attention - Recap
Flash Attention - Recap
Flash Decoding
Benchmarking on CodeLlama-34B
Inference through an LLM
Inference through an LLM
Inference through an LLM
Inference through an LLM
Speculative decoding
How to Guess?
How to Guess?
Example from HumanEval dataset
Speculative Sampling
Speculative Sampling
Algorithm
Algorithm
Algorithm
Rejection Sampling
Rejection Sampling
Rejection Sampling
Wall time speedup:
Illustration on an encoder-decoder model
Results
How to guess?
Medusa
How to train multiple LM heads?
Tree Attention
Prune the tree!
Prune the tree!
Acceptance Criteria
Impact of the Threshold
Results
How to guess?
Results
How to guess?
Lookahead Decoding
Summary
Continuous Batching
Continuous Batching
Source: https://lcs2-iitd.github.io/ELL881-AIL821-2401/lectures/