# allenai/olmo-core architecture

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

- Interactive diagram: https://gitdiagram.com/allenai/olmo-core
- Repository: https://github.com/allenai/olmo-core

## Overview

1. **What this repo is**
   - `OLMo-core` is a PyTorch-based library for training, evaluating, converting, and generating with OLMo-family language models.
   - The repository is organized as a reusable core package (`src/olmo_core`) plus a large set of runnable scripts (`src/scripts`) and reference/official training recipes.

2. **Top-level architecture**
   - The codebase is split into a few clear layers:
     - **Data ingestion and sampling**: `olmo_core.data`
     - **Model components**: `olmo_core.nn`
     - **Training orchestration**: `olmo_core.train`
     - **Distributed execution**: `olmo_core.distributed`
     - **Inference/generation**: `olmo_core.generate`
     - **Evaluation**: `olmo_core.eval`
     - **Launch/deployment helpers**: `olmo_core.launch`
   - This separation is important for the diagram: most flows enter through scripts, pass through config objects, and then connect data/model/training/distributed subsystems.

3. **Training entry points and configuration flow**
   - The primary runtime entry points are the scripts in `src/scripts/train/` and `src/scripts/official/`.
   - These scripts define model/training recipes for specific model families and stages, then hand off to the training framework through structured config objects.
   - The repo is designed for command-line overrides, so architecture-wise the script is a thin composition layer over core modules rather than a monolithic app.

4. **Data subsystem**
   - `olmo_core.data` handles the end-to-end input pipeline: tokenization, collating, dataset wrappers, mixture definitions, and dataloader construction.
   - The `composable/` subpackage is the most important architectural piece here: it provides reusable source abstractions for documents, tokens, instances, packing, slicing, and mixing.
   - The `.txt` mix files and YAML source-mixture configs define data composition externally from code, which is a key boundary between policy/configuration and the runtime pipeline.

5. **Model and neural network subsystem**
   - `olmo_core.nn` contains the model building blocks: transformer blocks, attention backends, RoPE, layer norm, feed-forward layers, LM head, MoE layers, and related utilities.
   - It also includes model conversion helpers and Hugging Face integration code, indicating that model weights/configs can be translated across formats.
   - Optional backend-specific code paths exist for FlashAttention, TransformerEngine, ring attention, float8, and MoE kernels; these are performance/scale extensions, not separate products.

6. **Training core**
   - `olmo_core.train` contains the generic training loop, training module abstractions, checkpointing, and the callback system.
   - The `train_module/transformer` subtree is the main specialization for transformer language models, including pipeline variants.
   - The training boundary is callback-driven: monitoring, checkpointing, logging, scheduling, and model-merging are all attached as pluggable behaviors around the core loop.

7. **Distributed and parallelism layer**
   - `olmo_core.distributed` encapsulates the multi-device/multi-node concerns: checkpointing, rank utilities, and parallelism strategies.
   - The `parallel/` area distinguishes data parallel, tensor parallel, pipeline parallel, expert parallel, and context parallel modes.
   - In an architecture diagram, this layer sits between the training module and the hardware cluster, shaping how the model and batches are partitioned across accelerators.

8. **Checkpointing and model format boundaries**
   - Checkpoints are a central artifact in this repo: training saves native/core checkpoints, and separate tools convert to/from Hugging Face format.
   - The conversion path is a distinct boundary: `src/examples/huggingface/` and `olmo_core.nn.hf` bridge internal training checkpoints with external inference ecosystems.
   - There are also standalone utilities for merging, resharding, and unsharding checkpoints, reflecting that storage format and sharding strategy are first-class concerns.

9. **Inference and generation**
   - `olmo_core.generate` provides autoregressive generation directly from OLMo-core checkpoints, including a chat-style demo entry point.
   - This path is separate from training: generation uses model loading, sampling, and generation modules rather than the training loop.
   - The repo also explicitly supports inference through Hugging Face Transformers and vLLM, so the architecture includes both native and external inference paths.

10. **Evaluation subsystem**
   - `olmo_core.eval` contains evaluator abstractions, language-model evaluation logic, task groups, and metrics.
   - This subsystem is meant to run alongside or after training, typically consuming checkpoints and producing comparable metrics rather than participating in the training loop itself.
   - It forms a read-only consumer of model artifacts and datasets.

11. **Operational and infrastructure integration**
   - `olmo_core.launch` contains Beaker-related launch helpers and cluster-specific utilities, showing the repo is built for large-scale training on managed infrastructure.
   - The callback layer also integrates with external services such as Weights & Biases, Comet, Slack, and Beaker for logging, alerting, and orchestration.
   - These integrations are peripheral to model logic but important to the overall system diagram because they sit on the control/observability plane.

12. **Official recipes vs reusable library**
   - The `src/scripts/official/` tree holds reproducible, versioned training recipes for released model families like OLMo-2 and OLMo-3.
   - The `src/scripts/train/` tree contains broader experiment scripts, ladders, SFT runs, MoE runs, debug helpers, and benchmarking utilities.
   - This creates a clear split between “reference production recipes” and “research/experimentation scripts.”

13. **Testing, docs, and build pipeline**
   - `src/test` mirrors the library structure closely, indicating the codebase is organized around testable subsystems rather than a single app surface.
   - `docs/` is a full Sphinx documentation site with separate pages for data, distributed, eval, generate, nn, optim, and train.
   - CI/CD and packaging are handled through GitHub Actions, Docker builds, and Python packaging metadata in `pyproject.toml`, reinforcing that the repo is both a library and a release artifact.

14. **How to draw the main data flow**
   - The key runtime pipeline is: external config/script → data source mixtures/tokenization → dataloader/collator → train module/model → distributed execution → checkpoint/logging callbacks.
   - A secondary flow is: checkpoint → conversion/load path → generation or external inference runtime.
   - A third flow is: checkpoint or evaluation dataset → evaluator/metrics → reports/logging.

Main entry points: [`src/olmo_core/train`](https://github.com/allenai/olmo-core/tree/main/src/olmo_core/train) (Training core), [`src/olmo_core/data`](https://github.com/allenai/olmo-core/tree/main/src/olmo_core/data) (Data stack), [`src/olmo_core/nn`](https://github.com/allenai/olmo-core/tree/main/src/olmo_core/nn) (Model stack), [`src/olmo_core/distributed/checkpoint`](https://github.com/allenai/olmo-core/tree/main/src/olmo_core/distributed/checkpoint) (Checkpoint store)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_core["Core package"]
  node_data[("Data stack<br/>pipeline")]
  node_data_composable["Composable I/O<br/>data pipeline"]
  node_data_mixes["Mix files<br/>data policy"]
  node_nn["Model stack<br/>transformer nn"]
  node_nn_conversion_hf["HF bridge<br/>format conversion"]
  node_train["Training core<br/>trainer"]
  node_train_transformer["Transformer training<br/>train module"]
  node_callbacks["Callbacks<br/>training extensions"]
  node_distributed["Distributed layer<br/>parallel runtime"]
  node_parallel_modes["Parallel modes<br/>partitioning"]
  node_checkpoint_dist[("Checkpoint store<br/>storage backend")]
  node_generate["Generation<br/>inference"]
  node_eval["Evaluation<br/>metrics"]
  node_launch["Launch helpers<br/>cluster utils"]
end

subgraph group_scripts["Scripts"]
  node_scripts_train["Train recipes<br/>entry scripts"]
  node_scripts_official["Official recipes<br/>reference scripts"]
  node_scripts_examples_hf["HF tools<br/>conversion scripts"]
  node_scripts_checkpoint_tools["Checkpoint tools<br/>artifact scripts"]
  node_scripts_release_launch["Ops scripts<br/>infra scripts"]
end

subgraph group_ops["Operations"]
  node_docs["Docs<br/>documentation"]
  node_tests["Tests<br/>verification"]
  node_ci_release["CI & release<br/>build pipeline<br/>[workflows]"]
end

node_scripts_train -->|"builds input pipeline"| node_data
node_scripts_train -->|"selects model"| node_nn
node_scripts_train -->|"launches loop"| node_train
node_scripts_official -->|"pins mixtures"| node_data_mixes
node_scripts_official -->|"specializes training"| node_train_transformer
node_scripts_examples_hf -->|"converts formats"| node_nn_conversion_hf
node_scripts_checkpoint_tools -->|"reshards stores"| node_distributed
node_scripts_release_launch -->|"orchestrates infra"| node_launch
node_data_composable -->|"feeds pipeline"| node_data
node_data_mixes -->|"defines policy"| node_data
node_data -->|"supplies batches"| node_train
node_nn -->|"implements model"| node_train_transformer
node_train -->|"attaches hooks"| node_callbacks
node_train -->|"runs distributed"| node_distributed
node_train_transformer -->|"partitions model"| node_parallel_modes
node_distributed -->|"persists state"| node_checkpoint_dist
node_nn -->|"maps weights"| node_nn_conversion_hf
node_train -->|"saves checkpoints"| node_checkpoint_dist
node_checkpoint_dist -->|"round-trips"| node_scripts_checkpoint_tools
node_generate -->|"loads model"| node_nn
node_generate -->|"reads checkpoints"| node_checkpoint_dist
node_eval -->|"evaluates artifacts"| node_checkpoint_dist
node_launch -->|"clusters jobs"| node_distributed
node_callbacks -->|"reports metrics"| node_eval
node_callbacks -->|"observability"| node_scripts_release_launch
node_docs -->|"documents"| node_data
node_docs -->|"documents"| node_train
node_tests -->|"verifies"| node_data
node_tests -->|"verifies"| node_nn
node_tests -->|"verifies"| node_train
node_ci_release -->|"runs"| node_tests
node_ci_release -->|"packages"| node_scripts_release_launch

click node_scripts_train "https://github.com/allenai/olmo-core/tree/main/src/scripts/train"
click node_scripts_official "https://github.com/allenai/olmo-core/tree/main/src/scripts/official"
click node_scripts_examples_hf "https://github.com/allenai/olmo-core/tree/main/src/examples/huggingface"
click node_scripts_checkpoint_tools "https://github.com/allenai/olmo-core/blob/main/src/scripts/merge_core_checkpoints.py"
click node_scripts_release_launch "https://github.com/allenai/olmo-core/tree/main/src/scripts/beaker"
click node_data "https://github.com/allenai/olmo-core/tree/main/src/olmo_core/data"
click node_data_composable "https://github.com/allenai/olmo-core/tree/main/src/olmo_core/data/composable"
click node_data_mixes "https://github.com/allenai/olmo-core/tree/main/src/olmo_core/data/mixes"
click node_nn "https://github.com/allenai/olmo-core/tree/main/src/olmo_core/nn"
click node_nn_conversion_hf "https://github.com/allenai/olmo-core/tree/main/src/olmo_core/nn/hf"
click node_train "https://github.com/allenai/olmo-core/tree/main/src/olmo_core/train"
click node_train_transformer "https://github.com/allenai/olmo-core/tree/main/src/olmo_core/train/train_module/transformer"
click node_callbacks "https://github.com/allenai/olmo-core/tree/main/src/olmo_core/train/callbacks"
click node_distributed "https://github.com/allenai/olmo-core/tree/main/src/olmo_core/distributed"
click node_parallel_modes "https://github.com/allenai/olmo-core/tree/main/src/olmo_core/distributed/parallel"
click node_checkpoint_dist "https://github.com/allenai/olmo-core/tree/main/src/olmo_core/distributed/checkpoint"
click node_generate "https://github.com/allenai/olmo-core/tree/main/src/olmo_core/generate"
click node_eval "https://github.com/allenai/olmo-core/tree/main/src/olmo_core/eval"
click node_launch "https://github.com/allenai/olmo-core/tree/main/src/olmo_core/launch"
click node_docs "https://github.com/allenai/olmo-core/tree/main/docs/source"
click node_tests "https://github.com/allenai/olmo-core/tree/main/src/test"
click node_ci_release "https://github.com/allenai/olmo-core/blob/main/.github/workflows"

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_data,node_data_composable,node_data_mixes,node_nn,node_nn_conversion_hf,node_train,node_train_transformer,node_callbacks,node_distributed,node_parallel_modes,node_checkpoint_dist,node_generate,node_eval,node_launch toneBlue
class node_scripts_train,node_scripts_official,node_scripts_examples_hf,node_scripts_checkpoint_tools,node_scripts_release_launch toneAmber
class node_docs,node_tests,node_ci_release toneMint
```

## Components

### Core package

Reusable library code for data, models, training, distributed execution, generation, evaluation, and launch helpers.

- [Data stack](https://github.com/allenai/olmo-core/tree/main/src/olmo_core/data): pipeline · Tokenization, collation, datasets, mixtures, and dataloader construction. · `src/olmo_core/data`
- [Composable I/O](https://github.com/allenai/olmo-core/tree/main/src/olmo_core/data/composable): data pipeline · Reusable document, token, and instance source abstractions for mixing, packing, slicing, and sampling. · `src/olmo_core/data/composable`
- [Mix files](https://github.com/allenai/olmo-core/tree/main/src/olmo_core/data/mixes): data policy · External text and YAML mixture definitions that define dataset composition. · `src/olmo_core/data/mixes`
- [Model stack](https://github.com/allenai/olmo-core/tree/main/src/olmo_core/nn): transformer nn · Transformer blocks, attention backends, RoPE, normalization, feed-forward layers, LM head, and MoE support. · `src/olmo_core/nn`
- [HF bridge](https://github.com/allenai/olmo-core/tree/main/src/olmo_core/nn/hf): format conversion · Internal-to-Hugging Face model/config/state conversion and checkpoint interoperability. · `src/olmo_core/nn/hf`
- [Training core](https://github.com/allenai/olmo-core/tree/main/src/olmo_core/train): trainer · Generic training loop, checkpointing, config, and callback-driven orchestration. · `src/olmo_core/train`
- [Transformer training](https://github.com/allenai/olmo-core/tree/main/src/olmo_core/train/train_module/transformer): train module · Transformer-specific training modules and pipeline-parallel variants. · `src/olmo_core/train/train_module/transformer`
- [Callbacks](https://github.com/allenai/olmo-core/tree/main/src/olmo_core/train/callbacks): training extensions · Pluggable behaviors for logging, monitoring, evaluation, checkpointing, merging, and integrations. · `src/olmo_core/train/callbacks`
- [Distributed layer](https://github.com/allenai/olmo-core/tree/main/src/olmo_core/distributed): parallel runtime · Multi-device and multi-node utilities, checkpoint support, and parallelism strategies. · `src/olmo_core/distributed`
- [Parallel modes](https://github.com/allenai/olmo-core/tree/main/src/olmo_core/distributed/parallel): partitioning · Data, tensor, pipeline, expert, and context parallel execution modes. · `src/olmo_core/distributed/parallel`
- [Checkpoint store](https://github.com/allenai/olmo-core/tree/main/src/olmo_core/distributed/checkpoint): storage backend · Filesystem-backed distributed checkpoint persistence and restore support. · `src/olmo_core/distributed/checkpoint`
- [Generation](https://github.com/allenai/olmo-core/tree/main/src/olmo_core/generate): inference · Autoregressive generation, sampling, and chat-style loading for native checkpoints. · `src/olmo_core/generate`
- [Evaluation](https://github.com/allenai/olmo-core/tree/main/src/olmo_core/eval): metrics · Evaluator abstractions, LM evaluation, task groups, and metric computation. · `src/olmo_core/eval`
- [Launch helpers](https://github.com/allenai/olmo-core/tree/main/src/olmo_core/launch): cluster utils · Beaker and cluster-oriented launch utilities for managed large-scale training. · `src/olmo_core/launch`

### Scripts

Runnable training recipes, conversion tools, and operational utilities.

- [Train recipes](https://github.com/allenai/olmo-core/tree/main/src/scripts/train): entry scripts · Experiment and family-specific training entry points that assemble configs and launch training. · `src/scripts/train`
- [Official recipes](https://github.com/allenai/olmo-core/tree/main/src/scripts/official): reference scripts · Versioned, reproducible training recipes for released model families and stages. · `src/scripts/official`
- [HF tools](https://github.com/allenai/olmo-core/tree/main/src/examples/huggingface): conversion scripts · Helpers for converting and uploading checkpoints to and from Hugging Face formats. · `src/examples/huggingface`
- [Checkpoint tools](https://github.com/allenai/olmo-core/blob/main/src/scripts/merge_core_checkpoints.py): artifact scripts · Standalone utilities for merging, resharding, and unsharding core and HF checkpoints. · `src/scripts/merge_core_checkpoints.py`
- [Ops scripts](https://github.com/allenai/olmo-core/tree/main/src/scripts/beaker): infra scripts · Beaker, lambda, and release helpers for images, launches, tests, and release automation. · `src/scripts/beaker`

### Operations

Documentation, tests, packaging, and CI/release plumbing around the core library.

- [Docs](https://github.com/allenai/olmo-core/tree/main/docs/source): documentation · Sphinx documentation for the library, examples, guides, and subsystem references. · `docs/source`
- [Tests](https://github.com/allenai/olmo-core/tree/main/src/test): verification · Unit and integration test suite mirroring the library subsystems. · `src/test`
- [CI & release](https://github.com/allenai/olmo-core/blob/main/.github/workflows): build pipeline · GitHub Actions, Docker, packaging, and release process automation. · `.github/workflows`

## Connections

- Train recipes → Data stack: builds input pipeline · Training scripts compose datasets, tokenizers, and dataloaders.
- Train recipes → Model stack: selects model · Recipes choose transformer or MoE model configurations.
- Train recipes → Training core: launches loop · Scripts hand off structured configs to the training framework.
- Official recipes → Mix files: pins mixtures · Official recipes reference versioned data mixtures and stages.
- Official recipes → Transformer training: specializes training · Reference recipes target transformer training modules and variants.
- HF tools → HF bridge: converts formats · Example scripts bridge core checkpoints and Hugging Face artifacts.
- Checkpoint tools → Distributed layer: reshards stores · Checkpoint utilities operate on native distributed checkpoint artifacts.
- Ops scripts → Launch helpers: orchestrates infra · Operational scripts use launch helpers and cluster utilities.
- Composable I/O → Data stack: feeds pipeline · Composable sources are assembled into the main data ingestion layer.
- Mix files → Data stack: defines policy · External mixture files control how sources are combined at runtime.
- Data stack → Training core: supplies batches · The training loop consumes collated batches and dataset iterators.
- Model stack → Transformer training: implements model · Transformer train modules instantiate the neural network stack.
- Training core → Callbacks: attaches hooks · The training loop is extended through callback-driven behavior.
- Training core → Distributed layer: runs distributed · Training coordinates execution through the distributed layer.
- Transformer training → Parallel modes: partitions model · Pipeline and tensor-parallel transformer variants use parallel strategies.
- Distributed layer → Checkpoint store: persists state · Distributed execution relies on checkpoint storage for save and restore.
- Model stack → HF bridge: maps weights · Conversion code translates internal modules and state to HF-compatible forms.
- Training core → Checkpoint store: saves checkpoints · Training writes native checkpoints through the distributed checkpoint backend.
- Checkpoint store → Checkpoint tools: round-trips · Checkpoint utilities transform, merge, reshard, or unshard stored artifacts.
- Generation → Model stack: loads model · Generation instantiates the model stack for autoregressive decoding.
- Generation → Checkpoint store: reads checkpoints · Native generation consumes saved core checkpoints.
- Evaluation → Checkpoint store: evaluates artifacts · Evaluators load checkpoints to score models against tasks and metrics.
- Launch helpers → Distributed layer: clusters jobs · Launch helpers support multi-host and managed infrastructure execution.
- Callbacks → Evaluation: reports metrics · Evaluation callbacks integrate scoring into training and logging flows.
- Callbacks → Ops scripts: observability · Callbacks connect training to external services and operational tooling.
- Docs → Data stack: documents · Docs describe the data stack, mixtures, and loading patterns.
- Docs → Training core: documents · Docs cover training modules, callbacks, and orchestration.
- Tests → Data stack: verifies · Tests mirror the data subsystem and its composable sources.
- Tests → Model stack: verifies · Tests cover neural network modules, conversions, and backends.
- Tests → Training core: verifies · Tests validate training, checkpointing, and callback behavior.
- CI & release → Tests: runs · CI executes the test suite and integration checks.
- CI & release → Ops scripts: packages · Build and release automation produces images and artifacts.
