Skip to main content

ExperimentConfig

Dataclass containing all experiment parameters for edge AI hardware optimization. Includes training settings, hardware constraints, and optimization configurations.

Fields

seed
int
required
Random seed for reproducibility across all random number generators.
dataset
str
required
Dataset name. Supported values: "mnist", "fashion-mnist".
batch_size
int
required
Batch size for training and validation data loaders.
epochs
int
required
Number of training epochs.
learning_rate
float
required
Learning rate for the optimizer.
train_subset
int | None
required
Maximum number of training samples to use. None uses the full training set.
val_subset
int | None
required
Maximum number of validation samples to use. None uses the full validation set.
power_watts
float
required
Power budget constraint in watts for edge device simulation.
pruning_levels
list[float]
required
List of pruning ratios to evaluate (e.g., [0.0, 0.3, 0.5] for 0%, 30%, 50% pruning).
precisions
list[str]
required
List of numeric precisions to evaluate (e.g., ["fp32", "fp16", "int8"]).
calibration_batches
int
required
Number of batches to use for quantization calibration.
output_dir
str
required
Directory path for saving experiment results and artifacts.
memory_budgets_mb
list[float]
required
List of memory budget constraints in megabytes to evaluate.
active_memory_budget_mb
float
required
Active memory budget in megabytes for runtime constraints.
cpu_frequency_scale
float
required
CPU frequency scaling factor (e.g., 0.8 for 80% of max frequency).
dataloader_seed
int
required
Seed for data loader shuffling. Defaults to seed if not specified in config file.
num_workers
int
required
Number of worker processes for data loading. Defaults to 2 if not specified.
benchmark_repeats
int
required
Number of times to repeat benchmarks for averaging. Defaults to 5 if not specified.
memory_bandwidth_gbps
float
required
Memory bandwidth in GB/s for hardware simulation. Defaults to 12.8 if not specified.

load_config

Loads and parses experiment configuration from a text file format.
def load_config(path: str | Path) -> ExperimentConfig
path
str | Path
required
Path to the configuration file. Accepts string paths or pathlib.Path objects.
config
ExperimentConfig
Parsed configuration object with all experiment parameters.

Configuration File Format

The configuration file uses a simple key: value format:
  • Lines starting with # are comments
  • Empty lines are ignored
  • Each line contains a key-value pair separated by :
  • Lists use bracket notation: [item1, item2, item3]
  • Supports automatic type inference for strings, integers, floats, booleans, null values, and lists

Supported Value Types

  • Integers: 42, 100
  • Floats: 0.001, 3.14
  • Strings: mnist, "output/results"
  • Booleans: true, false
  • Null: null, none
  • Lists: [0.0, 0.3, 0.5], [fp32, fp16, int8]
Some fields have default values if not specified: dataloader_seed defaults to seed, num_workers defaults to 2, benchmark_repeats defaults to 5, and memory_bandwidth_gbps defaults to 12.8.

Usage Example

from edge_opt.config import load_config
from pathlib import Path

# Load from string path
config = load_config("experiments/baseline.conf")

# Or use pathlib
config_path = Path("experiments/baseline.conf")
config = load_config(config_path)

# Access fields
print(f"Dataset: {config.dataset}")
print(f"Batch size: {config.batch_size}")
print(f"Pruning levels: {config.pruning_levels}")

Error Handling

The function will raise exceptions for:
  • FileNotFoundError: Config file doesn’t exist
  • KeyError: Required field missing from config file
  • ValueError: Invalid value format or type conversion failure

See Also

  • Model - Use config.seed with set_deterministic()
  • Data - Pass config fields to build_loaders()

Build docs developers (and LLMs) love