Skip to content
Merged
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
96 changes: 96 additions & 0 deletions README_HYDRA.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# Hydra Configuration System - Quick Start

## 🚀 Installation

```bash
# Install pip and create virtual environment
sudo apt install python3-pip python3.12-venv -y
python3 -m venv venv
source venv/bin/activate

# Install minimal requirements for Hydra
pip install -r requirements-minimal.txt
```

## 📋 Usage Examples

### Basic Configuration
```bash
# Use default configuration
python test_config.py

# Override parameters
python test_config.py experiments.training.lr=0.001 experiments.model.hidden_dims=[128,64]
```

### Pre-configured Experiments
```bash
# Debug experiment (small model, 10 epochs)
python test_config.py --config-name experiments/debug

# Baseline experiment (standard settings)
python test_config.py --config-name experiments/baseline
```

### Command-line Overrides
```bash
# Learning rate override
python test_config.py experiments.training.lr=0.001

# Model architecture override
python test_config.py experiments.model.hidden_dims=[32]

# Multiple overrides
python test_config.py experiments.training.lr=0.001 experiments.model.hidden_dims=[128,64] experiments.training.epochs=300
```

## 📁 Configuration Structure

```
configs/
├── config.yaml # Main configuration
├── model/gcn.yaml # GCN model configs
├── training/default.yaml # Training configs
├── data/cora.yaml # Dataset configs
└── experiments/
├── debug.yaml # Debug experiment
├── baseline.yaml # Baseline experiment
└── hyperparameter_search.yaml # Parameter sweep
```

## 🎯 Key Features

- **Easy Parameter Override**: `experiments.training.lr=0.001`
- **Pre-configured Experiments**: Debug, baseline, hyperparameter search
- **Automatic Output Organization**: Results saved to timestamped directories
- **Configuration Tracking**: Full config saved with results

## 📊 Test Results

The system successfully demonstrates:
- ✅ Configuration loading and merging
- ✅ Command-line parameter overrides
- ✅ Pre-configured experiment selection
- ✅ Automatic output organization
- ✅ Configuration tracking and logging

## 🔄 Next Steps

1. Install full PyTorch dependencies when needed:
```bash
pip install -r requirements.txt # May take time due to large downloads
```

2. Use the full training script:
```bash
python train.py experiments.training.lr=0.001
```

3. Run hyperparameter sweeps:
```bash
python train.py --multirun experiments.training.lr=0.001,0.01,0.1
```

---

**The Hydra configuration system is ready for easy experiment management!** 🚀
22 changes: 22 additions & 0 deletions configs/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Default configuration for AstroML training experiments
defaults:
- model: gcn
- training: default
- data: cora
- _self_

# Experiment settings
experiment:
name: "astroml_experiment"
seed: 42
device: "auto" # auto, cpu, cuda
save_dir: "outputs"
log_level: "INFO"

# Hydra settings
hydra:
run:
dir: outputs/${experiment.name}/${now:%Y-%m-%d_%H-%M-%S}
sweep:
dir: outputs/${experiment.name}/multirun
subdir: ${hydra.job.override_dirname}
23 changes: 23 additions & 0 deletions configs/data/cora.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Cora dataset configuration
_target_: torch_geometric.datasets.Planetoid

name: "Cora"
root: "data"
transform:
_target_: torch_geometric.transforms.NormalizeFeatures

# Dataset-specific settings
num_classes: 7
num_node_features: 1433

# Alternative datasets
variants:
citeseer:
name: "CiteSeer"
num_classes: 6
num_node_features: 3703

pubmed:
name: "PubMed"
num_classes: 3
num_node_features: 5003
26 changes: 26 additions & 0 deletions configs/experiments/baseline.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Baseline experiment configuration
defaults:
- /model: gcn
- /training: default
- /data: cora
- _self_

# Baseline settings
experiment:
name: "baseline_experiment"
seed: 42

# Model settings
model:
hidden_dims: [64, 32]
dropout: 0.5

# Training settings
training:
epochs: 200
lr: 0.01
weight_decay: 5e-4

# Data settings
data:
name: "Cora"
29 changes: 29 additions & 0 deletions configs/experiments/debug.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Debug experiment configuration
defaults:
- /model: gcn
- /training: default
- /data: cora
- _self_

# Debug settings
experiment:
name: "debug_experiment"
seed: 42
device: "auto"
save_dir: "outputs"
log_level: "INFO"

# Model overrides
model:
hidden_dims: [16] # Small model for fast debugging
dropout: 0.1

# Training overrides
training:
epochs: 10 # Short training for debugging
lr: 0.01
log_interval: 1

# Data overrides
data:
name: "Cora"
37 changes: 37 additions & 0 deletions configs/experiments/hyperparameter_search.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Hyperparameter search experiment configuration
defaults:
- /model: gcn
- /training: default
- /data: cora
- _self_

# Hyperparameter search settings
experiment:
name: "hyperparameter_search"
seed: 42

# Model parameter grid
model:
hidden_dims:
- [32]
- [64, 32]
- [128, 64]
dropout:
- 0.2
- 0.5
- 0.7

# Training parameter grid
training:
lr:
- 0.001
- 0.01
- 0.1
weight_decay:
- 1e-5
- 5e-4
- 1e-3

# Data settings
data:
name: "Cora"
28 changes: 28 additions & 0 deletions configs/model/gcn.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Graph Convolutional Network model configuration
_target_: astroml.models.gcn.GCN

input_dim: ???
hidden_dims: [64, 32]
output_dim: ???
dropout: 0.5
activation: "relu"
batch_norm: false
residual: false

# Alternative model configurations
variants:
small:
hidden_dims: [32]
dropout: 0.2

medium:
hidden_dims: [64, 32]
dropout: 0.5

large:
hidden_dims: [128, 64, 32]
dropout: 0.6

very_large:
hidden_dims: [256, 128, 64]
dropout: 0.7
38 changes: 38 additions & 0 deletions configs/training/default.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Training configuration
epochs: 200
lr: 0.01
weight_decay: 5e-4
optimizer: "adam"
scheduler: null
early_stopping:
patience: 50
min_delta: 1e-4
monitor: "val_loss"
mode: "min"

# Training settings
batch_size: null # Full batch for graph data
val_split: 0.1
test_split: 0.1
shuffle: true

# Logging
log_interval: 20
save_best_only: true
save_last: true

# Optimizer configurations
optimizer_configs:
adam:
betas: [0.9, 0.999]
eps: 1e-8
amsgrad: false

sgd:
momentum: 0.9
nesterov: true

adamw:
betas: [0.9, 0.999]
eps: 1e-8
weight_decay: 1e-2
4 changes: 4 additions & 0 deletions docs/_build/.buildinfo
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Sphinx build info version 1
# This file records the configuration used when building these files. When it is not found, a full rebuild will be done.
config: c77cbac2cb1078e76006b15750c98cfd
tags: 645f666f9bcd5a90fca523b33c5a78b7
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added docs/_build/.doctrees/docker-deployment.doctree
Binary file not shown.
Binary file added docs/_build/.doctrees/environment.pickle
Binary file not shown.
Binary file added docs/_build/.doctrees/experiment-configs.doctree
Binary file not shown.
Binary file added docs/_build/.doctrees/index.doctree
Binary file not shown.
Binary file added docs/_build/.doctrees/schema.doctree
Binary file not shown.
Loading
Loading