hpc_connect is a Python package that provides abstract interfaces to High-Performance Computing (HPC) schedulers and launchers. A default shell scheduler and MPI launcher is provided. Users can extend the functionality by subclassing the provided interfaces.
- Abstract Interfaces: Provides base classes for creating custom HPC schedulers and launchers.
- Default Implementations: Includes a default shell scheduler and an MPI launcher for immediate use.
- Extensibility: Easily create and register custom launchers and schedulers.
You can install hpc_connect using pip:
python3 -m pip install hpc-connectimport hpc_connect
submission_manager = hpc_connect.get_submission_manager("shell")
submission_manager.submit("hello-world", ["echo 'Hello, world!'"], cpus=1)A command-line interface for launching parallel applications using various HPC launchers.
hpc-launch [mpi-options] <application> [application-options]hpc-launch is a command line tool that forwards arguments to configured backend launchers such as mpiexec, mpirun, and jsrun. hpc-launch works by translating the command given by
hpc-launch [mpi-options] <application> [application options]to
<exec> <default-options> [mapped mpi-options] <application> [application-options]where default-options and mapped mpi-options are replaced according to the mappings in the configuration.
hpc-launch provides a unified command structure for launching parallel applications, allowing users to execute their applications without needing to remember the specific syntax for each launcher.
The behavior of hpc-launch is determined by a YAML configuration file. The default configuration is:
hpc_connect:
launch:
vendor: openmpi
exec: mpiexec
numproc_flag: -n
default_flags: []
local_flags: []
post_flags: []
mappings: {}- vendor: The MPI implementation vendor (e.g., openmpi, mpich).
- exec: The command to execute the launcher (e.g., mpiexec, mpirun).
- numproc_flag: The flag used to specify the number of processes (e.g., -n).
- default_flags: A list of default options passed to the launcher.
- local_flags: A list of options specific to local execution.
- post_flags: A list of options that are added to the command line after all other launcher args
- mappings: A dictionary for additional mappings or configurations, where command-line flags can be replaced with their corresponding values.
Configuration variables can also be specified through environment variables named HPCC_LAUNCH_NAME where NAME is any one of the configuration variables given above. Variables defined in the environment take precedent over variables defined in the configuration file.
Perhaps the base way to describe the behavior of hpc-connect is through example
Given the configuration
hpc_connect:
launch:
vendor: mpich
exec: mpiexec
numproc_flag: -npthe command line
hpc-launch -n 4 my-app ...becomes
mpiexec -np 4 my-app ...NOTE: the flag
-nwas replaced bynumproc_flag=-np
NOTE: the default flag mapping is
{'-n': '-np'}
Given the configuration
hpc_connect:
launch:
vendor: mpich
exec: mpiexec
numproc_flag: -np
default_flags: --bind-to nonethe command line
hpc-launch -n 4 my-app ...becomes
mpiexec --bind-to none -np 4 my-app ...Given the configuration
hpc_connect:
launch:
vendor: mpich
exec: mpiexec
numproc_flag: -np
mappings:
'--foo': '--bar'
'--spam': '--eggs'the command line
hpc-launch -n 4 --foo=on --spam yummy my-app ...becomes
mpiexec --bind-to none -np 4 --bar=on --eggs yummy my-app ...Given the configuration
hpc_connect:
launch:
vendor: mpich
exec: mpiexec
numproc_flag: -np
default_flags: --bind-to core --map-by ppr:%(np)d:numathe command line
hpc-launch -n 4 my-app ...becomes
mpiexec --bind-to core --map-by ppr:4:numa -np 4 my-app ...Given the configuration
hpc_connect:
launch:
vendor: mpich
exec: mpiexec
numproc_flag: -np
mappings:
'--account': SUPPRESS
'--clusters': SUPPRESSthe command line
hpc-launch -n 4 --account=[MASKED] --clusters=my-cluster my-app ...becomes
mpiexec -np 4 my-app ...Given the configuration
hpc_connect:
launch:
vendor: mpich
exec: mpiexec
numproc_flag: -np
default_flags: --bind-to core --map-by ppr:%(np)d:numa
local_flags: -H localhostthe command line
hpc-launch -n 4 app-1 app-1-options. : -n 5 app-2 app-2-optionsbecomes
mpiexec --bind-to core --map-by ppr:9:numa -H localhost -np 4 my-app -1 app-1-options : -H localhost -np 5 app-2 app-2-optionsGiven the configuration
hpc_connect:
launch:
vendor: schedmd
exec: srunthe command line
hpc-launch -n 4 app-1 app-1-options : -n 5 app-2 app-2-optionsbecomes
srun -n9 --multi-prog launch-multi-prog.confwhere
$ cat launch-multi-prog.conf
0-3 app-1 app-1-options
4-8 app-2 app-2-options