pygsti.tools.mpitools.build_slurm_script

pygsti.tools.mpitools.build_slurm_script#

build_slurm_script(*, job_name, nodes, ntasks_per_node, cpus_per_task, time, partition, output, error, ranks_per_host, num_ranks, runner_path, script_path)#

Build and return the text of a SLURM batch script.

The returned string is suitable for writing directly to a .sbatch file and submitting with sbatch. The script uses srun as the MPI launcher (SLURM-native; inherits the job allocation automatically).

Parameters:
  • job_name (str) – Value for #SBATCH --job-name.

  • nodes (int) – Value for #SBATCH --nodes.

  • ntasks_per_node (int) – Value for #SBATCH --ntasks-per-node.

  • cpus_per_task (int) – Value for #SBATCH --cpus-per-task. Also used for the BLAS thread environment variable exports.

  • time (str or None) – Walltime limit (e.g. '4:00:00'). None emits a FILL_IN placeholder.

  • partition (str or None) – SLURM partition name. None emits a FILL_IN placeholder.

  • output (str or None) – Path for SLURM stdout log. None defaults to slurm-%j.out in the same directory as script_path.

  • error (str or None) – Path for SLURM stderr log. None defaults to slurm-%j.err in the same directory as script_path.

  • ranks_per_host (int or None) – Used to set a suggested PYGSTI_MAX_HOST_PROCS comment in the script. None uses num_ranks // nodes as the suggestion.

  • num_ranks (int) – Total number of MPI ranks (used only when ranks_per_host is None to compute the suggestion).

  • runner_path (str) – Path to the mpi_runner.py script (embedded in the srun invocation).

  • script_path (str) – Destination path for the .sbatch file (embedded in the header comment).

Returns:

Complete text of the batch script, ending with a newline.

Return type:

str