Export fine-tuned models to GGUF and deploy on Ollama
After training with Soup CLI, export your model to GGUF format and serve it locally with Ollama in three commands.
0. Build llama.cpp first, if you want a quantized GGUF
Soup auto-clones llama.cpp (pinned at tag b5270) into ~/.soup/llama.cpp on first use, but it does not build it. Converting to f16 or f32 works from the Python script alone. Every quantized type additionally needs the llama-quantize binary, so build it once:
cd ~/.soup/llama.cpp
cmake -B build -DGGML_NATIVE=OFF -DLLAMA_CURL=OFF -DCMAKE_BUILD_TYPE=Release
cmake --build build --config Release --target llama-quantize -j 4Soup finds the binary in both the single-config layout (build/bin/llama-quantize, from Make or Ninja) and the multi-config one (build/bin/Release/llama-quantize.exe, from MSVC or Xcode), or on your PATH. To use a checkout you already have, pass --llama-cpp /path/to/llama.cpp or set LLAMA_CPP_PATH.
On Windows the validated toolchain is Visual Studio 2022 Build Tools with the "Desktop development with C++" workload plus CMake 3.14 or newer, CPU-only. Linux and macOS need only a C++ toolchain and CMake. CUDA builds of llama.cpp are untested.
Do not run
pip install -r ~/.soup/llama.cpp/requirements.txt. It pinstorch~=2.2.1against the CPU wheel index, so it will downgrade a CUDA PyTorch and break training. Soup deliberately installs only the convert script's own extras (gguf,sentencepiece,protobuf), unpinned.
1. Export to GGUF
soup export --model ./runs/my-model \
--format gguf \
--quant q4_k_m \
--output ./my-model.ggufQuantization levels:
| Quant | Size (7B) | Quality | Use case |
|---|---|---|---|
q4_k_m | ~4.1 GB | Good | Default — best size/quality balance |
q5_k_m | ~4.8 GB | Better | When you need higher accuracy |
q8_0 | ~7.5 GB | Near-lossless | Benchmarks, eval |
q4_0 | ~3.8 GB | Lower | The smallest rung --quant accepts |
f16 / f32 | ~14 GB / ~28 GB | Unquantized | A conversion with no quantization step |
--quant accepts exactly these six values (q4_0, q4_k_m, q5_k_m, q8_0, f16, f32) and exits 1 on anything else, so the smaller llama.cpp rungs like q2_k and q3_k_m are not reachable through Soup.
2. Deploy to Ollama
Soup CLI ships with Ollama integration (v0.18.0+):
soup deploy ollama \
--model ./my-model.gguf \
--name my-model \
--template chatmlThis creates an Ollama Modelfile, imports the GGUF, and registers your model.
3. Chat
ollama run my-modelOr via the API:
curl http://localhost:11434/api/generate -d '{
"model": "my-model",
"prompt": "Hello!"
}'One-liner: train → export → deploy
soup train --config soup.yaml && \
soup export --model ./output --format gguf --quant q4_k_m --output ./my-model.gguf && \
soup deploy ollama --model ./my-model.gguf --name my-model --yessoup train writes to the config's output: directory (./output unless you set it), and there is no latest subdirectory, so point --model at that directory. Without --output, soup export names the file <model-name>.<quant>.gguf and writes it next to the model directory (./output.q4_k_m.gguf), not inside it, so pass --output when a later command has to find the file. --yes skips the confirmation prompt of soup deploy ollama.
Running the llama.cpp programs with soup llama
soup llama <subcommand> [args...] starts one of five llama.cpp programs and forwards your arguments to it unchanged:
| Soup command | Program it starts |
|---|---|
soup llama cli | llama-cli |
soup llama mtmd-cli | llama-mtmd-cli |
soup llama gguf-split | llama-gguf-split |
soup llama server | llama-server |
soup llama quantize | llama-quantize |
soup llama quantize ./my-model.f16.gguf ./my-model.Q5_K_M.gguf Q5_K_M
soup llama server -m ./my-model.gguf --port 8080The arguments are llama.cpp's own syntax, not Soup's, and they depend on the llama.cpp build you installed. A few things are Soup's:
- The program must be on your
PATH. It is looked up by name only. SettingLLAMA_CPP_HOMEdoes not make Soup find it, and neither does the~/.soup/llama.cpp/build/bindirectory from step 0 above:soup exportsearches that directory itself,soup llamadoes not, so add it toPATHfirst. - When the program is missing the command prints
llama-quantize not found on PATH; install llama.cpp or set LLAMA_CPP_HOME(with the name of the program you asked for) and exits 2. --helpafter the subcommand shows Soup's help, not the program's. Run the program itself for its own options.- Arguments are limited: at most 64, each at most 1024 characters, with no NUL or line break in any of them. Otherwise it exits 2 before starting anything.
- The program runs with a reduced environment.
HF_TOKEN,OPENAI_API_KEYand every other variable outside a short allowlist are dropped (the list is in the CLI reference). Its output goes straight to your terminal and its exit code becomes the exit code ofsoup llama.
Other export formats
Soup CLI also supports:
- ONNX —
--format onnxfor cross-platform inference - TensorRT-LLM —
--format tensorrtfor NVIDIA optimized serving - AWQ / GPTQ —
--format awqor--format gptqplus--calibration-data <calib.jsonl>(required for both) for quantized GPU inference - Hugging Face — not an export format. A merged checkpoint comes from
soup merge --adapter <path> --output <dir>. The formatssoup exportaccepts aregguf,gguf-ud,onnx,tensorrt,awq,gptq,bitnet,tq1_0andtorchao.
Related
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.