Skip to content

Training Speed & Memory

Soup v0.28.0 shipped six throughput and memory features. They were SFT-only in v0.28, a gate lifted in v0.33 and finished in v0.35; tasks outside the 13-task allowlist (see Which tasks below) are still refused at config load, so a task that would ignore these keys is refused rather than allowed to ignore them. At v0.76.0 two of the features below changed: FP8 training now stops a run that cannot do FP8 instead of training on in bf16, and kernel_auto_compose: true is refused at config load. Gradient checkpointing tiers now differ on task: sft, and cross-document attention masking is a refused key, not a working mask. At v0.77.0 training.gradient_checkpointing reaches every trainer, so its default false now means off on tasks where TRL's default used to apply (see below), use_cut_ce is refused with layer streaming, and use_liger reports itself enabled only where Liger has kernels.

If the model does not fit at all, none of these six is the answer. They shave a resident run; they cannot make a model smaller than your card. For that, see layer streaming: the frozen base never loads resident, so peak VRAM is bounded by one decoder layer instead of the whole model, and Llama-3.1-8B fine-tunes on a 4 GB card. Since v0.72.4 that covers preference losses too, not just supervised fine-tuning. It is BETA, and it is slower than resident training, so reach for it only when resident training is impossible.

Cut Cross-Entropy

yaml
training:
  use_cut_ce: true

Cut CE avoids materialising the full [seq_len × vocab_size] logits tensor during the cross-entropy backward pass. Biggest expected win on models with vocab ≥ 128k (Llama 3, Qwen 3), when it engages (see the log note below). Architecture detection reads config.model_type first, so a local checkpoint directory resolves as correctly as a hub id; a substring match on the last path component (model_name.rsplit("/", 1)[-1]) is only the fallback when no config can be read. That order was the v0.74.0 repair: before it, name matching came first, so a soup merge output called checkpoint-2000 matched nothing and cut-cross-entropy stayed off on a flag you had explicitly set. It also means org prefixes like deepseek-ai/...-phi-... can't trigger the wrong patcher.

Install the optional dep:

bash
pip install "soup-cli[cce]"

Check the log: it may not engage. use_cut_ce patches the model only if the third-party cut_cross_entropy.transformers.cce_patch imports. When it cannot, or no patcher matches the architecture, the run continues without it and prints a yellow Cut Cross-Entropy: no matching architecture or cut_cross_entropy not installed. That line is also what you see when the package is installed and an import inside it fails, and nothing checks beforehand that the package is present. A success prints Cut Cross-Entropy enabled. The v0.73.0 probe record (see Measurement records) could not make the flag engage on any pip-installed stack it tried: cut-cross-entropy 25.1.1 ships no transformers submodule, and 25.9.3 failed importing symbols that transformers 4.57.6 no longer exports. That was measured on transformers 4.57.6, not on the 5.x that v0.76.0 and later require, and it has not been re-measured, so whether the current cut-cross-entropy release engages on transformers 5.x is unverified at v0.77.0. Treat the memory saving as unproven until your own log says it is enabled.

use_cut_ce is refused with training.stream_layers: true since v0.77.0 (#2023): the streamed setup never installs the resident Cut Cross-Entropy patch, so on v0.76.x the flag loaded there and did nothing. Set use_cut_ce: false to stream, or train resident. Removing the line from such a config changes nothing about what trained.

FP8 training (Ada and newer)

yaml
training:
  quantization_aware: fp8
  fp8_recipe: tensorwise   # tensorwise | rowwise | rowwise_with_gw_hp

fp8_recipe picks the torchao scaling recipe and defaults to tensorwise (one scale per tensor). rowwise scales per row, and rowwise_with_gw_hp is rowwise with the weight gradient kept in high precision. The source describes tensorwise as the fastest and the two rowwise recipes as more accurate; none of that has been measured here. The key is refused unless quantization_aware is fp8, and a value outside those three is refused at config load.

Configures float8 linear layers via torchao. The key's literal accepts false, "fp8" and "quest" (the experimental route covered under Backends); true is the refused int8 QAT, and unknown strings like "fp16" are rejected at config load.

FP8 needs CUDA and a card of compute capability 8.9 or higher: RTX 40/50-series, L4, L40S, RTX 6000 Ada, H100/H200 and B100/B200. Through v0.75.2 this page said Hopper and said Soup did not check at launch. v0.76.0 checks, at setup before the model loads, and stops the run with the reason when this card, OS or torch build cannot run it (FP8HardwareUnsupportedError); a missing torchao stops it the same way (FP8DependencyMissingError, naming pip install "soup-cli[qat]"), and so does a float8 conversion that fails, which quotes torchao's error. Before v0.76.0 the trainers printed a yellow advisory and trained in bf16 under a config that said FP8 (#835), so if you ran quantization_aware: fp8 or fp8_attention: true on a card or torch build that could not do it, the run was a bf16 run. quantization_aware: fp8 is refused at config load on backend: mlx and backend: unsloth and with stream_layers: true, as are fp8_attention and nvfp4. soup train --dry-run prints this machine's card as a note and exits 0, because FP8 configs are often written for another machine; a missing torchao still fails it. The [qat] extra declares torchao>=0.18.0 since v0.76.0 (it was >=0.4.0), so an older torchao is no longer accepted by the extra: run pip install -U "soup-cli[qat]".

tensorwise has no further limits. rowwise and rowwise_with_gw_hp run a separate torch kernel, so they also need a torch that dispatches it on your card, and they are never built on Windows. Before torch 2.11 that kernel is only built against CUDA 12 or newer. By compute capability: Ada (8.9) needs torch 2.7 or newer; Hopper (9.x) and datacenter Blackwell (10.x) work on any supported torch; the RTX 50-series (12.x) needs torch 2.8 or newer; 11.x needs torch 2.10 or newer. No torch release checked through 2.14 runs it on 13.x. This is a table transcribed from torch's source, not queried from torch.

Tiered gradient checkpointing

yaml
training:
  gradient_checkpointing: auto   # or: selective | medium | full

The schema accepts false, true, selective, medium, full and auto. On task: sft (and tts, which trains through it) the tiers differ since v0.76.0: full checkpoints every block; medium uses Transformers' native every_n_layers=2 path, which checkpoints every other block; selective wraps each decoder block's direct attention module and leaves Hugging Face's full-model checkpointing off, so nothing is recomputed twice. If an architecture exposes no direct attention child, Soup prints that selective is unavailable and applies full. auto picks full below 24 GB of VRAM, medium from 24 to 80 GB and selective above 80 GB. The other task wrappers read the key as on or off: any enabled tier is full checkpointing there, and the tier name changes nothing. Through v0.75.2 that was true of every task that read the key at all. The per-tier slowdowns in the source comments (about 30% for full, about 10% for selective) are upstream's estimates, not measurements, so no per-tier memory or speed figure is published here. The VRAM estimate behind the soup train pre-flight (v0.77.1) prices selective as no checkpointing, an upper bound, and medium from the per-layer costs measured with checkpointing off and on; neither tier is itself measured, so a run on either tier that the estimate says does not fit gets a warning rather than a refusal (see the hardware-fit calculator).

On a 4bit, 8bit or mxfp4 run, gradient_checkpointing: false was silently overridden to on through v0.75.2, because the k-bit preparation step used peft's default of checkpointing on (#797). Since v0.76.0 the setting is honoured there (fifteen call sites now pass it through), so a config that relied on the override can use more VRAM than it did. This covers that preparation step only.

Since v0.77.0 the key reaches the trainer, so false now means off. training.gradient_checkpointing now reaches the trainer. With the default false, grpo, ipo, bco, reward_model and online_dpo train with checkpointing off (TRL's own default used to apply), and on backend: unsloth false now disables Unsloth's checkpointing. Set training.gradient_checkpointing: true to keep the memory you had. distill, classifier, reranker, cross_encoder, asr and unlearn now honour true too (#1778, #1981, #2140). Upstream's shipped recipes, templates and examples for the first five tasks now set true (#1923). On those tasks, as on the other non-SFT wrappers, any enabled tier is full checkpointing. Through v0.76.1 the first five never passed the key to TRL, so a config that never set it trained with checkpointing on; the second six ignored it and always trained with it off; Unsloth always used its own kernel. No memory figure is published for the change.

When stream_layers is on, Soup leaves Hugging Face's checkpointing off, because the streamed layers already recompute; see layer streaming.

Resident 4-bit and 8-bit: embeddings and norms stay in bf16 (v0.78.0)

Through v0.77.2 the default resident 4-bit or 8-bit SFT path called PEFT's prepare_model_for_kbit_training, which cast every parameter that is not quantized (the embedding, the norms and an untied output head) to float32. Since v0.78.0 (#2609, #2683) a CUDA card with bf16 hardware casts back to bf16, right after that call, the parameters that loaded as bf16 (one that loaded as fp16 or fp32 keeps float32), so those take 2 bytes a parameter instead of 4. A card without bf16 hardware, the CPU, grpo_fp16 and an fp16 auto_mixed_precision pick keep PEFT's float32. The logits term of the VRAM estimate is unchanged.

Upstream recorded one measurement of the change (benchmarks/gate-2609-kbit-fp32-ab.md, written down before the run): one rented RTX 4090 with a 450 W power cap, Qwen2.5-7B-Instruct in NF4 with double quantization, LoRA r16 on all seven projections, batch 8 x 512 tokens, gradient checkpointing, three seeds. The unprofiled median step went from 2.2562 s to 1.6949 s (24.9% shorter), and the allocator peak from 17,425 MiB to 13,520 MiB, 3.8 GiB lower, with the loss inside the tolerance the record set beforehand. It is an A/B on soup-cli 0.77.2 with PEFT's function wrapped by the harness (the record's arm B), not a run of the v0.78.0 code. The scope travels with the figures. 8-bit, tied embeddings, other model families and batch shapes, another card, a 400 W cap and the cast-back together with a fused loss path (Liger was measured alone) were not measured. The record's own verdict on whether the float32 cast is the whole cause is PARTIAL: the cast accounts for 63.7% of the 818 ms elementwise gap, against a bar of 70%, and the three float32 logits tensors (7,128 MiB, more than half of the peak after the change) are untouched. Upstream lists this change among those that make a run not bit-comparable with v0.77.2; it is not a repair of a wrong result, and the adapter you trained was a correct adapter.

Kernel auto-composition (refused since v0.76.0)

training.kernel_auto_compose: true is refused at config load (#801): kernel_auto_compose is not supported: it benchmarks the same already-loaded model for every candidate and does not apply the selected flags. false, the default, still loads. Through v0.75.2 the key was accepted: it enumerated the installed combinations of Liger Kernel, FlashAttention and Cut Cross-Entropy, timed a few forward passes per candidate and printed Kernel auto-compose picked: <name>, but it never applied the pick (nothing set use_liger, use_flash_attn or use_cut_ce from the result, and the SFT trainer never called it at all), and the timing loop did not switch kernels between candidates. Set the kernels explicitly instead:

yaml
training:
  use_liger: true       # task sft or tts only
  use_flash_attn: true  # task sft or tts only

Both keys are refused at config load on any other task. Since v0.77.2 (#2278, by @abdulwaarith0) they are also refused inside task: sft on the paths that never read them: with backend: unsloth, modality: vision or modality: audio (a value of false loads; on backend: mlx the loader accepts them, but soup train stops on them before the MLX trainer starts, exit 1, and stream_layers: true has its own refusal). Which settings are refused on which path is in the table on Settings Soup refuses at load. Check the log for Liger too. Since v0.77.0 use_liger: true takes effect only for a config.model_type in Liger's own kernel table; for any other type (gpt_neox, phi, gpt2, ...) the run prints Liger Kernel: no matching architecture found and trains without it (#1947). Through v0.76.1 such a run printed Liger Kernel enabled with no kernel applied, and a phi model could be patched as Phi-3 because of its name.

The soup train VRAM pre-flight cannot know whether a fused loss applies, so with use_liger or use_cut_ce set on sft or tts it still charges the full logits term; the estimate says it may overstate the peak, and such a run that does not fit gets a warning instead of a refusal (v0.77.1).

Measured: Liger and FlashAttention on one H200 (v0.78.0)

use_liger and use_flash_attn have a second record since v0.78.0, taken on one H200 that other jobs shared (benchmarks/flash-liger-h200-2026-11-10.md, issue #378). Setup: Llama-3.1-8B, resident bf16 base, LoRA r16 on all seven projections, batch 4, sequence lengths 1024 to 8192 with gradient checkpointing off and on, five fresh processes per cell, 80 measured updates after 5 warm-up updates. Results are ratios of five-run medians to the default SDPA step: Liger alone ran at 1.197 to 1.229x with 21.6 to 54.7% less allocated peak; FlashAttention 2 alone at 0.929 to 0.989x with about the same peak; FlashAttention 2 plus Liger at 1.096 to 1.195x, below Liger alone in every feasible cell. Eight probe runs ran out of memory (gradient checkpointing off at 4096 and 8192 tokens, all four arms), so those cells have no ratio.

The riders are the record's: these are ratios on one model, one fixture, one stack and a card shared with other jobs, "not universal speedups or a training-quality recommendation"; the SDPA baseline already ran fused cuDNN attention kernels, so FlashAttention 2 gaining nothing says something about that baseline and not about attention in general; no held-out quality was evaluated; an out-of-memory here is a shared-session headroom failure, not a capacity limit of the card. The Liger path also disables Soup's logits-based rewind recorder, because its fused loss exposes no logits. It does not reproduce or replace the earlier H100 point (12.9% less VRAM, 1.051x throughput, v0.73.0), and it changes no default. This site publishes no FlashAttention 3 figure.

Cross-document attention masking

yaml
training:
  packing: true      # this is the whole answer

When sample packing is on, documents in one packed sequence must not attend across each other. That isolation is TRL's default bfd strategy, and you get it by setting packing: true with a FlashAttention attn_implementation. There is no second flag to set.

packing_cross_doc_attn_mask is refused at config load since v0.75.0, and it never worked before that. Soup mapped it to TRL packing_strategy="attention_free", which has never been in TRL's allowlist on any released version, so the flag was a TypeError at trainer setup rather than a working mask. It is now rejected by a @model_validator that names bfd / bfd-requeue / wrapped as the real allowlist and points at packing: true. This is a false-capability correction, not a regression: no release ever built that mask. Remove the key from any config that carries it.

Activation offloading

yaml
training:
  activation_offloading: cpu    # or: disk

Saved-tensor hooks offload activations to CPU RAM (cpu, an ordinary pageable copy, not pinned memory) or an on-disk scratch dir (disk). The disk variant keeps the mkstemp file descriptor open until torch.save flushes, closing the TOCTOU window between os.close(fd) and torch.save(path). torch.load(weights_only=True) prevents arbitrary Python deserialization on reload. Scratch dirs are containment-checked against cwd. backend: mlx is refused at config load. backend: unsloth is not: the schema refuses only quantization_aware: fp8 there, and whether the offload hooks take effect on Unsloth was not checked.

The VRAM estimate does not model it, and since v0.77.2 says so (#2331, by @ybai08): when activation_offloading is set, the soup train pre-flight, soup profile (text and --json), soup plan and the layer-streaming plan panel report that the activation term is still charged as if every saved tensor stayed on the card, because what cpu or disk offloading moves off it is not modelled. The estimate and the decision to refuse or warn are unchanged, so the figure for such a run is the one for a run that keeps its activations on the card.

Fast-LoRA kernels (v0.77.0)

training.fast_lora: true runs a LoRA's projections through Soup's own autograd functions instead of peft's modules, off by default, on task: sft with backend: transformers, text, quantization none or 4bit, and lora.dropout: 0 (#792). Upstream's statement: the correctness checks were run on CPU (float32 and float64 against peft), its correctness half is still listed as open (#792), and no speedup and no end-to-end result is claimed. Two CUDA readings exist since v0.78.0 and they point in different directions: the benchmarks index records one run of the Q/K/V harness on an RTX 3060 Laptop (two passes of three processes per cell, taken at main before #2383 landed: faster in all eight cells, fast over plain 0.8798 to 0.9779, peak allocated memory 32 to 37 MB lower; the index says the four NF4 cells are to be run once more after #2383; no record file, the results are in two GitHub issue comments), and the T4 record of one SwiGLU block found no measurable difference in time and a higher peak allocated memory for Fast-LoRA in both dtypes, with a cause upstream calls unknown. Both are one block on one card, so this site claims neither a speedup nor a saving. Two kernel changes in v0.78.0 (#2383, #2546) make a fast_lora run not bit-comparable with v0.77.2. Scope, refusals and what was checked are on LoRA quality.

Which tasks

use_cut_ce, quantization_aware: fp8 and activation_offloading were SFT-only in v0.28. Multi-trainer wiring landed in v0.33.0 and every transformer-backend trainer was wired in v0.35.0. fp8_attention and nvfp4 (the Quant Menu II keys) arrived later and use the same task allowlist. At v0.77.0 all five are accepted for 13 tasks (sft, dpo, pretrain, grpo, kto, orpo, simpo, ipo, bco, preference, ppo, reward_model, embedding) and refused at config load for the other ten (prm, tts, classifier, reranker, cross_encoder, distill, unlearn, moe_lora_routing, online_dpo, asr), and on backend: mlx; quantization_aware: fp8, fp8_attention and nvfp4 are also refused on backend: unsloth and with stream_layers: true, and since v0.77.0 so is use_cut_ce with stream_layers: true. See multi-trainer speed and memory for the per-trainer wiring.

See also

  • Multi-GPU mastery — ZeRO++ / FSDP2 / pipeline
  • Backends — transformers / unsloth / MLX
  • LoRA quality — Fast-LoRA kernels (training.fast_lora, v0.77.0)
  • soup bench — soup bench train runs a fixed number of steps and fails when the model was not training; before you compare two throughput numbers from it, note that thirteen runs of one byte-identical config spanned 2.43x in upstream's reference run

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.