# therealskyline/naylis architecture

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

- Interactive diagram: https://gitdiagram.com/therealskyline/naylis
- Repository: https://github.com/therealskyline/naylis

## Overview

Naylis is a Llama language-modeling project whose defining change is a shared, trainable memory bank read by a causally routed Mixture-of-Memory layer. The main workflow configures and pretrains a model, then evaluates checkpoints; kernel backends accelerate the memory read, while precision policies provide optional FP8 training. The README documents these capabilities, but several implementation paths are unsampled, so those links are shown only where source-index references or documentation support them.

Main entry points: [`model.py`](https://github.com/therealskyline/naylis/blob/main/model.py) (Llama and MoM model), [`pretrain.py`](https://github.com/therealskyline/naylis/blob/main/pretrain.py) (Pretraining harness), [`mom_kernels/probe.py`](https://github.com/therealskyline/naylis/blob/main/mom_kernels/probe.py) (Kernel preflight), [`evaluate.py`](https://github.com/therealskyline/naylis/blob/main/evaluate.py) (Checkpoint evaluation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_model["Model architecture"]
  node_model_impl["Llama and MoM model<br/>[model.py]"]
  node_mom_layer["MoM layer<br/>[model.py]"]
  node_memory_bank[("Shared memory bank<br/>[model.py]")]
  node_router["Causal router<br/>[model.py]"]
end

subgraph group_training["Training and evaluation"]
  node_configs["Experiment configs"]
  node_pretrain["Pretraining harness<br/>[pretrain.py]"]
  node_evaluate["Checkpoint evaluation<br/>[evaluate.py]"]
  node_checkpoint["Model checkpoint"]
  node_benchmark["Task benchmark results"]
end

subgraph group_kernels["Memory-read kernels"]
  node_reference["Eager math reference<br/>[reference.py]"]
  node_kernel_api["Kernel dispatch<br/>[__init__.py]"]
  node_xla["XLA read backend<br/>[xla_tpu.py]"]
  node_triton["Triton read backend<br/>[triton_gpu.py]"]
  node_pallas["Pallas read kernels<br/>[mom_pallas.py]"]
  node_pallas_sim["Pallas simulator<br/>[simulate.py]"]
  node_tpu_bench["TPU kernel benchmark<br/>[bench_tpu.py]"]
  node_probe["Kernel preflight<br/>[probe.py]"]
end

subgraph group_precision["Precision policy"]
  node_precision_policy["Precision planner"]
  node_fp8_probe["FP8 preflight<br/>[probe_fp8.py]"]
end

node_engineer(("Researcher"))

node_engineer -->|"starts training"| node_pretrain
node_configs -->|"configures run"| node_pretrain
node_pretrain -->|"builds model"| node_model_impl
node_pretrain -->|"applies policy"| node_precision_policy
node_model_impl -->|"adds per block"| node_mom_layer
node_model_impl -->|"owns shared bank"| node_memory_bank
node_mom_layer -->|"routes tokens"| node_router
node_mom_layer -.->|"dispatches read"| node_kernel_api
node_mom_layer -.->|"computes eager read"| node_reference
node_kernel_api -->|"dispatches read"| node_xla
node_kernel_api -->|"dispatches read"| node_triton
node_probe -->|"checks layer"| node_model_impl
node_probe -->|"compares against"| node_reference
node_probe -->|"checks parity"| node_xla
node_probe -->|"checks parity"| node_triton
node_tpu_bench -->|"benchmarks kernels"| node_pallas
node_tpu_bench -->|"simulates kernels"| node_pallas_sim
node_pretrain -.->|"saves model"| node_checkpoint
node_checkpoint -.->|"loads for evaluation"| node_evaluate
node_evaluate -->|"uses model"| node_model_impl
node_evaluate -->|"reports scores"| node_benchmark
node_fp8_probe -->|"checks policy"| node_precision_policy
node_fp8_probe -->|"checks model"| node_model_impl

click node_configs "https://github.com/therealskyline/naylis/tree/main/configs"
click node_pretrain "https://github.com/therealskyline/naylis/blob/main/pretrain.py"
click node_model_impl "https://github.com/therealskyline/naylis/blob/main/model.py"
click node_mom_layer "https://github.com/therealskyline/naylis/blob/main/model.py"
click node_memory_bank "https://github.com/therealskyline/naylis/blob/main/model.py"
click node_router "https://github.com/therealskyline/naylis/blob/main/model.py"
click node_reference "https://github.com/therealskyline/naylis/blob/main/mom_kernels/reference.py"
click node_kernel_api "https://github.com/therealskyline/naylis/blob/main/mom_kernels/__init__.py"
click node_xla "https://github.com/therealskyline/naylis/blob/main/mom_kernels/xla_tpu.py"
click node_triton "https://github.com/therealskyline/naylis/blob/main/mom_kernels/triton_gpu.py"
click node_pallas "https://github.com/therealskyline/naylis/blob/main/mom_kernels/pallas_tpu/mom_pallas.py"
click node_pallas_sim "https://github.com/therealskyline/naylis/blob/main/mom_kernels/pallas_tpu/simulate.py"
click node_tpu_bench "https://github.com/therealskyline/naylis/blob/main/mom_kernels/pallas_tpu/bench_tpu.py"
click node_probe "https://github.com/therealskyline/naylis/blob/main/mom_kernels/probe.py"
click node_precision_policy "https://github.com/therealskyline/naylis/blob/main/naylis_precision.py"
click node_evaluate "https://github.com/therealskyline/naylis/blob/main/evaluate.py"
click node_fp8_probe "https://github.com/therealskyline/naylis/blob/main/probe_fp8.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_model_impl,node_mom_layer,node_memory_bank,node_router toneBlue
class node_configs,node_pretrain,node_evaluate,node_checkpoint,node_benchmark toneAmber
class node_reference,node_kernel_api,node_xla,node_triton,node_pallas,node_pallas_sim,node_tpu_bench,node_probe toneMint
class node_precision_policy,node_fp8_probe toneRose
class node_engineer toneIndigo
```

## Components

### Model architecture

- [Llama and MoM model](https://github.com/therealskyline/naylis/blob/main/model.py): `model.py`
- [MoM layer](https://github.com/therealskyline/naylis/blob/main/model.py): `model.py`
- [Shared memory bank](https://github.com/therealskyline/naylis/blob/main/model.py): `model.py`
- [Causal router](https://github.com/therealskyline/naylis/blob/main/model.py): `model.py`

### Training and evaluation

- [Experiment configs](https://github.com/therealskyline/naylis/tree/main/configs): `configs`
- [Pretraining harness](https://github.com/therealskyline/naylis/blob/main/pretrain.py): `pretrain.py`
- [Checkpoint evaluation](https://github.com/therealskyline/naylis/blob/main/evaluate.py): `evaluate.py`
- **Model checkpoint**
- **Task benchmark results**

### Memory-read kernels

- [Eager math reference](https://github.com/therealskyline/naylis/blob/main/mom_kernels/reference.py): `mom_kernels/reference.py`
- [Kernel dispatch](https://github.com/therealskyline/naylis/blob/main/mom_kernels/__init__.py): `mom_kernels/__init__.py`
- [XLA read backend](https://github.com/therealskyline/naylis/blob/main/mom_kernels/xla_tpu.py): `mom_kernels/xla_tpu.py`
- [Triton read backend](https://github.com/therealskyline/naylis/blob/main/mom_kernels/triton_gpu.py): `mom_kernels/triton_gpu.py`
- [Pallas read kernels](https://github.com/therealskyline/naylis/blob/main/mom_kernels/pallas_tpu/mom_pallas.py): `mom_kernels/pallas_tpu/mom_pallas.py`
- [Pallas simulator](https://github.com/therealskyline/naylis/blob/main/mom_kernels/pallas_tpu/simulate.py): `mom_kernels/pallas_tpu/simulate.py`
- [TPU kernel benchmark](https://github.com/therealskyline/naylis/blob/main/mom_kernels/pallas_tpu/bench_tpu.py): `mom_kernels/pallas_tpu/bench_tpu.py`
- [Kernel preflight](https://github.com/therealskyline/naylis/blob/main/mom_kernels/probe.py): `mom_kernels/probe.py`

### Precision policy

- [Precision planner](https://github.com/therealskyline/naylis/blob/main/naylis_precision.py): `naylis_precision.py`
- [FP8 preflight](https://github.com/therealskyline/naylis/blob/main/probe_fp8.py): `probe_fp8.py`

### Other components

- **Researcher**

## Connections

- Researcher → Pretraining harness: starts training (evidence: `README.md`)
- Experiment configs → Pretraining harness: configures run (evidence: `pretrain.py`)
- Pretraining harness → Llama and MoM model: builds model (evidence: `pretrain.py`)
- Pretraining harness → Precision planner: applies policy (evidence: `pretrain.py`)
- Llama and MoM model → MoM layer: adds per block (evidence: `README.md`)
- Llama and MoM model → Shared memory bank: owns shared bank (evidence: `model.py`)
- MoM layer → Causal router: routes tokens (evidence: `README.md`)
- MoM layer → Kernel dispatch: dispatches read (evidence: `model.py`)
- MoM layer → Eager math reference: computes eager read (evidence: `model.py`)
- Kernel dispatch → XLA read backend: dispatches read (evidence: `mom_kernels/__init__.py`)
- Kernel dispatch → Triton read backend: dispatches read (evidence: `mom_kernels/__init__.py`)
- Kernel preflight → Llama and MoM model: checks layer (evidence: `mom_kernels/probe.py`)
- Kernel preflight → Eager math reference: compares against (evidence: `mom_kernels/probe.py`)
- Kernel preflight → XLA read backend: checks parity (evidence: `mom_kernels/probe.py`)
- Kernel preflight → Triton read backend: checks parity (evidence: `mom_kernels/probe.py`)
- TPU kernel benchmark → Pallas read kernels: benchmarks kernels (evidence: `mom_kernels/pallas_tpu/bench_tpu.py`)
- TPU kernel benchmark → Pallas simulator: simulates kernels (evidence: `mom_kernels/pallas_tpu/bench_tpu.py`)
- Pretraining harness → Model checkpoint: saves model
- Model checkpoint → Checkpoint evaluation: loads for evaluation
- Checkpoint evaluation → Llama and MoM model: uses model (evidence: `evaluate.py`)
- Checkpoint evaluation → Task benchmark results: reports scores (evidence: `README.md`)
- FP8 preflight → Precision planner: checks policy (evidence: `probe_fp8.py`)
- FP8 preflight → Llama and MoM model: checks model (evidence: `probe_fp8.py`)
