Spectrum targeted training (v0.71.23)
Spectrum picks the layers worth training. Instead of a full fine-tune (every weight) or a blanket LoRA (every layer, low rank), soup spectrum scan ranks each weight matrix by its signal-to-noise ratio and lets you full-fine-tune only the high-signal layers. You get most of the quality of a full fine-tune at a fraction of the memory and compute.
The reference Spectrum implementation needs the model on a GPU to scan its layers. Soup's scanner streams the
.safetensorsshards one tensor at a time, so it never loads the model. Peak RAM is the largest single weight matrix, which means you can scan a 70B on a laptop CPU.
Which files are the checkpoint (v0.77.0, #1806, #1906). The scan reads the files model.safetensors.index.json names; without an index, model.safetensors, else the model-*-of-*.safetensors shards, else every *.safetensors except consolidated*, and the Hub download fetches by the same rule. Before this release it read every top-level *.safetensors, so on a Mistral repository that ships a consolidated.safetensors (the mistral-inference copy transformers never loads) beside the shards it downloaded both and, in upstream's words, "scored both name sets", emitting unfrozen_parameters "matching no parameter". A directory holding only a consolidated file is now refused with its name.
Scan a model
soup spectrum scan --model meta-llama/Llama-3.1-8B --top-percent 50# write the patch straight to a file, restrict to specific module types
soup spectrum scan --model ./my-merged-model \
--top-percent 25 \
--modules mlp,attn \
--output patch.yaml| Flag | Default | Description |
|---|---|---|
--model | (required) | HF Hub id or local path. Streamed shard-by-shard, never loaded. |
--top-percent | 50 | Keep the top N% of layers by SNR, per module-type group. |
--modules | all | Restrict the scan to mlp, attn, or a comma list. |
--output | (stdout) | Write the training.unfrozen_parameters block to a file (kept under cwd). |
--no-cache | off | Skip the scan cache at ~/.soup/spectrum/<slug>.json. |
The command prints a per-group SNR table and a ready-to-paste config block.
Train on the result
The scan emits a training.unfrozen_parameters list of regex patterns. Drop it into your soup.yaml:
base: meta-llama/Llama-3.1-8B
task: sft
data:
train: ./data/train.jsonl
training:
quantization: none
unfrozen_parameters:
- "model.layers.(2|5|8|11).mlp.down_proj"
- "model.layers.(2|5|8).self_attn.v_proj"soup train --config soup.yamlThe SFT trainer freezes every parameter, then unfreezes only the matched set. This is a full fine-tune of a subset of layers (the matched weights train at full precision), not LoRA.
How the SNR ranking works
For each weight matrix, Spectrum takes the singular values and applies a Marchenko-Pastur noise threshold (arXiv:2406.06623): singular values above the random-matrix noise floor carry signal, the rest are noise. The ratio of signal energy to total energy is the layer's SNR. Layers are ranked within each module-type group, so attention and MLP layers compete with their own kind rather than against each other.
The kernel is pure-numpy and transpose-invariant (the singular values of W and W.T are identical), so GPT-2 Conv1D weights (c_attn / c_fc / c_proj) are recognised alongside Llama-style nn.Linear names.
Constraints
training.unfrozen_parameters requires a full-precision SFT run and is mutually exclusive with the LoRA stack and the other layer-selection knobs:
- requires
task: sft,backend: transformers,modality: text,quantization: none - mutually exclusive with LoRA features,
freeze_layers,freeze_ratio,train_router_only,expand_layers, andstream_layers(streaming keeps the base frozen on themetadevice, so there is nothing for Spectrum to unfreeze) - since v0.77.0 also refused beside it:
use_mod: true, because SFT installs no Mixture-of-Depths router on this route (#1752), andtraining.fast_lora(#1973)
soup profile budgets a Spectrum run as a full fine-tune of the model since v0.77.0, with optimizer state and gradients (#2041); through v0.76.1 it reported 0 trainable parameters and 0 GB of optimizer memory.
Since v0.77.1 soup profile, the soup train pre-flight, soup plan and the MCP profile tool price a run with one estimate (see Pre-flight tooling), and it counts every parameter of a Spectrum run as trainable, so its gradient and optimizer-state terms include parameters the run freezes. The pre-flight's refusal applies only inside the range the estimate was fitted on ("dense models of 3B and below on one 6 GB card"). Outside it the figure is printed as a warning and the run starts, unless the weights and the CUDA context alone are more than the card holds: for a full fine-tune of a subset of the parameters, those two are all the check counts.
Patterns are validated at parse time: null bytes and empties are rejected, with caps on count (50k) and length (512). Since v0.75.1 the regex check is the shared structural one, which parses the pattern and refuses nested or alternating repetition, backreferences and more than three unbounded repeats, without ever matching with it. The guard it replaced was a single hand-written expression that caught (x+)+y and missed ((.+))+z, (.+){2,}z and (?:.|.)+z, all of which backtrack exponentially against a parameter name. Hub downloads route through the SSRF-hardened, namespace-pinned loader; symlinked shards and matrices above a 2^31-element SVD cap are skipped, and --output stays under the working directory.
A Hugging Face cache snapshot has weights that are symlinks into the cache's blobs store, which the scanner skips, so Soup first copies such a snapshot to regular files under its spectrum cache (~/.soup/spectrum/weights/, or under SOUP_SPECTRUM_CACHE_DIR) and reuses the copy while the snapshot is unchanged. As of v0.76.0 that copy step also accepts a local path to a snapshot (.../models--org--name/snapshots/<commit>) and the cache-wide shared blob store that huggingface_hub 1.32 and later use, and it refuses a blobs directory that is itself a link (#1629). This paragraph is read from the code, not run.
Re-run this
| If you trained | What was wrong | What to do |
|---|---|---|
Spectrum from a soup spectrum scan of a Hub repository that ships consolidated.safetensors beside its shards (Mistral's do), before v0.77.0 | The scan scored both name sets and emitted unfrozen_parameters matching no parameter of the model (#1806, #1906) | Scan again on v0.77.0 and re-train |
See also
- Lean install + live wiring (v0.71) — the release line Spectrum caps off.
- LoRA quality — when a blanket low-rank adapter is the better trade-off.
- Optimizer & PEFT zoo — freeze ratios, LLaMA Pro, and the rest of the parameter-efficiency menu.
Soup is free and Apache-2.0. If it saved you a training run, starring the repo costs nothing and helps most. You can also fund the GPU time behind the work a 4 GB laptop cannot reach.