# whitecircle/halo architecture

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

- Interactive diagram: https://gitdiagram.com/whitecircle/halo
- Repository: https://github.com/whitecircle/halo

## Overview

Halo is a framework for pre- and post-training Hugging Face language and multimodal models, from SFT and preference optimization to asynchronous multi-turn RL. A typical run enters through its CLI and configuration, prepares data and a model, then trains using shared distributed infrastructure and writes standard checkpoints. For environmental RL, rollout actors interact with inference servers while the trainer scores trajectories and synchronizes updated weights. README-level capability descriptions establish several links below; source excerpts are partial, so finer internal calls and some subsystem wiring are not asserted.

Main entry points: [`halo/trainers/loop`](https://github.com/whitecircle/halo/tree/main/halo/trainers/loop) (Trainer loop), [`halo/environments/rollouts`](https://github.com/whitecircle/halo/tree/main/halo/environments/rollouts) (Rollout orchestration), [`halo/trainers/grpo`](https://github.com/whitecircle/halo/tree/main/halo/trainers/grpo) (GRPO training), [`halo/configs`](https://github.com/whitecircle/halo/tree/main/halo/configs) (Training configs)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_run["Run setup"]
  node_cli["CLI entrypoint<br/>[cli.py]"]
  node_configs["Training configs"]
  node_data["Data preparation"]
end

subgraph group_training["Training methods"]
  node_sft["Pretrain and SFT<br/>[sft.py]"]
  node_preference["Preference training"]
  node_distillation["Distillation"]
  node_grpo["GRPO training"]
  node_trainer["Trainer loop"]
  node_optimizers["Optimizers and kernels"]
end

subgraph group_distributed["Distributed execution"]
  node_parallel_config["Parallelism config"]
  node_parallelism["Parallel model execution"]
  node_pipeline["Pipeline training"]
end

subgraph group_rl["RL rollouts"]
  node_environments["Task environments"]
  node_rollouts["Rollout orchestration"]
  node_engines["Inference engines"]
  node_weight_sync["Weight synchronization"]
  node_rewards["Reward scoring"]
end

subgraph group_state["Models and checkpoints"]
  node_model_load["Model loading"]
  node_checkpoints["Checkpoint I/O"]
  node_checkpoint_store[("Checkpoint files")]
end

node_user(("Training operator"))
node_serving["vLLM or SGLang"]

node_user -->|"launches"| node_cli
node_cli -.->|"loads config"| node_configs
node_configs -->|"configures"| node_data
node_configs -.->|"configures"| node_model_load
node_data -.->|"provides batches"| node_sft
node_model_load -->|"provides model"| node_sft
node_sft -->|"trains with"| node_trainer
node_preference -->|"shares infrastructure"| node_trainer
node_distillation -->|"shares infrastructure"| node_trainer
node_grpo -->|"trains with"| node_trainer
node_trainer -.->|"updates parameters"| node_optimizers
node_parallel_config -->|"configures axes"| node_parallelism
node_trainer -->|"uses"| node_parallelism
node_trainer -->|"uses when enabled"| node_pipeline
node_parallelism -->|"parallelizes model"| node_model_load
node_trainer -->|"saves and resumes"| node_checkpoints
node_checkpoints -.->|"reads and writes"| node_checkpoint_store
node_grpo -->|"runs rollouts"| node_rollouts
node_rollouts -.->|"executes tasks"| node_environments
node_rollouts -->|"requests generations"| node_serving
node_serving -.->|"engine integration"| node_engines
node_rollouts -.->|"scores trajectories"| node_rewards
node_grpo -->|"pushes updated weights"| node_weight_sync
node_weight_sync -->|"synchronizes weights"| node_serving

click node_cli "https://github.com/whitecircle/halo/blob/main/halo/cli.py"
click node_configs "https://github.com/whitecircle/halo/tree/main/halo/configs"
click node_data "https://github.com/whitecircle/halo/tree/main/halo/data"
click node_sft "https://github.com/whitecircle/halo/blob/main/halo/trainers/sft.py"
click node_preference "https://github.com/whitecircle/halo/tree/main/halo/trainers/preference"
click node_distillation "https://github.com/whitecircle/halo/tree/main/halo/trainers/distillation"
click node_grpo "https://github.com/whitecircle/halo/tree/main/halo/trainers/grpo"
click node_trainer "https://github.com/whitecircle/halo/tree/main/halo/trainers/loop"
click node_optimizers "https://github.com/whitecircle/halo/tree/main/halo/optimizers"
click node_parallel_config "https://github.com/whitecircle/halo/blob/main/halo/distributed/parallelism_config.py"
click node_parallelism "https://github.com/whitecircle/halo/tree/main/halo/distributed"
click node_pipeline "https://github.com/whitecircle/halo/blob/main/halo/trainers/parallelism/pipeline_trainer.py"
click node_model_load "https://github.com/whitecircle/halo/tree/main/halo/model_loading"
click node_checkpoints "https://github.com/whitecircle/halo/tree/main/halo/checkpoint"
click node_environments "https://github.com/whitecircle/halo/tree/main/halo/environments"
click node_rollouts "https://github.com/whitecircle/halo/tree/main/halo/environments/rollouts"
click node_engines "https://github.com/whitecircle/halo/tree/main/halo/weight_sync/clients"
click node_weight_sync "https://github.com/whitecircle/halo/tree/main/halo/weight_sync"
click node_rewards "https://github.com/whitecircle/halo/tree/main/halo/rewards"

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_cli,node_configs,node_data toneBlue
class node_sft,node_preference,node_distillation,node_grpo,node_trainer,node_optimizers toneAmber
class node_parallel_config,node_parallelism,node_pipeline toneMint
class node_environments,node_rollouts,node_engines,node_weight_sync,node_rewards toneRose
class node_model_load,node_checkpoints,node_checkpoint_store,node_user,node_serving toneIndigo
```

## Components

### Run setup

- [CLI entrypoint](https://github.com/whitecircle/halo/blob/main/halo/cli.py): `halo/cli.py`
- [Training configs](https://github.com/whitecircle/halo/tree/main/halo/configs): `halo/configs`
- [Data preparation](https://github.com/whitecircle/halo/tree/main/halo/data): `halo/data`

### Training methods

- [Pretrain and SFT](https://github.com/whitecircle/halo/blob/main/halo/trainers/sft.py): `halo/trainers/sft.py`
- [Preference training](https://github.com/whitecircle/halo/tree/main/halo/trainers/preference): `halo/trainers/preference`
- [Distillation](https://github.com/whitecircle/halo/tree/main/halo/trainers/distillation): `halo/trainers/distillation`
- [GRPO training](https://github.com/whitecircle/halo/tree/main/halo/trainers/grpo): `halo/trainers/grpo`
- [Trainer loop](https://github.com/whitecircle/halo/tree/main/halo/trainers/loop): `halo/trainers/loop`
- [Optimizers and kernels](https://github.com/whitecircle/halo/tree/main/halo/optimizers): `halo/optimizers`

### Distributed execution

- [Parallelism config](https://github.com/whitecircle/halo/blob/main/halo/distributed/parallelism_config.py): `halo/distributed/parallelism_config.py`
- [Parallel model execution](https://github.com/whitecircle/halo/tree/main/halo/distributed): `halo/distributed`
- [Pipeline training](https://github.com/whitecircle/halo/blob/main/halo/trainers/parallelism/pipeline_trainer.py): `halo/trainers/parallelism/pipeline_trainer.py`

### RL rollouts

- [Task environments](https://github.com/whitecircle/halo/tree/main/halo/environments): `halo/environments`
- [Rollout orchestration](https://github.com/whitecircle/halo/tree/main/halo/environments/rollouts): `halo/environments/rollouts`
- [Inference engines](https://github.com/whitecircle/halo/tree/main/halo/weight_sync/clients): `halo/weight_sync/clients`
- [Weight synchronization](https://github.com/whitecircle/halo/tree/main/halo/weight_sync): `halo/weight_sync`
- [Reward scoring](https://github.com/whitecircle/halo/tree/main/halo/rewards): `halo/rewards`

### Models and checkpoints

- [Model loading](https://github.com/whitecircle/halo/tree/main/halo/model_loading): `halo/model_loading`
- [Checkpoint I/O](https://github.com/whitecircle/halo/tree/main/halo/checkpoint): `halo/checkpoint`
- **Checkpoint files**

### Other components

- **Training operator**
- **vLLM or SGLang**

## Connections

- Training operator → CLI entrypoint: launches (evidence: `README.md`)
- CLI entrypoint → Training configs: loads config
- Training configs → Data preparation: configures (evidence: `README.md`)
- Training configs → Model loading: configures (evidence: `halo/model_loading/tokenizer_setup.py`)
- Data preparation → Pretrain and SFT: provides batches
- Model loading → Pretrain and SFT: provides model (evidence: `README.md`)
- Pretrain and SFT → Trainer loop: trains with (evidence: `README.md`)
- Preference training → Trainer loop: shares infrastructure (evidence: `README.md`)
- Distillation → Trainer loop: shares infrastructure (evidence: `README.md`)
- GRPO training → Trainer loop: trains with (evidence: `README.md`)
- Trainer loop → Optimizers and kernels: updates parameters
- Parallelism config → Parallel model execution: configures axes (evidence: `README.md`)
- Trainer loop → Parallel model execution: uses (evidence: `README.md`)
- Trainer loop → Pipeline training: uses when enabled (evidence: `halo/trainers/parallelism/pipeline_trainer.py`)
- Parallel model execution → Model loading: parallelizes model (evidence: `README.md`)
- Trainer loop → Checkpoint I/O: saves and resumes (evidence: `README.md`)
- Checkpoint I/O → Checkpoint files: reads and writes
- GRPO training → Rollout orchestration: runs rollouts (evidence: `README.md`)
- Rollout orchestration → Task environments: executes tasks (evidence: `halo/environments/rollouts/engine_wire.py`)
- Rollout orchestration → vLLM or SGLang: requests generations (evidence: `README.md`)
- vLLM or SGLang → Inference engines: engine integration
- Rollout orchestration → Reward scoring: scores trajectories
- GRPO training → Weight synchronization: pushes updated weights (evidence: `README.md`)
- Weight synchronization → vLLM or SGLang: synchronizes weights (evidence: `README.md`)
