Transformers documentation
TensorRT-LLM
快速入门
基类
模型
预处理器
推理
Pipeline API
生成 API
优化
与模型对话
服务
训练
硬件
量化
生态系统集成
资源
API
You are viewing main version, which requires installation from source. If you'd like
regular pip install, checkout the latest stable version (v5.24.0).
TensorRT-LLM
TensorRT-LLM 可优化 NVIDIA GPU 上的 LLM 推理。它将模型编译为 TensorRT 引擎,支持 in-flight batching、paged KV caching 和 tensor parallelism。AutoDeploy 可直接接受 Transformers 模型,无需任何修改。它会自动将模型转换为优化后的运行时。
将来自 Hub 的模型 ID 传递给 build_and_run_ad.py,以运行 Transformers 模型。
cd examples/auto_deploy
python build_and_run_ad.py --model meta-llama/Llama-3.2-1BUnder the hood, AutoDeploy creates an LLM class. It loads the model configuration with AutoConfig.from_pretrained() and extracts any parallelism metadata stored in tp_plan. AutoModelForCausalLM.from_pretrained() loads the model with the config and enables Transformers’ built-in tensor parallelism.
from tensorrt_llm._torch.auto_deploy import LLM
llm = LLM(model="meta-llama/Llama-3.2-1B")TensorRT-LLM 使用 torch.export 提取模型图并应用优化。它将 Transformers 的注意力机制替换为 TensorRT-LLM 的 注意力内核,并将模型编译为优化后的执行后端。
资源
- 有关更详细的使用指南,请参阅 TensorRT-LLM 文档。
- AutoDeploy 指南通过高级示例介绍了其工作原理。