Experiment¶
The Experiment class is the main entry point for defining and running experiments in metalab. It orchestrates the execution of operations across parameter spaces with reproducible seeding.
metalab.Experiment
dataclass
¶
Experiment(name: str, version: str, context: ContextSpec, operation: OperationWrapper, params: ParamSource, seeds: SeedPlan, description: str | None = None, tags: list[str] = list(), param_resolver: ParamResolver | None = None, metadata: dict[str, Any] = dict())
Container for experiment configuration.
An Experiment defines what to run and how:
- name/version: Identifies the experiment
- description: Optional human-readable description
- operation: The computation to perform
- context: Shared configuration (lightweight spec)
- params: Parameter sweep definition
- seeds: Seed plan for replication
- metadata: Experiment-level metadata (not fingerprinted)
The metadata field is for arbitrary experiment-level information that should be persisted but does NOT affect reproducibility or run identity. Examples:
- Resource hints: {"gpu": True, "memory_gb": 16}
- Documentation: {"author": "name", "notes": "..."}
- Data summaries: {"n_samples": 1000, "groups": ["A", "B"]}
Example:
exp = Experiment(
name="pi_mc",
version="0.1",
description="Estimate pi using Monte Carlo sampling",
context={}, # or a @context_spec decorated class
operation=pi_monte_carlo,
params=grid(n_samples=[1000, 10000]),
seeds=seeds(base=42, replicates=3),
tags=["example", "monte_carlo"],
metadata={"author": "you", "resource_hints": {"gpu": False}},
)