/fold-cp:cpize_model_workflow [scope] [focus] [dp:N cp:(A,B)|cp:N] [model:path] [ref:path] [--local|--slurm] [data:path|--random] [--automatic|--manual-approve] [resume]from fold-cp
Orchestrates end-to-end integration of context parallelism into a custom co-folding model. Breaks the effort into prioritized, dependency-sorted phases from model mapping through profiling and benchmarking.
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.
This is the conductor. It does not re-implement any step — it decomposes the
integration into a (potentially long) task list, prioritizes and sorts it by dependency /
critical path / risk / quick-win, delegates each phase to the matching fold-cp skill, and
enforces the gate between phases — above all correctness before profiling. All work obeys
the hard rules in RULES.md (injected at SessionStart). The task schema, priority rubric, worked
sort, per-phase gate definitions, execution-mode detail, and ledger template are in
reference.md.
| # | Phase | Delegate to | Gate to advance |
|---|---|---|---|
| 0 | Map the model | /fold-cp:learn_context | docs/current_code_structure.md filled (module map + feature inventory) |
| 1 | Verify infra | /fold-cp:build_infra | docs/cp_infra.md; resource + hardware/runtime self-consistency recorded; collective + DTensor/device_mesh smoke tests pass |
| 2 | Shard data features | /fold-cp:shard_data_feats | data-feature parity test green |
| 3 | Port modules | /fold-cp:dtensor_modules (+ /fold-cp:dispatch_work to fan out) | each module's parity test green |
| 4 | Wire trainer/predictor | /fold-cp:dist_lifecycle | stop-and-go resume test green |
| 5 | Prove correctness | /fold-cp:test | end-to-end CP==serial parity + property tests green, non-vacuous |
| 6 | Profile | /fold-cp:mem_profile, /fold-cp:nsys_profile | peak ≤ budget (Rule 11); compute/comm attributed |
| 7 | Benchmark | /fold-cp:benchmark | max-token / walltime recorded |
The orchestrator owns only the plan, the ordering, the gates, and the ledger
(docs/cp_integration_plan.md).
Parse $ARGUMENTS by keyword (order-independent), then resolve the inputs below:
| token | input | default |
|---|---|---|
inference / training / all | scope (which workflow) | all |
dp:<d> cp:(<a>,<b>) / cp:<n> | mesh config (see below) | from cp_infra.md |
bare 1d / 2d | topology hint only (sizes deferred to build_infra) | from the cp: shape |
model:<path> | the user's model code | resolve by tracing |
ref:<path> | the reference repo ($BOLTZ_CP_REPO) | $BOLTZ_CP_REPO env / search |
--local / --slurm | launch environment | build_infra decides |
data:<path> / --random | parity/benchmark data source | ask, else synthesize |
resume | resume mode → Resume | — |
--automatic / --manual-approve | execution mode — continuous vs approve-each-wave (aliases: --auto / --manual) | automatic |
| any other token(s) | focus area | whole model |
--automatic (default) vs --manual-approve. Fix it once at the front
door: honor an explicit token without asking; else, if interactive, ask once
(AskUserQuestion, default automatic) and record it in the ledger (--auto/--manual alias).
--automatic drives the ENTIRE plan continuously to the final report — never handing off or
proposing a fresh session — verifying every gate on disk (Rule 22) and handling setbacks
autonomously (a red gate → re-prioritize, never stop,
Rule 3; a design fork → sensible default, recorded). --manual-approve pauses at every wave
boundary for approval. Full semantics — automatic vs manual behavior, the critical-blocker
list (the only halts allowed under --automatic), the 1D-CP sign-off exception, and the
per-call permission caveat — are in reference.md.$BOLTZ_CP_REPO) — the Boltz-CP implementation every mapping cites. Resolve
it first (env var → ref:<path> → search); phase-0 learn_context prompts if unset. Record it
in the ledger — the whole workflow is undefined without it. The model path (model:<path>)
and scope feed phase-0 learn_context; the launch flag feeds phase-1 build_infra.dp:<d> cp:(<cp0>,<cp1>) (2D) or dp:<d> cp:<n> (1D); dp defaults to 1,
world_size = dp · ∏cp (mechanics + threading in
reference.md). It is the single mesh threaded
to every parity test (phases 2–5), the benchmark (phase 7), and the profiles (phase 6), and it
sets the Step-4 slot bound (slots = floor(free_GPUs / world_size)). Absent ⇒ build_infra
picks a feasible mesh. If cp resolves to 1D — a scalar cp:<n>, or build_infra reports
only 1D is feasible (<4 GPUs / non-square) — apply the 1D-CP experimental gate (Rule 25) before
Step 2: warn that 1D has pending bugs / unestablished parity, take a one-time at-own-risk
AskUserQuestion (proceed-1D / switch-to-2D / abort), and record it in the ledger. Required
even under --automatic; 2D is the default and is not gated.data:<path> | --random) decides whether the parity/e2e tests and the
benchmark use real features or synthesized ones (the test skill synthesizes when none is given).trunk/pairformer, diffusion, confidence, data, losses, or a module name); it
filters the task list (Step 2) and seeds the sort (Step 3). Absent ⇒ the DATA
module/pipeline is the default ordering seed — not a filter (the whole model stays in
scope): its feature-sharding is integrated first, then propagated to every consumer (Rule 4).
Orthogonal to scope and mesh. Full behavior in
reference.md.docs/current_code_structure.md is missing/stale, run /fold-cp:learn_context first
(phase 0) — never plan module work against an un-mapped model (Rule 1). If docs/cp_infra.md is
missing, run /fold-cp:build_infra (phase 1).learn_context. Thread each module task's input-feature
placement contract from §4.5 so a dtensor_modules port wires against a known contract, and
make the synthetic test data (/fold-cp:test) emit at those same placements by reusing the
data-layer distributor (never a hand-rolled source). Why propagate once:
reference.md.Enumerate one task per unit of work and tag each with the attributes in
reference.md (phase · delegated skill · dependencies · status reuse/adapt/new ·
GPU need · risk). Include every data-feature task, every adapt/new module, the
lifecycle items, the tests, and the two profiling passes. Persist as
docs/cp_integration_plan.md (template in reference.md) — the living ledger you update every
wave.
If a focus area was given, restrict the master list to the tasks in that subsystem plus
their transitive dependencies (a focused module still needs its upstream data features, infra,
and producers — Rule 4), and mark every other task out-of-scope in the ledger rather than
deleting it — so a later run can widen the focus without re-deriving the plan. With no focus
area, include everything.
Focus area is the seed (if given): the focus subsystem and its dependency chain are scheduled
first, and the subsystem is the natural scope to hand to /fold-cp:dispatch_work. This does
not override rules 1–2 — you still cannot run a focus module before its infra/data/producers,
so the dependencies come first and the focus subsystem leads as soon as it is ready.
Order the list by these rules, in precedence (full rubric + worked example in reference.md):
Then choose fan-out vs direct per wave: a wave with ≥3 independent module/test items →
hand the wave to /fold-cp:dispatch_work (coder+reviewer pairs, GPU-slot-bounded). 1–2 items →
/fold-cp:dtensor_modules + /fold-cp:test directly. (dispatch_work sorts within the
module phase; this skill sorts across phases and feeds it the wave.)
Loop until the list is done:
slots = floor(free_GPUs / world_size) from cp_infra.md). On a shared local (non-SLURM)
box, give each fan-out pair a contiguous GPU chunk of world_size devices and HOLD if busy —
parallel tests otherwise overload the GPUs and stall (see /fold-cp:dispatch_work); under SLURM
the scheduler sets per-job device visibility.dispatch_work for a fan-out wave).Per-module delegation loop (what scales). Delegate each module to one coder agent that
writes → 1×1-mesh fp64 pre-check (/fold-cp:test Step 3) → multi-rank parity → iterates to
green. Serialize on the GPU test, not the whole agent: with slots=1, agents may draft code
in parallel but their multi-rank parity tests must not share GPUs. Reuse a warm agent for a
closely-related next module, or spawn a fresh agent with a distilled "playbook" (the
accumulated quirks) when its context bloats. Distinguish leaf ports (a new collective — high
risk, needs its own fresh parity test) from compositions (wiring already-green modules — lower
risk; the test focus is Rule-4 seam reconciliation + op-order, not new collective math). Commit at each wave boundary only if the user has authorized committing (otherwise leave
the distributed tree uncommitted and report it in the final summary — committing is an outward action,
never taken unprompted). Keep the loop cheap at scale: launch the wave's
independent module drafts together (Rule 24), have each coder write its report/log to a file
and return only a terse verdict + artifact paths (Rule 23), and verify each gate by inspecting
that evidence (Rule 22) rather than re-running by default.
Route to /fold-cp:test for the end-to-end workflow parity (CP fwd+bwd == serial) on top of
the per-module parity from phase 3, plus the property/invariant tests where there is no value
oracle (RNG entropy, determinism, layout). All must be green and non-vacuous (Rule 14 —
explicit random grad_output, sharding-active, replicated-identical, non-zero grads; property
tests carry a negative control). A stochastic head (diffusion) is validated by distribution,
not point value (test skill). This gate is the firewall: a profiling result on an incorrect
model is meaningless, so phase 6 does not start until phase 5 is green.
Run /fold-cp:mem_profile, then /fold-cp:nsys_profile (they may overlap if GPUs allow). Read
them against the rules, not just for numbers:
autograd.Function
(Rule 19) — both pass parity but surface here./fold-cp:benchmark for max-token-at-CP-size and end-to-end walltime → docs/cp_benchmark.md.
Then deliver the final summary (Output contract).
resume: read docs/cp_integration_plan.md, skip done tasks, and continue from the
first not-done ready wave — the ledger is the source of truth across sessions.--manual-approve convenience or a
response to an explicit user stop, never an --automatic default. Under --automatic
you never hand off or propose a fresh session — you drive to the final report, bounding context
with lean delegation + per-wave ledger writes + terse file-based agent verdicts (Rules 23/24), not
by stopping. When the user does stop (or between waves under --manual-approve), resume
re-enters from the ledger: skip done tasks and re-read only the ledger + the files the current
wave needs, not the whole accumulated transcript (Rule 23).out-of-scope; re-run Step 3 over the newly-included set.docs/cp_integration_plan.md: the prioritized ledger — every task with
phase/skill/deps/status/gate/artifact — kept current through the run.TODO(learn_context) / follow-ups.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
/benchmarkBenchmark a CP inference or training workflow to find the maximum token count that fits at a given CP size and to record end-to-end walltime. Sweeps input size (tokens N, atoms, MSA depth S) over real or synthesized data, ramps N until OOM to report the max, times fwd (inference) or fwd+bwd+step (training) with warmup and median-of-repeats, captures peak memory, and writes a results table to docs/cp_benchmark.md. Use once a CP workflow runs end-to-end, to quantify the memory headroom CP buys and the walltime cost.
/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.
/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).
Other plugins' skills for the same job