How allenai/olmo-core works
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: train Training core · data Data stack · nn Model stack · checkpoint Checkpoint store
Components 22
Core package
Reusable library code for data, models, training, distributed execution, generation, evaluation, and launch helpers.
- Data stack · Tokenization, collation, datasets, mixtures, and dataloader construction.
src/olmo_core/data - Composable I/O · Reusable document, token, and instance source abstractions for mixing, packing, slicing, and sampling.
src/olmo_core/data/composable - Mix files · External text and YAML mixture definitions that define dataset composition.
src/olmo_core/data/mixes - Model stack · Transformer blocks, attention backends, RoPE, normalization, feed-forward layers, LM head, and MoE support.
src/olmo_core/nn - HF bridge · Internal-to-Hugging Face model/config/state conversion and checkpoint interoperability.
src/olmo_core/nn/hf - Training core · Generic training loop, checkpointing, config, and callback-driven orchestration.
src/olmo_core/train - Transformer training · Transformer-specific training modules and pipeline-parallel variants.
src/olmo_core/train/train_module/transformer - Callbacks · Pluggable behaviors for logging, monitoring, evaluation, checkpointing, merging, and integrations.
src/olmo_core/train/callbacks - Distributed layer · Multi-device and multi-node utilities, checkpoint support, and parallelism strategies.
src/olmo_core/distributed - Parallel modes · Data, tensor, pipeline, expert, and context parallel execution modes.
src/olmo_core/distributed/parallel - Checkpoint store · Filesystem-backed distributed checkpoint persistence and restore support.
src/olmo_core/distributed/checkpoint - Generation · Autoregressive generation, sampling, and chat-style loading for native checkpoints.
src/olmo_core/generate - Evaluation · Evaluator abstractions, LM evaluation, task groups, and metric computation.
src/olmo_core/eval - Launch helpers · 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 · Experiment and family-specific training entry points that assemble configs and launch training.
src/scripts/train - Official recipes · Versioned, reproducible training recipes for released model families and stages.
src/scripts/official - HF tools · Helpers for converting and uploading checkpoints to and from Hugging Face formats.
src/examples/huggingface - Checkpoint tools · Standalone utilities for merging, resharding, and unsharding core and HF checkpoints.
src/scripts/merge_core_checkpoints.py - Ops 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 · Sphinx documentation for the library, examples, guides, and subsystem references.
docs/source - Tests · Unit and integration test suite mirroring the library subsystems.
src/test - CI & release · GitHub Actions, Docker, packaging, and release process automation.
.github/workflows
Connections 32
- 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.