{"id":"tensorrt-llm","name":"tensorrt-llm","summary":"NVIDIA TensorRTを用いて最大スループットと最小遅延を実現するためにLLM推論を最適化します。","body":"# TensorRT-LLM\n\nNVIDIA's open-source library for optimizing LLM inference with state-of-the-art performance on NVIDIA GPUs.\n\n## When to use TensorRT-LLM\n\n**Use TensorRT-LLM when:**\n- Deploying on NVIDIA GPUs (A100, H100, GB200)\n- Need maximum throughput (24,000+ tokens/sec on Llama 3)\n- Require low latency for real-time applications\n- Working with quantized models (FP8, INT4, FP4)\n- Scaling across multiple GPUs or nodes\n\n**Use vLLM instead when:**\n- Need simpler setup and Python-first API\n- Want PagedAttention without TensorRT compilation\n- Working with AMD GPUs or non-NVIDIA hardware\n\n**Use llama.cpp instead when:**\n- Deploying on CPU or Apple Silicon\n- Need edge deployment without NVIDIA GPUs\n- Want simpler GGUF quantization format\n\n## Quick start\n\n### Installation\n\n```bash\n# Docker (recommended)\ndocker pull nvidia/tensorrt_llm:latest\n\n# pip install\npip install tensorrt_llm==1.2.0rc3\n\n# Requires CUDA 13.0.0, TensorRT 10.13.2, Python 3.10-3.12\n```\n\n### Basic inference\n\n```python\nfrom tensorrt_llm import LLM, SamplingParams\n\n# Initialize model\nllm = LLM(model=\"meta-llama/Meta-Llama-3-8B\")\n\n# Configure sampling\nsampling_params = SamplingParams(\n    max_tokens=100,\n    temperature=0.7,\n    top_p=0.9\n)\n\n# Generate\nprompts = [\"Explain quantum computing\"]\noutputs = llm.generate(prompts, sampling_params)\n\nfor output in outputs:\n    print(output.text)\n```\n\n### Serving with trtllm-serve\n\n```bash\n# Start server (automatic model download and compilation)\ntrtllm-serve meta-llama/Meta-Llama-3-8B \\\n    --tp_size 4 \\              # Tensor parallelism (4 GPUs)\n    --max_batch_size 256 \\\n    --max_num_tokens 4096\n\n# Client request\ncurl -X POST http://localhost:8000/v1/chat/completions \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"model\": \"meta-llama/Meta-Llama-3-8B\",\n    \"messages\": [{\"role\": \"user\", \"content\": \"Hello!\"}],\n    \"temperature\": 0.7,\n    \"max_tokens\": 100\n  }'\n```\n\n## Key features\n\n### Performance optimizations\n- **In-flight batching**: Dynamic batching during generation\n- **Paged KV cache**: Efficient memory management\n- **Flash Attention**: Optimized attention kernels\n- **Quantization**: FP8, INT4, FP4 for 2-4× faster inference\n- **CUDA graphs**: Reduced kernel launch overhead\n\n### Parallelism\n- **Tensor parallelism (TP)**: Split model across GPUs\n- **Pipeline parallelism (PP)**: Layer-wise distribution\n- **Expert parallelism**: For Mixture-of-Experts models\n- **Multi-node**: Scale beyond single machine\n\n### Advanced features\n- **Speculative decoding**: Faster generation with draft models\n- **LoRA serving**: Efficient multi-adapter deployment\n- **Disaggregated serving**: Separate prefill and generation\n\n## Common patterns\n\n### Quantized model (FP8)\n\n```python\nfrom tensorrt_llm import LLM\n\n# Load FP8 quantized model (2× faster, 50% memory)\nllm = LLM(\n    model=\"meta-llama/Meta-Llama-3-70B\",\n    dtype=\"fp8\",\n    max_num_tokens=8192\n)\n\n# Inference same as before\noutputs = llm.generate([\"Summarize this article...\"])\n```\n\n### Multi-GPU deployment\n\n```python\n# Tensor parallelism across 8 GPUs\nllm = LLM(\n    model=\"meta-llama/Meta-Llama-3-405B\",\n    tensor_parallel_size=8,\n    dtype=\"fp8\"\n)\n```\n\n### Batch inference\n\n```python\n# Process 100 prompts efficiently\nprompts = [f\"Question {i}: ...\" for i in range(100)]\n\noutputs = llm.generate(\n    prompts,\n    sampling_params=SamplingParams(max_tokens=200)\n)\n\n# Automatic in-flight batching for maximum throughput\n```\n\n## Performance benchmarks\n\n**Meta Llama 3-8B** (H100 GPU):\n- Throughput: 24,000 tokens/sec\n- Latency: ~10ms per token\n- vs PyTorch: **100× faster**\n\n**Llama 3-70B** (8× A100 80GB):\n- FP8 quantization: 2× faster than FP16\n- Memory: 50% reduction with FP8\n\n## Supported models\n\n- **LLaMA family**: Llama 2, Llama 3, CodeLlama\n- **GPT family**: GPT-2, GPT-J, GPT-NeoX\n- **Qwen**: Qwen, Qwen2, QwQ\n- **DeepSeek**: DeepSeek-V2, DeepSeek-V3\n- **Mixtral**: Mixtral-8x7B, Mixtral-8x22B\n- **Vision**: LLaVA, Phi-3-vision\n- **100+ models** on HuggingFace\n\n## References\n\n- **[Optimization Guide](references/optimization.md)** - Quantization, batching, KV cache tuning\n- **[Multi-GPU Setup](references/multi-gpu.md)** - Tensor/pipeline parallelism, multi-node\n- **[Serving Guide](references/serving.md)** - Production deployment, monitoring, autoscaling\n\n## Resources\n\n- **Docs**: https://nvidia.github.io/TensorRT-LLM/\n- **GitHub**: https://github.com/NVIDIA/TensorRT-LLM\n- **Models**: https://huggingface.co/models?library=tensorrt_llm","author":"@Orchestra-Research","ownerProfile":null,"authorContacts":null,"sourceUrl":"https://github.com/Orchestra-Research/AI-Research-SKILLs/tree/main/12-inference-serving/tensorrt-llm","license":"MIT","category":"coding","lang":"en","tokens":1297,"stars":0,"calls30d":1,"claimed":false,"visibility":"public","origin":"crawler","version":"0.1.0","createdAt":"2026-08-22","updatedAt":"2026-08-22","files":[{"path":"references/multi-gpu.md","size":6699,"sha256":"f5992df6c444d4300dd1b7cbe150e998806128c911eba3387f4aada84a01ecee"},{"path":"references/optimization.md","size":5613,"sha256":"deb727998b471654231730faf2e4ad2ae82fea99e18ae991528a94bba57a83e8"},{"path":"references/serving.md","size":9798,"sha256":"edab4ad7f7bda4938ff62ddb9d01f846829f42a4fb03b7fcd00eb48d5d3fc893"}],"requires":{"mcp":[],"tools":[]},"safety":{"flags":[],"scannedAt":"2026-08-22","hasScripts":false,"networkEndpoints":["huggingface.co","nvidia.github.io"]}}