# alesha-pro/llm.asm architecture

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

- Interactive diagram: https://gitdiagram.com/alesha-pro/llm.asm
- Repository: https://github.com/alesha-pro/llm.asm

## Overview

llm.asm is a collection of three standalone x86-64 assembly projects: Qwen3 inference on Linux, a bootable bare-metal Qwen3 chat OS, and a from-scratch Mini-GPT trainer and sampler. The graphs preserve their separate workflows and shared assembly runtime capabilities. Runtime source excerpts were not provided, so most relationships rely on the README’s explicit descriptions; the model-export relationship is also visible in the exporter excerpt.

Main entry points: [`01-qwen3-inference/main.asm`](https://github.com/alesha-pro/llm.asm/blob/main/01-qwen3-inference/main.asm) (Inference CLI), [`03-minigpt-train/main.asm`](https://github.com/alesha-pro/llm.asm/blob/main/03-minigpt-train/main.asm) (Trainer CLI), [`02-baremetal-os/runtime.asm`](https://github.com/alesha-pro/llm.asm/blob/main/02-baremetal-os/runtime.asm) (OS LLM Runtime), [`shared/transformer.asm`](https://github.com/alesha-pro/llm.asm/blob/main/shared/transformer.asm) (Qwen Transformer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_inference["Qwen3 Inference"]
  node_exporter["Weight Exporter<br/>[export_weights.py]"]
  node_asmbin["Qwen .asmbin"]
  node_cli["Inference CLI<br/>[main.asm]"]
  node_linux_output["Generated Text"]
end

subgraph group_baremetal["Bare-Metal OS"]
  node_boot["Multiboot Startup<br/>[boot.asm]"]
  node_kernel["OS Kernel<br/>[kernel.asm]"]
  node_os_runtime["OS LLM Runtime<br/>[runtime.asm]"]
  node_drivers["Console Drivers<br/>[drivers.asm]"]
  node_smp["SMP Support<br/>[smp.asm]"]
  node_os_output["VGA Serial Chat"]
end

subgraph group_training["Mini-GPT Training"]
  node_trainer["Trainer CLI<br/>[main.asm]"]
  node_gpt_model["Mini-GPT Model<br/>[model.asm]"]
  node_train_kernels["Training Kernels<br/>[kernels.asm]"]
  node_sgemm["Blocked SGEMM<br/>[sgemm.asm]"]
  node_tui["Braille TUI<br/>[tui.asm]"]
  node_checkpoint["Model Checkpoint"]
  node_sample["Generated Sample"]
end

subgraph group_shared["Shared Assembly Runtime"]
  node_tokenizer["BPE Tokenizer<br/>[tokenizer.asm]"]
  node_transformer["Qwen Transformer<br/>[transformer.asm]"]
  node_math["Math Kernels<br/>[math.asm]"]
  node_matmul["GEMM Engine<br/>[matmul.asm]"]
  node_threads["Thread Pool<br/>[threads.asm]"]
end

node_user(("User"))
node_hf_model["HF Model Files"]
node_corpus["Training Text"]

node_user -->|"runs"| node_cli
node_hf_model -->|"provides weights"| node_exporter
node_exporter -->|"exports"| node_asmbin
node_asmbin -->|"loads model"| node_cli
node_cli -->|"tokenizes prompt"| node_tokenizer
node_cli -->|"runs inference"| node_transformer
node_cli -->|"generates text"| node_linux_output
node_user -->|"boots OS"| node_boot
node_boot -->|"starts"| node_kernel
node_kernel -->|"runs chat"| node_os_runtime
node_os_runtime -->|"uses console"| node_drivers
node_os_runtime -->|"uses SMP"| node_smp
node_os_runtime -->|"tokenizes prompts"| node_tokenizer
node_os_runtime -->|"runs inference"| node_transformer
node_drivers -->|"displays chat"| node_os_output
node_user -->|"starts training"| node_trainer
node_corpus -->|"provides text"| node_trainer
node_trainer -->|"trains model"| node_gpt_model
node_gpt_model -->|"uses kernels"| node_train_kernels
node_train_kernels -->|"uses SGEMM"| node_sgemm
node_trainer -->|"renders progress"| node_tui
node_trainer -->|"saves weights"| node_checkpoint
node_trainer -->|"generates sample"| node_sample
node_transformer -->|"uses math kernels"| node_math
node_transformer -->|"uses GEMM"| node_matmul
node_cli -->|"uses thread pool"| node_threads

click node_exporter "https://github.com/alesha-pro/llm.asm/blob/main/scripts/export_weights.py"
click node_cli "https://github.com/alesha-pro/llm.asm/blob/main/01-qwen3-inference/main.asm"
click node_tokenizer "https://github.com/alesha-pro/llm.asm/blob/main/shared/tokenizer.asm"
click node_transformer "https://github.com/alesha-pro/llm.asm/blob/main/shared/transformer.asm"
click node_math "https://github.com/alesha-pro/llm.asm/blob/main/shared/math.asm"
click node_matmul "https://github.com/alesha-pro/llm.asm/blob/main/shared/matmul.asm"
click node_threads "https://github.com/alesha-pro/llm.asm/blob/main/shared/threads.asm"
click node_boot "https://github.com/alesha-pro/llm.asm/blob/main/02-baremetal-os/boot.asm"
click node_kernel "https://github.com/alesha-pro/llm.asm/blob/main/02-baremetal-os/kernel.asm"
click node_os_runtime "https://github.com/alesha-pro/llm.asm/blob/main/02-baremetal-os/runtime.asm"
click node_drivers "https://github.com/alesha-pro/llm.asm/blob/main/02-baremetal-os/drivers.asm"
click node_smp "https://github.com/alesha-pro/llm.asm/blob/main/02-baremetal-os/smp.asm"
click node_trainer "https://github.com/alesha-pro/llm.asm/blob/main/03-minigpt-train/main.asm"
click node_gpt_model "https://github.com/alesha-pro/llm.asm/blob/main/03-minigpt-train/model.asm"
click node_train_kernels "https://github.com/alesha-pro/llm.asm/blob/main/03-minigpt-train/kernels.asm"
click node_sgemm "https://github.com/alesha-pro/llm.asm/blob/main/03-minigpt-train/sgemm.asm"
click node_tui "https://github.com/alesha-pro/llm.asm/blob/main/03-minigpt-train/tui.asm"

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_exporter,node_asmbin,node_cli,node_linux_output,node_user toneBlue
class node_boot,node_kernel,node_os_runtime,node_drivers,node_smp,node_os_output toneAmber
class node_trainer,node_gpt_model,node_train_kernels,node_sgemm,node_tui,node_checkpoint,node_sample toneMint
class node_tokenizer,node_transformer,node_math,node_matmul,node_threads toneRose
class node_hf_model,node_corpus toneIndigo
```

## Components

### Qwen3 Inference

- [Weight Exporter](https://github.com/alesha-pro/llm.asm/blob/main/scripts/export_weights.py): `scripts/export_weights.py`
- **Qwen .asmbin**
- [Inference CLI](https://github.com/alesha-pro/llm.asm/blob/main/01-qwen3-inference/main.asm): `01-qwen3-inference/main.asm`
- **Generated Text**

### Bare-Metal OS

- [Multiboot Startup](https://github.com/alesha-pro/llm.asm/blob/main/02-baremetal-os/boot.asm): `02-baremetal-os/boot.asm`
- [OS Kernel](https://github.com/alesha-pro/llm.asm/blob/main/02-baremetal-os/kernel.asm): `02-baremetal-os/kernel.asm`
- [OS LLM Runtime](https://github.com/alesha-pro/llm.asm/blob/main/02-baremetal-os/runtime.asm): `02-baremetal-os/runtime.asm`
- [Console Drivers](https://github.com/alesha-pro/llm.asm/blob/main/02-baremetal-os/drivers.asm): `02-baremetal-os/drivers.asm`
- [SMP Support](https://github.com/alesha-pro/llm.asm/blob/main/02-baremetal-os/smp.asm): `02-baremetal-os/smp.asm`
- **VGA Serial Chat**

### Mini-GPT Training

- [Trainer CLI](https://github.com/alesha-pro/llm.asm/blob/main/03-minigpt-train/main.asm): `03-minigpt-train/main.asm`
- [Mini-GPT Model](https://github.com/alesha-pro/llm.asm/blob/main/03-minigpt-train/model.asm): `03-minigpt-train/model.asm`
- [Training Kernels](https://github.com/alesha-pro/llm.asm/blob/main/03-minigpt-train/kernels.asm): `03-minigpt-train/kernels.asm`
- [Blocked SGEMM](https://github.com/alesha-pro/llm.asm/blob/main/03-minigpt-train/sgemm.asm): `03-minigpt-train/sgemm.asm`
- [Braille TUI](https://github.com/alesha-pro/llm.asm/blob/main/03-minigpt-train/tui.asm): `03-minigpt-train/tui.asm`
- **Model Checkpoint**
- **Generated Sample**

### Shared Assembly Runtime

- [BPE Tokenizer](https://github.com/alesha-pro/llm.asm/blob/main/shared/tokenizer.asm): `shared/tokenizer.asm`
- [Qwen Transformer](https://github.com/alesha-pro/llm.asm/blob/main/shared/transformer.asm): `shared/transformer.asm`
- [Math Kernels](https://github.com/alesha-pro/llm.asm/blob/main/shared/math.asm): `shared/math.asm`
- [GEMM Engine](https://github.com/alesha-pro/llm.asm/blob/main/shared/matmul.asm): `shared/matmul.asm`
- [Thread Pool](https://github.com/alesha-pro/llm.asm/blob/main/shared/threads.asm): `shared/threads.asm`

### Other components

- **User**
- **HF Model Files**
- **Training Text**

## Connections

- User → Inference CLI: runs (evidence: `README.md`)
- HF Model Files → Weight Exporter: provides weights (evidence: `scripts/export_weights.py`)
- Weight Exporter → Qwen .asmbin: exports (evidence: `scripts/export_weights.py`)
- Qwen .asmbin → Inference CLI: loads model (evidence: `README.md`)
- Inference CLI → BPE Tokenizer: tokenizes prompt (evidence: `README.md`)
- Inference CLI → Qwen Transformer: runs inference (evidence: `README.md`)
- Inference CLI → Generated Text: generates text (evidence: `README.md`)
- User → Multiboot Startup: boots OS (evidence: `README.md`)
- Multiboot Startup → OS Kernel: starts (evidence: `README.md`)
- OS Kernel → OS LLM Runtime: runs chat (evidence: `README.md`)
- OS LLM Runtime → Console Drivers: uses console (evidence: `README.md`)
- OS LLM Runtime → SMP Support: uses SMP (evidence: `README.md`)
- OS LLM Runtime → BPE Tokenizer: tokenizes prompts (evidence: `README.md`)
- OS LLM Runtime → Qwen Transformer: runs inference (evidence: `README.md`)
- Console Drivers → VGA Serial Chat: displays chat (evidence: `README.md`)
- User → Trainer CLI: starts training (evidence: `README.md`)
- Training Text → Trainer CLI: provides text (evidence: `README.md`)
- Trainer CLI → Mini-GPT Model: trains model (evidence: `README.md`)
- Mini-GPT Model → Training Kernels: uses kernels (evidence: `README.md`)
- Training Kernels → Blocked SGEMM: uses SGEMM (evidence: `README.md`)
- Trainer CLI → Braille TUI: renders progress (evidence: `README.md`)
- Trainer CLI → Model Checkpoint: saves weights (evidence: `README.md`)
- Trainer CLI → Generated Sample: generates sample (evidence: `README.md`)
- Qwen Transformer → Math Kernels: uses math kernels (evidence: `README.md`)
- Qwen Transformer → GEMM Engine: uses GEMM (evidence: `README.md`)
- Inference CLI → Thread Pool: uses thread pool (evidence: `README.md`)
