# LLM Inference Handbook ## 概要 Modular が公開する、LLM 推論をデプロイ・スケーリング・運用するエンジニア向けの技術ハンドブック。TTFT/TPS のようなコアな性能指標から、continuous batching・prefix caching といった最適化技法、GPU アーキテクチャ、BYOC やオンプレミスのようなデプロイパターンまでを一気通貫で扱う。書籍としての章構成を持たないが、体系的に整理されたオンラインドキュメントであり、継続的に更新される。 ## 書誌情報 - 発行元: Modular - 公開開始: 2025 年(GitHub リポジトリ `modular/llm-inference-handbook` 作成 2025-07-07) - 構成: 7 部構成(Foundations / Planning your deployment / Model preparation / Model interaction / Inference optimization / Kernel optimization / Infrastructure and operations)+ Introduction - URL: https://handbook.modular.com/ ## 構成と主要テーマ (fan-out 完了後にオーケストレータが各章の一行要約から追記する) ### Introduction → [[@2025__Modular__LLM Inference Handbook - Chapter 1 Introduction]] — 断片化したLLM推論知識を一冊に統合する動機と、通読/ルックアップ両対応の読み方を示す ### Part I: Foundations(第2〜6章) LLM推論の基礎用語・訓練との違い・Transformerの仕組み・実行環境・性能指標を扱う。 → [[@2025__Modular__LLM Inference Handbook - Chapter 2 What is LLM inference?]] — 推論/推論サーバ/サービング/推論最適化の用語整理 → [[@2025__Modular__LLM Inference Handbook - Chapter 3 Training vs. inference]] — 訓練と推論のコスト構造・ライフサイクル対比 → [[@2025__Modular__LLM Inference Handbook - Chapter 4 How does an LLM work?]] — トークン化・Transformer・アテンション・prefill/decode・dLLMの基礎解説 → [[@2025__Modular__LLM Inference Handbook - Chapter 5 Where is LLM inference run?]] — CPU/GPU/TPUとデプロイパターンの選定指針 → [[@2025__Modular__LLM Inference Handbook - Chapter 6 Key metrics for LLM inference]] — TTFT/E2EL/TPOT/ITL/RPS/TPS/Goodputなどの性能指標 ### Part II: Planning your deployment(第7〜13章) サーバーレスと自己ホストの選択、モデル・GPU・フレームワーク選定、BYOC/オンプレを扱う。 → [[@2025__Modular__LLM Inference Handbook - Chapter 7 Serverless vs. self-hosted LLM inference]] — サーバーレスAPIと自己ホストのトレードオフとコスト構造 → [[@2025__Modular__LLM Inference Handbook - Chapter 8 Choosing the right model]] — ベース/指示チューニング/チャット、密/MoE、重みフォーマットの選び方 → [[@2025__Modular__LLM Inference Handbook - Chapter 9 Choosing the right GPU]] — VRAM・帯域幅・計算スループット・インターコネクトとGPU CAP定理 → [[@2025__Modular__LLM Inference Handbook - Chapter 10 Calculating GPU memory for serving LLMs]] — GPUメモリ所要量の概算式とKVキャッシュオーバーヘッド → [[@2025__Modular__LLM Inference Handbook - Chapter 11 Choosing the right inference framework]] — vLLM/SGLang/MAX等の推論フレームワーク選定基準 → [[@2025__Modular__LLM Inference Handbook - Chapter 12 Bring Your Own Cloud (BYOC)]] — コントロール/データプレーンの責任分担とSaaS/BYOC/オンプレ比較 → [[@2025__Modular__LLM Inference Handbook - Chapter 13 On-prem LLM deployments]] — オンプレLLMデプロイの選定理由・課題 ### Part III: Model preparation(第14〜16章) ファインチューニング・量子化・蒸留によるモデル準備を扱う。 → [[@2025__Modular__LLM Inference Handbook - Chapter 14 LLM fine-tuning]] — ファインチューニングの位置づけと主要フレームワーク → [[@2025__Modular__LLM Inference Handbook - Chapter 15 LLM quantization]] — 量子化フォーマット・AWQ/SmoothQuant/GPTQと実行方法 → [[@2025__Modular__LLM Inference Handbook - Chapter 16 LLM distillation]] — ソフトラベル蒸留の仕組みとDeepSeek-R1の実例 ### Part IV: Model interaction(第17〜24章) API互換性・function calling・構造化出力・MCP・プロンプト・エージェントハーネス・推論パラメータを扱う。 → [[@2025__Modular__LLM Inference Handbook - Chapter 17 OpenAI-compatible API]] — OpenAI互換APIの意義と呼び出し方 → [[@2025__Modular__LLM Inference Handbook - Chapter 18 Anthropic-compatible API]] — Anthropic互換APIとOpenAI互換の比較 → [[@2025__Modular__LLM Inference Handbook - Chapter 19 Function calling]] — function callingの仕組みと構造化出力・エージェントとの違い → [[@2025__Modular__LLM Inference Handbook - Chapter 20 Structured outputs]] — 構造化出力の3手法(ネイティブ対応/再プロンプト/制約付きデコーディング) → [[@2025__Modular__LLM Inference Handbook - Chapter 21 Model Context Protocol]] — MCPのホスト・クライアント・サーバー構成 → [[@2025__Modular__LLM Inference Handbook - Chapter 22 Prompt engineering]] — プロンプトの役割とKVキャッシュ・コストへの影響 → [[@2025__Modular__LLM Inference Handbook - Chapter 23 Agent harnesses]] — 「エージェント=モデル+ハーネス」の枠組みとハーネス種別 → [[@2025__Modular__LLM Inference Handbook - Chapter 24 LLM inference parameters]] — temperature/top_p/top_k等の推論パラメータと本番運用指針 ### Part V: Inference optimization(第25〜34章) バッチング・PagedAttention・投機的デコーディング・PD分離・プレフィックスキャッシュ・ルーティング・並列化を扱う。 → [[@2025__Modular__LLM Inference Handbook - Chapter 25 LLM performance benchmarks]] — 品質ベンチマークと性能ベンチマークの違い → [[@2025__Modular__LLM Inference Handbook - Chapter 26 Static, dynamic and continuous batching]] — 静的/動的/連続バッチングとチャンク化プレフィル → [[@2025__Modular__LLM Inference Handbook - Chapter 27 PagedAttention]] — KVキャッシュの非連続ブロック管理による断片化解消 → [[@2025__Modular__LLM Inference Handbook - Chapter 28 Speculative decoding]] — draft-then-verifyとMedusa/MTP/Nグラム/EAGLE → [[@2025__Modular__LLM Inference Handbook - Chapter 29 Prefill-decode disaggregation]] — PD分離の利点・限界とクロスクラスタPD分離 → [[@2025__Modular__LLM Inference Handbook - Chapter 30 Prefix caching]] — 完全一致プレフィックス再利用とKVキャッシュとの違い → [[@2025__Modular__LLM Inference Handbook - Chapter 31 Inference routing]] — キャッシュ局所性・キュー深度に基づくルーティング戦略 → [[@2025__Modular__LLM Inference Handbook - Chapter 32 KV cache offloading]] — KVキャッシュオフロードの利点とトレードオフ → [[@2025__Modular__LLM Inference Handbook - Chapter 33 Data, tensor, pipeline, expert and hybrid parallelisms]] — DP/TP/PP/EP/ハイブリッド並列化 → [[@2025__Modular__LLM Inference Handbook - Chapter 34 Offline batch inference]] — オフライン対オンライン推論 ### Part VI: Kernel optimization(第35〜42章) GPUアーキテクチャ・スレッド階層・SM・メモリ階層・Tensor Core・FlashAttentionを扱う。 → [[@2025__Modular__LLM Inference Handbook - Chapter 35 Kernel optimization for LLM inference]] — カーネル最適化がシステム層と別レイヤーで性能上限を規定する → [[@2025__Modular__LLM Inference Handbook - Chapter 36 GPU architecture]] — ハードウェア視点と実行モデル視点の2軸でGPUを捉える → [[@2025__Modular__LLM Inference Handbook - Chapter 37 GPU threads, warps, blocks, and grids]] — スレッド/ワープ/ブロック/グリッドの階層 → [[@2025__Modular__LLM Inference Handbook - Chapter 38 Streaming multiprocessors]] — SM構成・ワープスケジューリング・occupancy → [[@2025__Modular__LLM Inference Handbook - Chapter 39 GPU memory hierarchy]] — レジスタ〜共有メモリ/L1〜L2〜HBMの階層 → [[@2025__Modular__LLM Inference Handbook - Chapter 40 Tensor Cores]] — Tensor Coreの精度対応拡張とprefill/decodeでの役割差 → [[@2025__Modular__LLM Inference Handbook - Chapter 41 Choosing the right kernel optimization tool]] — ベンダーライブラリ〜Mojo/MAXの選択指針 → [[@2025__Modular__LLM Inference Handbook - Chapter 42 FlashAttention]] — タイリング+フュージョンによるメモリ律速アテンションの解消 ### Part VII: Infrastructure and operations(第43〜50章) 推論インフラのスタック・分散推論・可観測性・スケーリング・コスト・マルチモデル・マルチクラウド・InferenceOpsを扱う。 → [[@2025__Modular__LLM Inference Handbook - Chapter 43 What is LLM inference infrastructure?]] — 推論スタックの8層とbuild/buy選択肢 → [[@2025__Modular__LLM Inference Handbook - Chapter 44 What is distributed inference?]] — マクロ/ミクロ2視点での分散推論と課題 → [[@2025__Modular__LLM Inference Handbook - Chapter 45 LLM observability]] — 可観測性の測定対象5カテゴリとメトリクス/ログの役割分担 → [[@2025__Modular__LLM Inference Handbook - Chapter 46 Fast scaling]] — コールドスタートとconcurrencyによるスケーリング指標 → [[@2025__Modular__LLM Inference Handbook - Chapter 47 Build and maintenance cost]] — 自前構築の複雑性・柔軟性欠如・人材コスト → [[@2025__Modular__LLM Inference Handbook - Chapter 48 Multi-model inference pipelines]] — マルチモデルパイプラインの4形態とトレードオフ → [[@2025__Modular__LLM Inference Handbook - Chapter 49 Multi-cloud and cross-region inference]] — マルチクラウド/クロスリージョン戦略とGPU価格差 → [[@2025__Modular__LLM Inference Handbook - Chapter 50 InferenceOps and management]] — InferenceOpsの4本柱(デプロイ標準化・安全更新・一元管理・コスト管理) ## 影響と位置づけ ## 関連 - 実体: [[Modular]] ## 出典 - Modular, *LLM Inference Handbook*, https://handbook.modular.com/, 2025–.