Working with Transformers#
TensorRT provides built-in layers and fusions for common transformer workloads, so attention, position embeddings, and expert routing map onto dedicated APIs instead of hand-built subgraphs.
In this guide
Rotary Position Embedding: express RoPE with
IRotaryEmbeddingLayerand import it from ONNXKV Cache: update the K/V cache during LLM inference with
IKVCacheUpdateLayerMoE (Mixture of Experts): route tokens to experts with
IMoELayeron SM100, SM103, and SM110Fused Attention: trigger attention fusion through
IAttentionor a primitive layer graphMulti-Device Attention: split the key-value sequence across GPUs with context parallelism