# pedromglo/tesy architecture

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

- Interactive diagram: https://gitdiagram.com/pedromglo/tesy
- Repository: https://github.com/pedromglo/tesy

## Overview

Tesy is an experimental research toolkit for assessing sparse/MoE inference on memory-constrained local hosts, not a production inference runtime. The main workflow inspects a host and locked model/backend, plans feasible placement, captures or ingests expert-routing traces, then simulates cache behavior and analyzes expert-byte capacity. Separate experiments measure mixed residency and expert crossover, with provenance checks supporting reproducible claims. The README documents these capabilities; relationships below use explicit CLI dispatch/import references or README statements, and unsampled implementation details are not inferred.

Main entry points: [`src/tesy/cli.py`](https://github.com/pedromglo/tesy/blob/main/src/tesy/cli.py) (Tesy CLI), [`src/tesy/trace.py`](https://github.com/pedromglo/tesy/blob/main/src/tesy/trace.py) (Routing Trace), [`native/tesy_moe_trace.cpp`](https://github.com/pedromglo/tesy/blob/main/native/tesy_moe_trace.cpp) (Native MoE Trace), [`src/tesy/native_trace.py`](https://github.com/pedromglo/tesy/blob/main/src/tesy/native_trace.py) (Trace Summary)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_host["Host and Inputs"]
  node_host_hw["Local Host"]
  node_model_file["Model Artifact"]
  node_cli["Tesy CLI<br/>[cli.py]"]
  node_host_doctor["Host Inspection<br/>[doctor.py]"]
  node_model_lock["Model Verification<br/>[models.py]"]
  node_backend["Backend Checks<br/>[backend.py]"]
  node_planner["Placement Planning<br/>[planner.py]"]
end

subgraph group_analysis["Trace Analysis"]
  node_routing_trace["Routing Trace<br/>[trace.py]"]
  node_native_trace["Native MoE Trace<br/>[tesy_moe_trace.cpp]"]
  node_trace_analysis["Trace Summary<br/>[native_trace.py]"]
  node_window_analysis["Expert Windows<br/>[weighted_trace.py]"]
  node_cache_sim["Cache Simulation<br/>[simulator.py]"]
  node_expert_inventory["GGUF Inventory<br/>[gguf_inventory.py]"]
  node_headroom["Capacity Headroom<br/>[headroom.py]"]
end

subgraph group_experiments["Residency Experiments"]
  node_mixed_residency["Mixed Residency<br/>[mixed_residency.py]"]
  node_overlap["Overlap Bounds"]
  node_expert_crossover["Expert Crossover"]
  node_capacity["Placement Capacity"]
end

subgraph group_evidence["Measurement Evidence"]
  node_runtime_prov["Runtime Provenance"]
  node_crossover_prov["Crossover Provenance"]
end

node_engineer(("Researcher"))
node_llama["llama.cpp"]
node_results["Research Results"]

node_engineer -->|"runs commands"| node_cli
node_cli -->|"dispatches inspection"| node_host_doctor
node_cli -->|"dispatches model checks"| node_model_lock
node_cli -->|"dispatches backend checks"| node_backend
node_cli -->|"dispatches planning"| node_planner
node_cli -->|"dispatches trace tools"| node_trace_analysis
node_cli -->|"dispatches simulation"| node_cache_sim
node_host_doctor -->|"inspects"| node_host_hw
node_model_lock -->|"verifies"| node_model_file
node_backend -->|"probes backend"| node_llama
node_engineer -->|"provides trace"| node_routing_trace
node_llama -.->|"emits routed experts"| node_native_trace
node_routing_trace -->|"summarizes"| node_trace_analysis
node_trace_analysis -->|"supports window analysis"| node_window_analysis
node_routing_trace -->|"drives simulation"| node_cache_sim
node_expert_inventory -->|"derives expert bytes"| node_model_file
node_native_trace -.->|"pairs with inventory"| node_expert_inventory
node_native_trace -->|"supports headroom analysis"| node_headroom
node_engineer -.->|"runs experiments"| node_mixed_residency
node_mixed_residency -.->|"analyzes overlap"| node_overlap
node_engineer -.->|"runs crossover"| node_expert_crossover
node_engineer -.->|"evaluates placement"| node_capacity
node_engineer -.->|"checks runtime identity"| node_runtime_prov
node_runtime_prov -->|"shared provenance checks"| node_crossover_prov
node_cli -->|"prints analysis output"| node_results

click node_cli "https://github.com/pedromglo/tesy/blob/main/src/tesy/cli.py"
click node_host_doctor "https://github.com/pedromglo/tesy/blob/main/src/tesy/doctor.py"
click node_model_lock "https://github.com/pedromglo/tesy/blob/main/src/tesy/models.py"
click node_backend "https://github.com/pedromglo/tesy/blob/main/src/tesy/backend.py"
click node_planner "https://github.com/pedromglo/tesy/blob/main/src/tesy/planner.py"
click node_routing_trace "https://github.com/pedromglo/tesy/blob/main/src/tesy/trace.py"
click node_native_trace "https://github.com/pedromglo/tesy/blob/main/native/tesy_moe_trace.cpp"
click node_trace_analysis "https://github.com/pedromglo/tesy/blob/main/src/tesy/native_trace.py"
click node_window_analysis "https://github.com/pedromglo/tesy/blob/main/src/tesy/weighted_trace.py"
click node_cache_sim "https://github.com/pedromglo/tesy/blob/main/src/tesy/simulator.py"
click node_expert_inventory "https://github.com/pedromglo/tesy/blob/main/src/tesy/gguf_inventory.py"
click node_headroom "https://github.com/pedromglo/tesy/blob/main/src/tesy/headroom.py"
click node_mixed_residency "https://github.com/pedromglo/tesy/blob/main/src/tesy/mixed_residency.py"
click node_overlap "https://github.com/pedromglo/tesy/blob/main/src/tesy/mixed_residency_overlap_bound.py"
click node_expert_crossover "https://github.com/pedromglo/tesy/blob/main/src/tesy/expert_crossover.py"
click node_capacity "https://github.com/pedromglo/tesy/blob/main/src/tesy/placement_capacity.py"
click node_runtime_prov "https://github.com/pedromglo/tesy/blob/main/src/tesy/runtime_provenance.py"
click node_crossover_prov "https://github.com/pedromglo/tesy/blob/main/src/tesy/crossover_provenance.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_host_hw,node_model_file,node_cli,node_host_doctor,node_model_lock,node_backend,node_planner toneBlue
class node_routing_trace,node_native_trace,node_trace_analysis,node_window_analysis,node_cache_sim,node_expert_inventory,node_headroom toneAmber
class node_mixed_residency,node_overlap,node_expert_crossover,node_capacity toneMint
class node_runtime_prov,node_crossover_prov toneRose
class node_engineer,node_llama,node_results toneIndigo
```

## Components

### Host and Inputs

- **Local Host**
- **Model Artifact**
- [Tesy CLI](https://github.com/pedromglo/tesy/blob/main/src/tesy/cli.py): `src/tesy/cli.py`
- [Host Inspection](https://github.com/pedromglo/tesy/blob/main/src/tesy/doctor.py): `src/tesy/doctor.py`
- [Model Verification](https://github.com/pedromglo/tesy/blob/main/src/tesy/models.py): `src/tesy/models.py`
- [Backend Checks](https://github.com/pedromglo/tesy/blob/main/src/tesy/backend.py): `src/tesy/backend.py`
- [Placement Planning](https://github.com/pedromglo/tesy/blob/main/src/tesy/planner.py): `src/tesy/planner.py`

### Trace Analysis

- [Routing Trace](https://github.com/pedromglo/tesy/blob/main/src/tesy/trace.py): `src/tesy/trace.py`
- [Native MoE Trace](https://github.com/pedromglo/tesy/blob/main/native/tesy_moe_trace.cpp): `native/tesy_moe_trace.cpp`
- [Trace Summary](https://github.com/pedromglo/tesy/blob/main/src/tesy/native_trace.py): `src/tesy/native_trace.py`
- [Expert Windows](https://github.com/pedromglo/tesy/blob/main/src/tesy/weighted_trace.py): `src/tesy/weighted_trace.py`
- [Cache Simulation](https://github.com/pedromglo/tesy/blob/main/src/tesy/simulator.py): `src/tesy/simulator.py`
- [GGUF Inventory](https://github.com/pedromglo/tesy/blob/main/src/tesy/gguf_inventory.py): `src/tesy/gguf_inventory.py`
- [Capacity Headroom](https://github.com/pedromglo/tesy/blob/main/src/tesy/headroom.py): `src/tesy/headroom.py`

### Residency Experiments

- [Mixed Residency](https://github.com/pedromglo/tesy/blob/main/src/tesy/mixed_residency.py): `src/tesy/mixed_residency.py`
- [Overlap Bounds](https://github.com/pedromglo/tesy/blob/main/src/tesy/mixed_residency_overlap_bound.py): `src/tesy/mixed_residency_overlap_bound.py`
- [Expert Crossover](https://github.com/pedromglo/tesy/blob/main/src/tesy/expert_crossover.py): `src/tesy/expert_crossover.py`
- [Placement Capacity](https://github.com/pedromglo/tesy/blob/main/src/tesy/placement_capacity.py): `src/tesy/placement_capacity.py`

### Measurement Evidence

- [Runtime Provenance](https://github.com/pedromglo/tesy/blob/main/src/tesy/runtime_provenance.py): `src/tesy/runtime_provenance.py`
- [Crossover Provenance](https://github.com/pedromglo/tesy/blob/main/src/tesy/crossover_provenance.py): `src/tesy/crossover_provenance.py`

### Other components

- **Researcher**
- **llama.cpp**
- **Research Results**

## Connections

- Researcher → Tesy CLI: runs commands (evidence: `README.md`)
- Tesy CLI → Host Inspection: dispatches inspection (evidence: `src/tesy/cli.py`)
- Tesy CLI → Model Verification: dispatches model checks (evidence: `src/tesy/cli.py`)
- Tesy CLI → Backend Checks: dispatches backend checks (evidence: `src/tesy/cli.py`)
- Tesy CLI → Placement Planning: dispatches planning (evidence: `src/tesy/cli.py`)
- Tesy CLI → Trace Summary: dispatches trace tools (evidence: `src/tesy/cli.py`)
- Tesy CLI → Cache Simulation: dispatches simulation (evidence: `src/tesy/cli.py`)
- Host Inspection → Local Host: inspects (evidence: `src/tesy/doctor.py`)
- Model Verification → Model Artifact: verifies (evidence: `src/tesy/models.py`)
- Backend Checks → llama.cpp: probes backend (evidence: `src/tesy/backend.py`)
- Researcher → Routing Trace: provides trace (evidence: `README.md`)
- llama.cpp → Native MoE Trace: emits routed experts (evidence: `README.md`)
- Routing Trace → Trace Summary: summarizes (evidence: `README.md`)
- Trace Summary → Expert Windows: supports window analysis (evidence: `src/tesy/weighted_trace.py`)
- Routing Trace → Cache Simulation: drives simulation (evidence: `README.md`)
- GGUF Inventory → Model Artifact: derives expert bytes (evidence: `src/tesy/gguf_inventory.py`)
- Native MoE Trace → GGUF Inventory: pairs with inventory (evidence: `README.md`)
- Native MoE Trace → Capacity Headroom: supports headroom analysis (evidence: `src/tesy/headroom.py`)
- Researcher → Mixed Residency: runs experiments (evidence: `README.md`)
- Mixed Residency → Overlap Bounds: analyzes overlap
- Researcher → Expert Crossover: runs crossover (evidence: `README.md`)
- Researcher → Placement Capacity: evaluates placement (evidence: `README.md`)
- Researcher → Runtime Provenance: checks runtime identity (evidence: `README.md`)
- Runtime Provenance → Crossover Provenance: shared provenance checks (evidence: `src/tesy/crossover_provenance.py`)
- Tesy CLI → Research Results: prints analysis output (evidence: `README.md`)
