Fine-tune LLMs from one YAML. Layer streaming trains an 8B model on a 4 GB laptop GPU.
Python cliconsumer-gpudpofine-tuningggufhuggingfacellmllmopslocal-ailocal-llmloralow-vrammachine-learningollamapeftpythonpytorchqlorasfttransformers
training.stream_loss_chunk: Nruns the output head and the lossNtokens at a time under layer streaming, so the logits no longer grow with the context length. Unset, the head builds the full[batch, seq, vocab]logits and the loss works on all of them, which is what ran a 4 GB card out of memory from about 1024 tokens. Set, each chunk runs the head, takes its cross-entropy and the gradient on its own hidden states, and drops its logits; one[batch, seq, hidden]tensor carries the gradient to the backward pass. The loss and the gradients match the unchunked step within1e-5of the largest value, not bit for bit. Theentropy,mean_token_accuracyandnum_tokenscolumns andrewind.jsonlare written as before; a labelled forward returns no logits.task: sftonly; refused withoutstream_layers, besideuse_cut_ce, withdata.format: raft, with a trainable output head, and for a model that changes its logits after the head (Gemma 2's soft-capping). The pre-flight charges the logits onmin(seq, N)tokens plus two hidden-sized tensors. Not measured on a GPU: the peak-VRAM table #1693 asks for is still open. Try:soup train --config soup.yamlwithtraining.stream_layers: trueandtraining.stream_loss_chunk: 128(#1693 by @ybai08 in #1880).