# Qwen3.8-27B finetunes

One llama.cpp configuration covers pi-adapted, Huihui, DaisyRose and Heretic finetunes. The default pi-adapted run reaches 16.62 tok/s with a 32k window.

- Recipe id: `qwen38-27b-family`  ·  status: measured  ·  updated 2026-11-23
- Model: [Qwen3.8-27B finetunes](https://huggingface.co/harness-hub/Qwen3.8-27B-pi-adapted) (27B Dense Gated DeltaNet hybrid)
- Weights: GGUF IQ3_XXS, 11.4 GB, from https://huggingface.co/netprojects/Qwen3.8-27B-pi-adapted-GGUF, file `Qwen3.8-27B-pi-IQ3_XXS.gguf`, revision `5ee3670a`
- Engine: [llama.cpp](https://github.com/ggml-org/llama.cpp) master 225a5345b
- Hardware: RTX 3060 12 GB, 62 GB RAM, i5-12500
- Context: 32,768 tokens
- Placement: For the default pi profile, the FFN weights of layers 0–2 stay in RAM and other model weights stay on the GPU.
- Contributor: [David Hatley](https://github.com/davidghatley)

## Run it

From `qwen38-27b-family/` in a clone of https://github.com/davidghatley/3060-recipes:

```sh
./serve.sh
```

API: OpenAI-compatible /v1 on port 8101

Key flags: `VARIANT=pi|huihui|daisyrose|heretic`, `Q38_PROFILE=default|fast|long`, `-ctk q4_0 -ctv q4_0 -ub 256`

The script itself (`qwen38-27b-family/serve.sh`, machine paths shown as `$MODELS`, `$SCRATCH`, `~`; set them to where your weights and builds live):

```sh
#!/usr/bin/env bash
# Qwen3.8-27B family (four finetunes of the same dense hybrid base) on stock llama.cpp master, one RTX 3060 12 GB.
# OpenAI-compatible on 127.0.0.1:8101. See README.md / RESULTS.md; experiment log in PLAN.md.
#   VARIANT=pi|heretic|daisyrose|huihui ./serve.sh      (default pi)
#   Q38_PROFILE=long ./serve.sh                          (long-context profile, see README)
# Every knob has a Q38_* env override; extra args go to llama-server. Holds the shared GPU lock (gpu_run) while serving.
set -euo pipefail
BIN=${Q38_BIN:-$SCRATCH/llama.cpp/master-225a5345b/bin}
W=$MODELS/qwen38-27b-family
VARIANT=${VARIANT:-pi}
# Per variant: weights, the card's sampling, thinking default.
case "$VARIANT" in
  pi)        d_model=$W/pi-adapted/Qwen3.8-27B-pi-IQ3_XXS.gguf; d_mmproj=$W/pi-adapted/mmproj-Qwen3.8-27B-pi-F16.gguf
             d_samp="--temp 0.8 --top-p 1.0 --top-k 0 --min-p 0"; d_think=off; d_ffn_default=3; d_ffn_fast=0; d_ffn_long=26 ;;  # harness-hub card: thinking off, T 0.8, top-p 1.0
  heretic)   d_model=$W/davidau-heretic/Qwen3.8-27B-TurboFCFusion-735-882-Here-Uncen-NEO-CODER-MAX-MTP-IQ2_M.gguf; d_mmproj=
             d_samp="--temp 0.7 --top-p 0.95 --top-k 20 --min-p 0 --repeat-penalty 1.0"; d_think=on; d_ffn_default=10; d_ffn_fast=5; d_ffn_long=37 ;;  # DavidAU card: T .6/.7, rep pen off
  daisyrose) d_model=$W/daisyrose/RadixArk_DaisyRose-27B-IQ3_XXS.gguf; d_mmproj=
             d_samp="--temp 1.0 --top-p 0.95 --top-k 20 --min-p 0"; d_think=on; d_ffn_default=7; d_ffn_fast=4; d_ffn_long=28 ;;          # RadixArk card: T 1.0, top-p .95, top-k 20
  huihui)    d_model=$W/huihui-abliterated/Huihui-Qwen3.8-27B-abliterated-GSQ-RCO-IQ3_XXS-mtp.gguf; d_mmproj=
             d_samp="--temp 1.0 --top-p 0.95 --top-k 20 --min-p 0"; d_think=on; d_ffn_default=0; d_ffn_fast=0; d_ffn_long=22 ;;          # Qwen3.8 base card (thinking mode)
  *) echo "VARIANT must be pi, heretic, daisyrose or huihui (or set Q38_MODEL)" >&2; exit 2 ;;
esac
MODEL=${Q38_MODEL:-$d_model}
SAMP=${Q38_SAMPLING:-$d_samp}
THINK=${Q38_THINK:-$d_think}

# Profiles (tuned on pi, PLAN.md / RESULTS.md). FFN_CPU = how many leading layers keep their FFN matrices in RAM
# (the fewest that load next to the window's K/V and compute buffer; per variant, since the files differ in size).
#   default: 32k window, q4_0 K/V, ub 256          fast: 16k, everything on the GPU          long: 128k
case "${Q38_PROFILE:-default}" in
  default) p_ctx=32768;  p_kv=q4_0; p_ub=256; p_ffn=${d_ffn_default} ;;
  fast)    p_ctx=16384;  p_kv=q4_0; p_ub=256; p_ffn=${d_ffn_fast} ;;
  long)    p_ctx=131072; p_kv=q4_0; p_ub=256; p_ffn=${d_ffn_long} ;;
  *) echo "Q38_PROFILE must be default, fast or long" >&2; exit 2 ;;
esac
p_ngl=99
CTX=${Q38_CTX:-$p_ctx}
KV=${Q38_KV:-$p_kv}
KV_V=${Q38_KV_V:-$KV}   # V cache type (default: same as K)
FFN_CPU=${Q38_FFN_CPU:-$p_ffn}
p_ot=''
if [ "$FFN_CPU" -gt 0 ]; then p_ot="blk\\.($(seq -s'|' 0 $((FFN_CPU-1))))\\.ffn_(up|gate|down)=CPU"; fi
OT=${Q38_OT-$p_ot}
OT_ARGS=(); [ -n "$OT" ] && OT_ARGS=(-ot "$OT")
# Speculative decoding: none | mtp (the file's own MTP head) | dflash2 (z-lab-style DFlash2 drafter on disk from kintsugi-27b)
SPEC_ARGS=()
case "${Q38_SPEC:-none}" in
  none) ;;
  mtp) SPEC_ARGS=(--spec-type draft-mtp --spec-draft-n-max "${Q38_DRAFT_N:-2}") ;;
  dflash2) SPEC_ARGS=(--spec-type draft-dflash2 -md "${Q38_DRAFT_MODEL:-$MODELS/kintsugi-27b/dflash-Qwen3.8-27B-Q4_0.gguf}"
                      --spec-draft-n-max "${Q38_DRAFT_N:-8}" -ngld "${Q38_DRAFT_NGL:-99}") ;;
  *) echo "Q38_SPEC must be none, mtp or dflash2" >&2; exit 2 ;;
esac
MMPROJ_ARGS=(--no-mmproj)
[ -n "${Q38_MMPROJ:-}" ] && MMPROJ_ARGS=(--mmproj "$Q38_MMPROJ")
[ "${Q38_MMPROJ:-}" = auto ] && MMPROJ_ARGS=(--mmproj "$d_mmproj")
LORA_ARGS=(); [ -n "${Q38_LORA:-}" ] && LORA_ARGS=(--lora "$Q38_LORA")

export LD_LIBRARY_PATH="$SCRATCH/envs/llama-build-cuda/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
# Layers that stay in RAM are mmap'd from the page cache, which gpu_run's memcap counts (AGENTS.md traps).
export GPU_RUN_MEM=${GPU_RUN_MEM:-44G}
# Q38_NO_GPU_RUN=1: start llama-server directly (already inside a gpu_run session, see tools/gpu_batch.sh)
RUN=("$HOME/anime-pipeline/tools/gpu_run" --free --need "${Q38_NEED:-10800}" --wait "${Q38_WAIT:-3600}")
[ -n "${Q38_NO_GPU_RUN:-}" ] && RUN=()
CMD=("$BIN/llama-server" -m "$MODEL" --alias "qwen38-$VARIANT" "${MMPROJ_ARGS[@]}" "${LORA_ARGS[@]}"
  -ngl "${Q38_NGL:-$p_ngl}" "${OT_ARGS[@]}" --fit "${Q38_FIT:-off}"
  -c "$CTX" -np 1 -t "${Q38_THREADS:-6}" -b "${Q38_BATCH:-2048}" -ub "${Q38_UBATCH:-$p_ub}"
  -fa on -ctk "$KV" -ctv "$KV_V" "${SPEC_ARGS[@]}"
  --jinja --reasoning-format deepseek --reasoning "$THINK" $SAMP
  --host 127.0.0.1 --port "${Q38_PORT:-8101}" ${Q38_EXTRA:-} "$@")
if [ "${Q38_DRY:-}" = 1 ]; then printf '%q ' "${CMD[@]}"; echo; exit 0; fi
exec "${RUN[@]}" prlimit --core=0 "${CMD[@]}"
```

## Measured results

| Metric | Conditions | Value | Stock | Ceiling | Source |
|---|---|---|---|---|---|
| decode | pi, empty context, default | 16.62 tok/s | 7.93 |  | [qwen38-27b-family/RESULTS.md:32](https://github.com/davidghatley/3060-recipes/blob/main/qwen38-27b-family/RESULTS.md#L32) |
| decode | pi, empty context, fast | 19.72 tok/s |  |  | [qwen38-27b-family/RESULTS.md:32](https://github.com/davidghatley/3060-recipes/blob/main/qwen38-27b-family/RESULTS.md#L32) |
| decode | pi, empty context, long | 7.48 tok/s |  |  | [qwen38-27b-family/RESULTS.md:32](https://github.com/davidghatley/3060-recipes/blob/main/qwen38-27b-family/RESULTS.md#L32) |
| prefill | pi, 8k prompt, default | 543 tok/s | 475 |  | [qwen38-27b-family/RESULTS.md:36](https://github.com/davidghatley/3060-recipes/blob/main/qwen38-27b-family/RESULTS.md#L36) |

## Caveats

- Offload placement varies by file and profile. MTP was rejected because its VRAM overhead forced more weights into RAM.

## Credits

- Qwen: The 15 mtp.* tensors grafted back into the 3D coder came from Qwen3.5-4B; Kintsugi-27B is built on Qwen3.8-27B. (https://huggingface.co/Qwen/Qwen3.5-4B)
- harness-hub: Pi-adapted LoRA. (https://huggingface.co/harness-hub/Qwen3.8-27B-pi-adapted)
- netprojects: Merged pi-adapted GGUFs. (https://huggingface.co/netprojects/Qwen3.8-27B-pi-adapted-GGUF)
- huihui-ai: Abliterated Qwen3.8-27B GGUF. (https://huggingface.co/huihui-ai/Huihui-Qwen3.8-27B-abliterated-GGUF)
- RadixArk: DaisyRose-27B. (https://huggingface.co/RadixArk/DaisyRose-27B)
- bartowski: The imatrix used when we requantized only the RAM-resident experts. (https://huggingface.co/bartowski/RecursiveSI_flint-GGUF)
- DavidAU: Heretic merges and GGUFs. (https://huggingface.co/DavidAU)
- llama.cpp (ggml-org and contributors): The engine for Flint, the 3D coder and Inkling-2-Mini, and the base of the Kintsugi fork. (https://github.com/ggml-org/llama.cpp)
- ggml-org: Flint-Q4_K_M.gguf and Inkling-2-Mini-IQ4_NL.gguf are the files the two recipes serve; the Q8_0 files are the KLD references. (https://huggingface.co/ggml-org/Flint-GGUF)
- 0xSero / Sybil Solutions: The tuning method behind the Flint and Inkling recipes; its q8_0 KV gotcha is one we confirmed on Flint. (https://github.com/sybil-solutions/inference-optimisation-skill)

## Reproductions

None yet. Ran it on your own 3060? Report your numbers: https://github.com/davidghatley/3060-recipes/issues/new?template=reproduction.yml

## Machine-readable

- https://davidghatley.github.io/3060-recipes/recipes/qwen38-27b-family/recipe.json
- Folder with scripts and raw runs: https://github.com/davidghatley/3060-recipes/tree/main/qwen38-27b-family
- Full results log: https://raw.githubusercontent.com/davidghatley/3060-recipes/main/qwen38-27b-family/RESULTS.md

## Full write-up (README)

Four finetunes of the dense [Qwen3.8-27B](https://huggingface.co/Qwen/Qwen3.8-27B) on the RTX 3060 12 GB, with stock
llama.cpp master. One serve script, one tuned config, a `VARIANT=` switch.

The 3-bit files are 10.4–12.2 GB, so with any context window some weights have to sit in RAM. Every GB there costs
~29 ms per token. The recipe shrinks everything else on the card (q4_0 K/V, ubatch 256) so that as little as possible
leaves it: only the FFN of layers 0–2 for pi at 32k, nothing at 16k.

Numbers and quality: [RESULTS.md](RESULTS.md). Experiment log: [PLAN.md](PLAN.md). Ceilings: [THEORY.md](THEORY.md).
Raw data: `runs/`, one config per run in `configs/`.

### Result (pi, single user)

| | Stock llama.cpp (`--fit on`, 32k) | **This recipe, 32k** | 16k (`fast`) | 128k (`long`) |
|---|---:|---:|---:|---:|
| Decode, coding answer | 7.9 tok/s | **16.6 tok/s (2.1×)** | **19.7 (2.5×)** | 7.5 |
| Decode deep in the window | | 13.8 at 30k | 17.6 at 15k | 5.6 at 120k |
| Prefill, 8k prompt | 475 tok/s | 543 | 570 | 403 |
| Needles, ~50% / ~95% of the window | | 3/3, 3/3 | 3/3, 3/3 | 3/3, 3/3 |

The all-on-GPU ceiling is 31.7 tok/s; the `fast` profile reaches 62% of it.

### The variants

| `VARIANT=` | Model | File (pinned) | Decode, 32k default | `fast` 16k / `long` 128k | Gates | Card sampling, thinking |
|---|---|---|---:|---:|---|---|
| `pi` (default) | harness-hub pi-adapted (coding-agent LoRA, merged) | netprojects IQ3_XXS, 11.4 GB | 16.6 | 19.7 / 7.5 | needles 3/3, codeeval 7/8 | T 0.8, top-p 1.0, thinking off |
| `huihui` | Huihui abliterated (uncensored) | huihui-ai GSQ-RCO IQ3_XXS + MTP, 10.4 GB | **20.8** | 20.8 / 9.4 | needles 3/3, codeeval 8/8, refusals 0/20 | T 1.0, top-p 0.95, top-k 20, thinking on |
| `daisyrose` | RadixArk DaisyRose-27B | bartowski IQ3_XXS, 12.2 GB | 14.4 | 16.5 / 7.4 | needles 3/3, codeeval 8/8 | T 1.0, top-p 0.95, top-k 20, thinking on |
| `heretic` | DavidAU TURBO Fable Cold-Fusion Heretic (uncensored) | DavidAU IQ2_M (BF16 LM head), 12.1 GB | 11.6 | 14.2 / 6.2 | needles 3/3, codeeval 6/8, refusals 0/20 | T 0.7, top-p 0.95, top-k 20, rep pen 1.0, thinking on |

All are the same Qwen3.8-27B architecture, so one config fits all; only the number of FFN layers that stay in RAM
differs, because the files differ in size (serve.sh sets it per variant and profile). Every member was checked
against stock llama.cpp flags with control / tuned / control: 1.7–2.1× decode. KL divergence was not measured (no
higher-precision reference on disk); the publishers' figures are in RESULTS.md.

### Use it

```bash
## 1. weights (pinned, see ../notes/trending-batch-1-weights.tsv) -> $MODELS/qwen38-27b-family/<variant>/
## 2. engine: llama.cpp master 225a5345b, CUDA build (this box: $SCRATCH/llama.cpp/master-225a5345b/bin)
## 3. serve (through gpu_run, OpenAI-compatible on 127.0.0.1:8101)
./serve.sh                                   # pi, 32k
VARIANT=huihui ./serve.sh                    # another member
Q38_PROFILE=fast ./serve.sh                  # 16k, fastest
Q38_PROFILE=long ./serve.sh                  # 128k
Q38_THINK=off VARIANT=daisyrose ./serve.sh   # thinking off for a thinking-default member
Q38_DRY=1 ./serve.sh                         # print the llama-server command and exit
```

Knobs (all `Q38_*` env vars): `Q38_PROFILE` default|fast|long, `Q38_CTX`, `Q38_KV` / `Q38_KV_V` (K/V cache types),
`Q38_FFN_CPU` (how many leading layers keep their FFN in RAM), `Q38_OT` (raw `-ot` override), `Q38_NGL`, `Q38_FIT`,
`Q38_UBATCH`, `Q38_BATCH`, `Q38_THREADS`, `Q38_THINK` on|off, `Q38_SAMPLING`, `Q38_SPEC` none|mtp|dflash2 with
`Q38_DRAFT_N` / `Q38_DRAFT_MODEL` / `Q38_DRAFT_NGL`, `Q38_MMPROJ` (path or `auto`), `Q38_LORA`, `Q38_PORT`,
`Q38_MODEL`, `Q38_BIN`, `Q38_EXTRA` (extra llama-server args), `Q38_NO_GPU_RUN`, `Q38_NEED`, `Q38_WAIT`, `GPU_RUN_MEM`
(default 44G: the FFN layers in RAM are mmap'd from the page cache, which `gpu_run`'s cap counts).

If you change the window, re-find the FFN count: the card has ~10.8 GB for weights + K/V + DeltaNet state + compute
buffer, and each FFN layer moved to RAM frees ~98 MiB (pi) and costs ~2.8 ms per token.

#### Things that do not help here

- **MTP** (`Q38_SPEC=mtp`): loads and drafts well (91–98% accepted), but its ~650 MiB of VRAM pushes 6–10 FFN layers
  to RAM, and no setting beat the plain control by more than noise. **DFlash2** with the Kintsugi drafter does not fit.
- **q8_0 K/V** or mixed K/V at 32k, **ubatch 128**, more CPU threads.

### Tools

| | |
|---|---|
| `serve.sh` | the server, every knob an env var |
| `tools/srvtest.py` | prefill / decode / deep-decode / needle tests against a running server, writes `runs/ledger.jsonl` |
| `tools/measure.sh` | the full measurement set: srvtest + codeeval + greedy prompts + refusal probe + memory |
| `tools/member.sh` | fit search, control / tuned / control and the measurement set for one variant |
| `tools/srv.sh`, `tools/gpu_batch.sh` | one config + one test via `../scripts/with_server.sh`; a batch inside one `gpu_run` session |
| `tools/fitprobe.py` | load + one 3k-token request: does this placement really fit |
| `tools/greedy.py` | 8 fixed prompts at temperature 0; `--compare` two runs |
| `tools/gguf_info.py` | GGUF header reader: metadata, bytes per tensor kind and per layer (works on `.part` files) |
| `tools/kintsugi_lora_serve.sh` | the Kintsugi bundle's server with `--lora` (the stretch test; it does not load) |
| `tools/mkconfigs.py` | `configs/<run>.json` from each run's exact command and ledger medians |

### Credits

- [Qwen](https://huggingface.co/Qwen/Qwen3.8-27B), for Qwen3.8-27B.
- [harness-hub](https://huggingface.co/harness-hub/Qwen3.8-27B-pi-adapted), for the pi-adapted LoRA, and
  [netprojects](https://huggingface.co/netprojects/Qwen3.8-27B-pi-adapted-GGUF), for the merged GGUFs with the MTP
  head kept.
- [DavidAU](https://huggingface.co/DavidAU/Qwen3.8-27B-TURBO-Fable-Cold-Fusion-735-882-Heretic-Uncensored-NEO-CODER-MAX-MTP-GGUF),
  for the Heretic uncensored merge.
- [RadixArk](https://huggingface.co/RadixArk/DaisyRose-27B), for DaisyRose-27B, and
  [bartowski](https://huggingface.co/bartowski/RadixArk_DaisyRose-27B-GGUF), for its GGUFs.
- [huihui-ai](https://huggingface.co/huihui-ai/Huihui-Qwen3.8-27B-abliterated-GGUF), for the abliterated model and
  its GSQ-RCO GGUF (the quantizer is ISTA-DASLab's GSQ-RCO).
- [llama.cpp](https://github.com/ggml-org/llama.cpp), for the engine, the `qwen35` / MTP support,
  `convert_lora_to_gguf.py` and `llama-bench`.
- [CaryPalmer/Kintsugi-27B](https://huggingface.co/CaryPalmer/Kintsugi-27B) and the `kintsugi-27b` recipe in this repo,
  for the DFlash2 drafter and the bundle used in the LoRA test.
- The tuning method comes from 0xSero's
  [inference-optimisation-skill](https://github.com/sybil-solutions/inference-optimisation-skill): ceilings first,
  one change at a time with controls, and output gated as well as speed.
- The inkling-2-mini and flint recipes in this repo, for the test tooling this recipe adapts.
