pygsti.protocols.protocol.SlurmSettings

Contents

pygsti.protocols.protocol.SlurmSettings#

class SlurmSettings(script_path, partition=None, time=None, nodes=1, job_name=None, output=None, error=None)#

Bases: object

Settings for auto-generating a SLURM batch script via Protocol.stage_slurm().

Pass an instance as the slurm argument to Protocol.stage_slurm(). The resulting .sbatch file can be submitted directly with sbatch <script_path>.

Parameters:
  • script_path (str or Path) – Where to write the .sbatch file.

  • partition (str or None) – SLURM partition (queue) name. Written as #SBATCH --partition=<value>. When None, a FILL_IN placeholder is emitted and a comment reminds you to edit before submitting.

  • time (str or None) – Walltime limit in SLURM format, e.g. '4:00:00' or '1-00:00:00'. When None, a FILL_IN placeholder is emitted.

  • nodes (int) – Number of nodes to request (#SBATCH --nodes). Default 1. Used together with num_ranks to compute --ntasks-per-node.

  • job_name (str or None) – Job name (#SBATCH --job-name). Defaults to the protocol class name when passed to Protocol.stage_slurm().

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

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

Notes

The generated script uses srun to launch the MPI workers; this is the SLURM-native launcher and inherits the job allocation automatically (no -n flag needed).

--cpus-per-task and the BLAS thread environment variables (OMP_NUM_THREADS, MKL_NUM_THREADS, etc.) are set to the value of blas_threads_per_rank passed to Protocol.stage_slurm(). If that value is 0 (the default auto-detect), note that it is measured on the machine where you call stage_slurm, which may differ from the HPC compute nodes. Pass an explicit blas_threads_per_rank to Protocol.stage_slurm() if your nodes have a different core count.

The generated script includes a commented block of optional #SBATCH directives (--account, --qos, --constraint, --exclusive, --mem, --mail-user, etc.) that are commonly needed but too site-specific to set automatically. Edit the script and uncomment the ones you need before submitting.

Methods

__init__(script_path[, partition, time, ...])

Attributes

error

job_name

nodes

output

partition

time

script_path