# poisonxa16/pxa architecture

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

- Interactive diagram: https://gitdiagram.com/poisonxa16/pxa
- Repository: https://github.com/poisonxa16/pxa

## Overview

PXA is a local language-model server and control suite optimized for older NVIDIA GPUs. The main workflow is choosing a model and cards in PXA Control or the launcher, loading and executing the model through llama.cpp/ggml, then serving generated responses through an OpenAI-style API. The repository also includes quant encoding/conversion, GPU profile management, and an assistant UI. Connections for unsampled subsystems are included only where the README documents their role; source-index references support the sampled internal links.

Main entry points: [`tools/pxa_chat/routes.py`](https://github.com/poisonxa16/pxa/blob/main/tools/pxa_chat/routes.py) (Assistant routes), [`src/llama.cpp`](https://github.com/poisonxa16/pxa/blob/main/src/llama.cpp) (Local model server), [`src/llama-model.cpp`](https://github.com/poisonxa16/pxa/blob/main/src/llama-model.cpp) (Model loading), [`tools/pxa_control.py`](https://github.com/poisonxa16/pxa/blob/main/tools/pxa_control.py) (PXA Control)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_control["Launch and Control"]
  node_control_ui["PXA Control<br/>[pxa_control.py]"]
  node_launcher["Launch planner<br/>[pxa-launch.py]"]
  node_gpu_profiles["GPU profiles<br/>[service.py]"]
  node_gpu_apply["Transactional apply<br/>[engine.py]"]
end

subgraph group_runtime["Model Runtime"]
  node_server["Local model server<br/>[llama.cpp]"]
  node_api["Public llama API<br/>[llama.h]"]
  node_model_load["Model loading<br/>[llama-model.cpp]"]
  node_model_graph["Graph execution"]
  node_model_arch["Architecture graphs"]
  node_context["Inference context<br/>[llama-context.h]"]
  node_ggml["Tensor backends<br/>[ggml-backend.cpp]"]
  node_chat_templates["Chat templates<br/>[parser.cpp]"]
  node_grammar["Grammar parsing<br/>[peg-parser.cpp]"]
end

subgraph group_formats["Quant Formats"]
  node_encoding["PXA encoders<br/>[pxa_encode.py]"]
  node_gguf_tools["GGUF conversion"]
  node_gguf_store[("GGUF model files<br/>[gguf_writer.py]")]
end

subgraph group_assistant["Chat Assistant"]
  node_chat_ui["Assistant routes<br/>[routes.py]"]
  node_agent_loop["Agent loop<br/>[loop.py]"]
  node_memory["Conversation memory<br/>[memory.py]"]
  node_chat_tools["Search and tools<br/>[tools.py]"]
end

node_user(("Local operator"))
node_model_api(("OpenAI-style client"))

node_user -->|"configures"| node_control_ui
node_control_ui -->|"builds launch request"| node_launcher
node_launcher -->|"starts server"| node_server
node_user -->|"manages cards"| node_gpu_profiles
node_gpu_profiles -->|"applies profile"| node_gpu_apply
node_server -.->|"loads model"| node_model_load
node_server -->|"exposes API"| node_api
node_model_load -.->|"initializes"| node_context
node_model_load -.->|"builds execution"| node_model_graph
node_model_graph -.->|"dispatches graph"| node_model_arch
node_model_graph -.->|"executes tensors"| node_ggml
node_api -.->|"formats prompts"| node_chat_templates
node_api -.->|"constrains output"| node_grammar
node_user -->|"encodes model"| node_encoding
node_encoding -.->|"writes quant"| node_gguf_store
node_gguf_tools -.->|"writes GGUF"| node_gguf_store
node_gguf_store -->|"loads model file"| node_model_load
node_control_ui -->|"hosts assistant"| node_chat_ui
node_chat_ui -->|"routes messages"| node_agent_loop
node_chat_ui -->|"uses memory"| node_memory
node_chat_ui -->|"offers tools"| node_chat_tools
node_agent_loop -.->|"requests completions"| node_model_api
node_model_api -->|"sends API requests"| node_server

click node_control_ui "https://github.com/poisonxa16/pxa/blob/main/tools/pxa_control.py"
click node_launcher "https://github.com/poisonxa16/pxa/blob/main/tools/pxa-launch.py"
click node_gpu_profiles "https://github.com/poisonxa16/pxa/blob/main/tools/pxa_ctl/service.py"
click node_gpu_apply "https://github.com/poisonxa16/pxa/blob/main/tools/pxa_ctl/engine.py"
click node_server "https://github.com/poisonxa16/pxa/blob/main/src/llama.cpp"
click node_api "https://github.com/poisonxa16/pxa/blob/main/include/llama.h"
click node_model_load "https://github.com/poisonxa16/pxa/blob/main/src/llama-model.cpp"
click node_model_graph "https://github.com/poisonxa16/pxa/blob/main/src/llama-build-context.cpp"
click node_model_arch "https://github.com/poisonxa16/pxa/tree/main/src/graphs"
click node_context "https://github.com/poisonxa16/pxa/blob/main/src/llama-context.h"
click node_ggml "https://github.com/poisonxa16/pxa/blob/main/ggml/src/ggml-backend.cpp"
click node_chat_templates "https://github.com/poisonxa16/pxa/blob/main/common/jinja/parser.cpp"
click node_grammar "https://github.com/poisonxa16/pxa/blob/main/common/peg-parser.cpp"
click node_encoding "https://github.com/poisonxa16/pxa/blob/main/tools/pxa_encode.py"
click node_gguf_tools "https://github.com/poisonxa16/pxa/blob/main/convert_hf_to_gguf.py"
click node_gguf_store "https://github.com/poisonxa16/pxa/blob/main/gguf-py/gguf/gguf_writer.py"
click node_chat_ui "https://github.com/poisonxa16/pxa/blob/main/tools/pxa_chat/routes.py"
click node_agent_loop "https://github.com/poisonxa16/pxa/blob/main/tools/pxa_chat/loop.py"
click node_memory "https://github.com/poisonxa16/pxa/blob/main/tools/pxa_chat/memory.py"
click node_chat_tools "https://github.com/poisonxa16/pxa/blob/main/tools/pxa_chat/tools.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_control_ui,node_launcher,node_gpu_profiles,node_gpu_apply,node_model_api toneBlue
class node_server,node_api,node_model_load,node_model_graph,node_model_arch,node_context,node_ggml,node_chat_templates,node_grammar toneAmber
class node_encoding,node_gguf_tools,node_gguf_store toneMint
class node_chat_ui,node_agent_loop,node_memory,node_chat_tools toneRose
class node_user toneIndigo
```

## Components

### Launch and Control

- [PXA Control](https://github.com/poisonxa16/pxa/blob/main/tools/pxa_control.py): `tools/pxa_control.py`
- [Launch planner](https://github.com/poisonxa16/pxa/blob/main/tools/pxa-launch.py): `tools/pxa-launch.py`
- [GPU profiles](https://github.com/poisonxa16/pxa/blob/main/tools/pxa_ctl/service.py): `tools/pxa_ctl/service.py`
- [Transactional apply](https://github.com/poisonxa16/pxa/blob/main/tools/pxa_ctl/engine.py): `tools/pxa_ctl/engine.py`

### Model Runtime

- [Local model server](https://github.com/poisonxa16/pxa/blob/main/src/llama.cpp): `src/llama.cpp`
- [Public llama API](https://github.com/poisonxa16/pxa/blob/main/include/llama.h): `include/llama.h`
- [Model loading](https://github.com/poisonxa16/pxa/blob/main/src/llama-model.cpp): `src/llama-model.cpp`
- [Graph execution](https://github.com/poisonxa16/pxa/blob/main/src/llama-build-context.cpp): `src/llama-build-context.cpp`
- [Architecture graphs](https://github.com/poisonxa16/pxa/tree/main/src/graphs): `src/graphs`
- [Inference context](https://github.com/poisonxa16/pxa/blob/main/src/llama-context.h): `src/llama-context.h`
- [Tensor backends](https://github.com/poisonxa16/pxa/blob/main/ggml/src/ggml-backend.cpp): `ggml/src/ggml-backend.cpp`
- [Chat templates](https://github.com/poisonxa16/pxa/blob/main/common/jinja/parser.cpp): `common/jinja/parser.cpp`
- [Grammar parsing](https://github.com/poisonxa16/pxa/blob/main/common/peg-parser.cpp): `common/peg-parser.cpp`

### Quant Formats

- [PXA encoders](https://github.com/poisonxa16/pxa/blob/main/tools/pxa_encode.py): `tools/pxa_encode.py`
- [GGUF conversion](https://github.com/poisonxa16/pxa/blob/main/convert_hf_to_gguf.py): `convert_hf_to_gguf.py`
- [GGUF model files](https://github.com/poisonxa16/pxa/blob/main/gguf-py/gguf/gguf_writer.py): `gguf-py/gguf/gguf_writer.py`

### Chat Assistant

- [Assistant routes](https://github.com/poisonxa16/pxa/blob/main/tools/pxa_chat/routes.py): `tools/pxa_chat/routes.py`
- [Agent loop](https://github.com/poisonxa16/pxa/blob/main/tools/pxa_chat/loop.py): `tools/pxa_chat/loop.py`
- [Conversation memory](https://github.com/poisonxa16/pxa/blob/main/tools/pxa_chat/memory.py): `tools/pxa_chat/memory.py`
- [Search and tools](https://github.com/poisonxa16/pxa/blob/main/tools/pxa_chat/tools.py): `tools/pxa_chat/tools.py`

### Other components

- **Local operator**
- **OpenAI-style client**

## Connections

- Local operator → PXA Control: configures
- PXA Control → Launch planner: builds launch request (evidence: `tools/pxa_control.py`)
- Launch planner → Local model server: starts server
- Local operator → GPU profiles: manages cards
- GPU profiles → Transactional apply: applies profile (evidence: `tools/pxa_ctl/service.py`)
- Local model server → Model loading: loads model
- Local model server → Public llama API: exposes API
- Model loading → Inference context: initializes
- Model loading → Graph execution: builds execution
- Graph execution → Architecture graphs: dispatches graph
- Graph execution → Tensor backends: executes tensors
- Public llama API → Chat templates: formats prompts
- Public llama API → Grammar parsing: constrains output
- Local operator → PXA encoders: encodes model
- PXA encoders → GGUF model files: writes quant
- GGUF conversion → GGUF model files: writes GGUF
- GGUF model files → Model loading: loads model file
- PXA Control → Assistant routes: hosts assistant (evidence: `tools/pxa_control.py`)
- Assistant routes → Agent loop: routes messages (evidence: `tools/pxa_chat/routes.py`)
- Assistant routes → Conversation memory: uses memory (evidence: `tools/pxa_chat/routes.py`)
- Assistant routes → Search and tools: offers tools (evidence: `tools/pxa_chat/routes.py`)
- Agent loop → OpenAI-style client: requests completions
- OpenAI-style client → Local model server: sends API requests
