Transformers documentation

TensorRT-LLM

You are viewing v5.24.0 version. A newer version v5.24.1 is available.
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 추론을 최적화합니다. 모델을 in-flight batching, paged KV caching, tensor parallelism을 지원하는 TensorRT 엔진으로 컴파일합니다. 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의 attention을 TensorRT-LLM attention 커널로 대체하고 모델을 최적화된 실행 백엔드로 컴파일합니다.

리소스

Update on GitHub