# orca3/llm-model-inference architecture

> Architecture diagram of the GitHub repository orca3/llm-model-inference, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/orca3/llm-model-inference
- Repository: https://github.com/orca3/llm-model-inference

## Overview

This repository is a companion collection for a book on LLM serving and optimization, not one unified runtime. Its central hands-on workflows move from a request through serving infrastructure to generated output, or from a knowledge query through planning, retrieval, and response generation. Separate chapter examples cover optimization, serving frameworks, and cloud deployment. The graph combines sampled implementation relationships with capabilities explicitly described in the README; unsampled notebook internals are not inferred.

Main entry points: [`ch03/single_model_llm_serving/llm/llm.py`](https://github.com/orca3/llm-model-inference/blob/main/ch03/single_model_llm_serving/llm/llm.py) (LLM engine), [`ch04/KnowledgeAgent/agent.py`](https://github.com/orca3/llm-model-inference/blob/main/ch04/KnowledgeAgent/agent.py) (Knowledge agent), [`ch03/multi_model_serving/app/server.py`](https://github.com/orca3/llm-model-inference/blob/main/ch03/multi_model_serving/app/server.py) (Multi-model API), [`ch03/multi_model_serving/app/manager.py`](https://github.com/orca3/llm-model-inference/blob/main/ch03/multi_model_serving/app/manager.py) (Model manager)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_serving["Serving systems"]
  node_single_api["Single-model API<br/>[main.py]"]
  node_single_engine["LLM engine<br/>[llm.py]"]
  node_batching["Batch workload"]
  node_executor["Model executor<br/>[model_executor.py]"]
  node_model_worker["Model worker<br/>[model_worker.py]"]
  node_model_manager["Model loader<br/>[model_manager.py]"]
  node_multi_api["Multi-model API<br/>[server.py]"]
  node_model_registry[("Model registry<br/>[store.py]")]
  node_model_manager_multi["Model manager<br/>[manager.py]"]
  node_model_engine["Model engine<br/>[engine.py]"]
  node_workers["Inference workers<br/>[worker.py]"]
  node_chapter2["Serving fundamentals"]
  node_streaming["Streaming example<br/>[streaming.py]"]
end

subgraph group_agent["Knowledge agent"]
  node_agent["Knowledge agent<br/>[agent.py]"]
  node_planner["Action planner<br/>[planner.py]"]
  node_actions["Action executor<br/>[actions.py]"]
  node_rag[("RAG system<br/>[rag_system.py]")]
  node_llm_manager["LLM manager<br/>[llm_manager.py]"]
end

subgraph group_optimization["Optimization examples"]
  node_quantization["Quantization walkthrough"]
  node_specdecode["Speculative decoding<br/>[SpecDecode.ipynb]"]
  node_lmcache["Advanced KV caching<br/>[LMCache.ipynb]"]
  node_practice["Optimization plan"]
end

subgraph group_frameworks["Serving frameworks"]
  node_sglang["SGLang<br/>[SGLang.ipynb]"]
  node_tensorrt["TensorRT-LLM<br/>[TensorRT_LLM.ipynb]"]
  node_llamacpp["llama.cpp<br/>[llamaCpp.ipynb]"]
end

subgraph group_cloud["Cloud deployment"]
  node_bedrock["AWS Bedrock"]
  node_jumpstart["AWS JumpStart"]
  node_dlc["Deep Learning Containers"]
  node_dlc_custom["DLC customization"]
end

node_engineer(("Engineer"))
node_agent_user(("Knowledge user"))
node_openai["OpenAI services"]

node_engineer -->|"studies"| node_chapter2
node_engineer -->|"submits request"| node_single_api
node_single_api -->|"routes requests"| node_single_engine
node_single_engine -->|"queues sequences"| node_batching
node_single_engine -->|"executes batches"| node_executor
node_executor -->|"delegates"| node_model_worker
node_model_worker -->|"loads model"| node_model_manager
node_single_engine -->|"streams output"| node_engineer
node_engineer -->|"requests inference"| node_multi_api
node_multi_api -->|"routes models"| node_model_manager_multi
node_multi_api -->|"lists models"| node_model_registry
node_model_manager_multi -->|"reads metadata"| node_model_registry
node_model_manager_multi -->|"creates workers"| node_model_engine
node_model_engine -->|"selects worker"| node_workers
node_agent_user -->|"asks question"| node_agent
node_agent -->|"plans actions"| node_planner
node_agent -->|"executes actions"| node_actions
node_agent -->|"builds knowledge base"| node_rag
node_planner -->|"requests planning"| node_llm_manager
node_actions -->|"retrieves context"| node_rag
node_actions -->|"generates response"| node_llm_manager
node_rag -->|"embeds text"| node_openai
node_llm_manager -->|"calls chat API"| node_openai
node_engineer -->|"explores streaming"| node_streaming
node_engineer -->|"studies trade-offs"| node_quantization
node_engineer -->|"explores decoding"| node_specdecode
node_engineer -->|"explores caching"| node_lmcache
node_engineer -->|"follows optimization plan"| node_practice
node_engineer -->|"studies framework"| node_sglang
node_engineer -->|"studies framework"| node_tensorrt
node_engineer -->|"studies framework"| node_llamacpp
node_engineer -->|"explores deployment"| node_bedrock
node_engineer -->|"explores deployment"| node_jumpstart
node_engineer -->|"explores deployment"| node_dlc
node_dlc -->|"customizes example"| node_dlc_custom

click node_single_api "https://github.com/orca3/llm-model-inference/blob/main/ch03/single_model_llm_serving/main.py"
click node_single_engine "https://github.com/orca3/llm-model-inference/blob/main/ch03/single_model_llm_serving/llm/llm.py"
click node_batching "https://github.com/orca3/llm-model-inference/blob/main/ch03/single_model_llm_serving/llm/workload_manager.py"
click node_executor "https://github.com/orca3/llm-model-inference/blob/main/ch03/single_model_llm_serving/llm/model_executor.py"
click node_model_worker "https://github.com/orca3/llm-model-inference/blob/main/ch03/single_model_llm_serving/llm/model_worker.py"
click node_model_manager "https://github.com/orca3/llm-model-inference/blob/main/ch03/single_model_llm_serving/llm/model_manager.py"
click node_multi_api "https://github.com/orca3/llm-model-inference/blob/main/ch03/multi_model_serving/app/server.py"
click node_model_registry "https://github.com/orca3/llm-model-inference/blob/main/ch03/multi_model_serving/app/store.py"
click node_model_manager_multi "https://github.com/orca3/llm-model-inference/blob/main/ch03/multi_model_serving/app/manager.py"
click node_model_engine "https://github.com/orca3/llm-model-inference/blob/main/ch03/multi_model_serving/app/engine.py"
click node_workers "https://github.com/orca3/llm-model-inference/blob/main/ch03/multi_model_serving/app/worker.py"
click node_agent "https://github.com/orca3/llm-model-inference/blob/main/ch04/KnowledgeAgent/agent.py"
click node_planner "https://github.com/orca3/llm-model-inference/blob/main/ch04/KnowledgeAgent/planner.py"
click node_actions "https://github.com/orca3/llm-model-inference/blob/main/ch04/KnowledgeAgent/actions.py"
click node_rag "https://github.com/orca3/llm-model-inference/blob/main/ch04/KnowledgeAgent/rag_system.py"
click node_llm_manager "https://github.com/orca3/llm-model-inference/blob/main/ch04/KnowledgeAgent/llm_manager.py"
click node_chapter2 "https://github.com/orca3/llm-model-inference/blob/main/ch02/ch2_Workthrough_LLM_execution.ipynb"
click node_streaming "https://github.com/orca3/llm-model-inference/blob/main/ch02/streaming.py"
click node_quantization "https://github.com/orca3/llm-model-inference/blob/main/ch06/quantization_3way_300.ipynb"
click node_specdecode "https://github.com/orca3/llm-model-inference/blob/main/ch07/SpecDecode.ipynb"
click node_lmcache "https://github.com/orca3/llm-model-inference/blob/main/ch07/LMCache.ipynb"
click node_practice "https://github.com/orca3/llm-model-inference/blob/main/ch09/model_optimization_in_practice.ipynb"
click node_sglang "https://github.com/orca3/llm-model-inference/blob/main/ch08/SGLang.ipynb"
click node_tensorrt "https://github.com/orca3/llm-model-inference/blob/main/ch08/TensorRT_LLM.ipynb"
click node_llamacpp "https://github.com/orca3/llm-model-inference/blob/main/ch08/llamaCpp.ipynb"
click node_bedrock "https://github.com/orca3/llm-model-inference/blob/main/ch04/bedrock/aws_bedrock_examples.ipynb"
click node_jumpstart "https://github.com/orca3/llm-model-inference/blob/main/ch04/jumpstart/aws_jumpstart.ipynb"
click node_dlc "https://github.com/orca3/llm-model-inference/blob/main/ch04/dlc/aws_dlc_serving.ipynb"
click node_dlc_custom "https://github.com/orca3/llm-model-inference/blob/main/ch04/dlc_customization/aws_dlc_serving_customization.ipynb"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_single_api,node_single_engine,node_batching,node_executor,node_model_worker,node_model_manager,node_multi_api,node_model_registry,node_model_manager_multi,node_model_engine,node_workers,node_chapter2,node_streaming,node_agent_user toneBlue
class node_agent,node_planner,node_actions,node_rag,node_llm_manager toneAmber
class node_quantization,node_specdecode,node_lmcache,node_practice toneMint
class node_sglang,node_tensorrt,node_llamacpp toneRose
class node_bedrock,node_jumpstart,node_dlc,node_dlc_custom,node_engineer,node_openai toneIndigo
```

## Components

### Serving systems

- [Single-model API](https://github.com/orca3/llm-model-inference/blob/main/ch03/single_model_llm_serving/main.py): `ch03/single_model_llm_serving/main.py`
- [LLM engine](https://github.com/orca3/llm-model-inference/blob/main/ch03/single_model_llm_serving/llm/llm.py): `ch03/single_model_llm_serving/llm/llm.py`
- [Batch workload](https://github.com/orca3/llm-model-inference/blob/main/ch03/single_model_llm_serving/llm/workload_manager.py): `ch03/single_model_llm_serving/llm/workload_manager.py`
- [Model executor](https://github.com/orca3/llm-model-inference/blob/main/ch03/single_model_llm_serving/llm/model_executor.py): `ch03/single_model_llm_serving/llm/model_executor.py`
- [Model worker](https://github.com/orca3/llm-model-inference/blob/main/ch03/single_model_llm_serving/llm/model_worker.py): `ch03/single_model_llm_serving/llm/model_worker.py`
- [Model loader](https://github.com/orca3/llm-model-inference/blob/main/ch03/single_model_llm_serving/llm/model_manager.py): `ch03/single_model_llm_serving/llm/model_manager.py`
- [Multi-model API](https://github.com/orca3/llm-model-inference/blob/main/ch03/multi_model_serving/app/server.py): `ch03/multi_model_serving/app/server.py`
- [Model registry](https://github.com/orca3/llm-model-inference/blob/main/ch03/multi_model_serving/app/store.py): `ch03/multi_model_serving/app/store.py`
- [Model manager](https://github.com/orca3/llm-model-inference/blob/main/ch03/multi_model_serving/app/manager.py): `ch03/multi_model_serving/app/manager.py`
- [Model engine](https://github.com/orca3/llm-model-inference/blob/main/ch03/multi_model_serving/app/engine.py): `ch03/multi_model_serving/app/engine.py`
- [Inference workers](https://github.com/orca3/llm-model-inference/blob/main/ch03/multi_model_serving/app/worker.py): `ch03/multi_model_serving/app/worker.py`
- [Serving fundamentals](https://github.com/orca3/llm-model-inference/blob/main/ch02/ch2_Workthrough_LLM_execution.ipynb): `ch02/ch2_Workthrough_LLM_execution.ipynb`
- [Streaming example](https://github.com/orca3/llm-model-inference/blob/main/ch02/streaming.py): `ch02/streaming.py`

### Knowledge agent

- [Knowledge agent](https://github.com/orca3/llm-model-inference/blob/main/ch04/KnowledgeAgent/agent.py): `ch04/KnowledgeAgent/agent.py`
- [Action planner](https://github.com/orca3/llm-model-inference/blob/main/ch04/KnowledgeAgent/planner.py): `ch04/KnowledgeAgent/planner.py`
- [Action executor](https://github.com/orca3/llm-model-inference/blob/main/ch04/KnowledgeAgent/actions.py): `ch04/KnowledgeAgent/actions.py`
- [RAG system](https://github.com/orca3/llm-model-inference/blob/main/ch04/KnowledgeAgent/rag_system.py): `ch04/KnowledgeAgent/rag_system.py`
- [LLM manager](https://github.com/orca3/llm-model-inference/blob/main/ch04/KnowledgeAgent/llm_manager.py): `ch04/KnowledgeAgent/llm_manager.py`

### Optimization examples

- [Quantization walkthrough](https://github.com/orca3/llm-model-inference/blob/main/ch06/quantization_3way_300.ipynb): `ch06/quantization_3way_300.ipynb`
- [Speculative decoding](https://github.com/orca3/llm-model-inference/blob/main/ch07/SpecDecode.ipynb): `ch07/SpecDecode.ipynb`
- [Advanced KV caching](https://github.com/orca3/llm-model-inference/blob/main/ch07/LMCache.ipynb): `ch07/LMCache.ipynb`
- [Optimization plan](https://github.com/orca3/llm-model-inference/blob/main/ch09/model_optimization_in_practice.ipynb): `ch09/model_optimization_in_practice.ipynb`

### Serving frameworks

- [SGLang](https://github.com/orca3/llm-model-inference/blob/main/ch08/SGLang.ipynb): `ch08/SGLang.ipynb`
- [TensorRT-LLM](https://github.com/orca3/llm-model-inference/blob/main/ch08/TensorRT_LLM.ipynb): `ch08/TensorRT_LLM.ipynb`
- [llama.cpp](https://github.com/orca3/llm-model-inference/blob/main/ch08/llamaCpp.ipynb): `ch08/llamaCpp.ipynb`

### Cloud deployment

- [AWS Bedrock](https://github.com/orca3/llm-model-inference/blob/main/ch04/bedrock/aws_bedrock_examples.ipynb): `ch04/bedrock/aws_bedrock_examples.ipynb`
- [AWS JumpStart](https://github.com/orca3/llm-model-inference/blob/main/ch04/jumpstart/aws_jumpstart.ipynb): `ch04/jumpstart/aws_jumpstart.ipynb`
- [Deep Learning Containers](https://github.com/orca3/llm-model-inference/blob/main/ch04/dlc/aws_dlc_serving.ipynb): `ch04/dlc/aws_dlc_serving.ipynb`
- [DLC customization](https://github.com/orca3/llm-model-inference/blob/main/ch04/dlc_customization/aws_dlc_serving_customization.ipynb): `ch04/dlc_customization/aws_dlc_serving_customization.ipynb`

### Other components

- **Engineer**
- **Knowledge user**
- **OpenAI services**

## Connections

- Engineer → Serving fundamentals: studies (evidence: `README.md`)
- Engineer → Single-model API: submits request (evidence: `README.md`)
- Single-model API → LLM engine: routes requests (evidence: `ch03/single_model_llm_serving/main.py`)
- LLM engine → Batch workload: queues sequences (evidence: `ch03/single_model_llm_serving/llm/llm.py`)
- LLM engine → Model executor: executes batches (evidence: `ch03/single_model_llm_serving/llm/llm.py`)
- Model executor → Model worker: delegates (evidence: `ch03/single_model_llm_serving/llm/model_executor.py`)
- Model worker → Model loader: loads model (evidence: `ch03/single_model_llm_serving/llm/model_worker.py`)
- LLM engine → Engineer: streams output (evidence: `README.md`)
- Engineer → Multi-model API: requests inference (evidence: `README.md`)
- Multi-model API → Model manager: routes models (evidence: `ch03/multi_model_serving/app/server.py`)
- Multi-model API → Model registry: lists models (evidence: `ch03/multi_model_serving/app/server.py`)
- Model manager → Model registry: reads metadata (evidence: `ch03/multi_model_serving/app/manager.py`)
- Model manager → Model engine: creates workers (evidence: `ch03/multi_model_serving/app/manager.py`)
- Model engine → Inference workers: selects worker (evidence: `ch03/multi_model_serving/app/engine.py`)
- Knowledge user → Knowledge agent: asks question
- Knowledge agent → Action planner: plans actions (evidence: `ch04/KnowledgeAgent/agent.py`)
- Knowledge agent → Action executor: executes actions (evidence: `ch04/KnowledgeAgent/agent.py`)
- Knowledge agent → RAG system: builds knowledge base (evidence: `ch04/KnowledgeAgent/agent.py`)
- Action planner → LLM manager: requests planning (evidence: `ch04/KnowledgeAgent/planner.py`)
- Action executor → RAG system: retrieves context (evidence: `ch04/KnowledgeAgent/actions.py`)
- Action executor → LLM manager: generates response (evidence: `ch04/KnowledgeAgent/actions.py`)
- RAG system → OpenAI services: embeds text (evidence: `ch04/KnowledgeAgent/rag_system.py`)
- LLM manager → OpenAI services: calls chat API (evidence: `ch04/KnowledgeAgent/llm_manager.py`)
- Engineer → Streaming example: explores streaming (evidence: `README.md`)
- Engineer → Quantization walkthrough: studies trade-offs (evidence: `README.md`)
- Engineer → Speculative decoding: explores decoding (evidence: `README.md`)
- Engineer → Advanced KV caching: explores caching (evidence: `README.md`)
- Engineer → Optimization plan: follows optimization plan (evidence: `README.md`)
- Engineer → SGLang: studies framework (evidence: `README.md`)
- Engineer → TensorRT-LLM: studies framework (evidence: `README.md`)
- Engineer → llama.cpp: studies framework (evidence: `README.md`)
- Engineer → AWS Bedrock: explores deployment (evidence: `README.md`)
- Engineer → AWS JumpStart: explores deployment (evidence: `README.md`)
- Engineer → Deep Learning Containers: explores deployment (evidence: `README.md`)
- Deep Learning Containers → DLC customization: customizes example (evidence: `README.md`)
