-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into am/upd-jobs
- Loading branch information
Showing
23 changed files
with
349 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
src/cloudai/schema/test_template/slurm_container/report_generation_strategy.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES | ||
# Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import re | ||
from pathlib import Path | ||
from typing import Optional | ||
|
||
from cloudai import ReportGenerationStrategy | ||
|
||
|
||
class SlurmContainerReportGenerationStrategy(ReportGenerationStrategy): | ||
"""Report generation strategy for a generic Slurm container test.""" | ||
|
||
def can_handle_directory(self, directory_path: Path) -> bool: | ||
stdout_path = directory_path / "stdout.txt" | ||
if stdout_path.exists(): | ||
with stdout_path.open("r") as file: | ||
if re.search( | ||
r"Training epoch \d+, iteration \d+/\d+ | lr: [\d.]+ | global_batch_size: \d+ | global_step: \d+ | " | ||
r"reduced_train_loss: [\d.]+ | train_step_timing in s: [\d.]+", | ||
file.read(), | ||
): | ||
return True | ||
return False | ||
|
||
def generate_report(self, test_name: str, directory_path: Path, sol: Optional[float] = None) -> None: | ||
stdout_path = directory_path / "stdout.txt" | ||
if not stdout_path.is_file(): | ||
return | ||
|
||
with stdout_path.open("r") as file: | ||
lines = file.readlines() | ||
with open(directory_path / "report.csv", "w") as csv_file: | ||
csv_file.write( | ||
"epoch,iteration,lr,global_batch_size,global_step,reduced_train_loss,train_step_timing,consumed_samples\n" | ||
) | ||
for line in lines: | ||
pattern = ( | ||
r"Training epoch (\d+), iteration (\d+)/\d+ \| lr: ([\d.]+) \| global_batch_size: (\d+) \| " | ||
r"global_step: (\d+) \| reduced_train_loss: ([\d.]+) \| train_step_timing in s: ([\d.]+)" | ||
) | ||
if " | consumed_samples:" in line: | ||
pattern = ( | ||
r"Training epoch (\d+), iteration (\d+)/\d+ \| lr: ([\d.]+) \| global_batch_size: (\d+) \| " | ||
r"global_step: (\d+) \| reduced_train_loss: ([\d.]+) \| train_step_timing in s: ([\d.]+) " | ||
r"\| consumed_samples: (\d+)" | ||
) | ||
|
||
match = re.match(pattern, line) | ||
if match: | ||
csv_file.write(",".join(match.groups()) + "\n") |
40 changes: 40 additions & 0 deletions
40
src/cloudai/schema/test_template/slurm_container/slurm_command_gen_strategy.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES | ||
# Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
from typing import Any, cast | ||
|
||
from cloudai import TestRun | ||
from cloudai.systems.slurm.strategy import SlurmCommandGenStrategy | ||
from cloudai.test_definitions.slurm_container import SlurmContainerTestDefinition | ||
|
||
|
||
class SlurmContainerCommandGenStrategy(SlurmCommandGenStrategy): | ||
"""Command generation strategy for generic Slurm container tests.""" | ||
|
||
def gen_srun_prefix(self, slurm_args: dict[str, Any], tr: TestRun) -> list[str]: | ||
tdef: SlurmContainerTestDefinition = cast(SlurmContainerTestDefinition, tr.test.test_definition) | ||
slurm_args["image_path"] = tdef.docker_image.installed_path | ||
slurm_args["container_mounts"] = ",".join(tdef.container_mounts(self.system.install_path)) | ||
|
||
cmd = super().gen_srun_prefix(slurm_args, tr) | ||
return cmd + ["--no-container-mount-home"] | ||
|
||
def generate_test_command(self, env_vars: dict[str, str], cmd_args: dict[str, str], tr: TestRun) -> list[str]: | ||
srun_command_parts: list[str] = [] | ||
if tr.test.extra_cmd_args: | ||
srun_command_parts.append(tr.test.extra_cmd_args) | ||
|
||
return srun_command_parts |
23 changes: 23 additions & 0 deletions
23
src/cloudai/schema/test_template/slurm_container/template.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES | ||
# Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
from cloudai import TestTemplate | ||
|
||
|
||
class SlurmContainer(TestTemplate): | ||
"""Generic Slurm container test template.""" | ||
|
||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.