Optimizing Inference for Large Language Models
Optimizing Inference for Large Language Models
2 Preliminary System-Level
≈
6 Optimization
2 Preliminary System-Level
(Xuefei Ning)
≈
6 Optimization
(Guohao Dai)
Problem Definition &
3 Algo-Level
Conceptual Analysis
(Xuefei Ning)
7 Optimization
(Haoli Bai)
4 Practical Pipeline
(Xuefei Ning)
8 Conclusion
(Haoli Bai)
Contents
Model-Level
1 Background 5 Optimization
2 Preliminary System-Level
≈
6 Optimization
Human AI World
Model
Performance
2018-2024
2018 3 orders of
1e8 magnitude increase in the
supported input length
Example:
DeepSeek-R1 [2] (year 2025): 671B params, open source.
1e2
Release Time
[1] Villalobos et al. “Machine Learning Model Sizes and the Parameter Gap.” arXiv 2022. [4] Achiam, Josh, et al. "Gpt-4 technical report." arXiv 2023.
[2] Guo, Daya, et al. "Deepseek-r1: Incentivizing reasoning capability in llms via reinforcement [Link] 2025. [5] Reid, Machel, et al. "Gemini 1.5: Unlocking multimodal
[3] Esser, Patrick et al., Scaling rectified flow transformers for high-resolution image synthesis, ICML 2024. understanding across millions of tokens of context." arXiv 2024.
Background
Application demands e.g., multimodal input, advanced tasks, may
continually drive increases in model scale and input/output length.
Human AI World
Deployment
Cloud Edge
Requirements or constraints of application scenarios and platforms
Normalized to 1B Model
10000 533.5x, 3.5PFLOPS 196.7x,
1000 15.6TB 1.6TB
100
100 84.4x,
10 769GB
26.2x, 10
1 401GB
1k 2k 4k 8k 16k 32k 64k 128k 256k 512k 1024k
1
Input Token Length Llama-3.2 Llama-3.2 Llama-3.1 Llama-3.1 Llama-3.1
-1B -3B -8B -70B -405B
1K token 15.9 TFLOPs 29.2 GB 15.3 GB 1xA100 73~170 ms 10~24 ms 1B Model 12.4 TFLOPs 19.2 GB 15.3 GB 1xA100 57~132 ms 1.8~4.3 ms
1M token 597 PFLOPs 15.6 TB 401 GB 6xA100 7.6~17.7 min 32~75 ms 405B Model 3.5 PFLOPs 1.6 TB 769 GB 10xA100 1.6~3.7 s 55~128 ms
*TTFT is estimated using Compute Amount / (Peak OPS x compute-util), as prefill is computation-bounded. We assume a compute utilization range 30%~70% to report the estimation.
TPOT is estimated using Memory Access / (Bandwidth x bandwidth-util), as decoding is memory-bounded. We assume a bandwidth utilization range 30%~70% to report the estimation.
A100 Peak Compute Performance (FP16) = 312 TFLOPS; Peak Bandwidth = 2 TB/s
Application Challenge
Per-request energy consumption w.r.t. model size and input/output lengths,
estimated with actual latency measurement, device & schedule
assumptions, and device spec.
Compa Estimated energy Estimated energy
ny; consumption consumption
Model Date
Host (100in-300out) (10kin-1.5kout)
(Device) (Wh) (Wh)
GPT-4.1
0.10±0.04 0.45±0.21
nano OpenAI;
Azure Apr,
GPT-4.1
(H200& 2025 0.42±0.20 1.59±0.80
mini
H100)
GPT-4.1 0.92±0.50 4.23±1.97
LLaMA-
0.10±0.02 0.60±0.09
3.1-8B
Meta; Jegham et al. made an attempt to estimate the
LLaMA- AWS Jul,
3.1-70B (H200& 2024
1.10±0.13 11.63±1.39 environmental footprint of LLM inference at per-
LLaMA-
H100) prompt level of commercial AI providers, based on
1.99±0.32 20.76±1.80
3.1-405B assumptions on the infrastructure and scheduling.
[1] Jegham, Nidhal, et al. "How hungry is ai? benchmarking energy, water, and carbon footprint of llm inference." arXiv preprint arXiv:2505.09598 (2025).
Application Challenge
Overall energy consumption, estimated with reported usage, device &
schedule assumptions, and device spec.
[1] Jegham, Nidhal, et al. "How hungry is ai? benchmarking energy, water, and carbon footprint of llm inference." arXiv preprint arXiv:2505.09598 (2025).
Contents
Model-Level
1 Background 5 Optimization
2 Preliminary System-Level
≈
6 Optimization
WQ WK WV Attention
layer
LayerNorm
…
I Ġlove ĠEM N LP 𝑁 tokens
[1] Vaswani, Ashish, et al. "Attention is all you need." Advances in neural information processing systems 30 (2017).
Attention Layer
Attention Layer
Wk WO
K
The idea of attention module is to
establish token-to-token X
WQ
Q A
Wv
V X’
“attention” relationships within
a sequence.
*In this tutorial, the terms “inference” and “sampling” will be used interchangeably. Although they differ in the context of probabilistic modeling, here they both refer to
either a single sampling step—i.e., a forward pass of the model—or the overall sampling process, depending on context.
Attention Computation in Prefill/Decode Stages
Prefill Decode
Attention Layer Attention Layer
Wk K WO Wk K-Cache K WO
Who Who
V-Cache
WQ Wv WQ Wv
won Q A V won V
? ?
Jack Q A V
Jack
Won
The LLM calculates and saves the KV The LLM samples the output tokens
cache of the initial input tokens, and one by one with the KV cache, and in
samples the first output token. the meantime updates the KV cache.
[1] [Link]
A Conceptual Layered Overview
Runtime Lib Toolchain OS / Driver • Toolchain produces hardware-specific instructions.
Software Interact with Compile instructions Orchestrate resources or provide • Runtime library manages program execution, send
device at runtime for host and device low-level resource-access API instruction to device, transfer data to/from device, and
optionally call toolchain dynamically.
Hardware System • A hardware system consists of host, accelerator
devices, and their interconnects
Accelerator Device(s)
Host Machine
(CPU & Memory & …) AI Chip Off-Chip Memory
Accelerator’s Instruction Set
Architecture (ISA)
Accelerator Chip Define the instruction interface of
the AI accelerator device
Microarchitecture
Define functional modules (controller, computation,
memory) and how they “connect”: (1) control path: Physical Design /
• A microarchitecture design organizes modules to
how the controller parse the instruction and distribute Implementation implement the accelerator’s ISA
control information; (2) data path: how modules
parse and pass data based on control information
register
register
Output
Capacity: tens of GB Vector/Scalar Computation
Input
Bandwidth: ~TB/s Matrix/Tenso processing core
HBM, DDR, r processing
LPDDR, … unit
unit
Bandwidth: The rate at which data can be
transferred between two components of a system. Computation
Connecting with other AI chips
Interconnection Controller flow control of
interface AI chips
General More general and fine-grained ISA. Rely on More specialized and coarse-grained Specialized
software to implement coarse-grained ISA or even template-based design that
operators, algorithms. hard code an algorithm.
Chip-level Evaluation Metrics
• Chip-level metrics/characteristics
Chip-level evaluation metrics
Computation per unit time
(OPS)
Performance
Computation per
unit of energy Energy Area (mm2) → Tape-
(OPS/W, OPs/J) Efficiency out fabrication and
PPA packaging costs
Power Area
Power (W) → Energy
consumption level
Sensor, Wearable Device Mobile / IoT Device Smart City / Auto-driving Car Cloud Center
Webpage
From AI 1.0 to AI 2.0: Energy Efficiency Metric
Hardware energy efficiency → Inference-system energy efficiency
TOPs/J → Tokens/J
Metric!Tokens/J
ASIC, WaferLLM,
University of Edinburgh, C.
He, et al., 6.2 Tokens/J WebPage
PIM/NDP, Towards, Tsinghua,
L. Guo et al., 47 Tokens/J
Paper
Basic Knowledge : Development of Chips
Stanford:
EIE sparse NVIDIA:
accelerator A100
HUAWEI:
600mW 1.5TOPS/W FP16(Tensor Core): AMD:MI100
2014 Institute Ascend 310 312 TFLOPS FP 32:95.7 TFLOPS NVIDIA
Computing THU:FPGA16 16 TOPS(INT8)
8 TFLOPS(FP16) B200/B100
2006 Technology, FPGA accelerator FP16(Tensor
NVIDIA: CAS: 187.8 GOPS NVIDIA H100 Core):2250
Wafer-level TFLOPS
Introduced Introduced Cambricon:
Chips FP32:60 TFLOPS
CUDA DianNao NVIDIA:P100 MLU100 400,000 computing FP16(Tensor Core):
452GOPS,485mW 10.6 TFLOPS 32 TOPS(INT8) units 1,000 TFLOPS
932 GOPS/W 16 TFLOPs(FP16)
SM (Streaming
Multiprocessor)
serves as the
basic hardware
unit for parallel
instructions.
SIMT
GPU Architecture
[1] E. Lindholm, et al. ”NVIDIA Tesla: A Unified Graphics and Computing Architecture.”, in IEEE Mirco, 2008.
GPU Software Stack
• NVIDIA GPU Software Stack
• CUDA (Compute Unified Device Architecture) is the NVIDIA’s GPU parallel
programming platform and programming model, featuring a rich software ecosystem.
• AI & LLM frameworks is built on them.
Analysis
Compiler Debugger
Tools
LLM Training
nvcc nsight cuda-gdb
Framework
Megatron-LM
Python (PyTorch)
(pybind) User
interface
CUDA C
PTX
Processed by
compilers
SASS Assemble
GPU
GPU Programming Model
• Programming Organization: How to Parallelize?
Thread
Minimal parallel Kernel<<<grid, block>>>
unit
Block
A block contains multiple
threads. Number of
threads per block
Grid Number of
A grid contains multiple blocks, blocks per grid
encompassing all threads of a
single kernel.
Memory Hierarchy
[1] C. John, et al. ”Professional CUDA C Programming."
GPU Programming Model
• GPU Memory Hierarchy
• From the perspective of memory access efficiency: how threads are organized
significantly impacts kernel performance.
Thread (256KB/SM)
RG
Shared ~19TB/s
Block (192KB/SM)
Memory RG RG RG
Global ~1.6TB/s
Grid Memory (40GB/GPU)
Activation N
FC1
FC1
K 𝑊
Add & LayerNorm Taking FC1 as an
K
WO example
Multi-head Self-Attention
Q K V M 𝑋 𝑌
K Cache V Cache
WQ WK WV
K 𝑊
Model-Level
1 Background 5 Optimization
2 Preliminary System-Level
≈
6 Optimization
Human AI World
Deployment
Cloud Edge
Requirements or constraints of application scenarios and platforms
To meetHuman
requirements or constraint AI
of application scenarios World
and
platforms, we need to optimize the resource consumption of AI inference.
Deployment
Cloud Edge
Requirements or constraints of application scenarios and platforms
Measured metrics
Measured by testing model on platform, platform-related
Directly correspond to objectives / constraints,
related to final user experience, resource consumption, etc.
1. KV Cache
[Link]
Activation
3. Other
Time
End-to-end/Request/Generation Latency
Energy Energy Prefill Stage Decode Stage
*Note this is only a conceptual illustration. In actual serving framework, the KV cache pool is usually pre-allocated.
Problem Definition: Objectives & Constraints
Optimization objective or constraint: Usually, latency, memory, energy
consumption or throughput will be the ultimate objective or constraint on
“efficiency”. In the meantime, the intelligence level of AI needs to be retained.
Higher Latency
Higher Compute Amount
• But the compute units might not be fully utilized, the bandwidth might not be fully utilized:
+,-./0/1 234567/ 8/9:. +,-./0/1 ><?1@.17-
Compute_utilization = 8/<= 234567/ 8/9:.
Bandwidth_utilization = 8/<= ><?1@.17-
• Review our previous estimation example:
Peak performance
The maximum
Performance
performance when
Compute
Operational Intensity
#compute amount
Number of operations per byte of
memory accessed #memory access amount
Performance Analysis Model: Roofline Model
• Proposed by David Patterson in 2009
• Purpose: Uses an algorithm’s compute and memory access characteristics (operational
intensity) along with the chip’s peak performance and memory bandwidth to roughly assess
computational bottlenecks and guide subsequent optimization directions.
Performance
Compute
Operational Intensity
Number of operations per byte of
memory accessed
Performance Analysis Model: Roofline Model
• Proposed by David Patterson in 2009
• Purpose: Uses an algorithm’s compute and memory access characteristics (operational
intensity) along with the chip’s peak performance and memory bandwidth to roughly assess
computational bottlenecks and guide subsequent optimization directions.
Memory Bound
Compute
Compute Bound
2 Preliminary System-Level
≈
6 Optimization
Performance
Operational Intensity
• Solution approach: Apply INT4 quantization to the weights to reduce weight’s memory
access cost.
Input Output
FP16 (us) INT4 (us)
channel channel
4096 11008 159.3 52.0
11008 4096 45.6 37.6
4096 4096 43.5 23.0
Operational Intensity (FLOP/Byte) RTX 3090 GPU
GPU Software Stack
• NVIDIA GPU Diagnosis Tool
• Nsight Compute
• Taking LLaMA2-7B as an example
• Implementation: To achieve acceleration, the dequantization operator and the GEMV
computation operator need to be fused.
Dequantization Operator
Fusion
GEMV
Example: Design Thought of Model Compression Method
Dynamic: Static:
Design extension
Sparse low high Homogeneous Heterogeneous
rules of the attention
Attention hardware hardware sparse pattern attention pattern
span
efficiency efficiency
[1] Fu, Tianyu*, Huang, Haofeng*, Ning, Xuefei*, et al. “MoA: Mixture of Sparse Attention for Automatic Large Language Model Compression.” CoLM 2025.
Contents
Model-Level
1 Background 5 Optimization
2 Preliminary System-Level
≈
6 Optimization
[-127, 128]
Quantization
Tools
FP32 INT8
Weights Weights
int8 int16
Input int32 int32 Output
Linear Accumulator Activation Quant
(int8) (int8)
S Z INT
S Z INT
FP16 Channel-wise quantization
S Z INT
S Z INT
S Z INT INT S Z
S Z INT INT S Z
Group-wise quantization
S Z INT INT S Z
S Z INT INT S Z
* 图片来源: MIT EfficientML Course
[1] Deep compression: Compressing deep neural networks with pruning, trained quantization and huffman coding, Han et al., ICLR 2016.
Quantization
• Core focus of quantization parameter decision: Appropriately balance representational
range and precision (i.e., balancing truncation error and rounding error).
[1] Zhao, Ritchie, et al. "Improving neural network quantization without retraining using outlier channel splitting." International conference on machine learning. PMLR, 2019.
Quantization
• Two types of quantization process
• PTQ v.s. QAT
PTQ Workflow QAT Workflow
Pretrain
Repara- Quantizer Repara- Quantizer Quant.
meterize Selection meterize Selection configuration
Weight
Act. quant. Adjust PTQ Training
quant. QAT
parameters quant. value techniques
parameters
Outliers
Val
ue
[1] Xiao, Guangxuan, et al. "Smoothquant: Accurate and efficient post-training quantization for large language models." ICML, 2023.
SmoothQuant
Method
[1] Xiao, Guangxuan, et al. "Smoothquant: Accurate and efficient post-training quantization for large language models." ICML, 2023.
AWQ
• Typical PTQ Method: AWQ[1]
• Not all weights in an LLM are equally Methods To consider bothsalient and non
Motiv important. salient weights, AWQ searches for
ation • Protecting only 1% salient weights an optimal scaling factor that
can greatly reduce quantization minimizes the reconstruction error
error. for a certain layer.
[1] Lin, Ji, et al. "Awq: Activation-aware weight quantization for on-device llm compression and acceleration." Proceedings of machine learning and systems 6 (2024): 87-100.
FlatQuant: Flatness Matters for LLM
Quantization
• Motivation: Affine transformations are more powerful to suppress outliers
• Methodology: Learning affine transformations for each linear layer
• Reducing transformation overhead: Kronecker product & kernel fusion
[1] Sun, Y., Liu, R., Bai, H., et al. "FlatQuant: Flatness Matters for LLM Quantization". ICML 2025.
FlatQuant: Flatness Matters for LLM
Quantization
How to Integrate FlatQuant with the Transformer architecture?
Integration with
Self-attention
[1] Ruikang Liu, Haoli Bai†, [Link]. IntactKV: Improving Large Language Model Quantization by Keeping Pivot Tokens Intact. Findings of ACL, 2024.
IntactKV: Keeping Pivot Tokens Intact
Avoid the quantization error accumulated on pivot tokens that are critical to the performance.
• System KV cache
are generated by the
BF16 model
• They can be further
trained like LLM
parameters
[1] Ruikang Liu, Haoli Bai†, [Link]. IntactKV: Improving Large Language Model Quantization by Keeping Pivot Tokens Intact. Findings of ACL, 2024.
Evaluating Quantized Models
[1] Li, S., et al. "Evaluating Quantized
Large Language Models." ICML 2024.
• Evaluation Dimensions
• Effects of quantization on 5 major categories of
tasks
• Effects of quantization on 11 model families
• Effects of quantizing 3 tensor types on model
performance
• Application scope of SOTA quantization
methods
[1] Li, Shiyao, Ning, Xuefei, et al. "Evaluating Quantized Large Language Models." ICML2024.
Evaluating Quantized Models
• Effects of Quantization on Emergent Abilities
• The tolerance to quantization varies across the four abilities, listed in descending order of
tolerance: In-context Learning ∼ Instruction Following > Multi-Step Reasoning ~ Self-
calibration.
[1] Li, Shiyao, Ning, Xuefei, et al. "Evaluating Quantized Large Language Models." ICML2024.
Evaluating Quantized Reasoning Models
• Reasoning LLMs: Qwen 1.5B - 32B distilled from DeepSeek-R1
• Hard tasks (e.g., AIME) suffer more than easier ones (e.g., GSM8K)
• W8A8 and W4A16 is safe to use (<1% acc drop)
• W4A4 and KV4 can be still risky in practice
[1] Liu, R., Sun Y., Zhang M., Bai H., et al. "Quantization Hurts Reasoning? An Empirical Study on Quantized Reasoning Models". COLM 2025.
Evaluating Quantized Reasoning LLMs
The scaling effect of quantized reasoning LLMs
• (a) & (b): Large quantized LLMs are preferred to small BF16 LLMs w.r.t. size and latency
• (c) Test-time scaling: higher accuracy with more reasoning tokens, but at a slower rate
when compared to BF16 models
(a) Model Size (GB) (b) Latency (s) (c) Test-time Scaling
[1] Liu, R., Sun Y., Zhang M., Bai H., et al. "Quantization Hurts Reasoning? An Empirical Study on Quantized Reasoning Models". COLM 2025.
Menu of Techniques
Efficient Output Decoding
parallel generation, verification, or
refinement strategies
Algorithm- Model Compression
Input Compression
level prompt compression, RAG • Quantization
Alternative Generative • Sparse Attention
Paradigms • Weight Pruning
• Sharing
Model Compression • Knowledge Distillation
reduce model redundancy in a
static manner
token
[1] Child, Rewon, et al. "Generating long sequences with sparse transformers." arXiv preprint arXiv:1904.10509 (2019).
[2] Xiao, Guangxuan, et al. "Efficient Streaming Language Models with Attention Sinks." The Twelfth International Conference on Learning Representations.
[3] Zaheer, Manzil, et al. "Big bird: Transformers for longer sequences." Advances in neural information processing systems 33 (2020): 17283-17297.
[4] Wang, Hanrui, Zhekai Zhang, and Song Han. "Spatten: Efficient sparse attention architecture with cascade token and head pruning." 2021 IEEE International Symposium on High-Performance
Computer Architecture (HPCA). IEEE, 2021.
[5] Kitaev, Nikita, Lukasz Kaiser, and Anselm Levskaya. "Reformer: The Efficient Transformer." International Conference on Learning Representations.
[6] Zhang, Zhenyu, et al. "H2o: Heavy-hitter oracle for efficient generative inference of large language models." Advances in Neural Information Processing Systems 36 (2023): 34661-34710.
[7] Fu, Tianyu, et al. "Mixture of Attention Spans: Optimizing LLM Inference Efficiency with Heterogeneous Sliding-Window Lengths." Second Conference on Language Modeling.
[8] Yuan, Jingyang, et al. "Native sparse attention: Hardware-aligned and natively trainable sparse attention." arXiv preprint arXiv:2502.11089 (2025).
StreamingLLM
• Sparse Attention: StreamingLLM
[1] Xiao, Guangxuan, et al. “Efficient Streaming Language Models with Attention Sinks.” ICLR 2024.
MoA
• Sparse Attention: MoA
[1] Fu, Tianyu, et al. "Mixture of Attention Spans: Optimizing LLM Inference Efficiency with Heterogeneous Sliding-Window Lengths." Second Conference on Language Modeling.
MoA
Resul Increase the inference throughput by about 7×.
ts Expand the effective context length by 3.9×.
Accuracy-Throughput Needle-in-a-haystack Task Efficiency
3.9x 1.7x-1.9x
Effective context length
Throughput Improvement
Compared with VLLM on
7B and 13B LLMs using
256k
Extrapolatable input length
50% attention sparsity on
A100-80GB GPUs
[1] Fu, Tianyu, et al. "Mixture of Attention Spans: Optimizing LLM Inference Efficiency with Heterogeneous Sliding-Window Lengths." Second Conference on Language Modeling.
NSA
• Sparse Attention: NSA
[1] Yuan, Jingyang, et al. "Native sparse attention: Hardware-aligned and natively trainable sparse attention." arXiv preprint arXiv:2502.11089 (2025).
Menu of Techniques
Efficient Output Decoding
parallel generation, verification, or
refinement strategies
Algorithm- Model Compression
Input Compression
level prompt compression, RAG • Quantization
Alternative Generative • Sparse Attention
Paradigms • Weight Pruning
• Sharing
Model Compression • Knowledge Distillation
reduce model redundancy in a
static manner
Idea Method
• Removing weights and updating the • Incrementally prune weights in each column of the
remaining ones to compensate for the weight, using a sequence of Hessian inverses,
and updating the remainder of the weights.
error.
Category
[1] Elias Frantar, et al. “SparseGPT: Massive Language Models Can Be Accurately Pruned in One-Shot” ICML 2023.
SparseGPT
Results
• High Sparsity, Low Accuracy Loss: Prunes OPT-175B to 60% sparsity in
one shot with a negligible increase in perplexity
• High Efficiency: Process the 175-billion-parameter models in under 4.5
hours, removing more than 100 billion weights.
[1] Elias Frantar, et al. “SparseGPT: Massive Language Models Can Be Accurately Pruned in One-Shot” ICML 2023.
LLM-Pruner
Idea Methods
• Identify and remove non-critical, coupled • LLM-Pruner automatically identifies and
structures. removes non-critical, coupled structures
based on gradient information, and recovers
performance using a LoRA with a small
dataset.
Category
• Type: Structured Pruning
• Granularity: Head, Channel
[1] Xinyin Ma, et al. “LLM-Pruner: On the Structural Pruning of Large Language Models” Neurips 2023.
Channel Permutation for Better N:M Sparsity
Find a permutation strategy that preserves more important parameters under N:M sparsity
2:4 Sparsity
2 zeros out of every 4
contiguous elements
[1] Zhang, Y., Bai, H., et al. "Plug-and-play: An Efficient Post-training Pruning Method for Large Language Models". ICLR 2024.
Menu of Techniques
Efficient Output Decoding
parallel generation, verification, or
refinement strategies
Algorithm- Model Compression
Input Compression
level prompt compression, RAG • Quantization
Alternative Generative • Sparse Attention
Paradigms • Weight Pruning
• Sharing
Model Compression • Knowledge Distillation
reduce model redundancy in a
static manner
LCKV √
CLA √
Block
[1] Reid, Machel, Edison Marrese-Taylor, and Yutaka Matsuo. "Subformer: Exploring weight sharing for parameter efficiency in generative transformers." arXiv preprint arXiv:2101.00234 (2021).
[2] Liu, Zechun, et al. "Mobilellm: Optimizing sub-billion parameter language models for on-device use cases." Forty-first International Conference on Machine Learning. 2024.
[3] Hay, Tamir David, and Lior Wolf. "Dynamic Layer Tying for Parameter-Efficient Transformers." The Twelfth International Conference on Learning Representations.
[4] Wu, Haoyi, and Kewei Tu. "Layer-Condensed KV Cache for Efficient Inference of Large Language Models." Proceedings of the 62nd Annual Meeting of the Association for Computational
Linguistics (Volume 1: Long Papers). 2024.
[5] Brandon, William, et al. "Reducing transformer key-value cache size with cross-layer attention." Advances in Neural Information Processing Systems 37 (2024): 86927-86957.
MobileLLM
• MobileLLM
Idea Methods
• Weight sharing between two • Design three different weight-sharing strategies:
adjacent blocks avoids weight
movement, requiring only
computing the block twice
and incurring minimal latency
overhead.
Category
Immediate block- Repeat-all-over Reverse
• Type: Weight Sharing wise sharing sharing sharing
[1] Zechun Liu, et al. “MobileLLM: Optimizing Sub-billion Parameter Language Models for On-Device Use Cases” ICML 2024.
LCKV
• Layer-Condensed KV Cache
Motivation Methods
• In LCKV, all layers attend to only the top
• Existing methods focus on compressing the layer's KVs.
KV cache sequence length. • A few "warmup" layers with standard
attention are kept to maintain performance.
• This approach reduces the number of
cached layers, not just the sequence length.
[1] Haoyi Wu, et al. “Layer-Condensed KV Cache for Efficient Inference of Large Language Models” ACL 2024.
Menu of Techniques
Efficient Output Decoding
parallel generation, verification, or
refinement strategies
Algorithm- Model Compression
Input Compression
level prompt compression, RAG • Quantization
Alternative Generative • Sparse Attention
Paradigms • Weight Pruning
• Sharing
Model Compression • Knowledge Distillation
reduce model redundancy in a
static manner
Teacher Student
…
…
GKD √
Block Block DISCO √
2. Logits MCKD √
Logits Logits
DeepSeek-R1 √
3. Data
Data Data
[1] Liang, Chen, et al. "Less is more: Task-aware layer-wise distillation for language model compression." International Conference on Machine Learning. PMLR, 2023.
[2] Gu, Yuxian, et al. "MiniLLM: Knowledge Distillation of Large Language Models." The Twelfth International Conference on Learning Representations.
[3] Agarwal, Rishabh, et al. "Gkd: Generalized knowledge distillation for auto-regressive sequence models." CoRR (2023).
[4] Chen, Zeming, et al. "DISCO: Distilling Counterfactuals with Large Language Models." Proceedings of the 61st Annual Meeting of the Association for Computational Linguistics. 2023.
[5] Zhao, Jiachen, et al. "Multistage collaborative knowledge distillation from large language models." arXiv preprint arXiv:2311.08640 (2023).
[6] Guo, Daya, et al. "Deepseek-r1: Incentivizing reasoning capability in llms via reinforcement learning." arXiv preprint arXiv:2501.12948 (2025).
Menu of Techniques
Efficient Output Decoding
parallel generation, verification, or
refinement strategies
Algorithm- Model Compression
Input Compression
level prompt compression, RAG • Quantization
Alternative Generative • Sparse Attention
Paradigms • Weight Pruning
• Sharing
Model Compression • Knowledge Distillation
reduce model redundancy in a
static manner
MoE: Token-level dynamic module routing R2R: Token-level dynamic model routing
[1] Dynamic Neural Networks: A Survey, Han et al., IEEE Transactions on Pattern Analysis and Machine Intelligence.
Mixture-of-Depths
• Mixture-of-Depths
Idea Methods
• In language modeling, not all tokens • At specific layers, a learned router selects the
and sequences require the same time top-k most important tokens to be processed
or effort to accurately make a by the self-attention and MLP blocks, while
prediction. other tokens bypass these computations
through a simple residual connection.
Category
[1] David Raposo, et al. “Mixture-of-Depths: Dynamically allocating compute in transformer-based language models.” ArXiv 2024.
RouteLLM
• RouteLLM
Motivation Methods
• Direct simpler queries to smaller • RouteLLM trains a router model on human
models and more complex ones to preference data to intelligently direct queries to
larger models to balance response either a strong, expensive LLM or a weak, cheap
quality with cost efficiency. one.
Category
• routers outperform
• Granularity:query-level random baselines
• Dimension: model
• Method: similarity-based
retrieval / training a router
[1] David Raposo, et al. “RouteLLM: Learning to Route LLMs with Preference Data.” ArXiv 2024.
Recent Work: SLM-LLM Mix Inference (R2R)
Use small language model (SLM) and LLM for different reasoning steps
Fast but weak SLM Given same context, SLM and LLM
Motivation Insight
slow but strong LLM predictions are often identical
[1] Tianyu, Fu, et al. "Efficiently Navigating Divergent Reasoning Paths with Small-Large Model Token Routing" Submitted to NeurIPS’25. [Under Review]
Recent Work: SLM-LLM Mix Inference (R2R)
Label divergent token, then train a neural token-router,
utilizing LLMs only for path-divergent tokens during SLM generation
Label divergent tokens Train neural router,
Method Method route to LLM for divergent SLM tokens
generate model preference training data
input: It’s
SLM: It’s 99 It’s hard, It’s hard, re It’s hard, rewrite
✔ ✔ ✔
LLM: It’s hard
output: hard , re write
[1] Tianyu, Fu, et al. "Efficiently Navigating Divergent Reasoning Paths with Small-Large Model Token Routing" Submitted to NeurIPS’25. [Under Review]
Experimental Results
Mixing R1-1.5B & 32B, uing R2R with 5.6B avg. activated param. per token
achieve performance exceeding R1-14B
Performance-Efficiency Reaching 84.3 token/s
Result Demo
Pareto Frontier on two A800-80GB GPUs
source
code
[1] Tianyu, Fu, et al. "Efficiently Navigating Divergent Reasoning Paths with Small-Large Model Token Routing" Submitted to NeurIPS’25. [Under Review]
Menu of Techniques
Efficient Output Decoding
parallel generation, verification, or
refinement strategies
Algorithm- Model Compression
Input Compression
level prompt compression, RAG • Quantization
Alternative Generative • Sparse Attention
Paradigms • Weight Pruning
• Sharing
Model Compression • Knowledge Distillation
reduce model redundancy in a
static manner
[1] Mu, Siyuan, and Sen Lin. "A comprehensive survey of mixture-of-experts: Algorithms, theory, and applications." arXiv preprint arXiv:2503.07137 (2025).
MoE
• DeepSeekMoE
Motivation Methods
• The designated expert will intend • Segment the experts into a finer grain by
to assemble different types of splitting the FFN intermediate hidden dimension.
knowledge in its parameters, • Isolate certain experts to serve as shared
which are hard to utilize experts that are always activated.
simultaneously.
• Multiple experts may converge in
acquiring shared knowledge in
their respective parameters,
leading to redundancy in expert
parameters.
[1] Dai, Damai, et al. "DeepSeekMoE: Towards Ultimate Expert Specialization in Mixture-of-Experts Language Models." Proceedings of the 62nd Annual Meeting of the Association for
Computational Linguistics (Volume 1: Long Papers). 2024.
Efficient Attention mechanism
• Efficient structure design
• Efficient Attention mechanism
Research directions:
1. Design better parametrization or initialization strategy.
2. Design better model architecture based on SSM.
Mamba
• Mamba
• Let the SSM parameters be
Motivation • Linear-time-invariant (LTI) Methods
SSMs cannot efficiently functions of the input,
select data in an input- allowing the model to
dependent manner. selectively propagate or
forget information
depending on the current
token.
[1] The router can direct simpler queries to smaller models and more complex ones to larger models, thereby balancing response quality with cost efficiency.
Menu of Techniques
Efficient Output Decoding
parallel generation, verification, or
refinement strategies
Algorithm-
Input Compression
level prompt compression, RAG
Alternative Generative
Paradigms Operator-Level Opt.
Model Compression
reduce model redundancy in a Framework-Level Opt.
static manner
Operator-Level Opt.
System-
Framework-Level Opt.
level
Hardware-Level Opt.
Design Space
• System Design: Operator-level Optimization
Intermediate representation
and hardware instructions
Hardware
Level Operator Computation Memory
Hardware Fusion Opt. Opt.
Operator-level Optimization
Optimizes the hardware utilization by tailoring
Method
workload mapping to hardware specifications
FlashAttention FlashDecoding++
Add & LayerNorm
Matmul Operator (NeurIPS 22) (MLSys 24)
FC2 FC2
Main Operator of NN
Reduces the Reduces the update overhead of
Act. Act.
with Highly Optimized memory footprint attention operator and optimizes
FC1 FC1 Linear Algebra Libraries by fusing attention GEMM in decoding, achieving up
into one kernel to 4x end-to-end speedup
Add & LayerNorm
WO
cuBLAS FlashDecoding FlashInfer
Multi-head Self-Attention
Q K V (~2007-present) (arXiv 23) (MLSys 25 Best Paper)
K Cache V Cache
Attention Operator NVIDIA GPU’s Uses sequence Dynamically aware
WQ WK WV
official library partitioning for workload allocation and
Core of Transformer Achieves over 90% decoding, using unified mask
peak utilization of achieving up to 50x representation
A transformer block Tensor Cores speedup for long 13%-69% e2e speedup
texts
*Matmul: Matrix Multiplication
Matmul Operator
𝑐𝑜𝑚𝑝𝑢𝑡𝑎𝑡𝑖𝑜𝑛 𝑎𝑚𝑜𝑢𝑛𝑡
Comp−to−Mem Ratio =
𝑚𝑒𝑚𝑜𝑟𝑦 𝑎𝑐𝑐𝑒𝑠𝑠 𝑎𝑚𝑜𝑢𝑛𝑡
A C
Store in SMEM
(Shared memory)
*store A and 𝐵 into shared memory, total memory access reduces to 128Byte
Matmul Operator
• Memory Optimization: Using Shared Memory
Operator Implementation: 𝐶 0×0 = 𝐴0×0 ×𝐵 0×0
__global__ void MatMul_shared(int *A, int *B, int *C, int width) {
__shared__ int sharedA[width][width]; // Declare shared memory
__shared__ int sharedB[width][width]; B
int tx = threadIdx.x; int ty = threadIdx.y;
32bit
32bit
32bit
32bit
+ + + +
× × × ×
A!,# "$,! A%,# "$,% A&,# "$,& A',# "$,'
16bit 16bit 16bit 16bit 16bit 16bit 16bit 16bit
[1] [Link]
Matmul Operator
• Special Hardware: using Tensor Core
•CUDA provides mma.h and wmma API for Tensor Core operations
Pesudo code:
#include <mma.h>
__global__ void MatMul_mma(half *a, half *b, float *c, int M, int N, int K) {
// Declare fragments (16x16x16 tile size)
wmma::fragment<wmma::matrix_a, 16, 16, 16, half, wmma::row_major> a_frag;
wmma::fragment<wmma::matrix_b, 16, 16, 16, half, wmma::col_major> b_frag;
wmma::fragment<wmma::accumulator, 16, 16, 16, float> c_frag;
FC2 FC2
Activation Activation
FC1 FC1
WO WO
Prompt: ['I', 'like', ‘natural', ‘language’] (4*dim) Prompt: [‘I’, ‘like’, ‘natural’, ‘language’, ‘Processing] (1*dim)
Attention Operator
[1] Dao, Tri, et al. "Flashattention: Fast and memory-efficient exact attention with io-awareness." Advances in neural information processing systems 35 (2022): 16344-16359.
[2] Dao, Tri. "Flashattention-2: Faster attention with better parallelism and work partitioning." arXiv preprint arXiv:2307.08691 (2023).
[3] Shah, Jay, et al. "Flashattention-3: Fast and accurate attention with asynchrony and low-precision." Advances in Neural Information Processing Systems 37 (2024): 68658-68685.
[4] [Link]
Attention Operator
• Prefill Optimization: FlashAttention[1,2,3]
• Why:Complex Attention I/O; Large activation memory
• How:Operator fusion, including fwd and bwd
• Results:2-4x speedup; memory: 𝑂 𝑁 : → 𝑂(𝑁)
Saves I/O & memory via operator fusion Tiling strategies differ between fwd/bwd passes
[1] Dao, Tri, et al. "Flashattention: Fast and memory-efficient exact attention with io-awareness." Advances in neural information processing systems 35 (2022): 16344-16359.
[2] Dao, Tri. "Flashattention-2: Faster attention with better parallelism and work partitioning." arXiv preprint arXiv:2307.08691 (2023).
[3] Shah, Jay, et al. "Flashattention-3: Fast and accurate attention with asynchrony and low-precision." Advances in Neural Information Processing Systems 37 (2024): 68658-68685.
Attention Operator
tiling SM2
Prefill tiling Fully utilizes
GPU SMs
SM3
SM4
Attention map
SM1
tiling
SM2
FlashDecoding
SM3
…
…
Original Softmax Online Softmax B
All elements wait for global M dimension = batch
Global reduction via
reduction incremental updates
size M A1 A2 A3 … A C1 C2 C
K N
[1] Dao T, Fu D, Ermon S, et al. Flashattention: Fast and memory-efficient exact attention with io-awareness[J]. Advances in neural information processing systems, 2022, 35: 16344-16359.
[2] [Link]
[3] [Link]
FlashDecoding++
Motivation Suboptimal implementation against various Matmul shapes
M=32 M=3
Various
Matmul
K=4096 K=5120 … M=1024
K=1024 Shape 1: M=1, K=4096, N=4096]
N=11008 N=5120 N=1024
Shapes FastGEMV is 20% faster
than cuBLAS
Model Input
specs dynamics
…
Manual Hardware Shape 2: M=4, K=4096, N=4096]
implementatio capability
n Flat GEMM is 50% faster
than FastGEMV
Update
99.99% 99.99% 99.99% Numerical Overhead
Feasibility
Data shows no FP32 Online softmax Async softmax
[-16.8] [6.5] [-440.2] [71.6] [-16.8] [6.5]
overflow in 99.99% Parallel but large update Parallel with zero update
cases overhead overhead
-70 -20 -10 0 10 40 -440 -40 -20 0 20 60 80 -70 -20 -10 0 10 40
[1] Ke, Hong, et al. “FlashDecoding++: Faster Large Language Model Inference with Asynchronization, Flat GEMM Optimization, and Heuristics.” Proceedings of Machine Learning and Systems. 2024.
FlashDecoding++
Synchronized partia
Leverage value distribution in LLM inference to
Method
optimize Attention operator[1] Attention
N-1
mul1 ma
synchronized u
N is large: Low Parallelism N is large: Memory-bound N is large: Low Parallelism N is large: Memory-bound
Need more tiles Low Comp-to-mem ratio Fine-grained tiling on N-dim for Double buffering to
sufficient parallelism hide access latency
[1] Ke, Hong, et al. “FlashDecoding++: Faster Large Language Model Inference with Asynchronization, Flat GEMM Optimization, and Heuristics.” Proceedings of Machine Learning and Systems. 2024.
FlashDecoding++
Leverage Matmul shape patterns in LLM inference for
Method
dynamic implementation selection[1]
Observation 2:
Only M dimension For each [N, K]
varies with input Offline: fine 2 critical
Prefill: M=total token points per [N, K]
count
Decode: M=batch size Only 4 shape Online: select based
categories! on M value
Columns: [N, K] combinations
[1] Ke, Hong, et al. “FlashDecoding++: Faster Large Language Model Inference with Asynchronization, Flat GEMM Optimization, and Heuristics.” Proceedings of Machine Learning and Systems. 2024.
FlashDecoding++
Throughput surpasses SOTA by over 10%
Method
1.88x faster v.s. HuggingFace on average
40.07
FlashDecoding++
HuggingFace LightLLM DeepSpeed vLLM OpenPPL TRT-LLM
*Test setup: L Llama2-7B, bs=1, 128 I/O tokens, single A100 GPU
[1] Ke, Hong, et al. “FlashDecoding++: Faster Large Language Model Inference with Asynchronization, Flat GEMM Optimization, and Heuristics.” Proceedings of Machine Learning and Systems. 2024.
Design Space
• System Design: Framework-level Optimization
Edge Cloud
Intermediate representation
and hardware instructions
Hardware Request Memory
Offload
Level Scheduling Optimization
Hardware
Framework-level Optimization
Optimizing the system throughput
Method
adhering to the service-level objective (SLO)
vLLM Sarathi-Serve SGLang
batching
How to schedule? (SOSP 23) (OSDI 24) (NeurIPS 24)
Paged KV cache Mixed P/D request Prefix caching technique
Basic memory batching Reuses repeated KV
or management for LLM Basic batching method for cache across requests
Inference Engine: Parallel Strategy serving co-located systems 6x throughput
2-4x throughput 2x throughput improvement
Card0 Card0 improvement improvement
or
Request Queue Card1 Card1 Orca DistServe Mooncake
(OSDI 22) (OSDI 24) (FAST 25 Best
Decode (D) Request Completed Continuous batching P/D disaggregated Paper)
Requests Basic scheduling system
Prefill (P) Request KV cache-centric
method for LLM Specialized optimization scheduling and storage
Send inference serving for P/D instances strategy based on a
Request ~10x throughput Improves effective
disaggregated system
User 0 improvement throughput by 4.48x
design
User 1
Offloading Techniques
• Offloading Technique: Definition and Motivation
• Definition: Offloading parts of the model (model weights, KV cache, etc.) from GPU to
other devices (e.g., CPU) for storage or even computation, to save space and improve
computational efficiency
• Motivation: The large volume of model parameters and KV cache data exceeds the
storage capacity of GPU memory
[1] Memory Analysis on the Training Course of DeepSeek Models, Zhang et al. Arxiv Preprint 2502.07486.
Offloading Techniques
• Offloading Techniques: Categories
Offloading Model Weights Offloading KV Cache Offloading Experts
Adopt the Zig-zag computation order to Offload KV Cache to CPUs to relieve KTransformers offloads experts to
hide the communication time of weight the storage pressure on GPUs CPUs (detailed in the next page)
transmission during the decode phase
[1] FlexGen: High-Throughput Generative Inference of Large Language Models with a Single GPU, Sheng et al. Arxiv Preprint 2303.06865.
[2] FastDecode: High-Throughput GPU-Efficient LLM Serving using Heterogeneous Pipelines, He et al. Arxiv Preprint 2403.11421.
[3] [Link]
Request Scheduling
• Request Scheduling
• Definition: Scheduling requests in different phases to GPU instances for batched
computation
• Motivation: Requests for LLM inference have varying lengths and distinct phases (Prefill
and Decode phases), and scheduling greatly impacts the performance of inference
Decode:
memory-bound
bottleneck
Prefill:
Statistical distribution of request lengths compute-bound
bottleneck
across different datasets
How to perform batch processing for
requests with varying lengths?
Request Scheduling
• Request Scheduling: Batching
• Orca (G. Yu et al, OSDI’22) proposes the continuous batching technique, which batches
requests with varying lengths at the TOKEN granularity. Compared to request-level
batching, it improves throughput by 36.9x
Request Request
1 1
Request Request
2 2
Request Request
3 3
Request Request
4 4
[1] G. Yu, et al. ”ORCA: A Distributed Serving System for Transformer-Based Generative Models.”, OSDI, 2022.
Memory Optimization
• Memory Optimization: PagedAttention
• The growth of KV cache and memory fragmentation limit concurrency, resulting in
suboptimal system throughput.
• vLLM (W. Kwon et al, SOSP’23) proposes PagedAttention,which stores KV cache in a
paged manner. This approach effectively eliminates memory fragmentation, and improves
throughput by 2–4 times.
Storage
Storage GPU KV GPU
Fusion GPU HBM cache
Separation HBM HBM
[1] W. Kwon, et al. ” Efficient Memory Management for Large Language Model Serving with PagedAttention.”, SOSP, 2023.
[2] L. Zheng, et al. “SGLang: Efficient Execution of Structured Language Model Programs”, NeurIPS, 2024.
[3] R. Qin, et al. “Mooncake: Trading More Storage for Less Computation”, FAST, 2025.
[4] DeepSeek Team. “DeepSeek-V3 Technical Report”. arXiv, 2024.
semi-PD
Key Co-located and disaggregated systems for Prefill/Decode have their own
Problem strengths and weaknesses in computation and storage.
Representativ
e Frameworks
Mixed Computational Disadvantages
computation
GPU SMs Resource contention and latency
interference between P and D
Storage Advantages
Shared No need to transfer KV cache
Storage
GPU HBM between P and D → High HBM
utilization
[1] W. Kwon, et al. ” Efficient Memory Management for Large Language Model Serving with PagedAttention.”, SOSP, 2023.
[2] L. Zheng, et al. “SGLang: Efficient Execution of Structured Language Model Programs”, NeurIPS, 2024.
semi-PD
Key Co-located and disaggregated systems for Prefill/Decode have their own
Problem strengths and weaknesses in computation and storage.
[1] R. Qin, et al. “Mooncake: Trading More Storage for Less Computation”, FAST, 2025.
[2] DeepSeek Team. “DeepSeek-V3 Technical Report”. arXiv, 2024.
semi-PD
Combine the computational advantage of disaggregated systems and
Method
the storage advantage of co-located systems[1]
Computation Disaggregation & Storage Unification: P/D computing resources are
isolated, but storage resources are shared
Prefill Decode
Requests Requests P/D computing resources are isolated
and divided into different processes
Computational Advantage
P/D isolated computation with no
latency interference.
Isolated
Computation GPU SMs
[1] Ke, Hong, et al. ”semi-PD: Towards Efficient LLM Serving via Phase-wise Computation Disaggregation and Unified Storage." arXiv preprint arXiv:2504.19867. 2025.
semi-PD
Combine the computational advantage of disaggregated systems and the
Method
storage advantage of co-located systems[1]
Isolated Computation and Shared Storage via IPC Low-Overhead Resource Adjustment Mechanism
[1] Ke, Hong, et al. ”semi-PD: Towards Efficient LLM Serving via Phase-wise Computation Disaggregation and Unified Storage." arXiv preprint arXiv:2504.19867. 2025.
Design Space
• System Design: Hardware-level Optimization
Dense computing + High-end hardware
AI algorithm
Model Duration!
Software
Level 4 cycles
LLMs VGMs
(mainly considering the (Temporal, spatial,
decode stage) and FFN structure)
: ≈ 16𝐹𝑁𝑑 :
Computation* ≈ 12𝑑 + 2𝑁𝑑
+ 2𝐹𝑁(𝐹 + 𝑁)𝑑
Memory ≈ 16𝑑 :
≈ 12𝑑 : + 2𝑁𝑑
access* + 15𝐹𝑁𝑑
Operational
≈𝟏 ≈ 𝑭𝑵 LLMs VGMs
intensity (OI)
F: Video frames. N: Tokens. d: Hidden dimension.
*Calculation of a single block/layer.
Hardware for Video Generation Models
H.262/MPEG-2 [1995] H.264/MPEG-4 [1996]
Developed for TV The most used video
H.261 [1988]
broadcasts and DVD- codec today, max
First modern and Video playback, max
useful codec, max resolution
resolution 1920*1080 4096*2048
resolution 352*288
H.265/HEVC [2013]
Further reduce the
MPEG-1 [1993] H.263 [1996]
video size, enables
Compressed video Low-bandwidth
technologies such as
making video CDs standard used for the
AR and VR [1]
possible internet
Video with
small size
DCT
(Discrete Cosine
Unimportant
Transform)
Unimportant
Video Generation Important (INT8)
(FP16)
Generated
1. Activation sparsification 2. Hybrid precision quantization video
Hardware for Video Generation Models
For linear-heavy video generation models, we propose FlightVGM, a HW-SW
co-design with temporal-spatial & floating-fixed strategies
Similarity Frame
Spatial-temporal
To Token
Token compression 2 Only
skip skip skip
1
Token 2 4 !
Token T
2 Token 2 1 skip
3 4
e
am
1 1 2 3 4 Token
Fr
Fixed-point DSP-Expansion Floating-point
computation (DSP-E) computation
(e.g., attention) (e.g., linear)
Max
DSP-E DSP-E
(INT8 mode) DSP (scalar) (FP16 mode)
Ø Attention dominated! resolution ↑ or dim.↓
Ø Linear dominated!resolution↓ or dim.↑ Sparse Computing + Configurable Design
→ Higher Performance
Hardware for Video Generation Models
Main To address the computational redundancy problem in VGMs, a
Method temporal-spatial joint sparse method is proposed
A A
*
_.frac INT8 B DSP58 P INT8 B DSP58 P
INT8 INT8
C C
MUL
MUL * MUL
MUL
Max
Max Alignment
Normalization Max
Max Alignment
Normalization
X, Y
_.exp INT6
EXP INT
INT INT6
EXP INT
INT
ADD
Align ADD
ADD ADD
Align ADD
ADD x, y
FP16 mode INT8 mode - -!"
! = #×%! + '! , ) = #×%" + '" *, + = ,! , ," × !! + .! , ."
-"! -""
[1] Liu J, Zeng S, Ding L, et al. Flightvgm: Efficient video generation model inference with online sparsification and hybrid precision on fpgas[C]//Proceedings of the 2025 ACM/SIGDA International Symposium
on Field Programmable Gate Arrays. 2025: 2-13.
Hardware for Video Generation Models
n Models and datasets
n Models!Latte-1 and Open-Sora 1.2
n Datasets!UCF-101
n Metrics
n CLIPSIM: Text-Video Alignment
n VBench: Video quality
n Baseline
n Generic hardware: NVIDIA 3090 GPU
n FPGA-based accelerator for Transformer: HiSpMV[FPGA’24] and
FlightLLM[FPGA’24]
n ASIC-based accelerator for DiT: InterArch[DAC’24] and CMC[ASPLOS’24]
Hardware for Video Generation Models
With 21× lower peak compute than the NVIDIA 3090, FlightVGM achieves
1.3× higher speedup and 4.5× better energy efficiency
Operator-Level Opt.
System-
Framework-Level Opt.
level
Hardware-Level Opt.
Menu of Techniques
Efficient Output Decoding
parallel generation, verification, or
refinement strategies
Algorithm-
Input Compression
level prompt compression, RAG
Efficient Output Decoding
Alternative Generative • Speculative Decoding
Paradigms • Jacobi Decoding
• Agentic Generation
Model Compression
reduce model redundancy in a
static manner Input Compression
Model- Dynamic Inference • Input Compression
reduce model redundancy in a
level dynamic manner
Alternative Generative Paradigms
Structure Design
design novel structure, which often • Diffusion for Text
require training
Operator-Level Opt.
System-
Framework-Level Opt.
level
Hardware-Level Opt.
Speculative Decoding: Concepts
● Recall: autoregressive decoding of LLMs
- Decoding stage: memory bound (data transfer of model weights & KV cache)
- Redundant computation is left unused!
Decoding stage
T1 T2 T3 …
Auto-regressive decoding
LLM
User Prompt T1 T2 T3
Speculative Decoding: Concepts
● Core idea of speculative decoding
- Use a small draft model to generate multiple token for verification
- The LLM conducts parallel verification (memory bound allows more computation)
- Key elements: 1) the acceptance rate of generated tokens; 2) the cost of draft model
Context T1 T2 T3 T4 Context T1 T2 T3 T4
Context T1 T2 T3 Context T1 T2 T3 T4
[1] Leviathan, Yaniv, Matan Kalman, and Yossi Matias. Fast inference from transformers via speculative decoding. ICML 2023.
Speculative Decoding: Demo
● Demo from [1]
- Green: accepted tokens
- Red: rejected tokens
- Blue: corrected tokens
[1] Leviathan, Yaniv, Matan Kalman, and Yossi Matias. Fast inference from transformers via speculative decoding. ICML 2023.
Speculative Decoding: Speed-up Estimation
● The speed-up rate of speculative decoding (SD) can be estimated!
- S: the total number of tokens
- R: the number of SD rounds
- γ: the number of generated tokens in each SD round
① ② ③
② The cost of multi-token verification. A large batch size B is harmful to speed-up rate
[1] Sadhukhan, Ranajoy, et al. Magicdec: Breaking the latency-throughput tradeoff for long context generation with speculative decoding. ICLR 2025.
[2] Huang, Zongle, et al. MoESD: Unveil Speculative Decoding's Potential for Accelerating Sparse MoE. arXiv preprint arXiv:2505.19645 (2025).
Speculative Decoding: Representative Works
● How to find an good draft model?
- consistent with the target model
- efficient in decoding
23-9: Medusa [1] 24-1: Eagle [2] 24-10: LayerSkip [3] 24-12: DeepSeek-V3 [4]
[Draft model] Independently [Draft model] A single transformer [Draft model] The first a few [Draft model] Independent multi-layer
trained multi-layer decoders layer taking the output from LLM layers of the LLM itself perception pre-trained together with DS-V3
[1] Tianle Cai, et. al. Medusa: Simple llm inference acceleration framework with multiple decoding heads. ICML 2024.
[2] Yuhui Li, et. al, EAGLE: Speculative Sampling Requires Rethinking Feature Uncertainty, ICML 2024
[3] Mostafa Elhoushi, et. al. LayerSkip: Enabling Early Exit Inference and Self-Speculative Decoding, arXiv preprint, 2024
[4] Deepseek Team. DeepSeek-V3 Technical Report.
Speculative Decoding: Eagle
Drat model: a single transformer layer
- # params: 0.25B ~ 1B
- # training data: 1B tokens
- Acceptance rate: 75%
[1] Yuhui Li, et. al, EAGLE: Speculative Sampling Requires Rethinking Feature Uncertainty, ICML 2024
[2] Yuhui Li, et, al, Eagle-2: Faster inference of language models with dynamic draft trees. EMNLP 2024
[3] Yuhui Li, et. al, EAGLE-3: Scaling up Inference Acceleration of Large Language Models via Training-Time Test, arXiv preprint 2503.01840.
Speculative Decoding: Multi-Token Prediction
● Multi-Token Prediction (MTP): trained from scratch with the LLM backbone
[1] Huang, Zongle, et al. MoESD: Unveil Speculative Decoding's Potential for Accelerating Sparse MoE. NeurIPS 2025 spotlight.
Menu of Techniques
Efficient Output Decoding
parallel generation, verification, or
refinement strategies
Algorithm-
Input Compression
level prompt compression, RAG
Efficient Output Decoding
Alternative Generative • Speculative Decoding
Paradigms • Jacobi Decoding
• Agentic Generation
Model Compression
reduce model redundancy in a
static manner Input Compression
Model- Dynamic Inference • Input Compression
reduce model redundancy in a
level dynamic manner
Alternative Generative Paradigms
Structure Design
design novel structure, which often • Diffusion for Text
require training
Operator-Level Opt.
System-
Framework-Level Opt.
level
Hardware-Level Opt.
Jacobian Decoding
[1] [Link]
Lookahead Decoding
“Lookahead”: reuse the promising draft from past N-gram trajectories
[1] [Link]
Lookahead Decoding
Lookahead branch
maintains a fixed-sized, 2D Verification branch selects
window to generate n-grams and verifies promising n-gram
from the Jacobi iteration candidates.
trajectory.
[1] [Link]
Menu of Techniques
Efficient Output Decoding
parallel generation, verification, or
refinement strategies
Algorithm-
Input Compression
level prompt compression, RAG
Efficient Output Decoding
Alternative Generative • Speculative Decoding
Paradigms • Jacobi Decoding
• Agentic Generation
Model Compression
reduce model redundancy in a
static manner Input Compression
Model- Dynamic Inference • Input Compression
reduce model redundancy in a
level dynamic manner
Alternative Generative Paradigms
Structure Design
design novel structure, which often • Diffusion for Text
require training
Operator-Level Opt.
System-
Framework-Level Opt.
level
Hardware-Level Opt.
Skeleton-of-Thought (SoT)
SoT: LLM generates the skeleton autoregressively, and then each points in parallel
(an attempt in agentic generation for efficiency)
• Skeleton Stage: Guide the LLM to output a
concise skeleton of the answer
• Point-expanding Stage: Guide the LLM to
expand on each point from the skeleton in
parallel
• Achieve up to 2.39x end-to-end speed-up
[1] Ning, Xuefei*, Zinan Lin*, et. al., ”Skeleton-of-Thought: Prompting LLMs for Efficient Parallel Generation." ICLR 2024.
Menu of Techniques
Efficient Output Decoding
parallel generation, verification, or
refinement strategies
Algorithm-
Input Compression
level prompt compression, RAG
Efficient Output Decoding
Alternative Generative • Speculative Decoding
Paradigms • Jacobi Decoding
• Agentic Generation
Model Compression
reduce model redundancy in a
static manner Input Compression
Model- Dynamic Inference • Input Compression
reduce model redundancy in a
level dynamic manner
Alternative Generative Paradigms
Structure Design
design novel structure, which often • Diffusion for Text
require training
Operator-Level Opt.
System-
Framework-Level Opt.
level
Hardware-Level Opt.
Prompt Compression
● Prompt compression: eliminate redundant tokens in the prompt
Selective Context: filter out redundant tokens to shorten the input prompt
[1] Li Y, Dong B, Guerin F, et al. Compressing Context to Enhance Inference Efficiency of Large Language Models. EMNLP, 2023.
LLMLingua
Compress the prompt with an small language model, with an reduction rate up to 20x.
0. Distribution alignment
Instruction tuning of small LLM
1. Budget controller
Calculate the token-wise perplexity and
sort in the descending order
[1] Huiqiang Jiang, et al. RECOMP: Improving Retrieval-Augmented LMs with Compression and Selective Augmentation. EMNLP, 2023.
LLMLingua-2
A better way to construct training data for the compressor: instructed by GPT-4
[1] Pan Z, Wu Q, Jiang H, et al. Llmlingua-2: Data distillation for efficient and faithful task-agnostic prompt compression[J]. arXiv preprint arXiv:2403.12968, 2024.
AutoCompressor
The LLM learns to summarize history context given the instruction <summary_token>
[1] Chevalier A, Wettig A, Ajith A, et al. Adapting Language Models to Compress Contexts. EMNLP, 2023.
RECOMP
● Prompt compression for RAG systems
● Otherwise, the retrieved documents can be extremely long
Ultra-long context!
[1] [Link]
Context Folding for Agentic AI
● Context Folding: prompt compression for Agentic AI
[1] Weiwei Sun, et al. Scaling Long-Horizon LLM Agent via Context-Folding. arXiv,2510.11967.
Menu of Techniques
Efficient Output Decoding
parallel generation, verification, or
refinement strategies
Algorithm-
Input Compression
level prompt compression, RAG
Efficient Output Decoding
Alternative Generative • Speculative Decoding
Paradigms • Jacobi Decoding
• Agentic Generation
Model Compression
reduce model redundancy in a
static manner Input Compression
Model- Dynamic Inference • Input Compression
reduce model redundancy in a
level dynamic manner
Alternative Generative Paradigms
Structure Design
design novel structure, which often • Diffusion for Text
require training
Operator-Level Opt.
System-
Framework-Level Opt.
level
Hardware-Level Opt.
Diffusion Language Models
Any other solutions? —— Don’t use the autoregressive model?
—— To fully parallelized input & output, diffusion language models
Completion Infiliing
[1] Jiacheng Ye, et al. Dream 7B: Diffusion Large Language Models. arXiv preprint, 2508.15487.
Diffusion Language Models
● Autoregressive modeling v.s. Diffusion modeling
[1] Jiacheng Ye, et al. Dream 7B: Diffusion Large Language Models. arXiv preprint, 2508.15487.
[2] Shen Nie, et al. Large Language Diffusion Models. NeurIPS 2025.
Diffusion Language Models
● Inference latency of diffusion models
Contents
Model-Level
1 Background 5 Optimization
2 Preliminary System-Level
≈
6 Optimization
● Preliminary:
● Most LLMs use autoregressive model as the generative modeling method, the
transformer architecture, in which the attention operation is a core mechanism.
● We introduce basic concepts of software, hardware system, device, chip,
microarchitecture, and the interface between software & hardware – instruction.
● AI inference is seen as forwarding data on a computational graph, where each node
represents a single operator, edge represents dependency. Operators are translated
to instructions. Hardware execute instructions.
Tutorial Review
● Problem Definition: Usually, latency, memory, energy consumption and
throughput will be the ultimate objective or constraint on “efficiency”. In the
meantime, the intelligence level of AI needs to be retained.
● Measured metrics are actually tested on platform (thus is platform-related), and
directly correspond to the objectives / constraints.
● Proxy metrics are estimated with only model specification. In practice, they are
useful in diagnosis of the bottleneck and estimation of measured metrics.
Data-mixture of QAT
Compression of reasoning models
Training objectives v.s. LLM origins
RL with quantization
Xuefei Ning1, Guohao Dai2,4, Haoli Bai3, Lu Hou3, Yu Wang1, Qun Liu3
1Tsinghua University 2Shanghai Jiao Tong University 3Huawei 4Infinigence-AI
Tutorial Website
[Link]