Transformers documentation

TensorRT-LLM

You are viewing main version, which requires installation from source. If you'd like regular pip install, checkout the latest stable version (v5.22.1).
Hugging Face's logo
Join the Hugging Face community

and get access to the augmented documentation experience

to get started

TensorRT-LLM

TensorRT-LLMはNVIDIA GPU上のLLM推論を最適化します。モデルをTensorRTエンジンにコンパイルし、in-flight batching、paged KVキャッシュ、テンソル並列処理を実現します。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-1B

Under 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 の アテンションカーネル に置き換え、モデルを最適化された実行バックエンドにコンパイルします。

リソース

Update on GitHub