# Run Whittle 9B with llama.cpp

Our llama.cpp fork adds Whittle 9B's ternary weights to llama.cpp as a new weight type, `WTG`, on the CPU and on Metal, so Whittle 9B runs in `llama-cli`, `llama-server` and `llama-bench` as one 2.5 GB GGUF. This quickstart builds the fork on a Mac and runs the model.

## What you need

- An Apple-silicon Mac with the Xcode command-line tools and CMake (`brew install cmake`). Other backends, such as CUDA and Vulkan, don't run `WTG` yet and fall back to the CPU.
- `whittle-9b-WTG2_0.gguf` from [whittle-9b-gguf](https://huggingface.co/literal-labs/whittle-9b-gguf) in `~/models/whittle/`, checked against its `SHA256SUMS` (see [Get the model](https://www.literal-labs.ai/docs/whittle/#get-the-model)).

Apps built on upstream llama.cpp can't load this GGUF: its weight type exists only in this fork.

## 1. Build

Clone the fork's `whittle` branch (its default; `master` is upstream llama.cpp, unchanged):

```sh
git clone --branch whittle https://github.com/literal-labs/whittle-llama.cpp.git
cd whittle-llama.cpp
```

Then build the tools. `HF_UI_VERSION` names the upstream release the fork is based on, so `llama-server` downloads that release's chat UI.

```sh
HF_UI_VERSION=b12484 cmake -B build
cmake --build build --config Release -j --target llama-cli llama-server llama-bench
```

## 2. Chat from the command line

Ask one question with every layer on the GPU (`-ngl 99`) and flash attention on (`-fa 1`), then exit (`-st`):

```sh
build/bin/llama-cli -m ~/models/whittle/whittle-9b-WTG2_0.gguf -ngl 99 -fa 1 --presence-penalty 1.5 -p "Explain why the sky is blue." -st
```

Leave out `-p` and `-st` for an interactive chat. The GGUF carries the model's sampling settings (temperature 1.0, top-p 0.95, top-k 20, min-p 0), so llama.cpp uses them unless told otherwise. A presence penalty can't be stored in a GGUF, so pass `--presence-penalty 1.5` yourself. Don't use `--temp 0`: greedy decoding loops in thinking mode.

To draft tokens with the model's MTP head, add:

```sh
--spec-type draft-mtp --spec-draft-n-max 1
```

## 3. Serve it

Start llama.cpp's OpenAI-compatible server, with its chat UI at [localhost:8080](http://localhost:8080):

```sh
build/bin/llama-server -m ~/models/whittle/whittle-9b-WTG2_0.gguf -ngl 99 -fa 1
```

Any OpenAI-compatible client works with the base URL `http://localhost:8080/v1`.

## Images

Images need the model's vision tower as an `mmproj` GGUF, published beside the model. Pass it with `--mmproj`:

```sh
build/bin/llama-server -m ~/models/whittle/whittle-9b-WTG2_0.gguf --mmproj ~/models/whittle/mmproj-whittle-9b-bf16.gguf -ngl 99 -fa 1
```

## Make the GGUF yourself

`convert_whittlebin_to_gguf.py`, in the fork, turns a `.whittlebin` into a GGUF. `--hf-dir` is a folder with Qwen3.5-9B's `config.json`, `tokenizer.json` and `tokenizer_config.json`, and the script needs the packages in `requirements/requirements-convert_hf_to_gguf.txt`.

```sh
python3 convert_whittlebin_to_gguf.py ~/models/whittle/whittle-9b-WTG2_0.whittlebin --hf-dir ~/models/Qwen3.5-9B --outfile ~/models/whittle/whittle-9b-WTG2_0.gguf
```

## Next

The fork's `docs/whittle.md` describes the `WTG` format, how its output is checked against the Whittle engine, its speed, and what is not done yet. Everything else is llama.cpp's own documentation.
