Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ trainite init my-experiment --model transformer --dataset string-reverse
├─ 2. Config assembly
│ Instantiate Pydantic config defaults for each component
│ Inject collate function target from ModelSpec into DataConfig
│ Build a complete ProjectConfig and dump it to config.yaml
│ Build a complete ProjectConfig and dump it to configs/config.yaml
│
├─ 3. Template copying
│ Copy implementation files (model, dataset, trainer, utils, main, config)
Expand Down
21 changes: 11 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ Built on [PyTorch-Ignite](https://github.com/pytorch/ignite), the generated code

```
my-experiment/
├── config.yaml # YAML configuration (edit hyperparameters here)
├── configs/ # YAML configurations (edit hyperparameters here)
│ └── config.yaml
├── config.py # Pydantic validation models (IDE autocomplete)
├── models/ # Model architecture templates
├── dataset_impl/ # Dataset and transform implementations
Expand Down Expand Up @@ -100,15 +101,15 @@ cd my-experiment
pip install -e .

# 3. Run training
python main.py config.yaml
python main.py configs/config.yaml
```

---

## Usage

> [!NOTE]
> If you are using the `uv` workflow, prefix commands with `uv run` (e.g., `uv run trainite init` or `uv run python main.py config.yaml`). If you are using standard `pip`/`venv`, run them directly (e.g., `trainite init` or `python main.py config.yaml`).
> If you are using the `uv` workflow, prefix commands with `uv run` (e.g., `uv run trainite init` or `uv run python main.py configs/config.yaml`). If you are using standard `pip`/`venv`, run them directly (e.g., `trainite init` or `python main.py configs/config.yaml`).

### Initialize a Project

Expand Down Expand Up @@ -137,7 +138,7 @@ Interactive prompt preview:
? Run name: rope-transformer__string-reverse
? Enable SkyPilot cloud training (generate sky.yaml)? No

Generated config.yaml
Generated configs/config.yaml
Generated models/rope_transformer.py
Generated dataset_impl/string_reverse.py
Generated dataset_impl/transformed.py
Expand All @@ -156,15 +157,15 @@ Your generated project is a standalone application with no runtime dependency on

```bash
cd my-experiment
python main.py config.yaml
python main.py configs/config.yaml
```

### Monitor & Iterate

- **TensorBoard**: `tensorboard --logdir outputs`
- **ClearML**: Run `clearml-init`, then set `logger: clearml` in `config.yaml`.
- **ClearML**: Run `clearml-init`, then set `logger: clearml` in `configs/config.yaml`.
- **Edit architecture**: Open `models/transformer.py` and modify the model.
- **Edit hyperparameters**: Open `config.yaml` and change learning rates, batch sizes, data splits, etc.
- **Edit hyperparameters**: Open `configs/config.yaml` and change learning rates, batch sizes, data splits, etc.

With ClearML enabled, Trainite keeps checkpoints in the run directory and uploads them to ClearML's default file
server. Generated projects document how to use another storage URI, defer to ClearML configuration, or keep
Expand Down Expand Up @@ -251,7 +252,7 @@ sky launch sky.yaml

## Configuration

All configuration lives in `config.yaml`. The top-level blocks map to base validation schemas in `config.py` (e.g. `ModelConfig`, `DatasetConfig`). This ensures that your configuration has the correct overall structure and valid keys, while allowing you to pass custom hyperparameters to your local components.
All configuration lives in `configs/config.yaml`. The top-level blocks map to base validation schemas in `config.py` (e.g. `ModelConfig`, `DatasetConfig`). This ensures that your configuration has the correct overall structure and valid keys, while allowing you to pass custom hyperparameters to your local components.

### Swapping Components with `_target_`

Expand Down Expand Up @@ -283,7 +284,7 @@ Since the generated code is yours, you can override at any layer without touchin
| Eval step | Override `_eval_step()` in `trainer.py` |
| Metrics | Add Ignite metrics in `_attach_metrics()` in `trainer.py` |
| Handlers | Attach Ignite event handlers to `self.trainer` in `trainer.py` |
| Config fields | Add fields to the Pydantic models in `config.py` and corresponding keys in `config.yaml` |
| Config fields | Add fields to the Pydantic models in `config.py` and corresponding keys in `configs/config.yaml` |

---

Expand All @@ -296,7 +297,7 @@ Working examples are in the [`examples/`](examples/) directory:
| [`string_reversal`](examples/string_reversal/) | Train a decoder-only transformer to reverse strings. Demonstrates the full pipeline: data generation, training, evaluation, and inference logging. |
| [`counting`](examples/counting/) | Train a decoder-only transformer to count the number of occurrences of a target token in a sequence. |

Each example is a standalone project — `cd` into it, install dependencies, and run `python main.py config.yaml`.
Each example is a standalone project — `cd` into it, install dependencies, and run `python main.py configs/config.yaml`.

---

Expand Down
22 changes: 11 additions & 11 deletions docs/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Trainite exposes a small command-line interface for scaffolding and extending standalone training projects.

For project structure and first-run setup, see [Home](index.md).
For `config.yaml` details and training behavior, see [Training Guide](training.md).
For `configs/config.yaml` details and training behavior, see [Training Guide](training.md).

## Command summary

Expand Down Expand Up @@ -45,8 +45,8 @@ You will be prompted for:
3. The primary active model (when multiple models are selected)
4. Dataset template
5. Trainer template
6. Output root (`output.root` in `config.yaml`)
7. Run name (`output.run_name` in `config.yaml`)
6. Output root (`output.root` in `configs/config.yaml`)
7. Run name (`output.run_name` in `configs/config.yaml`)
8. Whether to generate `sky.yaml` for SkyPilot

### Non-interactive mode
Expand All @@ -68,11 +68,11 @@ trainite init my-experiment \

- `PROJECT_DIR` (positional): Output directory for the generated project (default: `my-cool-experiment`).
- `--model`: One or more model templates. At least one is required.
- `--primary-model`: Active model in generated `config.yaml`. Must be one of the selected models; defaults to the first selected model.
- `--primary-model`: Active model in generated `configs/config.yaml`. Must be one of the selected models; defaults to the first selected model.
- `--dataset`: Dataset template.
- `--trainer`: Trainer template.
- `--output-root`: Value written to `output.root` in generated `config.yaml` (default: `outputs`).
- `--run-name`: Value written to `output.run_name` in generated `config.yaml` (default: `<primary_model>__<dataset>`, with `-` replaced by `_`).
- `--output-root`: Value written to `output.root` in generated `configs/config.yaml` (default: `outputs`).
- `--run-name`: Value written to `output.run_name` in generated `configs/config.yaml` (default: `<primary_model>__<dataset>`, with `-` replaced by `_`).
- `--sky`: Also generate `sky.yaml` and include SkyPilot dependency in generated `pyproject.toml`.
- `--force`: Overwrite starter files in a non-empty existing directory.

Expand All @@ -96,14 +96,14 @@ trainite init my-experiment \
When multiple models are selected:

- Trainite scaffolds each model template into `models/` (for example, `models/rope_transformer.py` and `models/basic_transformer.py`).
- The **first** model is the default primary model for generated `config.yaml`. Use `--primary-model` to choose a different selected model without changing the model list order.
- In interactive mode, use <kbd>Space</kbd> to select or deselect multiple checkboxes, and press <kbd>Enter</kbd> to confirm. Trainite then asks which selected model should be the primary active model in `config.yaml`.
- The **first** model is the default primary model for generated `configs/config.yaml`. Use `--primary-model` to choose a different selected model without changing the model list order.
- In interactive mode, use <kbd>Space</kbd> to select or deselect multiple checkboxes, and press <kbd>Enter</kbd> to confirm. Trainite then asks which selected model should be the primary active model in `configs/config.yaml`.

## `trainite add:sky`

Enable SkyPilot support in an **existing** Trainite-generated project.

Run this command from your project directory (the one containing `config.yaml` and `main.py`):
Run this command from your project directory (the one containing `configs/config.yaml` and `main.py`):

```bash
cd my-experiment
Expand All @@ -113,14 +113,14 @@ trainite add:sky
What it does:

1. Generates `sky.yaml` from Trainite's SkyPilot template.
2. Uses `project_name` from `config.yaml` (or falls back to the folder name) in the generated config.
2. Uses `project_name` from `configs/config.yaml` (or falls back to the folder name) in the generated config.
3. Adds a `skypilot` dependency to `pyproject.toml` (if it is not already present).

Option:

- `--force`: Overwrite an existing `sky.yaml`.

If `config.yaml` or `main.py` is missing, the command exits with an error and asks you to run it from a valid Trainite experiment directory.
If `configs/config.yaml` or `main.py` is missing, the command exits with an error and asks you to run it from a valid Trainite experiment directory.

### Quickstart with SkyPilot

Expand Down
14 changes: 7 additions & 7 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ to see the currently available model, dataset, and trainer choices.
See also:

- [CLI Guide](cli.md) for all commands and flags.
- [Training Guide](training.md) for `config.yaml` structure and run behavior.
- [Training Guide](training.md) for `configs/config.yaml` structure and run behavior.

## Getting Started

Expand Down Expand Up @@ -71,12 +71,12 @@ trainite init my-experiment \
```

Trainite will generate both model files under `models/`; the first model listed
is used as the default active model in `config.yaml`.
is used as the default active model in `configs/config.yaml`.

The command prints the files it created:

```text
Generated config.yaml
Generated configs/config.yaml
Generated models/rope_transformer.py
Generated dataset_impl/string_reverse.py
Generated dataset_impl/transformed.py
Expand All @@ -91,7 +91,7 @@ Generated pyproject.toml

Trainite creates `my-experiment/` with:

- `config.yaml` for model, data, training, and output settings
- `configs/config.yaml` for model, data, training, and output settings
- `main.py` as the training entry point
- local `models/`, `dataset_impl/`, and `trainer.py` implementations
- `pyproject.toml` with the generated project's runtime dependencies
Expand All @@ -106,7 +106,7 @@ Install the generated project's dependencies and start training:
```bash
cd my-experiment
uv sync
uv run python main.py config.yaml
uv run python main.py configs/config.yaml
```

#### With pip
Expand All @@ -120,13 +120,13 @@ cd my-experiment
python3 -m venv .venv
source .venv/bin/activate
pip install -e .
python main.py config.yaml
python main.py configs/config.yaml
```

The run writes logs, checkpoints, and TensorBoard data beneath
`outputs/rope_transformer__string_reverse/` in a timestamped directory.

You now have a standalone project. Change `config.yaml` to tune the experiment,
You now have a standalone project. Change `configs/config.yaml` to tune the experiment,
or edit the generated Python modules to replace the starter implementation.

## Case Studies & Resources
Expand Down
6 changes: 3 additions & 3 deletions docs/training.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,16 +133,16 @@ Split behavior by dataset family:

## Running training

Each example has a `main.py` entry point. From the example directory:
Each generated project has a `main.py` entry point. From the project directory:

```bash
uv run python main.py config.yaml
uv run python main.py configs/config.yaml
```

Or without `uv`:

```bash
python main.py config.yaml
python main.py configs/config.yaml
```

What happens under the hood:
Expand Down
8 changes: 4 additions & 4 deletions examples/counting/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ Therefore, the model must learn to recognize `L_k` up to `k = d + 2` block alter

## Project Structure

* `config.yaml`: Baseline hyperparameters for a single training run.
* `main.py`: Entrypoint for single run. Run it with `python main.py config.yaml`.
* `configs/config.yaml`: Baseline hyperparameters for a single training run.
* `main.py`: Entrypoint for single run. Run it with `python main.py configs/config.yaml`.
* `sweep.py`: Outer loop hyperparameter sweep script.
* `plot_results.py`: Unified plotting script that generates heatmaps for every unique configuration and the aggregated best configurations.
* `models/transformer.py`: Causal transformer decoder without positional encodings.
Expand All @@ -74,9 +74,9 @@ pip install -e .
```

### 2. Run a Baseline Experiment
Train a single model configuration defined in `config.yaml`:
Train a single model configuration defined in `configs/config.yaml`:
```bash
uv run python main.py config.yaml
uv run python main.py configs/config.yaml
```

### 3. Run the Multi-Config Sweep
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion examples/counting/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

def main() -> None:
parser = argparse.ArgumentParser()
parser.add_argument("config", nargs="?", default="config.yaml")
parser.add_argument("config", nargs="?", default="configs/config.yaml")
args = parser.parse_args()
config = load_config(Path(args.config), ProjectConfig)
trainer = Trainer(config)
Expand Down
2 changes: 1 addition & 1 deletion examples/counting/sweep.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def main() -> None:
)

# Load base config from local yaml
config = load_config(Path("config.yaml"), ProjectConfig)
config = load_config(Path("configs/config.yaml"), ProjectConfig)

# Dynamic overrides
config.data.dataset.k = k
Expand Down
6 changes: 3 additions & 3 deletions examples/string_reversal/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ The decoder receives a prompt followed by the expected completion:
<BOS> abc123 <SEP> 321cba <EOS>
```

Only completion tokens contribute to the training loss. The dataset is automatically split into training, validation, and test sets using the ratios in `config.yaml`.
Only completion tokens contribute to the training loss. The dataset is automatically split into training, validation, and test sets using the ratios in `configs/config.yaml`.

Important data settings:

Expand Down Expand Up @@ -100,7 +100,7 @@ From this directory:

```bash
uv sync
uv run python main.py config.yaml
uv run python main.py configs/config.yaml
```

Training outputs are written below `outputs/<run_name>/<timestamp>/`. Each run contains its resolved configuration, console log, TensorBoard data, and model checkpoints.
Expand Down Expand Up @@ -142,7 +142,7 @@ Replace `depth` with `width` or `full` as needed. Without `--time-budget`, a run

## Files

- `config.yaml` — experiment configuration.
- `configs/config.yaml` — experiment configuration.
- `main.py` — single-run entry point.
- `sweep.py` — depth and width sweeps.
- `trainer.py` — training, metrics, generation, and checkpoints.
Expand Down
2 changes: 1 addition & 1 deletion examples/string_reversal/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

def main() -> None:
parser = argparse.ArgumentParser()
parser.add_argument("config", nargs="?", default="config.yaml")
parser.add_argument("config", nargs="?", default="configs/config.yaml")
args = parser.parse_args()
config = load_config(Path(args.config), ProjectConfig)
trainer = Trainer(config)
Expand Down
6 changes: 5 additions & 1 deletion examples/string_reversal/sweep.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,11 @@ def parse_args():
choices=["depth", "width", "full"],
help="which axis to sweep: depth (vary layers), width (vary hidden/heads), or full (cross-product)",
)
p.add_argument("--config", default="config.yaml", help="path to config.yaml (default: config.yaml)")
p.add_argument(
"--config",
default="configs/config.yaml",
help="path to configs/config.yaml (default: configs/config.yaml)",
)
p.add_argument(
"--logger",
default="tensorboard",
Expand Down
5 changes: 3 additions & 2 deletions tests/cli_sky_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ def mock_trainite_project(tmp_path: Path) -> Path:
root: outputs
run_name: test_run
"""
(project_dir / "config.yaml").write_text(config_yaml)
(project_dir / "configs").mkdir()
(project_dir / "configs/config.yaml").write_text(config_yaml)
(project_dir / "main.py").write_text("# main entrypoint\n")

pyproject_toml = """[project]
Expand Down Expand Up @@ -49,7 +50,7 @@ def test_sky_init_in_valid_project(mock_trainite_project: Path, monkeypatch: pyt
assert data["resources"]["use_spot"] is False
assert data["resources"]["disk_size"] == 50
assert "uv sync" in data["setup"]
assert "uv run python main.py config.yaml" in data["run"]
assert "uv run python main.py configs/config.yaml" in data["run"]

# Check pyproject.toml updated
pyproject_doc = tomlkit.parse((mock_trainite_project / "pyproject.toml").read_text())
Expand Down
Loading