-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for Slurm heterogeneous jobs (#346)
This PR adds basic support for hetereogeneous jobs on Slurm. Users can set the `--het-group` flag through the `SrunSettings::set_het_group` method. Some checks are added to make sure users don't run MPMD workloads within heterogeneous jobs, as this is not allowed by Slurm. In particular, orchestrators cannot be run with `single_cmd=True` in a heterogeneous job. [ committed by @al-rigazzi ] [ reviewed by @MattToast @ashao ]
- Loading branch information
1 parent
d7a6b60
commit 1d4d7a9
Showing
4 changed files
with
155 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
# BSD 2-Clause License | ||
# | ||
# Copyright (c) 2021-2023, Hewlett Packard Enterprise | ||
# All rights reserved. | ||
# | ||
# Redistribution and use in source and binary forms, with or without | ||
# modification, are permitted provided that the following conditions are met: | ||
# | ||
# 1. Redistributions of source code must retain the above copyright notice, this | ||
# list of conditions and the following disclaimer. | ||
# | ||
# 2. Redistributions in binary form must reproduce the above copyright notice, | ||
# this list of conditions and the following disclaimer in the documentation | ||
# and/or other materials provided with the distribution. | ||
# | ||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
|
||
import pytest | ||
|
||
from smartsim import Experiment | ||
from smartsim.settings import SrunSettings | ||
|
||
|
||
# retrieved from pytest fixtures | ||
if pytest.test_launcher != "slurm": | ||
pytestmark = pytest.mark.skip(reason="Test is only for Slurm WLM systems") | ||
|
||
def test_mpmd_errors(monkeypatch): | ||
monkeypatch.setenv("SLURM_HET_SIZE", "1") | ||
exp_name = "test-het-job-errors" | ||
exp = Experiment(exp_name, launcher="slurm") | ||
rs: SrunSettings = exp.create_run_settings("sleep", "1", run_command="srun") | ||
rs2: SrunSettings = exp.create_run_settings("sleep", "1", run_command="srun") | ||
with pytest.raises(ValueError): | ||
rs.make_mpmd(rs2) | ||
|
||
monkeypatch.delenv("SLURM_HET_SIZE") | ||
rs.make_mpmd(rs2) | ||
with pytest.raises(ValueError): | ||
rs.set_het_group(1) | ||
|
||
|
||
def test_set_het_groups(monkeypatch): | ||
"""Test ability to set one or more het groups to run setting | ||
""" | ||
monkeypatch.setenv("SLURM_HET_SIZE", "4") | ||
exp_name = "test-set-het-group" | ||
exp = Experiment(exp_name, launcher="slurm") | ||
rs: SrunSettings = exp.create_run_settings("sleep", "1", run_command="srun") | ||
rs.set_het_group([1]) | ||
assert rs.run_args["het-group"] == "1" | ||
rs.set_het_group([3,2]) | ||
assert rs.run_args["het-group"] == "3,2" | ||
with pytest.raises(ValueError): | ||
rs.set_het_group([4]) | ||
|
||
|
||
def test_orch_single_cmd(monkeypatch, wlmutils): | ||
"""Test that single cmd is rejected in a heterogeneous job""" | ||
monkeypatch.setenv("SLURM_HET_SIZE", "1") | ||
exp_name = "test-orch-single-cmd" | ||
exp = Experiment(exp_name, launcher="slurm") | ||
orc = exp.create_database( | ||
wlmutils.get_test_port(), | ||
db_nodes=3, | ||
batch=False, | ||
interface=wlmutils.get_test_interface(), | ||
single_cmd=True, | ||
hosts=wlmutils.get_test_hostlist(), | ||
) | ||
|
||
for node in orc: | ||
assert node.is_mpmd == False |