Table of Contents
CPU/GPU Performance Discipline
When To Use
- At the beginning of every session (auto-load alongside
token-conservation).
- Whenever you plan to build, train, or test anything that could pin CPU cores
or GPUs for more than a minute.
- Before retrying a failing command that previously consumed significant resources.
When NOT To Use
- Simple operations with no resource impact
- Quick single-file operations
Required TodoWrite Items
cpu-gpu-performance:baseline
cpu-gpu-performance:scope
cpu-gpu-performance:instrument
cpu-gpu-performance:throttle
cpu-gpu-performance:log
Step 1: Establish Current Baseline
Capture current utilization:
uptime
ps -eo pcpu,cmd | head
nvidia-smi --query-gpu=utilization.gpu,memory.used --format=csv
Note which hosts/GPUs are already busy.
Record any CI/cluster budgets (time quotas, GPU hours) before launching work.
Set a per-task CPU minute / GPU minute budget that respects those limits.
Step 2: Narrow the Scope
- Avoid running "whole world" jobs after a small fix. Prefer diff-based
or tag-based selective testing:
pytest -k
- Bazel target patterns
cargo test <module>
- Batch low-level fixes so you can validate multiple changes with a single targeted command.
- For GPU jobs, favor unit-scale smoke inputs or lower epoch counts before
scheduling the full training/eval sweep.
Step 3: Instrument Before You Optimize
- Pick the right profiler/monitor:
- CPU work:
perf
intel vtune
cargo flamegraph
- language-specific profilers
- GPU work:
nvidia-smi dmon
nsys
nvprof
- DLProf
- framework timeline tracers
- Capture kernel/ops timelines, memory footprints, and data pipeline latency
so you have evidence when throttling or parallelizing.
- Record hot paths and I/O bottlenecks in notes so future reruns can jump straight to the culprit.
Step 4: Throttle and Sequence Work
- Use
nice, ionice, or Kubernetes/Slurm quotas to prevent starvation of shared nodes.
- Chain heavy tasks with guardrails:
- Rerun only the failed test/module
- Then (optionally) escalate to the next-wider shard
- Reserve the full suite for the final gate
- Stagger GPU kernels (smaller batch sizes or gradient accumulation) when memory
pressure risks eviction; prefer checkpoint/restore over restarts.
Step 5: Log Decisions and Next Steps
Conclude by documenting the commands that were run and their resource cost
(duration, CPU%, GPU%), confirming whether they remained within the per-task
budget. If a full suite or long training run was necessary, justify why selective
or staged approaches were not feasible. Capture any follow-up tasks, such as
adding a new test marker or profiling documentation, to simplify future sessions.
Output Expectations
- Brief summary covering:
- baseline metrics
- scope chosen
- instrumentation captured
- throttling tactics
- follow-up items
- Concrete example(s) of what ran (e.g.):
- "reran
pytest tests/test_orders.py -k test_refund instead of pytest -m slow"
- "profiled
nvidia-smi dmon output to prove GPU idle time before scaling"
Exit Criteria
Source: athola/claude-night-market → plugins/conserve/skills/cpu-gpu-performance/SKILL.md
1---2name: cpu-gpu-performance3description: Establishes CPU/GPU baselines before resource-intensive operations. Use before builds, training runs, or any task that pins cores or GPUs for over a minute.4---56## Table of Contents78- [When to Use](#when-to-use)9- [Required TodoWrite Items](#required-todowrite-items)10- [Step 1: Establish Current Baseline](#step-1-establish-current-baseline)11- [Step 2: Narrow the Scope](#step-2-narrow-the-scope)12- [Step 3: Instrument Before You Optimize](#step-3-instrument-before-you-optimize)13- [Step 4: Throttle and Sequence Work](#step-4-throttle-and-sequence-work)14- [Step 5: Log Decisions and Next Steps](#step-5-log-decisions-and-next-steps)15- [Output Expectations](#output-expectations)161718# CPU/GPU Performance Discipline1920## When To Use21- At the beginning of every session (auto-load alongside `token-conservation`).22- Whenever you plan to build, train, or test anything that could pin CPU cores23 or GPUs for more than a minute.24- Before retrying a failing command that previously consumed significant resources.2526## When NOT To Use2728- Simple operations with no resource impact29- Quick single-file operations3031## Required TodoWrite Items321. `cpu-gpu-performance:baseline`332. `cpu-gpu-performance:scope`343. `cpu-gpu-performance:instrument`354. `cpu-gpu-performance:throttle`365. `cpu-gpu-performance:log`3738## Step 1: Establish Current Baseline39- Capture current utilization:40 - `uptime`41 - `ps -eo pcpu,cmd | head`42 - `nvidia-smi --query-gpu=utilization.gpu,memory.used --format=csv`4344 Note which hosts/GPUs are already busy.45- Record any CI/cluster budgets (time quotas, GPU hours) before launching work.46- Set a per-task CPU minute / GPU minute budget that respects those limits.4748## Step 2: Narrow the Scope49- Avoid running "whole world" jobs after a small fix. Prefer diff-based50 or tag-based selective testing:51 - `pytest -k`52 - Bazel target patterns53 - `cargo test <module>`54- Batch low-level fixes so you can validate multiple changes with a single targeted command.55- For GPU jobs, favor unit-scale smoke inputs or lower epoch counts before56 scheduling the full training/eval sweep.5758## Step 3: Instrument Before You Optimize59- Pick the right profiler/monitor:60 - CPU work:61 - `perf`62 - `intel vtune`63 - `cargo flamegraph`64 - language-specific profilers65 - GPU work:66 - `nvidia-smi dmon`67 - `nsys`68 - `nvprof`69 - DLProf70 - framework timeline tracers71- Capture kernel/ops timelines, memory footprints, and data pipeline latency72 so you have evidence when throttling or parallelizing.73- Record hot paths and I/O bottlenecks in notes so future reruns can jump straight to the culprit.7475## Step 4: Throttle and Sequence Work76- Use `nice`, `ionice`, or Kubernetes/Slurm quotas to prevent starvation of shared nodes.77- Chain heavy tasks with guardrails:78 - Rerun only the failed test/module79 - Then (optionally) escalate to the next-wider shard80 - Reserve the full suite for the final gate81- Stagger GPU kernels (smaller batch sizes or gradient accumulation) when memory82 pressure risks eviction; prefer checkpoint/restore over restarts.8384## Step 5: Log Decisions and Next Steps8586Conclude by documenting the commands that were run and their resource cost87(duration, CPU%, GPU%), confirming whether they remained within the per-task88budget. If a full suite or long training run was necessary, justify why selective89or staged approaches were not feasible. Capture any follow-up tasks, such as90adding a new test marker or profiling documentation, to simplify future sessions.9192## Output Expectations93- Brief summary covering:94 - baseline metrics95 - scope chosen96 - instrumentation captured97 - throttling tactics98 - follow-up items99- Concrete example(s) of what ran (e.g.):100 - "reran `pytest tests/test_orders.py -k test_refund` instead of `pytest -m slow`"101 - "profiled `nvidia-smi dmon` output to prove GPU idle time before scaling"102103## Exit Criteria104105- [ ] `uptime` and `ps` baseline captured and recorded before any106 build, training run, or test suite starts107- [ ] Scope narrowed to diff-based or tag-based targets (e.g.,108 `pytest -k`, `cargo test <module>`); full-suite justification109 documented if selective approach was not feasible110- [ ] Output summary includes: duration, CPU% or GPU% consumed, and111 whether the run stayed within the per-task budget112- [ ] Any follow-up tasks (new test markers, profiling docs) written113 to a todo or issue so they survive the session114115---116117**Source:** [`athola/claude-night-market`](https://github.com/athola/claude-night-market) → `plugins/conserve/skills/cpu-gpu-performance/SKILL.md`