# tagman45/oga-xdna architecture

> Architecture diagram of the GitHub repository tagman45/oga-xdna, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/tagman45/oga-xdna
- Repository: https://github.com/tagman45/oga-xdna

## Overview

OGA XDNA is a Windows inference daemon and integration layer for running ONNX Runtime GenAI models on AMD XDNA2 NPU hardware. The documented main workflow sends JSON commands from a llama.cpp integration through a named pipe to `ogad.py`, which loads a model and generates text. The repository also provides stdio-based daemon variants and C++ clients, a GGUF-to-OGA conversion utility, included model wrappers, and guidance/configuration for hybrid NPU+GPU use. The excerpts show cache and generation behavior; converter/export relationships and the hybrid capability are documented, but their full runtime integrations are not shown.

Main entry points: [`ogad_v3.py`](https://github.com/tagman45/oga-xdna/blob/main/ogad_v3.py) (Model and KV cache), [`ogad_client.cpp`](https://github.com/tagman45/oga-xdna/blob/main/ogad_client.cpp) (Named-pipe caller), [`gguf_to_oga.py`](https://github.com/tagman45/oga-xdna/blob/main/gguf_to_oga.py) (GGUF metadata converter), [`ogad.py`](https://github.com/tagman45/oga-xdna/blob/main/ogad.py) (Named-pipe daemon)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_daemon["Daemon inference"]
  node_pipe_daemon["Named-pipe daemon<br/>[ogad.py]"]
  node_v2_daemon["Stdio daemon v2<br/>[ogad_v2.py]"]
  node_v3_daemon["Stdio daemon v3<br/>[ogad_v3.py]"]
  node_model_cache[("Model and KV cache<br/>[ogad_v3.py]")]
  node_oga["ONNX Runtime GenAI"]
end

subgraph group_clients["Client interfaces"]
  node_pipe_client["Named-pipe caller<br/>[ogad_client.cpp]"]
  node_stdio_client["Subprocess client<br/>[ogad_client_v3.cpp]"]
  node_header_client["Client API and JSON<br/>[ogad_client.h]"]
end

subgraph group_models["Models and conversion"]
  node_converter["GGUF metadata converter<br/>[gguf_to_oga.py]"]
  node_oga_config["OGA model wrappers<br/>[genai_config.json]"]
  node_tiny_model["TinyLlama wrapper<br/>[genai_config.json]"]
end

subgraph group_hybrid["Hybrid guidance"]
  node_hybrid_guide["Hybrid NPU/GPU guide"]
  node_hybrid_config["Hybrid model config"]
end

node_llama(("llama.cpp integration"))
node_npu["RyzenAI XDNA2 NPU"]
node_gguf["GGUF input model"]
node_hf["Hugging Face model"]

node_llama -->|"invokes"| node_pipe_client
node_pipe_client -->|"sends JSON commands"| node_pipe_daemon
node_pipe_client -->|"launches process"| node_v2_daemon
node_stdio_client -->|"launches process"| node_v3_daemon
node_header_client -->|"provides client API"| node_stdio_client
node_pipe_daemon -->|"dispatches commands"| node_model_cache
node_v2_daemon -->|"loads and generates"| node_model_cache
node_v3_daemon -->|"loads and generates"| node_model_cache
node_model_cache -->|"loads and runs"| node_oga
node_oga -->|"runs inference on"| node_npu
node_gguf -->|"provides metadata"| node_converter
node_converter -->|"creates model config"| node_oga_config
node_hf -->|"exports via builder"| node_converter
node_hybrid_guide -.->|"describes configuration"| node_hybrid_config

click node_pipe_client "https://github.com/tagman45/oga-xdna/blob/main/ogad_client.cpp"
click node_stdio_client "https://github.com/tagman45/oga-xdna/blob/main/ogad_client_v3.cpp"
click node_header_client "https://github.com/tagman45/oga-xdna/blob/main/ogad_client.h"
click node_pipe_daemon "https://github.com/tagman45/oga-xdna/blob/main/ogad.py"
click node_v2_daemon "https://github.com/tagman45/oga-xdna/blob/main/ogad_v2.py"
click node_v3_daemon "https://github.com/tagman45/oga-xdna/blob/main/ogad_v3.py"
click node_model_cache "https://github.com/tagman45/oga-xdna/blob/main/ogad_v3.py"
click node_converter "https://github.com/tagman45/oga-xdna/blob/main/gguf_to_oga.py"
click node_oga_config "https://github.com/tagman45/oga-xdna/blob/main/qwen2_oga/genai_config.json"
click node_tiny_model "https://github.com/tagman45/oga-xdna/blob/main/tinyllama_oga/genai_config.json"
click node_hybrid_guide "https://github.com/tagman45/oga-xdna/blob/main/GUIDE_OGA_TURBOQUANT.md"
click node_hybrid_config "https://github.com/tagman45/oga-xdna/blob/main/qwen35_9b_balanced_ogad.json"

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_pipe_daemon,node_v2_daemon,node_v3_daemon,node_model_cache,node_oga toneBlue
class node_pipe_client,node_stdio_client,node_header_client toneAmber
class node_converter,node_oga_config,node_tiny_model toneMint
class node_hybrid_guide,node_hybrid_config toneRose
class node_llama,node_npu,node_gguf,node_hf toneIndigo
```

## Components

### Daemon inference

- [Named-pipe daemon](https://github.com/tagman45/oga-xdna/blob/main/ogad.py): `ogad.py`
- [Stdio daemon v2](https://github.com/tagman45/oga-xdna/blob/main/ogad_v2.py): `ogad_v2.py`
- [Stdio daemon v3](https://github.com/tagman45/oga-xdna/blob/main/ogad_v3.py): `ogad_v3.py`
- [Model and KV cache](https://github.com/tagman45/oga-xdna/blob/main/ogad_v3.py): `ogad_v3.py`
- **ONNX Runtime GenAI**

### Client interfaces

- [Named-pipe caller](https://github.com/tagman45/oga-xdna/blob/main/ogad_client.cpp): `ogad_client.cpp`
- [Subprocess client](https://github.com/tagman45/oga-xdna/blob/main/ogad_client_v3.cpp): `ogad_client_v3.cpp`
- [Client API and JSON](https://github.com/tagman45/oga-xdna/blob/main/ogad_client.h): `ogad_client.h`

### Models and conversion

- [GGUF metadata converter](https://github.com/tagman45/oga-xdna/blob/main/gguf_to_oga.py): `gguf_to_oga.py`
- [OGA model wrappers](https://github.com/tagman45/oga-xdna/blob/main/qwen2_oga/genai_config.json): `qwen2_oga/genai_config.json`
- [TinyLlama wrapper](https://github.com/tagman45/oga-xdna/blob/main/tinyllama_oga/genai_config.json): `tinyllama_oga/genai_config.json`

### Hybrid guidance

- [Hybrid NPU/GPU guide](https://github.com/tagman45/oga-xdna/blob/main/GUIDE_OGA_TURBOQUANT.md): `GUIDE_OGA_TURBOQUANT.md`
- [Hybrid model config](https://github.com/tagman45/oga-xdna/blob/main/qwen35_9b_balanced_ogad.json): `qwen35_9b_balanced_ogad.json`

### Other components

- **llama.cpp integration**
- **RyzenAI XDNA2 NPU**
- **GGUF input model**
- **Hugging Face model**

## Connections

- llama.cpp integration → Named-pipe caller: invokes (evidence: `README.md`)
- Named-pipe caller → Named-pipe daemon: sends JSON commands (evidence: `README.md`)
- Named-pipe caller → Stdio daemon v2: launches process (evidence: `ogad_client.cpp`)
- Subprocess client → Stdio daemon v3: launches process (evidence: `ogad_client_v3.cpp`)
- Client API and JSON → Subprocess client: provides client API (evidence: `ogad_client_v3.cpp`)
- Named-pipe daemon → Model and KV cache: dispatches commands (evidence: `ogad.py`)
- Stdio daemon v2 → Model and KV cache: loads and generates (evidence: `ogad_v2.py`)
- Stdio daemon v3 → Model and KV cache: loads and generates (evidence: `ogad_v3.py`)
- Model and KV cache → ONNX Runtime GenAI: loads and runs (evidence: `ogad_v3.py`)
- ONNX Runtime GenAI → RyzenAI XDNA2 NPU: runs inference on (evidence: `README.md`)
- GGUF input model → GGUF metadata converter: provides metadata (evidence: `gguf_to_oga.py`)
- GGUF metadata converter → OGA model wrappers: creates model config (evidence: `gguf_to_oga.py`)
- Hugging Face model → GGUF metadata converter: exports via builder (evidence: `gguf_to_oga.py`)
- Hybrid NPU/GPU guide → Hybrid model config: describes configuration
