Partitions & QOS
Exercises¶
- Create a new partition for long-running jobs
Add a long partition in slurm.conf that uses nodes cpu[001-064], allows a maximum walltime of 14 days, and has a lower PriorityTier than the default batch partition. Apply the change and verify the partition exists.
Hint / Solution
# Add to slurm.conf:
# PartitionName=long Nodes=cpu[001-064] MaxTime=14-00:00:00 DefaultTime=04:00:00 PriorityTier=50 State=UP
# Apply
scontrol reconfigure
# Verify
scontrol show partition long
sinfo -p long
slurm-training-val (Slurm 25.11.4, ParallelCluster 3.15.0).
$ scontrol show partition val_long
PartitionName=val_long
AllowGroups=ALL AllowAccounts=ALL AllowQos=ALL
AllocNodes=ALL Default=NO QoS=N/A
DefaultTime=04:00:00 DisableRootJobs=NO ExclusiveUser=NO ExclusiveTopo=NO GraceTime=0 Hidden=NO
MaxNodes=UNLIMITED MaxTime=14-00:00:00 MinNodes=0 LLN=NO MaxCPUsPerNode=UNLIMITED MaxCPUsPerSocket=UNLIMITED
Nodes=debug-dy-small-[1-2]
PriorityJobFactor=1 PriorityTier=50 RootOnly=NO ReqResv=NO OverSubscribe=NO
OverTimeLimit=NONE PreemptMode=OFF
State=UP TotalCPUs=4 TotalNodes=2 SelectTypeParameters=NONE
JobDefaults=(null)
DefMemPerNode=UNLIMITED MaxMemPerNode=UNLIMITED
TRES=cpu=4,mem=7782M,node=2,billing=4
ResumeTimeout=GLOBAL SuspendTimeout=GLOBAL SuspendTime=GLOBAL PowerDownOnIdle=NO
$ sinfo -p val_long
PARTITION AVAIL TIMELIMIT NODES STATE NODELIST
val_long up 14-00:00:0 2 idle~ debug-dy-small-[1-2]
- Create a QOS with specific resource limits
Create a QOS called restricted that limits each user to 32 CPUs and 2 GPUs across all their running jobs, and caps concurrent running jobs at 10 per user.
Hint / Solution
sacctmgr add qos restricted set \
MaxTRESPerUser=cpu=32,gres/gpu=2 \
MaxJobsPerUser=10 \
Priority=0
# Verify
sacctmgr show qos restricted format=Name,MaxTRESPerUser,MaxJobsPerUser,Priority
slurm-training-val (Slurm 25.11.4, ParallelCluster 3.15.0).
$ sudo /opt/slurm/bin/sacctmgr -i add qos val_pq_restricted set MaxTRESPerUser=cpu=32 MaxJobsPerUser=10 Priority=0
Adding QOS(s)
val_pq_restricted
Settings
Description = val_pq_restricted
MaxJobsPerUser = 10
MaxTRESPerUser = cpu=32
Priority = 0
$ sacctmgr show qos val_pq_restricted format=Name%-20,MaxTRESPerUser%-30,MaxJobsPerUser,Priority
Name MaxTRESPU MaxJobsPU Priority
-------------------- ------------------------------ --------- ----------
val_pq_restricted cpu=32 10 0
- Assign a QOS to an account
Allow all users in the smith_lab account to use both the normal and restricted QOS. Set normal as their default.
Hint / Solution
# Add the QOS to the account
sacctmgr modify account smith_lab set qos=normal,restricted defaultqos=normal
# Verify
sacctmgr show association where account=smith_lab format=Account,User,QOS,DefaultQOS
slurm-training-val (Slurm 25.11.4, ParallelCluster 3.15.0).
$ sudo /opt/slurm/bin/sacctmgr -i modify account training set qos=normal,val_pq_restricted defaultqos=normal
Modified account associations...
C = slurm-training-val A = training of root
$ sacctmgr show association where account=training format=Account,User,QOS,DefaultQOS
Account User QOS Def QOS
---------- ---------- -------------------- ---------
training normal,val_pq_restr+ normal
- Test that a QOS limit prevents over-allocation
Create a test QOS called tiny that allows a maximum of 2 CPUs per user total. Assign it to a test user. Submit two single-CPU jobs (they should start), then submit a third and confirm it is held pending with a QOS limit reason.
Hint / Solution
# Create the restrictive QOS
sacctmgr add qos tiny set MaxTRESPerUser=cpu=2 MaxJobsPerUser=10
# Assign to a test user
sacctmgr modify user testuser set qos=tiny defaultqos=tiny
# As testuser, submit jobs:
su - testuser
sbatch --qos=tiny --wrap="sleep 300" -n 1
sbatch --qos=tiny --wrap="sleep 300" -n 1
sbatch --qos=tiny --wrap="sleep 300" -n 1
# Check status -- the third job should be pending
squeue -u testuser -o "%.8i %.2t %.20R"
# Expected reason: (QOSMaxCpuPerUserLimit) or (QOSMaxTRESPerUser)
# Clean up
scancel -u testuser
sacctmgr delete qos tiny
slurm-training-val (Slurm 25.11.4, ParallelCluster 3.15.0).