-
Notifications
You must be signed in to change notification settings - Fork 198
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move MPI behavior from HTEX to MPIExecutor (#3582)
This PR moves the following MPI related functionality and options from HTEX to MPIExecutor: Kwarg options enable_mpi_mode and mpi_launcher is now removed from HTEX Checks for launcher being set to SimpleLauncher Checks for a valid mpi_launcher in now in MPIExecutor A new validate_resource_specification method is added to HTEX that currently asserts that no resource_specification is passed to it, since HTEX does not support any such options MPIExecutor overrides validate_resource_specification to check for a valid MPI resource specification These changes should make it easier to have executor specific resource validation. Changed Behaviour HTEX kwarg enable_mpi_mode and mpi_launcher are no longer supported. Expect to use MPI functionality only through the MPIExecutor
- Loading branch information
Showing
10 changed files
with
171 additions
and
145 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,40 @@ | ||
import queue | ||
from unittest import mock | ||
|
||
import pytest | ||
|
||
from parsl.executors import HighThroughputExecutor | ||
from parsl.executors.high_throughput.mpi_prefix_composer import ( | ||
InvalidResourceSpecification, | ||
) | ||
|
||
|
||
def double(x): | ||
return x * 2 | ||
|
||
|
||
@pytest.mark.local | ||
def test_submit_calls_validate(): | ||
|
||
htex = HighThroughputExecutor() | ||
htex.outgoing_q = mock.Mock(spec=queue.Queue) | ||
htex.validate_resource_spec = mock.Mock(spec=htex.validate_resource_spec) | ||
|
||
res_spec = {} | ||
htex.submit(double, res_spec, (5,), {}) | ||
htex.validate_resource_spec.assert_called() | ||
|
||
|
||
@pytest.mark.local | ||
def test_resource_spec_validation(): | ||
htex = HighThroughputExecutor() | ||
ret_val = htex.validate_resource_spec({}) | ||
assert ret_val is None | ||
|
||
|
||
@pytest.mark.local | ||
def test_resource_spec_validation_bad_keys(): | ||
htex = HighThroughputExecutor() | ||
|
||
with pytest.raises(InvalidResourceSpecification): | ||
htex.validate_resource_spec({"num_nodes": 2}) |
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 |
---|---|---|
@@ -1,33 +1,48 @@ | ||
import pytest | ||
|
||
from parsl import Config | ||
from parsl.executors import HighThroughputExecutor | ||
from parsl.executors import MPIExecutor | ||
from parsl.launchers import AprunLauncher, SimpleLauncher, SrunLauncher | ||
from parsl.providers import SlurmProvider | ||
|
||
|
||
@pytest.mark.local | ||
def test_bad_launcher_with_mpi_mode(): | ||
"""AssertionError if a launcher other than SimpleLauncher is supplied""" | ||
def test_bad_launcher(): | ||
"""TypeError if a launcher other than SimpleLauncher is supplied""" | ||
|
||
for launcher in [SrunLauncher(), AprunLauncher()]: | ||
with pytest.raises(AssertionError): | ||
with pytest.raises(TypeError): | ||
Config(executors=[ | ||
HighThroughputExecutor( | ||
enable_mpi_mode=True, | ||
MPIExecutor( | ||
provider=SlurmProvider(launcher=launcher), | ||
) | ||
]) | ||
|
||
|
||
@pytest.mark.local | ||
def test_correct_launcher_with_mpi_mode(): | ||
def test_bad_mpi_launcher(): | ||
"""ValueError if an unsupported mpi_launcher is specified""" | ||
|
||
with pytest.raises(ValueError): | ||
Config(executors=[ | ||
MPIExecutor( | ||
mpi_launcher="bad_launcher", | ||
provider=SlurmProvider(launcher=SimpleLauncher()), | ||
) | ||
]) | ||
|
||
|
||
@pytest.mark.local | ||
@pytest.mark.parametrize( | ||
"mpi_launcher", | ||
["srun", "aprun", "mpiexec"] | ||
) | ||
def test_correct_launcher_with_mpi_mode(mpi_launcher: str): | ||
"""Confirm that SimpleLauncher works with mpi_mode""" | ||
|
||
config = Config(executors=[ | ||
HighThroughputExecutor( | ||
enable_mpi_mode=True, | ||
provider=SlurmProvider(launcher=SimpleLauncher()), | ||
) | ||
]) | ||
assert isinstance(config.executors[0].provider.launcher, SimpleLauncher) | ||
executor = MPIExecutor( | ||
mpi_launcher=mpi_launcher, | ||
provider=SlurmProvider(launcher=SimpleLauncher()), | ||
) | ||
|
||
assert isinstance(executor.provider.launcher, SimpleLauncher) |
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.