/fold-cp:benchmark [inference | training] [data path | --random] [cp size]from fold-cp
Benchmarks a CP inference or training workflow to find the maximum token count fitting at a given CP size, measures end-to-end walltime with warmup and median-of-repeats, and captures peak memory.
Ships in fold-cp. 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.
CP exists to push the maximum sequence length past what one GPU holds; the headline
number is the largest N that fits at a given CP size, alongside the walltime to
process representative inputs. The driver skeleton is
scripts/bench_driver.py; adapt its three hooks to the
user's model.
/fold-cp:test.docs/cp_infra.md gives topology, world_size, GPU slots, launch recipe.inference (time forward + sampling) or training (time
fwd+bwd+optimizer step). Clarify with the user if ambiguous — they measure
different things.cp size from cp_infra.md. Hold it fixed within one
benchmark so numbers are comparable; sweep CP size only as an explicit second axis.(N_tokens, N_atoms, S).current_code_structure.md §3), sweeping N_tokens (the headline axis), and
N_atoms, S as secondary. Keep masks valid and atom_to_token consistent.For the fixed CP size, ramp N upward (e.g. geometric: 512, 1024, 2048, …; then
bisect the last gap) running a single forward each time, until it OOMs. Report the
largest N that fits and its peak memory. Reset CUDA memory stats
(torch.cuda.reset_peak_memory_stats()) between points and catch
torch.cuda.OutOfMemoryError to ramp gracefully. Report this per CP size if a CP
sweep is requested — that curve is the CP value proposition.
For each (N, atoms, S) point that fits:
repeats (≥5) iterations with torch.cuda.synchronize() around each;
report the median (robust to jitter), not the mean.max_memory_allocated) for the point.Write docs/cp_benchmark.md with a table and the run metadata (date, GPU model,
CP config, torch/cuda versions, clocks-locked y/n):
| N_tokens | N_atoms | MSA_seq | CP config | peak_mem (GiB) | walltime (ms) | <user col> |
|---------:|--------:|--------:|-----------|---------------:|--------------:|------------|
| 1024 | 8192 | 128 | 2d cp=4 | 31.2 | 842 | … |
| max-fit | … | … | 2d cp=4 | 78.9 (OOM@N+δ) | … | … |
Add any user-requested columns (e.g. tokens/sec, per-module time, energy). Save the raw CSV next to it for re-plotting.
timeout-wrap every run; tee logs under /tmp/$USER/.high_performance_computing:benchmark-design is installed, follow its
warmup/repeat/drift-cancellation guidance for publishable numbers.docs/cp_benchmark.md with the max-token result per CP size and a walltime table
over the swept points, plus run metadata; raw CSV saved alongside.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub nvidia-bionemo/boltz-cp --plugin fold-cp11 skills in this plugin
/build_infraProbe and establish the distributed test infrastructure for CP development. Inventories local GPUs (count, model, memory, NVLink topology), checks the software stack (Python, PyTorch+CUDA, NCCL, torch.distributed), and runs shipped smoke tests for batch_isend_irecv P2P, all_gather, all_reduce, reduce_scatter, and a DTensor round-trip. Maps the GPU count to which CP topologies are testable (2D needs >=4 GPUs, 1D needs >=2 ideally 3, full integration wants 8). When no local GPUs are available, generates a SLURM submission template and guides the user to provide cluster access. Records docs/cp_infra.md. Use after learn_context, before shard_data_feats / dtensor_modules / test.
/cpize_model_workflowOrchestrate the END-TO-END integration of context parallelism into a custom co-folding / structure-prediction model: turn the whole effort into a prioritized, dependency-sorted worklist, then drive it phase by phase — map the model (learn_context), verify infra (build_infra), shard data features (shard_data_feats), port modules (dtensor_modules, fanned out via dispatch_work), prove correctness (test), wire the trainer/predictor (dist_lifecycle), and finally profile memory and compute (mem_profile, nsys_profile) and benchmark. Use as the front door when the user wants to "CP-ify my model" as a whole program of work — it prioritizes, sequences, and gates the long task list and delegates each task to the right fold-cp skill. Not for a single module (use dtensor_modules + test directly).
/dispatch_workOrchestrate a team of agents to integrate many CP modules and tests in parallel. Builds the work-list from the module map, derives a data-flow dependency graph, topologically sorts it into GPU-slot-bounded waves, and spawns a coder+reviewer pair per work item. Reviewers enforce serial-as-ground-truth, no-vacuous-tests, and the fold-cp hard rules; coupled up/down-stream items cross-review each other's input/output placement contracts before finalizing. Use when the scope is several CP modules and their tests at once — not for a single module (use dtensor_modules + test directly for that).
/dist_lifecycleStand up the distributed-model lifecycle for a CP training/inference run: device placement before DTensor wrapping, the all-trainable-params-are-DTensors invariant (with placeholder/freeze for unimplemented modules), checkpoint save (DTensor → plain) and load (realign via the live state_dict template + redistribute optimizer state to parameter placements), resume RNG seed offset, and DTensor-safe EMA. Use after dtensor_modules + build_infra, when wiring the ported CP modules into a real trainer/predictor (Lightning or custom) and you need checkpoints, resume, or EMA to work — the gap between "modules pass parity" and "training runs and resumes".
/dtensor_modulesImplement DTensor-based context-parallel model modules that mirror a serial reference. Maps each serial layer/module to its Boltz-CP counterpart with exact input/output shapes, placements, collectives, and backward memory budget; writes the CP implementation following the autograd.Function conventions (explicit collectives, no implicit DTensor ops, promote_types, explicit from_local shape/stride, attribute-name + registration-order mirroring); and verifies it against the serial forward+backward via the test skill. Use when porting a custom model's trunk / attention / triangle / OPM / diffusion / confidence / loss modules to CP.
/learn_contextExplore a custom co-folding / structure-prediction model to understand its inference and training workflows, entry points, training framework (PyTorch Lightning vs DeepSpeed), data-feature format, and featurization pipeline — then map those components onto the existing Boltz-CP context-parallel reference so downstream CP integration reuses what already exists. Produces docs/current_code_structure.md. Use FIRST, before any other fold-cp skill, or whenever that doc is missing/stale. Runs interactively (Q&A with the user) or autonomously on request.
Other plugins' skills for the same job