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

benchmark docs #109

Merged
merged 2 commits into from
Dec 29, 2023
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
26 changes: 26 additions & 0 deletions docs/BENCHMARK.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# ORTOA-TEE Benchmarking

```txt
usage: main.py [-h] [-e EXPERIMENTS [EXPERIMENTS ...]] [-d EXPERIMENT_DIRS [EXPERIMENT_DIRS ...]] [-w WORKING_DIR]

optional arguments:
-h, --help show this help message and exit
-w WORKING_DIR, --working-dir WORKING_DIR
Directory to use as base for experiment directory tree (default: out/benchmark-2023-12-29-11-38-05)

Experiments:
Options to control experiments selected for compilation

-e EXPERIMENTS [EXPERIMENTS ...], --experiments EXPERIMENTS [EXPERIMENTS ...]
List of experiments to compile (experiment name should match zoo object)
-d EXPERIMENT_DIRS [EXPERIMENT_DIRS ...], --experiment-dirs EXPERIMENT_DIRS [EXPERIMENT_DIRS ...]
List of local directories to use for experiment files
```

## Entrypoint

The main entry point is `extras/ortoa/benchmark/infrastructure/main.py`

## Jobs

The `ClientJob` class defined in `extras/ortoa/benchmark/infrastructure/jobs.py` implements the `JobProtocol` class. Most importantly, is specifies how a job is run.
10 changes: 5 additions & 5 deletions extras/ortoa/benchmark/infrastucture/experiment_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ def model_post_init(self, __context: Any) -> None:
assert self.experiment_path.is_file()
return super().model_post_init(__context)


@classmethod
def construct_experiments(cls, experiment: Path) -> List[Self]:
"""
Expand All @@ -38,9 +37,7 @@ def from_path(cls, experiment: Path) -> List[Self]:

@classmethod
def from_dir(cls, experiment_dir: Path) -> List[Self]:
return [
cls(experiment_path=e) for e in experiment_dir.glob("**/*.yaml")
]
return [cls(experiment_path=e) for e in experiment_dir.glob("**/*.yaml")]


def collect_experiments(experiments: Iterable[Path]) -> List[ExperimentPath]:
Expand All @@ -49,6 +46,9 @@ def collect_experiments(experiments: Iterable[Path]) -> List[ExperimentPath]:
"""
return list(
itertools.chain.from_iterable(
[ExperimentPath.construct_experiments(experiment) for experiment in experiments]
[
ExperimentPath.construct_experiments(experiment)
for experiment in experiments
]
)
)
16 changes: 1 addition & 15 deletions extras/ortoa/benchmark/infrastucture/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,6 @@ def parse_args() -> argparse.Namespace:
required=False,
help="Directory to use as base for experiment directory tree (default: %(default)s)",
)
parser.add_argument(
"-m",
"--max-processes",
type=int,
default=None,
required=False,
help="Maximum number of processes to use when running experiments (default: %(default)s)",
)

args = parser.parse_args()

Expand All @@ -73,8 +65,6 @@ def parse_args() -> argparse.Namespace:
def benchmark(
experiment_base: Path,
experiment_names: List[Path],
max_processes: Optional[int] = None,
log_errors_in_main_thread: bool = False,
) -> Stats:
"""Main entrypoint to the benchmarking flow

Expand Down Expand Up @@ -110,8 +100,6 @@ def benchmark(
# Orchestrate and the jobs
orchestration = JobOrchestration(
jobs=jobs,
max_processes=max_processes,
log_errors_in_main_thread=log_errors_in_main_thread,
)
results = orchestration.run_sequential()

Expand All @@ -123,9 +111,7 @@ def main():
args = parse_args()
args.working_dir.mkdir(parents=True, exist_ok=True)

stats: Stats = benchmark(
args.working_dir, args.experiments + args.experiment_dirs, args.max_processes
)
stats: Stats = benchmark(args.working_dir, args.experiments + args.experiment_dirs)

stats.save_to(args.working_dir)

Expand Down
2 changes: 0 additions & 2 deletions extras/ortoa/benchmark/infrastucture/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ class Config:
arbitrary_types_allowed = True

jobs: Sequence[JobT]
max_processes: Optional[int]
log_errors_in_main_thread: bool = False

def model_post_init(self, __context: Any) -> None:
if len(self.jobs) == 0:
Expand Down
20 changes: 15 additions & 5 deletions extras/ortoa/benchmark/interface/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,21 @@ def generate_data(self) -> None:
output_file,
)

if self.client_config.data.seed and not self.client_config.data.seed.exists():
raise FileNotFoundError(f"Seed file {self.client_config.data.seed} was not found.")
if (
self.client_config.data.seed
and not self.client_config.data.seed.exists()
):
raise FileNotFoundError(
f"Seed file {self.client_config.data.seed} was not found."
)

if self.client_config.data.operations and not self.client_config.data.operations.exists():
raise FileNotFoundError(f"Operations file {self.client_config.data.operations} was not found.")
if (
self.client_config.data.operations
and not self.client_config.data.operations.exists()
):
raise FileNotFoundError(
f"Operations file {self.client_config.data.operations} was not found."
)


def load_experiments(
Expand Down Expand Up @@ -133,7 +143,7 @@ def atomicize_experiments(experiments: List[Experiment]) -> List[AtomicExperimen
assert isinstance(experiment.client_config.data, SeedData)
assert experiment.client_config.data.seed is not None
assert experiment.client_config.data.operations is not None

all_client_flags = [
flag.get_atomic_flags() for flag in experiment.client_config.flags
]
Expand Down
2 changes: 2 additions & 0 deletions extras/ortoa/benchmark/interface/parameter.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
# Abstractions
##########################


class IntType(BaseModel):
type: Literal["int"] = Field(default="int", frozen=True)

Expand All @@ -32,6 +33,7 @@ class RangeParameter(Parameter, Generic[NumberT]):
# Parameter Types
##########################


class IntegerIncrementRange(RangeParameter[int], IntType):
step: int

Expand Down