# Partition

> Rank available Slurm partitions for yaoshen, choose a suitable partition/account/QOS for CPU-heavy or GPU jobs based on memory and resource requirements, update

- Skill: `alina-shen/partition` (Agent Skill)
- Install (CLI): `npx skillmds@latest add alina-shen/partition`
- Raw SKILL.md: https://api.skillmd.com/api/skills/alina-shen/partition/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: Alina-Shen (https://skillmd.com/u/alina-shen)
- Updated: 2026-09-22
- Page: https://skillmd.com/skills/alina-shen/partition

---


# Partition

Use this skill when the user asks to choose, rank, compare, or change Slurm
partitions for job scripts on the Berkeley cluster.

## Core Workflow

1. Query current Slurm data before deciding. Partition availability changes.
2. Rank partitions using current availability, physical max memory, CPU count,
   GPU presence, account/QOS association, and benchmark suitability.
3. For given `.sh` job files, read their `#SBATCH --mem` request and choose a
   partition whose physical max memory is strictly larger than the request.
4. Edit only these SBATCH fields unless the user explicitly asks otherwise:
   `--partition`, `--account`, `--qos`.
5. Do not change `--mem`. If no ranked partition can satisfy the existing
   memory request, stop and explain the blocker.
6. After edits, print one representative modified `.sh` file or at least its
   SBATCH header so the user can verify the change.

## Helper Script

Prefer the bundled helper for ranking and edits:

```bash
python3 /global/home/users/yaoshen/.codex/skills/partition/scripts/partition_helper.py rank
python3 /global/home/users/yaoshen/.codex/skills/partition/scripts/partition_helper.py update path/to/job.sh
python3 /global/home/users/yaoshen/.codex/skills/partition/scripts/partition_helper.py update --apply path/to/job1.sh path/to/job2.sh
```

`update` defaults to dry-run. Use `--apply` only when the user asked for file
edits. The helper prints the selected partition/account/QOS and an example
header. It queries Slurm with `sacctmgr`, `sinfo`, and `scontrol`; if sandboxing
blocks Slurm sockets, rerun with escalated permissions.

Common options:

```bash
--cpu-only              Prefer CPU partitions and penalize GPU partitions.
--allow-gpu             Permit GPU partitions in the ranking.
--include-interactive   Permit ood_inter.
--prefer PARTITION      Add a ranking bonus to one partition.
--partition PARTITION   Force a partition if it fits the existing --mem.
--show-lines N          Print N lines from the example script.
```

## Local Policy

For routine CPU-only WB97M(OS) or Q-Chem benchmarks, prefer CPU partitions over
GPU partitions. Current practical defaults are usually:

- `cm1`, `account=lr_qchem`, `qos=condo_qchem`
- `lr8`, `account=lr_mhg2`, `qos=mhg2_lr8_normal`
- `mhg`, `account=mhg`, `qos=normal`
- `lr6`, `account=lr_mhg2`, `qos=lr_lowprio`
- `lr7`, `account=lr_mhg2`, `qos=condo_mhg_lr7` by default; use another lr7 QOS only when explicitly requested by the user

Use `lr_bigmem` only when the existing memory request is above normal CPU-node
capacity. Avoid `ood_inter` for production benchmark batches unless the user
explicitly asks for interactive work.

## Manual Editing Rules

If editing without the helper, preserve all unrelated lines and comments.
Modify or insert exactly these lines near the top SBATCH block:

```bash
#SBATCH --partition=<partition>
#SBATCH --account=<account>
#SBATCH --qos=<qos>
```

Validate after editing with:

```bash
rg -n '^#SBATCH --(partition|account|qos|mem)=' path/to/job.sh
sed -n '1,40p' path/to/job.sh
```

