/foundationskills:fskills-mergingfrom foundationskills
Folds a LoRA adapter into its base model as merged full weights with plan-first workflow and dual verification (structural checks + numeric logit parity).
Ships in foundationskills. 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.
None: SKILL.md is the whole skill.
Fold a LoRA adapter into its base as merged full weights, planned probe-first and
verified twice. plan probes the merge (interfaces/fs/emit_merge.py: model dir,
adapter_config/weights, matching base, empty output, toolchain, disk) and emits an
fs_launch_spec that runs FoundationScale's own merge_lora.py; the skill never
launches and never echoes a hash — the user reads it from fskills hash and types it
back to fskills launch --confirm. verify then checks the merge structurally
(seven checks from the merge script) and by numeric logit parity (parity.py):
the merged checkpoint must reproduce base + adapter, because structure alone passes a
merge that lost the adapter's effect. Only structure + parity PASS writes a checkpoint.
| Field | Required | Meaning |
|---|---|---|
action | no | plan (default) or verify |
base | yes (plan) | path to the base model directory |
adapter | yes (plan) | path to the LoRA adapter (adapter_config.json + weights) |
out | yes (plan) | output directory for merged full weights (must be absent or empty — never overwrites) |
store_dtype | no | float32 (default) or bfloat16 storage of the merged weights (ME-HO-001) |
device_map | no | device map the merge script loads the base with (default cpu) |
spec | yes (verify) | path to the fs_launch_spec written by plan |
parity | no | run numeric parity (default true); false → UNMEASURED, never PASS (ME-HO-004) |
device | no | device parity.py runs on (default cuda:0) |
max_ratio | no | parity ratio tolerance (default 0.1) |
min_agreement | no | argmax-agreement floor (default 0.95) |
plan → fs_launch_spec.merge.json (atomically, with provenance): a merge block
(base, adapter, out, store_dtype, device_map, results, the merge-lora argv)
plus next steps. verify → <out>.parity.json, and only on PASS a checkpoint
artifact (path, base_model, adapter, store_dtype, structural_checks, parity).
Exit codes: 0 PASS (plan; verify only when all seven structural checks and parity pass),
5 RED (ME-HO-002/ME-HO-003), 95 UNMEASURED (ME-HO-004 — parity absent, not run, or too weak
to tell merged from base), 96 REFUSED (ME-IN-*; nothing written). A bf16 plan is still
PASS but carries the WARN ME-HO-001.
Merging is a local plan + verify; the merge itself runs on the GPU host through the universal launch gate:
fskills merge plan --base <base> --adapter <run>/final --out <merged-dir> [--store-dtype float32] [--device-map cuda:0]:
probes the merge and writes fs_launch_spec.merge.json. It never launches.fskills hash --spec <spec>: you read the hash. Then
fskills launch --spec <spec> --confirm <the hash you read> --no-submit runs FoundationScale's merge_lora.py
inside your allocation. Without the hash, the launch is refused (96).fskills merge verify --spec <spec> [--device cuda:0]: reads the seven structural checks and runs numeric parity on
the GPU. On PASS it writes the merged checkpoint.Run step 2 and step 3 on the leased GPU: CUDA_VISIBLE_DEVICES=<the leased GPU UUID> for a direct run, or inside
srun --overlap --jobid=<hold> --gres=gpu:N.
One LoRA or QLoRA adapter folded into the base it was trained on (LLM or VLM, any family FS's merge script loads: gemma4 and qwen3_5 are measured), on GB200, H100 or local. Combining several full models (TIES, DARE, SLERP soups) is out of scope. Training adapters belongs to fskills-training, and scoring the merged model to fskills-evaluation.
fskills merge plan
--adapter (required)--base (required)--device-map (default 'cpu')--out (required)--store-dtype (choices {float32,bfloat16}; default 'float32')--workdirfskills merge verify
--device (default 'cuda:0')--max-ratio--no-parity (default False)--spec (required)--workdir| Rule | Phase | Severity | Description |
|---|---|---|---|
| ME-HO-001 | handoff | WARN | plan: bfloat16 storage requested; sub-precision LoRA updates are rounded away (measured) |
| ME-HO-002 | handoff | BLOCK | verify: a structural check of the merge script failed (parameter counts, LoRA weights left, processor) - RED |
| ME-HO-003 | handoff | BLOCK | verify: numeric parity outside tolerance (merged does not reproduce base + adapter) - RED |
| ME-HO-004 | handoff | WARN | verify: parity not run, or the adapter's effect too small to tell merged from base - UNMEASURED, never PASS |
| ME-IN-001 | input | BLOCK | plan: base is not a model directory, or the adapter has no adapter_config.json/weights |
| ME-IN-002 | input | BLOCK | plan: the adapter was trained on a different base than the one declared |
| ME-IN-003 | input | BLOCK | plan: the output directory exists and is not empty (a merge never overwrites) |
| ME-IN-004 | input | BLOCK | plan: the merge cannot run here (FS merge script not found, peft/transformers/torch not importable, or not enough free disk) |
| ME-IN-005 | input | BLOCK | verify: the merge results JSON is missing or unreadable (the merge was not launched) |
checkpoint, fs_launch_spec
PASS 0 · RED 5 · UNMEASURED 95 · REFUSED 96
| Rule | Phase | Severity | When |
|---|---|---|---|
| ME-IN-001 | input | BLOCK | plan: base is not a model directory, or the adapter has no adapter_config.json/weights |
| ME-IN-002 | input | BLOCK | plan: the adapter was trained on a different base than the one declared (its base_model_name_or_path) |
| ME-IN-003 | input | BLOCK | plan: the output directory exists and is not empty (a merge never overwrites) |
| ME-IN-004 | input | BLOCK | plan: the merge cannot run here (FS merge script not found, peft/transformers/torch not importable, or not enough free disk) |
| ME-IN-005 | input | BLOCK | verify: the merge results JSON is missing or unreadable (the merge was not launched) |
| ME-HO-001 | handoff | WARN | plan: bfloat16 storage requested; sub-precision LoRA updates are rounded away (measured) |
| ME-HO-002 | handoff | BLOCK | verify: a structural check of the merge script failed (parameter counts, LoRA weights left, processor): RED |
| ME-HO-003 | handoff | BLOCK | verify: numeric parity outside tolerance (merged does not reproduce base + adapter): RED |
| ME-HO-004 | handoff | WARN | verify: parity not run, or the adapter's effect too small to tell merged from base: UNMEASURED, never PASS |
Measured on gemma-4-12B-it with the A4.4 16-frame LoRA adapter, on one GB200 GPU:
Parity: ratio = mean|merged − adapter| / mean|base − adapter| over fixed prompts, in fp32 forwards. PASS needs
ratio ≤ 0.1 and argmax agreement ≥ 0.95. An adapter effect below 1e-3 is UNMEASURED.
verify before the merge was launched: REFUSED (96) with ME-IN-005, which names the hash, then launch, then verify
steps.<out>.merge_results.json and the merge log.examples/vlm-2xH200/scripts/merge_lora.py (PEFT merge_and_unload, safetensors, seven
structural checks), run through fskills launch behind the confirmation hash.foundationskills.interfaces.fs.emit_merge (entry fskills-merge).foundationskills/skills/merging/parity.py.training.emit names this skill when a LoRA stage feeds a later stage.fskills merge plan --base gemma-4-12B-it --adapter runs/fskills-sft/final --out merged_fp32 --device-map cuda:0, then hash and launch, then fskills merge verify. Seven of seven structural checks pass, parity ratio is
4e-5 with agreement 1.0, and checkpoint.merged.json is written.verify gives RED with ME-HO-003 (ratio 0.237, agreement 0.915),
although every structural check passed.What SKILL.md sets; muted values are Claude Code's defaults
21 skills in this plugin
/fs-dataUser-invoked slash command: run ONLY when the user types /fs-data; never choose it on your own. Slash-command data preparation workflow (/fs-data) that composes the model skill data_engine to turn raw data refs into a dataset, data_pipeline_spec and readiness_report. Inputs: the data_engine request fields (sources, target_format, tokenizer, chat_template_family, out_dir, requirements, pipeline, reasoning_unsupported, benchmarks, ...) passed through unchanged, plus optional goal_spec (a path recorded in outputs, not interpreted). The workflow record says which step ran, what it produced and the verdict (PASS/RED/UNMEASURED). Do NOT use for explaining fskills results (use /fs-status), fixing data problems yourself, or training a model (use /fs-training): this composes data_engine and produces data artifacts only./fs-evalUser-invoked slash command: run ONLY when the user types /fs-eval; never choose it on your own. /fs-eval is the A3.2 user-invoked workflow skill: it takes the evaluation request (checkpoint, run_manifest, base, benchmarks, policy, eval_cache, out, baseline_cache, ...) and forwards it UNCHANGED to the ONE composed model skill `evaluation`, run through foundationskills.skills._workflow, then writes one workflow_record {workflow, steps, outputs, verdict} whose outputs name the eval_report BY PATH. Outcome mapping (PASS 0 / RED 5 / UNMEASURED 95 / REFUSED 96): inner REFUSED -> FE-IN-002 REFUSED; inner RED -> FE-HO-001 RED; inner UNMEASURED -> FE-HO-002 UNMEASURED (never PASS). Do NOT use for fixing a regression, running a bare lm-eval harness or judging launch-readiness: /fs-eval records the evaluation verdict, it never repairs a benchmark or tunes a policy.npx claudepluginhub trannhiem/foundationscale --plugin foundationskillsOther plugins' skills for the same job