/hpc-assistant-skills:frontier-frequency-power-cappingfrom hpc-assistant-skills
Runs GPU frequency-cap and power-cap experiments on Frontier (AMD MI250X). Covers Slurm job header controls, runtime frequency changes, telemetry, sweep planning, and energy analysis.
Ships in hpc-assistant-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
Frontier gives users three GPU power-management controls:
| Control | How | Scope | Values |
|---|---|---|---|
| Power cap | #SBATCH --gpu-power-cap=W in the job header | whole job; one job per power cap | integer 100–600 W per MI250X package, default 560 |
| Max frequency (freq cap) | srun -N $SLURM_JOB_NUM_NODES --ntasks-per-node=1 --exclusive /usr/bin/set_gpu_max_sclk MHz | runtime; can change between steps of the same job | above the current MIN (e.g. 501) up to 1700 MHz |
| Min/max frequency range | #SBATCH --gpu-srange=MIN-MAX in the job header | whole job | MIN ≥ 500, MIN < MAX, MAX ≤ 1700; default 500-1700 |
| (not a cap) | #SBATCH --gpu-counters=0 | whole job | turns off the OLCF counter daemon; use 0 for measurements |
#!/bin/bash
#SBATCH -A abc123
#SBATCH -N 1
#SBATCH -t 01:00:00
#SBATCH --gpu-power-cap=300 # fixed for this job; another cap = another job
#SBATCH --gpu-counters=0
for maxfreq in 1700 1300 900; do # max frequency can change inside the job
srun -N "$SLURM_JOB_NUM_NODES" --ntasks-per-node=1 --exclusive /usr/bin/set_gpu_max_sclk "$maxfreq"
srun -N1 -n8 -c7 --gpus-per-task=1 --gpu-bind=closest ./app > "out-${maxfreq}MHz.txt"
done
srun -N "$SLURM_JOB_NUM_NODES" --ntasks-per-node=1 --exclusive /usr/bin/set_gpu_max_sclk 1700 # restore
--gpu-power-cap on the sbatch command line overrides the header.set_gpu_max_sclk exists only on compute nodes. Run it once per node (--ntasks-per-node=1) before the application step, not inside it. It changes only the max; the min stays as set by the job (500 by default), so the smallest usable value is 501. The setting persists until changed again or until the job ends.#SBATCH --gpu-srange=MIN-MAX. The OLCF guide documents this option, the Slurm plugin validates it at submission (checked with sbatch --test-only), and the prolog applies it with rocm-smi --setsrange. Its effect on a compute node has not been confirmed yet: the template's verify_caps.py reads pp_od_clk_voltage on every node and stops the job if the range is not the one requested. Check its output on the first run.Sources: the OLCF Frontier User Guide (section OLCF Custom Slurm Plugins; in a project also under .hpc-assistant/docs/frontier/), the plugin code on the login nodes, /etc/slurm/lua.d/gpu-srange.lua and /etc/slurm/lua.d/gpu-power-cap.lua (read 2026-11-05), and existing Frontier job scripts that use set_gpu_max_sclk. If the behavior described here looks wrong, re-read those two files; they are the source of truth. The full rules are in references/mechanisms.md.
--gpu-power-cap and --gpu-srange on every GPU of every node before the script starts, and the epilog resets them to 500-1700 MHz and 560 W. srun --gpu-power-cap on a step has no effect, and rocm-smi --setpoweroverdrive/--setsrange need root. A script that loops over several power caps inside one job measures the header's cap every time, so use one job per power cap. Only the max frequency has a runtime command (set_gpu_max_sclk, rule 7). Slurm records the accepted values in the job's AdminComment (GPU_SRANGE=...,GPU_POWER_CAP=...,..._SRC=user|default); check them with sacct -j <jobid> -X -o JobID,AdminComment%150.--gpu-srange syntax: MIN-MAX, or a single number, which sets only MAX (--gpu-srange=1300 means 500-1300). MIN below 500 is rejected, and so is MIN ≥ MAX, so MIN = MAX (a pinned clock) is impossible. The nearest option is a narrow band such as 1299-1300. The plugin accepts MAX > 1700 for vendor margin testing; do not use it for experiments. An invalid value makes the submission fail.power1_cap for cards 0, 2, 4 and 6, one per MI250X. --gpu-power-cap=300 lets each pair of GCDs draw up to 300 W, so 1200 W of GPU power per node. A one-GCD job still shares its package budget with the idle sibling GCD.500-X) is the energy-saving knob. It mostly costs runtime on compute-bound kernels and costs little on memory- or communication-bound phases.X-1700) keeps the clock from dropping during idle, communication, or launch gaps. It tests sensitivity to DVFS ramp-up latency in bursty workloads. It usually raises idle power and energy.X-1-X) approximates a fixed clock, which is good for reproducible per-frequency measurements.--gpu-srange and set_gpu_max_sclk change only sclk. HBM bandwidth stays the same, which is why memory-bound codes often lose little performance at lower sclk.set_gpu_max_sclk). Run srun -N "$SLURM_JOB_NUM_NODES" --ntasks-per-node=1 --exclusive /usr/bin/set_gpu_max_sclk MHz from the batch script between application steps; it covers every node of the job. The value must stay above the job's sclk MIN, so use 501 rather than 500 with the default range. Restore 1700 (or the header max) at the end, so later steps of the same job are not left slow. Changing frequency inside a job means the same nodes and power cap apply to every frequency, which reduces node-to-node noise. However, each point inherits the thermal state of the previous one, so keep an idle gap between points and shuffle their order.Copy the template and edit the cap lines in its header:
export PROJECT=abc123
export CAP_SKILL_DIR=/abs/path/to/skills/frontier-frequency-power-capping # must be readable from compute nodes
export RUN_ROOT=/lustre/orion/$PROJECT/scratch/$USER/caps/myapp
cp "$CAP_SKILL_DIR/templates/cap-run.sbatch" cap-300W.sbatch
sed -i 's/^#SBATCH --gpu-power-cap=.*/#SBATCH --gpu-power-cap=300/' cap-300W.sbatch # or edit by hand
sbatch --account="$PROJECT" \
--export=ALL,CAP_SKILL_DIR="$CAP_SKILL_DIR",RUN_ROOT="$RUN_ROOT" \
cap-300W.sbatch srun -N1 -n8 -c7 --gpus-per-task=1 --gpu-bind=closest ./myapp input.dat
To sweep the max frequency inside the same job, add CAP_FREQS (space- or colon-separated MHz). The template then calls set_gpu_max_sclk before each point, runs the application once per value into its own result directory (.../rep<N>-job<JOBID>-i<k>/), and restores the header max at the end:
sbatch --account="$PROJECT" \
--export=ALL,CAP_SKILL_DIR="$CAP_SKILL_DIR",RUN_ROOT="$RUN_ROOT",CAP_FREQS=1700:1500:1300:1100:900 \
cap-300W.sbatch srun -N1 -n8 -c7 --gpus-per-task=1 --gpu-bind=closest ./myapp input.dat
python3 $CAP_SKILL_DIR/scripts/capspec.py header 1300 300 prints valid header lines and rejects values the plugin would refuse. templates/cap-run.sbatch does the following:
AdminComment and uses them to label the run. If you also set CAP_SRANGE/CAP_POWER as a cross-check and they disagree, it stops (exit 5) before doing anything.run.env, command.txt, and scontrol show job into $RUN_ROOT/<label>/rep<N>-job<JOBID>/. The label looks like s500-1300_p560.pp_od_clk_voltage) and the package power caps (hwmon/power1_cap) from sysfs. On a mismatch it aborts before the application (exit 4, CAP_STRICT=1). If the files cannot be read it continues with a warning (exit 3).srun --overlap, 1 core). It records hwmon package power, sclk, mclk, and temperatures, plus HPE Cray pm_counters energy (node, CPU, memory, accelN_energy per package).IDLE_SECONDS, default 10 s) before and after the run, so the idle power of a raised MIN shows up.application.out/.err and timing.env (start, end, exit code).status.txt. With CAP_FREQS, steps 3–7 repeat for each frequency after set_gpu_max_sclk. If the application fails at one frequency, the template moves on to the next and the job exits with the first non-zero code.The verification can also be run alone in any job: srun --overlap -N$SLURM_NNODES --ntasks-per-node=1 -c1 python3 $CAP_SKILL_DIR/scripts/verify_caps.py --expect-srange 500-1300 --expect-power-cap 560.
scripts/cap_sweep.py submits one job per (configuration, repetition). For each configuration it writes a copy of the template, $RUN_ROOT/jobs/cap-<label>.sbatch, whose header holds that configuration's #SBATCH --gpu-power-cap=, --gpu-srange= and --gpu-counters= lines. Every value is checked against the plugin rules first. It does a dry run by default: it writes the job scripts for review and prints every sbatch line and the worst-case node-hours. --submit actually submits and appends to $RUN_ROOT/manifest.csv.
S=$CAP_SKILL_DIR/scripts
# Max-frequency sweep at 560 W plus power-cap sweep at default clocks (one factor at a time):
python3 $S/cap_sweep.py --account "$PROJECT" --run-root "$RUN_ROOT" \
--srange 1500 --srange 1300 --srange 1100 --srange 900 --srange 700 \
--power-cap 450 --power-cap 350 --power-cap 250 --power-cap 150 \
--mode separate --reps 3 --shuffle --seed 1 --time 00:20:00 \
-- srun -N1 -n8 -c7 --gpus-per-task=1 --gpu-bind=closest ./myapp input.dat
# One job per power cap; inside each job the max frequency is swept at runtime
# (set_gpu_max_sclk). 1700 is added automatically as the in-job baseline. Size --time for all points.
python3 $S/cap_sweep.py --account "$PROJECT" --run-root "$RUN_ROOT/rt" \
--power-cap 560 --power-cap 400 --power-cap 250 --mode grid \
--runtime-freqs 1500 1300 1100 900 700 501 --reps 3 --shuffle --time 02:00:00 \
-- srun -N1 -n8 -c7 --gpus-per-task=1 --gpu-bind=closest ./myapp input.dat
# Min-frequency (floor) study, full grid with two power caps:
python3 $S/cap_sweep.py --account "$PROJECT" --run-root "$RUN_ROOT/floor" \
--srange 500-1700 --srange 1000-1700 --srange 1400-1700 --power-cap 560 --power-cap 300 \
--mode grid --reps 3 --shuffle -- srun -N1 -n8 -c7 --gpus-per-task=1 --gpu-bind=closest ./myapp
--mode separate always includes the baseline (500-1700, 560 W) once. --max-jobs (default 60) guards against flooding the queue. Other options: --nodelist pins all jobs to the same nodes (less node-to-node variation, longer queue waits), --gpu-counters 1 (default 0), --qos debug, and --extra-sbatch "...", which refuses --gpu-* options so the header stays the only source of the caps. Show the dry run to the user and get confirmation before --submit, since a sweep spends allocation.
python3 $S/analyze_caps.py "$RUN_ROOT" --fom-regex 'Throughput:\s*([0-9.]+)' --work-units 1e6
scripts/analyze_caps.py writes runs.csv (one row per run, with exclusion reasons), summary.csv, summary.json, and summary.md (one row per configuration). Metrics are computed over the application window only:
| Metric | Definition |
|---|---|
gpu_energy_J | Σ over nodes and packages of accelN_energy deltas from pm_counters (preferred). Fallback: the time integral of hwmon package power on cards --package-cards (default 0,2,4,6) |
avg_gpu_power_W | GPU energy / elapsed time (whole job) |
runtime_ratio, energy_ratio | t/t₀ and E/E₀ against --baseline (default s500-1700_p560) |
edp_ratio, ed2p_ratio | (E·t)/(E₀·t₀) and (E·t²)/(E₀·t₀²); below 1 is better |
cap_bound_frac | Fraction of package power samples ≥ 97 % of the cap. Near 0 means the power cap never acted |
sclk_mean/p95/max | Observed engine clock; a max above the requested MAX + 25 MHz is flagged |
pareto | No other configuration is both faster and lower-energy |
node_energy_J | Node total from pm_counters (GPU + CPU + memory + rest). Do not add the GPU energy to it |
A run is excluded when the application exit code is non-zero, the pre-run check found a mismatch, or energy could not be computed (no counters, a counter reset, or sample gaps over --max-gap). Report excluded runs; do not drop them silently.
Details, recommended value grids, and statistics are in references/experiment-design.md.
500-1700, 560 W, passed explicitly) in the same sweep, on the same software stack.srun --gpu-power-cap or rocm-smi --set*) does not change anything; every iteration runs at the header value. Only the max frequency can change at runtime, with set_gpu_max_sclk.set_gpu_max_sclk placement: call it from the batch script with one task per node (--ntasks-per-node=1 --exclusive), never inside the application's srun. It does not exist on login nodes. A value at or below the sclk MIN (500 by default) is invalid; use 501.set_gpu_max_sclk 900 leaves later steps of the same job at 900 MHz. The template restores the header max in its EXIT trap.--gpu-power-cap on the sbatch command line overrides the #SBATCH line. Check AdminComment (GPU_POWER_CAP_SRC=user means the value was requested explicitly).##SBATCH --gpu-power-cap=... is ignored, and so is any #SBATCH line after the first command in the script.--gpu-srange=1300-1300 fails (MIN must be < MAX). Use 1299-1300.cap_bound_frac ≈ 0, the power cap did not bind. That is a valid result, not an error.--gpu-counters=1 by default, which runs a rocprofiler-based sampler. Set --gpu-counters=0 for clean measurements and when using rocprofv3, and use the same value in every configuration of a sweep.rocm-smi --set* is not available: users cannot change clocks or power caps with rocm-smi/amd-smi (that needs root). Use the header options and set_gpu_max_sclk. Read-only rocm-smi/amd-smi queries are fine.--cpu-freq is per step, and its governors are OnDemand, Performance, and UserSpace. Verify that it took effect before relying on it (see references/mechanisms.md).CAP_SKILL_DIR and RUN_ROOT on Orion, absolute paths without commasverify_pre=0, samples for all nodes, energy_source=pm_counters, AdminComment shows the requested capscap_sweep.py (dry run reviewed, node-hours accepted by the user)squeue --me and sacctanalyze_caps.py run; excluded runs, CVs, and cap_bound_frac checkedfrontier-slurm-job-management: accounts, partitions/QOS, binding (-c7 --gpu-bind=closest)energy-profiling: Omnistat on Frontier (references/omnistat-frontier.md). It can replace gpu_sampler.py (CAP_SAMPLER=0 plus with_omnistat.sh) when dashboards are neededprofiling: rocprofv3, to explain why a kernel is or is not sensitive to the clockThe offline tests need only Python and Bash; they use fake sysfs trees and a fake srun:
python3 -B -m unittest discover -s skills/frontier-frequency-power-capping/tests -v
rocm-smi/amd-smi commands, pm_counters, CPU frequencyreferences/experiment-design.md (opens in a new tab)references/mechanisms.md (opens in a new tab)scripts/analyze_caps.py (opens in a new tab)scripts/cap_sweep.py (opens in a new tab)scripts/capspec.py (opens in a new tab)scripts/gpu_sampler.py (opens in a new tab)scripts/verify_caps.py (opens in a new tab)templates/cap-run.sbatch (opens in a new tab)tests/test_capping.py (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
frontier, gpu-capping, power-cap, frequency-cap, hpc-experiments
8 skills in this plugin
/energy-profilingUse when profiling GPU job energy or power consumption on AMD systems with Omnistat. Handles Omnistat/VictoriaMetrics setup, Slurm job instrumentation, report-card interpretation, and troubleshooting. Covers LUMI and Frontier. Do NOT use for rocprofv3 kernel/API performance profiling./frontier-resource-managementCheck Frontier allocations, storage, and project access./frontier-slurm-job-managementSubmit, monitor, and debug Slurm jobs on Frontier.npx claudepluginhub silogen/hpc-assistant --plugin hpc-assistant-skillsOther plugins' skills for the same job