# TensorRT-LLM

[TensorRT-LLM](https://github.com/NVIDIA/TensorRT-LLM) يحسّن استنتاج نماذج اللغة الكبيرة على وحدات معالجة الرسوميات من NVIDIA. يقوم بتجميع النماذج إلى محرك TensorRT مع تضمين الدفعات أثناء التنفيذ، وتخزين مؤقت مقسّم لصفحات KV، والتوازي على مستوى الموترات. يقبل [AutoDeploy](https://nvidia.github.io/TensorRT-LLM/torch/auto_deploy/auto-deploy.html) نماذج Transformers دون الحاجة إلى أي تغييرات. يقوم تلقائيًا بتحويل النموذج إلى وقت تشغيل محسّن.

مرّر معرّف نموذج من Hub إلى [build_and_run_ad.py](https://github.com/NVIDIA/TensorRT-LLM/blob/main/examples/auto_deploy/build_and_run_ad.py) لتشغيل نموذج Transformers.

```bash
cd examples/auto_deploy
python build_and_run_ad.py --model meta-llama/Llama-3.2-1B
```

Under the hood, AutoDeploy creates an [LLM](https://nvidia.github.io/TensorRT-LLM/llm-api/reference.html#tensorrt_llm.llmapi.LLM) class. It loads the model configuration with [AutoConfig.from_pretrained()](/docs/transformers/main/ar/model_doc/auto#transformers.AutoConfig.from_pretrained) and extracts any parallelism metadata stored in `tp_plan`. [AutoModelForCausalLM.from_pretrained()](/docs/transformers/main/ar/model_doc/auto#transformers.AutoModel.from_pretrained) loads the model with the config and enables Transformers' built-in tensor parallelism.

```py
from tensorrt_llm._torch.auto_deploy import LLM

llm = LLM(model="meta-llama/Llama-3.2-1B")
```

يستخرج TensorRT-LLM رسم النموذج باستخدام `torch.export` ويطبّق التحسينات. ويستبدل انتباه Transformers بنوى الانتباه الخاصة بـ TensorRT-LLM [attention kernels](https://github.com/NVIDIA/TensorRT-LLM/tree/main/tensorrt_llm/_torch/attention_backend) ويجمع النموذج إلى واجهة تنفيذ خلفية مُحسّنة.

## الموارد

- [وثائق TensorRT-LLM](https://nvidia.github.io/TensorRT-LLM/) للحصول على أدلة استخدام أكثر تفصيلاً.
- يشرح [دليل AutoDeploy](https://nvidia.github.io/TensorRT-LLM/torch/auto_deploy/auto-deploy.html) كيفية عمله مع أمثلة متقدمة.

