# nvlabs/gateddeltanet architecture

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

- Interactive diagram: https://gitdiagram.com/nvlabs/gateddeltanet
- Repository: https://github.com/nvlabs/gateddeltanet

## Overview

This repository implements and trains Gated DeltaNet language models. The main workflow is to launch pretraining with training and validation data, construct the configured GPT model, process batches through its model blocks and gated-delta computations, and save checkpoints while tracking training speed and metrics. The implementation also includes ordinary attention and model-support kernels. README-described performance and FLA-kernel alternatives are represented, but source excerpts do not establish all runtime dispatch details; those links are omitted or marked unverified.

Main entry points: [`pretrain.py`](https://github.com/nvlabs/gateddeltanet/blob/main/pretrain.py) (Pretraining Loop), [`lit_gpt/model.py`](https://github.com/nvlabs/gateddeltanet/blob/main/lit_gpt/model.py) (GPT Model), [`lit_gpt/config.py`](https://github.com/nvlabs/gateddeltanet/blob/main/lit_gpt/config.py) (Model Config), [`lit_gpt/gated_delta_net.py`](https://github.com/nvlabs/gateddeltanet/blob/main/lit_gpt/gated_delta_net.py) (Gated DeltaNet)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_training["Training"]
  node_pretrain["Pretraining Loop<br/>[pretrain.py]"]
  node_dataset["Packed Dataset<br/>[packed_dataset.py]"]
  node_monitor["Speed Monitor<br/>[speed_monitor.py]"]
  node_checkpoint[("Checkpoints")]
end

subgraph group_model["Model"]
  node_config["Model Config<br/>[config.py]"]
  node_gpt["GPT Model<br/>[model.py]"]
  node_block["Model Blocks<br/>[model.py]"]
  node_delta["Gated DeltaNet<br/>[gated_delta_net.py]"]
  node_tokenizer["Tokenizer<br/>[tokenizer.py]"]
end

subgraph group_kernels["Delta Kernels"]
  node_chunk["Chunk Kernels<br/>[chunk.py]"]
  node_wy["WY Kernels<br/>[wy_fast.py]"]
  node_fla_chunk["FLA Chunk Kernels<br/>[chunk_fla.py]"]
  node_fla_wy["FLA WY Kernels<br/>[wy_fast_fla.py]"]
end

subgraph group_support["Model Support"]
  node_fused_loss["Fused Cross Entropy"]
  node_rotary["Rotary Embedding"]
  node_rmsnorm["Fused RMSNorm<br/>[rmsnorm.py]"]
  node_rotary_helpers["Rotary Helpers<br/>[rotary.py]"]
  node_utils["Training Utilities<br/>[utils.py]"]
end

node_operator(("Training Operator"))
node_data[("Training Data")]
node_wandb["W&amp;B Logger"]

node_operator -->|"launches"| node_pretrain
node_data -.->|"provides batches"| node_pretrain
node_pretrain -->|"loads data"| node_dataset
node_pretrain -->|"trains"| node_gpt
node_pretrain -->|"tracks speed"| node_monitor
node_pretrain -->|"saves state"| node_checkpoint
node_pretrain -->|"logs metrics"| node_wandb
node_gpt -->|"uses settings"| node_config
node_gpt -.->|"runs blocks"| node_block
node_block -->|"selects mixer"| node_delta
node_delta -->|"uses kernels"| node_chunk
node_chunk -->|"prepares WY"| node_wy
node_fla_chunk -->|"prepares WY"| node_fla_wy
node_gpt -->|"uses embedding"| node_rotary
node_config -->|"selects norm"| node_rmsnorm
node_config -->|"uses helpers"| node_utils

click node_pretrain "https://github.com/nvlabs/gateddeltanet/blob/main/pretrain.py"
click node_dataset "https://github.com/nvlabs/gateddeltanet/blob/main/lit_gpt/packed_dataset.py"
click node_monitor "https://github.com/nvlabs/gateddeltanet/blob/main/lit_gpt/speed_monitor.py"
click node_config "https://github.com/nvlabs/gateddeltanet/blob/main/lit_gpt/config.py"
click node_gpt "https://github.com/nvlabs/gateddeltanet/blob/main/lit_gpt/model.py"
click node_block "https://github.com/nvlabs/gateddeltanet/blob/main/lit_gpt/model.py"
click node_delta "https://github.com/nvlabs/gateddeltanet/blob/main/lit_gpt/gated_delta_net.py"
click node_tokenizer "https://github.com/nvlabs/gateddeltanet/blob/main/lit_gpt/tokenizer.py"
click node_chunk "https://github.com/nvlabs/gateddeltanet/blob/main/lit_gpt/gated_delta_rule_ops/chunk.py"
click node_wy "https://github.com/nvlabs/gateddeltanet/blob/main/lit_gpt/gated_delta_rule_ops/wy_fast.py"
click node_fla_chunk "https://github.com/nvlabs/gateddeltanet/blob/main/lit_gpt/gated_delta_rule_ops/fla_version/chunk_fla.py"
click node_fla_wy "https://github.com/nvlabs/gateddeltanet/blob/main/lit_gpt/gated_delta_rule_ops/fla_version/wy_fast_fla.py"
click node_fused_loss "https://github.com/nvlabs/gateddeltanet/blob/main/lit_gpt/fused_cross_entropy.py"
click node_rotary "https://github.com/nvlabs/gateddeltanet/blob/main/lit_gpt/fused_rotary_embedding.py"
click node_rmsnorm "https://github.com/nvlabs/gateddeltanet/blob/main/lit_gpt/rmsnorm.py"
click node_rotary_helpers "https://github.com/nvlabs/gateddeltanet/blob/main/lit_gpt/rotary.py"
click node_utils "https://github.com/nvlabs/gateddeltanet/blob/main/lit_gpt/utils.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_pretrain,node_dataset,node_monitor,node_checkpoint toneBlue
class node_config,node_gpt,node_block,node_delta,node_tokenizer,node_data toneAmber
class node_chunk,node_wy,node_fla_chunk,node_fla_wy toneMint
class node_fused_loss,node_rotary,node_rmsnorm,node_rotary_helpers,node_utils toneRose
class node_operator,node_wandb toneIndigo
```

## Components

### Training

- [Pretraining Loop](https://github.com/nvlabs/gateddeltanet/blob/main/pretrain.py): `pretrain.py`
- [Packed Dataset](https://github.com/nvlabs/gateddeltanet/blob/main/lit_gpt/packed_dataset.py): `lit_gpt/packed_dataset.py`
- [Speed Monitor](https://github.com/nvlabs/gateddeltanet/blob/main/lit_gpt/speed_monitor.py): `lit_gpt/speed_monitor.py`
- **Checkpoints**

### Model

- [Model Config](https://github.com/nvlabs/gateddeltanet/blob/main/lit_gpt/config.py): `lit_gpt/config.py`
- [GPT Model](https://github.com/nvlabs/gateddeltanet/blob/main/lit_gpt/model.py): `lit_gpt/model.py`
- [Model Blocks](https://github.com/nvlabs/gateddeltanet/blob/main/lit_gpt/model.py): `lit_gpt/model.py`
- [Gated DeltaNet](https://github.com/nvlabs/gateddeltanet/blob/main/lit_gpt/gated_delta_net.py): `lit_gpt/gated_delta_net.py`
- [Tokenizer](https://github.com/nvlabs/gateddeltanet/blob/main/lit_gpt/tokenizer.py): `lit_gpt/tokenizer.py`

### Delta Kernels

- [Chunk Kernels](https://github.com/nvlabs/gateddeltanet/blob/main/lit_gpt/gated_delta_rule_ops/chunk.py): `lit_gpt/gated_delta_rule_ops/chunk.py`
- [WY Kernels](https://github.com/nvlabs/gateddeltanet/blob/main/lit_gpt/gated_delta_rule_ops/wy_fast.py): `lit_gpt/gated_delta_rule_ops/wy_fast.py`
- [FLA Chunk Kernels](https://github.com/nvlabs/gateddeltanet/blob/main/lit_gpt/gated_delta_rule_ops/fla_version/chunk_fla.py): `lit_gpt/gated_delta_rule_ops/fla_version/chunk_fla.py`
- [FLA WY Kernels](https://github.com/nvlabs/gateddeltanet/blob/main/lit_gpt/gated_delta_rule_ops/fla_version/wy_fast_fla.py): `lit_gpt/gated_delta_rule_ops/fla_version/wy_fast_fla.py`

### Model Support

- [Fused Cross Entropy](https://github.com/nvlabs/gateddeltanet/blob/main/lit_gpt/fused_cross_entropy.py): `lit_gpt/fused_cross_entropy.py`
- [Rotary Embedding](https://github.com/nvlabs/gateddeltanet/blob/main/lit_gpt/fused_rotary_embedding.py): `lit_gpt/fused_rotary_embedding.py`
- [Fused RMSNorm](https://github.com/nvlabs/gateddeltanet/blob/main/lit_gpt/rmsnorm.py): `lit_gpt/rmsnorm.py`
- [Rotary Helpers](https://github.com/nvlabs/gateddeltanet/blob/main/lit_gpt/rotary.py): `lit_gpt/rotary.py`
- [Training Utilities](https://github.com/nvlabs/gateddeltanet/blob/main/lit_gpt/utils.py): `lit_gpt/utils.py`

### Other components

- **Training Operator**
- **Training Data**
- **W&B Logger**

## Connections

- Training Operator → Pretraining Loop: launches (evidence: `README.md`)
- Training Data → Pretraining Loop: provides batches
- Pretraining Loop → Packed Dataset: loads data (evidence: `pretrain.py`)
- Pretraining Loop → GPT Model: trains (evidence: `pretrain.py`)
- Pretraining Loop → Speed Monitor: tracks speed (evidence: `pretrain.py`)
- Pretraining Loop → Checkpoints: saves state (evidence: `pretrain.py`)
- Pretraining Loop → W&B Logger: logs metrics (evidence: `pretrain.py`)
- GPT Model → Model Config: uses settings (evidence: `lit_gpt/model.py`)
- GPT Model → Model Blocks: runs blocks (evidence: `lit_gpt/model.py`)
- Model Blocks → Gated DeltaNet: selects mixer (evidence: `lit_gpt/model.py`)
- Gated DeltaNet → Chunk Kernels: uses kernels (evidence: `lit_gpt/gated_delta_net.py`)
- Chunk Kernels → WY Kernels: prepares WY (evidence: `lit_gpt/gated_delta_rule_ops/chunk.py`)
- FLA Chunk Kernels → FLA WY Kernels: prepares WY (evidence: `lit_gpt/gated_delta_rule_ops/fla_version/chunk_fla.py`)
- GPT Model → Rotary Embedding: uses embedding (evidence: `lit_gpt/model.py`)
- Model Config → Fused RMSNorm: selects norm (evidence: `lit_gpt/config.py`)
- Model Config → Training Utilities: uses helpers (evidence: `lit_gpt/config.py`)
