AI & LLMOps
LLM Inference Optimization with TensorRT-LLM and Speculative Decoding
Deploying Large Language Models into high-throughput production environments presents formidable financial and infrastructure hurdles. At scale, LLM serving is overwhelmingly memory-bandwidth bound during autoregressive token generation: memory buses struggle to stream gigabytes of weight matrices per single-token output. Maximizing serving efficiency requires cutting-edge acceleration techniques: NVIDIA TensorRT-LLM kernel fusion, FP8 quantization on Ada Lovelace/Hopper architectures, and speculative decoding using compact draft models.
Understanding Speculative Decoding Acceleration
Speculative decoding pairs a small, fast “draft model” (e.g., Llama-3.2-1B) with a high-capacity “target model” (e.g., Llama-3.1-70B). The draft model speculatively generates $K$ candidate tokens at very low latency, which the large target model verifies in parallel within a single forward pass:
| Inference Technique | Tokens Per Second (70B Model) | GPU Memory Consumption | Accuracy Impact |
|---|---|---|---|
| Standard HuggingFace FP16 | 12 – 18 tok/s | 140 GB VRAM | Baseline (0% loss) |
| vLLM PagedAttention (AWQ 4-bit) | 45 – 65 tok/s | 42 GB VRAM | < 0.5% Perplexity drop |
| TensorRT-LLM FP8 Native | 85 – 110 tok/s | 72 GB VRAM | No measurable quality loss |
| TensorRT-LLM + Speculative Decoding | 140 – 195 tok/s | 80 GB VRAM | Identical output distribution to target model |
Deploying Optimized TensorRT-LLM Engines
Building a high-throughput TensorRT-LLM deployment pipeline involves compiling model weights into optimized engine formats utilizing custom GEMM kernels and in-flight batching:
# Compile Llama-3-70B to TensorRT-LLM FP8 Engine
trtllm-build \
--checkpoint_dir ./llama-3-70b-fp8/ \
--output_dir ./engine_output/ \
--gemm_plugin fp8 \
--gpt_attention_plugin fp8 \
--paged_kv_cache enable \
--remove_input_padding enable \
--use_custom_all_reduce enable \
--max_batch_size 128 \
--max_input_len 4096 \
--max_output_len 2048 \
--speculative_decoding_mode draft_tokens_external
- In-Flight Continuous Batching: Evicts completed sequences and schedules newly arrived requests dynamically at token-level iteration boundaries rather than waiting for batch completion.
- Chunked Prefill: Prevents long initial prompt processing from starving active token-generation streams of compute cycles.
- Hardware Alignment: Leverage FP8 tensor cores natively supported on Hopper (H100) and Ada Lovelace (L40S) GPUs for maximum operational throughput.
