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

Fix aiaccel/hpo/apps/optimize.py . #414

Merged
merged 17 commits into from
Feb 3, 2025
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
9 changes: 2 additions & 7 deletions aiaccel/hpo/apps/optimize.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,8 @@ def main() -> None:

result_filename_template = "{job.cwd}/{job.job_name}_result.pkl"

finished_job_count = 0

while finished_job_count < config.n_trials:
n_running_jobs = len(jobs.get_running_jobs())
n_max_jobs = min(jobs.available_slots(), config.n_trials - finished_job_count - n_running_jobs)
while jobs.finished_job_count < config.n_trials:
n_max_jobs = min(jobs.available_slots(), config.n_trials - jobs.submitted_job_count)
for _ in range(n_max_jobs):
trial = study.ask()

Expand All @@ -172,8 +169,6 @@ def main() -> None:

study.tell(trial, y)

finished_job_count += 1


if __name__ == "__main__":
main()
2 changes: 1 addition & 1 deletion aiaccel/hpo/job_executors/abci_job_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def __init__(
self.job_group = job_group
self.job_list: list[AbciJob] = []

def submit(
def submit_impl(
self,
args: list[str],
tag: Any = None,
Expand Down
15 changes: 14 additions & 1 deletion aiaccel/hpo/job_executors/base_job_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,11 @@ def __init__(

self.job_list: list[Any] = []

self.submitted_job_count = 0
self.finished_job_count = 0

@abstractmethod
def submit(
def submit_impl(
self,
args: list[str],
tag: Any = None,
Expand All @@ -61,6 +64,15 @@ def submit(
"""
pass

def submit(
self,
args: list[str],
tag: Any = None,
sleep_time: float = 5.0,
) -> Any:
self.submitted_job_count += 1
return self.submit_impl(args, tag, sleep_time)

def update_status_batch(self) -> None:
"""
Updates the status of a batch of jobs.
Expand All @@ -87,6 +99,7 @@ def collect_finished(self) -> list[Any]:
finished_jobs = [job for job in self.job_list if job.status >= JobStatus.FINISHED]
for job in finished_jobs:
self.job_list.remove(job)
self.finished_job_count += 1

return finished_jobs

Expand Down
2 changes: 1 addition & 1 deletion aiaccel/hpo/job_executors/local_job_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def __init__(

self.job_list: list[LocalJob] = []

def submit(
def submit_impl(
self,
args: list[str],
tag: Any = None,
Expand Down
Loading