Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow the dataset configuration to be overridden in experiment. #138

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
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: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

- Added ability to override `dataset` and `data_loader` configurations in internal experiment builder.

### Added

- Added support for tensor parallelism. See the `TransformerConfig` class for usage.
Expand Down
22 changes: 20 additions & 2 deletions src/olmo_core/internal/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,8 @@ def build_config(
model_config_builder: Callable[[CommonComponents], TransformerConfig],
optim_config_builder: Callable[[CommonComponents], OptimConfig],
trainer_config_builder: Callable[[CommonComponents], TrainerConfig],
dataset_config_builder: Callable[[CommonComponents], NumpyDatasetConfig] | None = None,
data_loader_config_builder: Callable[[CommonComponents], NumpyDataLoaderConfig] | None = None,
finalize_config: Optional[Callable[[ExperimentConfig], None]] = None,
) -> ExperimentConfig:
common = build_common_components(
Expand All @@ -218,13 +220,25 @@ def build_config(
if name not in trainer.callbacks:
trainer.add_callback(name, cb)

# allow the dataset to be overridden
dataset = (
dataset_config_builder(common) if dataset_config_builder is not None else common.dataset
)

# allow the data loader to be overridden
data_loader = (
data_loader_config_builder(common)
if data_loader_config_builder is not None
else common.data_loader
)

config = ExperimentConfig(
run_name=run_name,
launch=common.launch,
model=model,
optim=optim_config_builder(common),
dataset=common.dataset,
data_loader=common.data_loader,
dataset=dataset,
data_loader=data_loader,
trainer=trainer,
)

Expand Down Expand Up @@ -296,6 +310,8 @@ def main(
model_config_builder: Callable[[CommonComponents], TransformerConfig],
optim_config_builder: Callable[[CommonComponents], OptimConfig],
trainer_config_builder: Callable[[CommonComponents], TrainerConfig],
dataset_config_builder: Callable[[CommonComponents], NumpyDatasetConfig] | None = None,
data_loader_config_builder: Callable[[CommonComponents], NumpyDataLoaderConfig] | None = None,
finalize_config: Optional[Callable[[ExperimentConfig], None]] = None,
):
usage = f"""
Expand Down Expand Up @@ -334,6 +350,8 @@ def main(
model_config_builder=model_config_builder,
optim_config_builder=optim_config_builder,
trainer_config_builder=trainer_config_builder,
dataset_config_builder=dataset_config_builder,
data_loader_config_builder=data_loader_config_builder,
finalize_config=finalize_config,
)

Expand Down
Loading