# navodpeiris/airllm-cpu-inference-support architecture

> Architecture diagram of the GitHub repository navodpeiris/airllm-cpu-inference-support, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/navodpeiris/airllm-cpu-inference-support
- Repository: https://github.com/navodpeiris/airllm-cpu-inference-support

## Overview

AirLLM is a memory-efficient large-language-model inference library. The primary workflow is: a user selects a model through AutoModel, model files are prepared as layer-wise shards, and generation loads and executes layers incrementally; model-family adapters customize that execution. README also documents block-wise 4/8-bit compression and Apple Silicon/MLX support. The graph preserves the indexed model-family and persistence modules. Some internal calls are not visible in the excerpts, so those links are omitted rather than inferred.

Main entry points: [`air_llm/airllm/airllm_base.py`](https://github.com/navodpeiris/airllm-cpu-inference-support/blob/main/air_llm/airllm/airllm_base.py) (Layered inference engine), [`air_llm/airllm/utils.py`](https://github.com/navodpeiris/airllm-cpu-inference-support/blob/main/air_llm/airllm/utils.py) (Model preparation utilities), [`air_llm/airllm/persist/model_persister.py`](https://github.com/navodpeiris/airllm-cpu-inference-support/blob/main/air_llm/airllm/persist/model_persister.py) (Persister selector), [`air_llm/airllm/airllm.py`](https://github.com/navodpeiris/airllm-cpu-inference-support/blob/main/air_llm/airllm/airllm.py) (Llama entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Public API"]
  node_auto["AutoModel selector<br/>[auto_model.py]"]
  node_llama_entry["Llama entry<br/>[airllm.py]"]
end

subgraph group_inference["Inference Runtime"]
  node_base["Layered inference engine<br/>[airllm_base.py]"]
  node_utils["Model preparation utilities<br/>[utils.py]"]
  node_profiler["Inference profiler<br/>[profiler.py]"]
end

subgraph group_families["Model Families"]
  node_baichuan["Baichuan adapter<br/>[airllm_baichuan.py]"]
  node_baichuan_tokenizer["Baichuan tokenizer"]
  node_chatglm["ChatGLM adapter<br/>[airllm_chatglm.py]"]
  node_internlm["InternLM adapter<br/>[airllm_internlm.py]"]
  node_mistral["Mistral adapter<br/>[airllm_mistral.py]"]
  node_mixtral["Mixtral adapter<br/>[airllm_mixtral.py]"]
  node_qwen["QWen adapter<br/>[airllm_qwen.py]"]
end

subgraph group_storage["Layer Storage"]
  node_persister["Persister selector<br/>[model_persister.py]"]
  node_safetensor_persister["Safetensors persister"]
  node_mlx_persister["MLX persister"]
end

subgraph group_platform["Platform Support"]
  node_mlx_inference["MLX inference"]
end

node_user(("Inference user"))
node_hf_hub[("Hugging Face Hub")]
node_shard_store[("Layer shard files")]

node_user -->|"selects model"| node_auto
node_auto -->|"routes model"| node_llama_entry
node_llama_entry -->|"inherits from"| node_base
node_user -->|"initializes directly"| node_llama_entry
node_base -->|"prepares shards"| node_utils
node_utils -->|"downloads model"| node_hf_hub
node_utils -->|"writes layer shards"| node_shard_store
node_base -.->|"loads layer weights"| node_shard_store
node_base -->|"records timings"| node_profiler
node_baichuan -->|"extends runtime"| node_base
node_baichuan -->|"uses tokenizer"| node_baichuan_tokenizer
node_chatglm -->|"extends runtime"| node_base
node_internlm -->|"extends runtime"| node_base
node_mistral -->|"extends runtime"| node_base
node_mixtral -->|"extends runtime"| node_base
node_qwen -->|"extends runtime"| node_base
node_utils -.->|"selects persistence"| node_persister
node_persister -->|"selects by platform"| node_safetensor_persister
node_persister -->|"selects by platform"| node_mlx_persister
node_mlx_inference -->|"loads layer weights"| node_persister
node_mlx_inference -.->|"uses MLX storage"| node_mlx_persister

click node_auto "https://github.com/navodpeiris/airllm-cpu-inference-support/blob/main/air_llm/airllm/auto_model.py"
click node_llama_entry "https://github.com/navodpeiris/airllm-cpu-inference-support/blob/main/air_llm/airllm/airllm.py"
click node_base "https://github.com/navodpeiris/airllm-cpu-inference-support/blob/main/air_llm/airllm/airllm_base.py"
click node_utils "https://github.com/navodpeiris/airllm-cpu-inference-support/blob/main/air_llm/airllm/utils.py"
click node_profiler "https://github.com/navodpeiris/airllm-cpu-inference-support/blob/main/air_llm/airllm/profiler.py"
click node_baichuan "https://github.com/navodpeiris/airllm-cpu-inference-support/blob/main/air_llm/airllm/airllm_baichuan.py"
click node_baichuan_tokenizer "https://github.com/navodpeiris/airllm-cpu-inference-support/blob/main/air_llm/airllm/tokenization_baichuan.py"
click node_chatglm "https://github.com/navodpeiris/airllm-cpu-inference-support/blob/main/air_llm/airllm/airllm_chatglm.py"
click node_internlm "https://github.com/navodpeiris/airllm-cpu-inference-support/blob/main/air_llm/airllm/airllm_internlm.py"
click node_mistral "https://github.com/navodpeiris/airllm-cpu-inference-support/blob/main/air_llm/airllm/airllm_mistral.py"
click node_mixtral "https://github.com/navodpeiris/airllm-cpu-inference-support/blob/main/air_llm/airllm/airllm_mixtral.py"
click node_qwen "https://github.com/navodpeiris/airllm-cpu-inference-support/blob/main/air_llm/airllm/airllm_qwen.py"
click node_persister "https://github.com/navodpeiris/airllm-cpu-inference-support/blob/main/air_llm/airllm/persist/model_persister.py"
click node_safetensor_persister "https://github.com/navodpeiris/airllm-cpu-inference-support/blob/main/air_llm/airllm/persist/safetensor_model_persister.py"
click node_mlx_persister "https://github.com/navodpeiris/airllm-cpu-inference-support/blob/main/air_llm/airllm/persist/mlx_model_persister.py"
click node_mlx_inference "https://github.com/navodpeiris/airllm-cpu-inference-support/blob/main/air_llm/airllm/airllm_llama_mlx.py"

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_auto,node_llama_entry,node_user toneBlue
class node_base,node_utils,node_profiler,node_hf_hub,node_shard_store toneAmber
class node_baichuan,node_baichuan_tokenizer,node_chatglm,node_internlm,node_mistral,node_mixtral,node_qwen toneMint
class node_persister,node_safetensor_persister,node_mlx_persister toneRose
class node_mlx_inference toneIndigo
```

## Components

### Public API

- [AutoModel selector](https://github.com/navodpeiris/airllm-cpu-inference-support/blob/main/air_llm/airllm/auto_model.py): `air_llm/airllm/auto_model.py`
- [Llama entry](https://github.com/navodpeiris/airllm-cpu-inference-support/blob/main/air_llm/airllm/airllm.py): `air_llm/airllm/airllm.py`

### Inference Runtime

- [Layered inference engine](https://github.com/navodpeiris/airllm-cpu-inference-support/blob/main/air_llm/airllm/airllm_base.py): `air_llm/airllm/airllm_base.py`
- [Model preparation utilities](https://github.com/navodpeiris/airllm-cpu-inference-support/blob/main/air_llm/airllm/utils.py): `air_llm/airllm/utils.py`
- [Inference profiler](https://github.com/navodpeiris/airllm-cpu-inference-support/blob/main/air_llm/airllm/profiler.py): `air_llm/airllm/profiler.py`

### Model Families

- [Baichuan adapter](https://github.com/navodpeiris/airllm-cpu-inference-support/blob/main/air_llm/airllm/airllm_baichuan.py): `air_llm/airllm/airllm_baichuan.py`
- [Baichuan tokenizer](https://github.com/navodpeiris/airllm-cpu-inference-support/blob/main/air_llm/airllm/tokenization_baichuan.py): `air_llm/airllm/tokenization_baichuan.py`
- [ChatGLM adapter](https://github.com/navodpeiris/airllm-cpu-inference-support/blob/main/air_llm/airllm/airllm_chatglm.py): `air_llm/airllm/airllm_chatglm.py`
- [InternLM adapter](https://github.com/navodpeiris/airllm-cpu-inference-support/blob/main/air_llm/airllm/airllm_internlm.py): `air_llm/airllm/airllm_internlm.py`
- [Mistral adapter](https://github.com/navodpeiris/airllm-cpu-inference-support/blob/main/air_llm/airllm/airllm_mistral.py): `air_llm/airllm/airllm_mistral.py`
- [Mixtral adapter](https://github.com/navodpeiris/airllm-cpu-inference-support/blob/main/air_llm/airllm/airllm_mixtral.py): `air_llm/airllm/airllm_mixtral.py`
- [QWen adapter](https://github.com/navodpeiris/airllm-cpu-inference-support/blob/main/air_llm/airllm/airllm_qwen.py): `air_llm/airllm/airllm_qwen.py`

### Layer Storage

- [Persister selector](https://github.com/navodpeiris/airllm-cpu-inference-support/blob/main/air_llm/airllm/persist/model_persister.py): `air_llm/airllm/persist/model_persister.py`
- [Safetensors persister](https://github.com/navodpeiris/airllm-cpu-inference-support/blob/main/air_llm/airllm/persist/safetensor_model_persister.py): `air_llm/airllm/persist/safetensor_model_persister.py`
- [MLX persister](https://github.com/navodpeiris/airllm-cpu-inference-support/blob/main/air_llm/airllm/persist/mlx_model_persister.py): `air_llm/airllm/persist/mlx_model_persister.py`

### Platform Support

- [MLX inference](https://github.com/navodpeiris/airllm-cpu-inference-support/blob/main/air_llm/airllm/airllm_llama_mlx.py): `air_llm/airllm/airllm_llama_mlx.py`

### Other components

- **Inference user**
- **Hugging Face Hub**
- **Layer shard files**

## Connections

- Inference user → AutoModel selector: selects model (evidence: `README.md`)
- AutoModel selector → Llama entry: routes model (evidence: `air_llm/airllm/auto_model.py`)
- Llama entry → Layered inference engine: inherits from (evidence: `air_llm/airllm/airllm.py`)
- Inference user → Llama entry: initializes directly
- Layered inference engine → Model preparation utilities: prepares shards (evidence: `air_llm/airllm/airllm_base.py`)
- Model preparation utilities → Hugging Face Hub: downloads model (evidence: `air_llm/airllm/utils.py`)
- Model preparation utilities → Layer shard files: writes layer shards (evidence: `air_llm/airllm/utils.py`)
- Layered inference engine → Layer shard files: loads layer weights
- Layered inference engine → Inference profiler: records timings (evidence: `air_llm/airllm/airllm_base.py`)
- Baichuan adapter → Layered inference engine: extends runtime (evidence: `air_llm/airllm/airllm_baichuan.py`)
- Baichuan adapter → Baichuan tokenizer: uses tokenizer (evidence: `air_llm/airllm/airllm_baichuan.py`)
- ChatGLM adapter → Layered inference engine: extends runtime (evidence: `air_llm/airllm/airllm_chatglm.py`)
- InternLM adapter → Layered inference engine: extends runtime (evidence: `air_llm/airllm/airllm_internlm.py`)
- Mistral adapter → Layered inference engine: extends runtime (evidence: `air_llm/airllm/airllm_mistral.py`)
- Mixtral adapter → Layered inference engine: extends runtime (evidence: `air_llm/airllm/airllm_mixtral.py`)
- QWen adapter → Layered inference engine: extends runtime (evidence: `air_llm/airllm/airllm_qwen.py`)
- Model preparation utilities → Persister selector: selects persistence
- Persister selector → Safetensors persister: selects by platform (evidence: `air_llm/airllm/persist/model_persister.py`)
- Persister selector → MLX persister: selects by platform (evidence: `air_llm/airllm/persist/model_persister.py`)
- MLX inference → Persister selector: loads layer weights (evidence: `air_llm/airllm/airllm_llama_mlx.py`)
- MLX inference → MLX persister: uses MLX storage
