Experimenting with Ternary Model Fine-tuning for Agentic Coding
professormunchies · reddit · 2026-07-19
The author attempts post-training fine-tuning on true ternary/binary low-bit models like PrismML Bonsai 8B, aiming to make it function more like an agentic coding model, and tests it on 10 Python issues from SWE-rebench-v1.
Key Background
- Bonsai is not pre-trained from scratch using the BitNet approach; instead, it converts existing Qwen3 models into ternary/binary weights.
- The ternary model is approximately 1.7 bits/weight, meaning the 8B version takes up only about 2GB.
- This is not a standard GGUF quantization. Calibration methods for quantization error like imatrix/AWQ/GPTQ are essentially ineffective because the checkpoint itself is scale × {-1,0,+1}.
Fine-tuning Method
- Continued training uses standard QAT: weights are ternarized during the forward pass, and a straight-through estimator is used for the backward pass.
- Training was done on Metal without relying on CUDA.
- After training, it was re-ternarized and packed back into a 2-bit GGUF, maintaining its original size.
Results
| Run | patch rate | pass rate | training loss | notes |
|---|---:|---:|---:|---|
| base 8B (unfine-tuned) | 50% | 0% | - | - |
| QAT, trained only last 18 layers | 40% | 0% | 1.0 | Falls into repetitive loops |
| QAT, trained by "gradient impact layers" | 40% | 0% | 1.0 | Loop issue fixed, runs more stable |
| QAT, trained all 36 layers | 30% | 0% | 0.91 | Most stable, but worst patch rate |
Conclusion Leanings
- A drop in training loss does not mean the model has actually learned coding abilities.
- The author emphasizes the need to distinguish whether "the weight code actually flipped" or if "only the scale changed". Otherwise, it may look like it learned something while the underlying logic remains unchanged.
More from coding & agent
- HeyGen adds a media-sourcing skill for coding agents with 75k images and 10k tracks — HeyGen · 2026-07-22
- Agent search bottlenecks are now about variance, not raw latency — rohanpaul_ai · 2026-07-22
- LangSmith adds tracing for Pipecat, LiveKit, OpenAI Realtime, and Gemini Live — LangChain · 2026-07-22
- An MCP server signs every AI agent tool call into a verifiable Merkle chain — Funky_Chicken_22 · 2026-07-22
- Annotated transcript of a Claude Code team interview is now available — trq212 · 2026-07-22
- Claude Code skill uses 10 Markdown rules to make outputs ADHD-friendly — alex_verem · 2026-07-22