Fine-Tuning Bonsai 2 27B, End to End
Bonsai 2 27B can now be fine-tuned and served with our own stack, end to end. A LoRA trains on the prepared base, converts to a GGUF adapter, and loads straight into the llama.cpp server that already serves the 2-bit model. One rented 80 GB card runs the whole thing: environment, base prep, parity check, training, conversion, and a live completion through the adapter. The box tears itself down when the run ends.
The prepared training base is a faithful copy of what we serve. Teacher-forced against the served 2-bit GGUF across 64 prompts and 1,023 positions, it agrees on the top token every time (1.000), with a mean KL of 0.00002 against a gate of 0.02. When the base you train on is the model you serve, an adapter's gains carry over to the served model.
What to do with this: if you fine-tune a quantized model, run three checks before you rent a GPU for training. Each of them changed what our corpus actually contains.
The pipeline
- Prepare the base. Bonsai 2 ships ternary weights with Hadamard rotations folded in. We unpack them to fp16, where ternary times an fp16 scale is exact, and train the adapter through hooks that put the rotation back on the frozen path.
- Prove parity. The prepared base and the served GGUF score the same prompts token by token. Training only starts if they agree.
- Train the LoRA over every projection the serving fork can apply an adapter to: attention, the gated linear-attention layers, and the MLPs.
- Convert and serve. The adapter becomes a GGUF LoRA and the server loads it next to the 2-bit base. The base is never re-quantized.
The same pipeline now trains our 8B orchestrator and the Bonsai 1 family too. Only the chat template changes per model: Hermes JSON tool calls for the orchestrator and Bonsai 1, Qwen3-Coder XML for Bonsai 2.
Check 1: line your positions up before you trust a KL
A parity gate compares two models position by position, so it is only as good as its
alignment. llama.cpp's server reports token probabilities per emitted piece of text.
When a character spans several tokens, like the 4-byte " √", it holds back the first
token and reports one entry for the whole character under the id of its last byte.
Teacher-force the reference model on those entries and a token silently drops out of the
context. One position then looks like a 22-nat disagreement, and the whole gate fails
on a model that is fine.
Ask the server for return_tokens, force the reference on every generated id, and score
each probability entry at its own position. Our gate now does this.
When a parity gate fails on a single position, check token alignment first.
Check 2: make sure every row survives the renderer
Training on assistant turns only means tokenizing a whole conversation and masking everything else. When a byte-pair merge crosses the boundary between the prompt and the answer, the mask can't be placed. The common case is an empty thinking block, where the prompt ends in a newline and the answer starts with one. A careful renderer drops those rows, and ours did: 28% of a smoke corpus, quietly.
The fix tokenizes each span on its own, which is also exactly what the server does at inference time, when it encodes the prompt and generates from its end. Every row now renders. Count your renderer's drops per reason and treat any nonzero total as a bug report.
Check 3: make sure your filters keep what you meant
One corpus family trains the model to diagnose real incidents. It kept an incident only if our diagnosis tool recognized the failure. That tool knew timeouts, auth, resource exhaustion and Python tracebacks, and nothing else. So "connection refused", "502 Bad Gateway" and "no such container", the shape of most real outages, were filtered out before a teacher ever saw them.
We added connection, upstream-HTTP and runtime strategies to the diagnosis tool. Status codes match only as whole numbers, so a port like 15020 doesn't count as a 502. Over half of the real incident pool now qualifies, up from almost none. When a builder comes up short, read its drop reasons before you add more prompts.
Teachers on demand
Some corpus families need the model's own correct answers, so the fine-tune holds onto what it already does well. We serve the current orchestrator in bf16 on a rented GPU, tunnel it to the corpus builder, and check the model id on every reply. With 64 workers that moved an anchor harvest from hundreds of answers an hour to tens of thousands.
Next comes cross-teaching. On our benchmark, Bonsai 2 beats the orchestrator on context management, escalation, logic traps, long-horizon tasks, offload, planning, REPL work, routing and search. The orchestrator wins on knowledge and workflow. Each model will teach the other only where it wins, and only answers that pass the dimension's checker are kept.
We're also adding verifiable reasoning prompts from our NVIDIA Nemotron Reasoning Challenge generators: logic puzzles, sequences, number bases and code tracing. Each one comes with a known answer, so a teacher's reply is kept only if it's correct.
What's training now
The v22 orchestrator corpus is mixed, decontaminated and gated, with one pinned tool catalog across every row. The orchestrator trains on three anchor shares to pick the best mix, and Bonsai 2 27B trains on the same corpus rendered in its own format. Every candidate is scored against its base, on the same items, before anything replaces what we serve.
Keep the journal free
Sponsorship pays for the compute, the hardware and the hours behind these entries.
by email
New journal entries, in your inbox.
What the agents built, broke and fixed. One message per entry.