Qwen3.8-27B with the pi coding-agent adapter, merged and stored as float16
This is Qwen/Qwen3.8-27B with the LoRA adapter harness-hub/Qwen3.8-27B-pi-adapted merged into the base weights and written back as float16 instead of bfloat16.
The adapter is the one Hugging Face trained with AsyncGRPO inside the pi coding agent: on its own card it lifts SWE-bench Pro (hard 51) from 39.2% to 64.7% and Terminal-Bench 2.1 from 39.5% to 55.8%, with fewer than half the turns per solved task.
What this repository adds. A merged checkpoint that anybody can quantize. There was no merged copy of this adapter in a format that keeps the model's multi-token prediction (MTP) head, so this repository is built to make the two useful downstream artifacts possible:
- Apple Silicon / Ollama, native MLX with speculative decoding. Import it with
ollama create -q nvfp4(see below). The MTP tensors are carried over untouched, so the MLX engine keeps self-drafting: about 30 tok/s decode instead of the ~15 tok/s the memory bandwidth alone allows on an M4 Pro. - GGUF for llama.cpp. Convert it with
convert_hf_to_gguf.pyas usual. Note that a GGUF conversion does not carry the MTP head, so decode speed drops.
It is deliberately not published as a GGUF or as an oQ/oQ4e MLX build. Those are easy to make from this checkpoint and lose either the MTP head or precision, and a merged float16 base is the artifact that lets each user choose.
Files
- 18 shards of
model-*.safetensorsin float16 (about 55 GB in total), plusconfig.json(dtype: float16),model.safetensors.index.json, tokenizer, chat template and preprocessor files copied from the base. merge_report.json, the per-tensor record of what was merged (delta RMS, weight magnitude) written by the merge script.
Every tensor name and every shard boundary is identical to the base checkpoint,
so the base's model.safetensors.index.json applies unchanged.
How it was built
-
Merge, in float32, written as float16. For each LoRA pair,
W + (alpha / r) * B @ Awithr = 32,alpha = 64(scale 2.0, PEFT's convention), computed in float32 and stored as float16. The LoRA touches 256 modules:q_proj,k_proj,v_proj,o_projon the 16 full-attention layers, andgate_proj,up_proj,down_projon all 64 layers. Vision tower, embeddings, norms and the 15mtp.*tensors are copied through. -
Why float16 and not bfloat16. A LoRA delta here has an RMS of about 1e-5 against weights whose absolute maximum is 0.1 to 0.9, so the change is around 1e-4 per weight. That is below bfloat16's resolution at that magnitude, and saving the merge in bfloat16 keeps only a fraction of the adapter (another independent merge of this same adapter measured 65 to 82% of the delta surviving in bfloat16, and 99.9 to 100% in float16). Tensors the adapter does not touch are upcast bfloat16 to float16, which is exact: bfloat16 has a wider exponent but a shorter mantissa, so every normal bfloat16 value is representable in float16.
-
Streaming, one shard at a time.
PeftModel.merge_and_unload()needs the whole base model in RAM (55 GB). The merge instead opens one shard, converts one tensor at a time, and writes the output shard with a streaming writer, so peak memory is one tensor plus its float32 delta (well under 1 GB). It runs on a laptop. -
Verified before publishing. For every shard: all base tensors present, float16 dtype, shapes unchanged; untouched tensors bit-identical to the base; and every merged tensor bit-identical to an independent recomputation of
W + scale * B @ Adone witheinsuminstead ofmatmul. All 256 LoRA pairs matched a base tensor, none was left over.
Scripts: zonca/lora-merge-tools, the streaming
merge and verifier plus the parallel-range downloader, the post-upload sha256
check and the audit of the published repository. They take any sharded
checkpoint and any PEFT LoRA, not just this pair, and the repository also has
bench_ollama.py, the prefill and decode benchmark used on the machine.
Use it on Apple Silicon with Ollama (keeps MTP)
Convert to the native MLX nvfp4 format that Ollama's MLX engine reads. This is
what the official qwen3.8:27b-nvfp4 tag is, and it preserves the mtp.*
tensors, so speculative decoding keeps working.
hf download zonca/Qwen3.8-27B-pi-adapted-merged --local-dir Qwen3.8-27B-pi-merge
# clone the template and parameters of the base tag, keep everything but FROM
ollama show --modelfile qwen3.8:27b-nvfp4 | grep -v '^FROM' > Modelfile
printf 'FROM ./Qwen3.8-27B-pi-merge\n' | cat - Modelfile > Modelfile.new && mv Modelfile.new Modelfile
ollama create qwen3.8-pi:27b-nvfp4 -q nvfp4 -f Modelfile
ollama show qwen3.8-pi:27b-nvfp4 # artifacts should list 15 MTP layers
Notes:
ollama createfrom MLX safetensors needs Ollama 0.34.1 or newer; on older builds add--experimentalaftercreate.- Import as MLX, not as GGUF. On Ollama the
nvfp4quantization is always the native MLX engine, never llama.cpp, and MLX is the path that reads the MTP head. A GGUF import works but loses speculative decoding. - If tool calls come out malformed, the chat template was not picked up: add
RENDERER qwen3.5andPARSER qwen3.5to the Modelfile (the family Qwen 3.8 belongs to) and recreate. - The adapter was trained with thinking off. Send
"think": false, or the equivalent in your client. ollama createneeds roughly 55 GB of free disk for the download plus the converted artifact, and it quantizes on the machine, so give it a few minutes.
Use it with llama.cpp
python convert_hf_to_gguf.py Qwen3.8-27B-pi-merge --outfile qwen3.8-pi-f16.gguf --outtype f16
llama-quantize qwen3.8-pi-f16.gguf qwen3.8-pi-Q4_K_M.gguf Q4_K_M
Limitations
- No benchmarks of my own yet. The numbers above are the adapter author's, on the unmerged adapter under pi. This repository only claims the merge is faithful; a separate evaluation on a smaller machine is in progress.
- Trained for pi, on software-engineering and terminal tasks. Gains under other harnesses are not established.
- Thinking on is outside the adapter's training. It still works, and the
adapter card reports it reaches the base model's
xhighscore, at about 4x the tokens. - The vision tower is untouched and was not evaluated by the adapter authors or by me.
- float16 rather than bfloat16 changes the storage dtype only; the numerics of the merged tensors are the ones the merge produced in float32.
Licence
Apache 2.0, inherited from the base model and the adapter. Base weights by the
Qwen team, adapter by Hugging Face (harness-hub). Merge performed with the
scripts above; no additional training.