# Qwen3.8-27B NariQ trellis files all in VRAM

Nari Labs' 2.5 and 3.0 bpw trellis-coded Qwen3.8-27B on their llama.cpp fork, every layer on the GPU. With ngram-mod and a 0.8B draft model the 2.5 bpw file decodes at 41.9 tok/s at 64k; 112k without the draft. Stock flags give 1.7-2.8 tok/s.

- Recipe id: `qwen38-27b-nariq`  ·  status: measured  ·  updated 2026-11-29
- Model: [Qwen3.8-27B-NariQ](https://huggingface.co/nari-labs/Qwen3.8-27B-NariQ-GGUF) (27B dense hybrid (Qwen3.8-27B: 3 Gated DeltaNet : 1 full attention))
- Weights: GGUF (NariQ trellis, TRL1-TRL6 types) NariQ 2.5 bpw (default) and 3.0 bpw, 8.44 GB, from https://huggingface.co/nari-labs/Qwen3.8-27B-NariQ-GGUF, file `Qwen3.8-27B-NariQ-2.5bpw.gguf`, revision `f886dfa7581169661d218f22fc83a186b78e385a`
- Engine: [nari-labs llama.cpp fork](https://github.com/nari-labs/nari-llama.cpp) nariq/b12431 at 2644f7de4; CUDA sm_86 build
- Hardware: NVIDIA GeForce RTX 3060 12 GB, 62 GB RAM, Intel Core i5-12500, NVMe SSD
- Context: 65,536 tokens
- Placement: Every layer, the K/V cache and the 0.8B draft model in VRAM; the TRL2 token embedding (0.32 GB) stays in host memory and is decoded on the CPU. Optional projector on the CPU.
- Contributor: [David Hatley](https://github.com/davidghatley)

## Run it

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

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

API: OpenAI-compatible /v1 (llama-server) on port 8109

Key flags: `VARIANT=2.5|3.0`, `NQ_PROFILE=default|fast|long|card|stock`, `--spec-type ngram-mod,draft-simple with a 0.8B draft, n 8, p-min 0.75`, `q4_0 K/V, ub 256, -np 1`, `NQ_MMPROJ=cpu for images`

The script itself (`qwen38-27b-nariq/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 in nari-labs' NariQ trellis format (3.0 or 2.5 bpw) all in VRAM on one RTX 3060 12 GB,
# on nari-labs' llama.cpp fork. OpenAI-compatible on 127.0.0.1:8109. See README.md / RESULTS.md; log in PLAN.md.
#   ./serve.sh                      default: VARIANT=2.5, the default profile
#   VARIANT=3.0 ./serve.sh          the card's default file (short window on a 12 GB card)
#   NQ_PROFILE=fast ./serve.sh      with the 0.8B draft model (3.0: 8k window; 2.5: same as default)
#   NQ_PROFILE=long ./serve.sh      the longest window that fits (2.5: 112k without the draft)
#   NQ_PROFILE=card ./serve.sh      the card's own command (-ngl 99 -c 131072 --jinja + its samplers; mmproj on)
#   NQ_PROFILE=stock ./serve.sh     what the fork's run.sh starts: -m FILE --min-p 0 (+ --mmproj --fit-target 2560); fit picks the rest
#   NQ_MMPROJ=1 ./serve.sh          the BF16 vision projector on the GPU (2.5 only, 32k, no draft)
#   NQ_MMPROJ=cpu ./serve.sh        the projector on the CPU (image encode slower, window kept)
#   NQ_THINK=off ./serve.sh         thinking off server-wide (per request: chat_template_kwargs.enable_thinking=false)
# Every knob has an NQ_* env override; extra args go to llama-server. Holds the shared GPU lock (gpu_run) while serving.
set -euo pipefail
W=$MODELS/qwen38-27b-nariq/nari-labs
FORK=$SCRATCH/llama.cpp/nari-2644f7de4/bin
MMPROJ=$W/Qwen3.8-27B-NariQ-mmproj-BF16.gguf
VARIANT=${VARIANT:-2.5}
case "$VARIANT" in
  3.0|2.5) v_m=$W/Qwen3.8-27B-NariQ-${VARIANT}bpw.gguf ;;
  *) echo "VARIANT must be 3.0 or 2.5" >&2; exit 2 ;;
esac
PROFILE=${NQ_PROFILE:-default}
MM=${NQ_MMPROJ:-0}
# Profiles (RESULTS.md "Which config"). p_ctx=0 / p_fit=on: llama-server picks the window and layout itself.
# Windows are the largest that loaded with ~0.5 GB of the card left (PLAN.md b08/b09) and passed the near-window
# prefill, deep decode and needle gates. The 0.8B draft model and the projector on the GPU each cost window, so:
#   default  2.5: ngram-mod + 0.8B draft, q4_0 K/V, 64k     3.0: ngram-mod, q4_0 K/V, 40k
#   fast     both: ngram-mod + 0.8B draft, q4_0 K/V; 2.5 64k (same as default), 3.0 8k
#   long     2.5: ngram-mod, q4_0 K/V, 112k                  3.0: same as default (40k is the most that fits)
# NQ_MMPROJ=1 (projector on the GPU) fits only with 2.5 at 32k without the draft; NQ_MMPROJ=cpu keeps every window.
case "$PROFILE" in
  stock)   p_ctx=0;      p_kv=f16;  p_ub=512; p_fa=auto; p_fit=on;  p_spec=none;  MM=${NQ_MMPROJ:-1} ;;
  card)    p_ctx=131072; p_kv=f16;  p_ub=512; p_fa=auto; p_fit=off; p_spec=none; MM=${NQ_MMPROJ:-1} ;;
  default|fast|long)
    p_kv=q4_0; p_ub=256; p_fa=on; p_fit=off
    case "$PROFILE:$VARIANT" in
      default:2.5|fast:2.5) p_ctx=65536;  p_spec=both ;;
      default:3.0|long:3.0) p_ctx=40960;  p_spec=ngram ;;
      fast:3.0)             p_ctx=8192;   p_spec=both ;;
      long:2.5)             p_ctx=114688; p_spec=ngram ;;
    esac
    if [ "$MM" = 1 ]; then
      [ "$VARIANT" = 3.0 ] && { echo "the projector on the GPU does not fit next to the 3.0 bpw file; use NQ_MMPROJ=cpu" >&2; exit 2; }
      p_ctx=32768; p_spec=ngram
    fi ;;
  *) echo "NQ_PROFILE must be default, fast, long, card or stock" >&2; exit 2 ;;
esac
BIN=${NQ_BIN:-$FORK}
MODEL=${NQ_MODEL:-$v_m}
[ -f "$MODEL" ] || { echo "model file not found: $MODEL" >&2; exit 2; }
CTX=${NQ_CTX:-$p_ctx}
KV=${NQ_KV:-$p_kv}
KV_V=${NQ_KV_V:-$KV}
CTX_ARGS=(-c "$CTX"); [ "$CTX" = 0 ] && CTX_ARGS=()
NGL_ARGS=(-ngl "${NQ_NGL:-99}"); [ "$PROFILE" = stock ] && [ -z "${NQ_NGL:-}" ] && NGL_ARGS=()
NP_ARGS=(-np "${NQ_NP:-1}"); case "$PROFILE" in stock|card) [ -z "${NQ_NP:-}" ] && NP_ARGS=() ;; esac
FIT_ARGS=(--fit "${NQ_FIT:-$p_fit}")
MM_ARGS=(--no-mmproj); [ "$MM" = 1 ] && MM_ARGS=(--mmproj "$MMPROJ"); [ "$MM" = cpu ] && MM_ARGS=(--mmproj "$MMPROJ" --no-mmproj-offload)
# Speculation (NQ_SPEC): ngram-mod drafts from text already in the context (free: no model, ~0.1 GB); draft uses a
# separate small model with its own embedding and head (NQ_DRAFT=path; the fork refuses drafters such as DFlash
# that would share the target's trellis-coded embedding/head); both = ngram-mod first, then the draft model.
# Default draft: a Q4_K_M requant of ggml-org/Qwen3.5-0.8B-GGUF Q8_0 (tools/make_draft.sh), K/V q4_0 (PLAN.md b11).
DRAFT=${NQ_DRAFT:-$MODELS/qwen38-27b-nariq/local/Qwen3.5-0.8B-Q4_K_M-from-Q8_0-local.gguf}
DRAFT_ARGS=(-md "$DRAFT" -ngld 99 --spec-draft-n-max "${NQ_DRAFT_N:-8}" --spec-draft-n-min "${NQ_DRAFT_NMIN:-0}"
            --spec-draft-p-min "${NQ_DRAFT_PMIN:-0.75}" -ctkd "${NQ_KV_DRAFT:-q4_0}" -ctvd "${NQ_KV_DRAFT:-q4_0}")
case "${NQ_SPEC:-$p_spec}" in
  none)  SPEC_ARGS=() ;;
  ngram) SPEC_ARGS=(--spec-type ngram-mod) ;;
  draft) SPEC_ARGS=(--spec-type draft-simple "${DRAFT_ARGS[@]}") ;;
  both)  SPEC_ARGS=(--spec-type ngram-mod,draft-simple "${DRAFT_ARGS[@]}") ;;
  *) echo "NQ_SPEC must be none, ngram, draft or both" >&2; exit 2 ;;
esac
# Sampling: the card's thinking-mode settings (temp 1.0, top-p 0.95, top-k 20, min-p 0, no penalties).
SAMP=${NQ_SAMPLING:---temp 1.0 --top-p 0.95 --top-k 20 --min-p 0 --repeat-penalty 1.0 --presence-penalty 0}
THINK=${NQ_THINK:-on}
COMMON=(-t "${NQ_THREADS:-6}" -b "${NQ_BATCH:-2048}" -ub "${NQ_UBATCH:-$p_ub}" -fa "${NQ_FA:-$p_fa}" -ctk "$KV" -ctv "$KV_V")
JINJA=(--jinja)
REASON=(--reasoning-format deepseek --reasoning "$THINK")
if [ "$PROFILE" = card ]; then
  # The card's command as published: llama-server -m … --mmproj … -ngl 99 -c 131072 --jinja --temp 1.0 --top-p 0.95 --top-k 20 --min-p 0
  COMMON=(); FIT_ARGS=(); SAMP="--temp 1.0 --top-p 0.95 --top-k 20 --min-p 0"; [ -z "${NQ_THINK:-}" ] && REASON=()
elif [ "$PROFILE" = stock ]; then
  # nariq/run.sh: llama-server -m FILE --min-p 0 [--mmproj FILE --fit-target 2560] (the GGUF carries the other samplers)
  COMMON=(); FIT_ARGS=(); [ "$MM" = 1 ] && FIT_ARGS=(--fit-target 2560); SAMP="--min-p 0"; JINJA=()
  [ -z "${NQ_THINK:-}" ] && REASON=()
fi

export LD_LIBRARY_PATH="$SCRATCH/envs/llama-build-cuda/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
# Everything sits in VRAM, but the mmap'd file still counts in the page cache that memcap sees (AGENTS.md traps).
export GPU_RUN_MEM=${GPU_RUN_MEM:-24G}
# NQ_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 "${NQ_NEED:-10400}" --wait "${NQ_WAIT:-3600}")
[ -n "${NQ_NO_GPU_RUN:-}" ] && RUN=()
CMD=("$BIN/llama-server" -m "$MODEL" --alias "${NQ_ALIAS:-qwen38-27b-nariq}" "${MM_ARGS[@]}"
  "${NGL_ARGS[@]}" "${FIT_ARGS[@]}" "${CTX_ARGS[@]}" "${NP_ARGS[@]}" "${COMMON[@]}" "${SPEC_ARGS[@]}"
  "${JINJA[@]}" "${REASON[@]}" $SAMP
  --host 127.0.0.1 --port "${NQ_PORT:-8109}" ${NQ_EXTRA:-} "$@")
if [ "${NQ_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 | 2.5 bpw default, 64k, thinking off, fresh code | 41.93 tok/s | 2.77 | 40.6 | [qwen38-27b-nariq/RESULTS.md:46](https://github.com/davidghatley/3060-recipes/blob/main/qwen38-27b-nariq/RESULTS.md#L46) |
| decode | 2.5 bpw default, thinking on | 25.65 tok/s |  |  | [qwen38-27b-nariq/RESULTS.md:47](https://github.com/davidghatley/3060-recipes/blob/main/qwen38-27b-nariq/RESULTS.md#L47) |
| decode | 2.5 bpw default at 60k depth | 25.05 tok/s |  |  | [qwen38-27b-nariq/RESULTS.md:48](https://github.com/davidghatley/3060-recipes/blob/main/qwen38-27b-nariq/RESULTS.md#L48) |
| decode | 3.0 bpw default, 40k, no draft | 21.9 tok/s | 1.71 | 33.9 | [qwen38-27b-nariq/RESULTS.md:62](https://github.com/davidghatley/3060-recipes/blob/main/qwen38-27b-nariq/RESULTS.md#L62) |
| decode | 2.5 bpw long profile at 105.7k depth | 11.61 tok/s |  |  | [qwen38-27b-nariq/RESULTS.md:61](https://github.com/davidghatley/3060-recipes/blob/main/qwen38-27b-nariq/RESULTS.md#L61) |
| prefill | 8k prompt, 2.5 bpw default | 359.5 tok/s |  |  | [qwen38-27b-nariq/RESULTS.md:49](https://github.com/davidghatley/3060-recipes/blob/main/qwen38-27b-nariq/RESULTS.md#L49) |
| prefill | 105.7k prompt, 2.5 bpw long | 272.7 tok/s |  |  | [qwen38-27b-nariq/RESULTS.md:61](https://github.com/davidghatley/3060-recipes/blob/main/qwen38-27b-nariq/RESULTS.md#L61) |
| needles | 2.5 bpw long, 3/3 at 57.4k and 108.1k | 3/3 found |  |  | [qwen38-27b-nariq/RESULTS.md:61](https://github.com/davidghatley/3060-recipes/blob/main/qwen38-27b-nariq/RESULTS.md#L61) |
| quality | codeeval, 2.5 bpw default (3.0 bpw: 7/8) | 8/8 tasks |  |  | [qwen38-27b-nariq/RESULTS.md:52](https://github.com/davidghatley/3060-recipes/blob/main/qwen38-27b-nariq/RESULTS.md#L52) |
| quality | mean KLD of 2.5 bpw vs the 3.0 bpw file, wikitext | 0.165308 nats |  |  | [qwen38-27b-nariq/RESULTS.md:105](https://github.com/davidghatley/3060-recipes/blob/main/qwen38-27b-nariq/RESULTS.md#L105) |
| vram_peak | card total incl. desktop, 2.5 bpw default | 11557 MiB |  |  | [qwen38-27b-nariq/RESULTS.md:140](https://github.com/davidghatley/3060-recipes/blob/main/qwen38-27b-nariq/RESULTS.md#L140) |
| startup | ready, warm page cache, 2.5 bpw default | 1.9 s |  |  | [qwen38-27b-nariq/RESULTS.md:140](https://github.com/davidghatley/3060-recipes/blob/main/qwen38-27b-nariq/RESULTS.md#L140) |

## Caveats

- No BF16 or Q8_0 reference was on disk, so KLD is measured against the 3.0 bpw file, not against the original model.
- The baseline is the fork's own run.sh start line (fit moves 16-26 layers to the CPU, 4k window); the card's -c 131072 command does not start on 12 GB.
- The draft model costs window: 64k with it vs 112k without on 2.5 bpw, 8k vs 40k on 3.0 bpw.
- q4_0 K/V in every tuned profile (KLD 0.002-0.005 on the 3.0 file).
- The ceilings (40.6 and 33.9 tok/s) are for undrafted decode: bytes per token at the card's measured 342 GB/s.

## Credits

- Nari Labs: Both model files and the engine (branch nariq/b12431 at 2644f7de4) for the NariQ recipe. (https://huggingface.co/nari-labs/Qwen3.8-27B-NariQ-GGUF)
- 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)
- turboderp (exllamav3): Background for the NariQ recipe: the trellis tile layout the fork's libtrellis reads is exllamav3's. (https://github.com/turboderp-org/exllamav3)
- 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)
- 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)
- Hugging Face: Every model, quant and drafter in these recipes is fetched from the Hub at a pinned revision and checked against the API's sha256; the base model's MTP tensors were fetched with HTTP range requests. (https://huggingface.co)
- NVIDIA: Every recipe runs on CUDA on this card; cuBLAS SGEMV is our VRAM bandwidth probe (342 GB/s), nvidia-smi dmon is the telemetry, and Inkling's experts ship in NVFP4. (https://www.nvidia.com/en-us/geforce/graphics-cards/30-series/rtx-3060-3060ti/)

## 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-nariq/recipe.json
- Folder with scripts and raw runs: https://github.com/davidghatley/3060-recipes/tree/main/qwen38-27b-nariq
- Full results log: https://raw.githubusercontent.com/davidghatley/3060-recipes/main/qwen38-27b-nariq/RESULTS.md

## Full write-up (README)

This recipe serves Nari Labs' [NariQ](https://huggingface.co/nari-labs/Qwen3.8-27B-NariQ-GGUF) files of
Qwen3.8-27B on the RTX 3060 12 GB with **every layer in VRAM**, on their
[llama.cpp fork](https://github.com/nari-labs/nari-llama.cpp) (required: stock llama.cpp cannot load the format).

NariQ is a trellis-coded post-training quantization (QTIP-style, in exllamav3's tile layout), calibrated on
coding-agent traces. The 3.0 bpw file is 10.1 GB and the 2.5 bpw file 8.4 GB; both carry a 16-band LM head and a
CPU-decoded embedding, and neither has the model's MTP layer.

### Result

- **41.9 tok/s** on fresh code (thinking off) and 25.7 with thinking on, 25.1 at 60k depth, with the 2.5 bpw file,
  a 64k window and two kinds of speculation the fork allows: ngram-mod and a 0.8B Qwen3.5 draft model. Rewriting a
  file already in the context runs at ~138 tok/s. Needles 3/3 at 33k and 62k, codeeval 8/8.
- **Plain decode** is 21.9 tok/s (3.0 bpw) and 23.0 (2.5 bpw), 57–65% of the bandwidth ceiling.
- **Longest window:** 112k on 2.5 bpw (needles 3/3 at 108k, 11.6 tok/s there); 40k on 3.0 bpw.
- **Stock:** the card's command does not start on 12 GB, and the fork's own launcher lets `--fit` put 16–26 layers
  on the CPU, where trellis decode runs at 1.7–2.8 tok/s. The tuned profiles are 12.8–15× that.
- **The two files differ:** 2.5 bpw is KLD 0.165 (wiki) / 0.316 (code) from 3.0 bpw with 7.6% / 16% higher
  perplexity. The card reports both at BF16 level on its agent benchmarks; with no BF16 on disk that cannot be
  checked here. If quality matters more than speed and window, use `VARIANT=3.0`.

Numbers and quality are in [RESULTS.md](RESULTS.md). The experiment log is [PLAN.md](PLAN.md), the ceilings are in
[THEORY.md](THEORY.md), and the raw data is in `runs/`.

### Which config

| Use | Command | Window | Decode d0 off / on | Deep | Quality notes |
|---|---|---|---:|---:|---|
| **Default: coding and chat** | `./serve.sh` | 64k | 41.9 / 25.7 | 25.1 at 60k | 2.5 bpw, codeeval 8/8 |
| Long documents | `NQ_PROFILE=long ./serve.sh` | 112k | 23.0 / 23.8 | 11.6 at 106k | 2.5 bpw, no draft model |
| The card's default file | `VARIANT=3.0 ./serve.sh` | 40k | 21.9 / 22.7 | 16.4 at 38k | 3.0 bpw, codeeval 7/8, closer to itself on plain text |
| 3.0 bpw, short and fast | `VARIANT=3.0 NQ_PROFILE=fast ./serve.sh` | 8k | 39.0 / 27.5 | 34.5 at 7.5k | |
| Images | add `NQ_MMPROJ=cpu` to any of these | same | same | | projector on the CPU, ~3.5 s per image |

### Compared with the other Qwen3.8-27B recipes on this card

Numbers are taken from each recipe's own RESULTS.md, single user, thinking off unless noted. The four recipes are not
the same weights: `qwen38-27b-family` serves finetunes, Ternary Bonsai is a ternary re-training, Kintsugi and NariQ
are post-training trellis quantizations of the base model.

| | [qwen38-27b-family](../qwen38-27b-family/) (pi IQ3_XXS) | [kintsugi-27b](../kintsugi-27b/) (EXL3 2.47 bpw) | [ternary-bonsai-27b](../ternary-bonsai-27b/) (PTQ1_0) | **NariQ 2.5 bpw** | **NariQ 3.0 bpw** |
|---|---:|---:|---:|---:|---:|
| File | 11.4 GB | 10.5 GB | 6.23 GB | 8.44 GB | 10.12 GB |
| Engine | stock master | author's bundle | PrismML fork | nari-labs fork | nari-labs fork |
| Plain decode, empty context | 19.72 (16k, all on GPU); 16.62 at 32k | ~16 (drafter off) | 47.6 | 23.0 | 21.9 |
| Best decode, empty context | 19.72 at 16k (MTP rejected) | 39.4 chat / 60.2 code (DFlash2) | 89.9 (MTP n 3) | 41.9 (ngram-mod + 0.8B draft) | 39.0 at 8k (same) |
| Thinking on | – | – | 65.7 | 25.7 | 22.7 |
| Default window | 32k | 262k (most of it in RAM) | 96k | 64k | 40k |
| Longest window | 128k at 7.5 tok/s | 262k | 262k | 112k at 23.0 (11.6 at 106k) | 40k |
| Prefill 8k | 543 | 628 (6k) | 572 | 360 | 372 |
| Quality evidence | codeeval 7/8; publisher KLD 0.124 vs its own Q8_0 | not measured (author's benchmarks only) | codeeval 8/8; q8_0 K/V at the KLD floor | codeeval 8/8; KLD 0.165 / 0.316 vs the 3.0 file | codeeval 7/8 |

- **For speed and window, Ternary Bonsai wins** on this card: half the bytes and an MTP head. NariQ's case is that it
  is the base model's own weights, post-training quantized, and that it fits entirely on the card with a
  40–112k window, which the 11–12 GB IQ3_XXS files do not.
- **NariQ vs Kintsugi** (both trellis, both forks): NariQ's plain decode is faster (21.9–23.0 vs ~16) and it keeps the
  whole window in VRAM; Kintsugi's DFlash2 drafter gives it more on code (60 vs 42) and a 262k window held in RAM.
  NariQ's fork refuses that drafter by design. Kintsugi's prefill is faster (628 vs 360–372).
- **NariQ vs the IQ3_XXS family**: similar plain decode with every layer on the GPU, but NariQ keeps 40–112k of
  window on the card where the 11.4 GB pi IQ3_XXS needs layers in RAM past 16k, and the 0.8B draft model pays here because the
  verify step is nearly free (4 tokens cost 1.15× one).



### What the nari-labs fork changes

`nari-labs/nari-llama.cpp` branch `nariq/b12431` at `2644f7de4` is 19 commits on ggml-org master `a946eb541`
(2026-11-16). The release tag `b12431-nariv0` is `9d5c990a2`; the commits after it are docs, launchers and Windows
fixes. Read before building:

- **ggml:** six new tensor types `TRL1`–`TRL6` (GGUF ids 44–49: trellis codes for 1–6 bits per weight, 16-weight
  blocks of 2 × bits bytes) and two trellis ops, with a CPU implementation (`ggml-cpu/trellis.cpp`).
- **CUDA:** `trellis.cu` on top of `libtrellis` (Nari Labs' own CUDA library, Apache-2.0, vendored in
  `ggml-cuda/libtrellis`; it reads exllamav3's tile layout). Built for sm_80 and newer. Single-token decode fusions
  (ADD + RMS_NORM, ADD + softplus + MUL, a narrow `get_rows`) that only run in graphs containing trellis ops, and BF16
  K/V in the MMA flash-attention kernel on SM90 / SM120 only (so on this SM86 card BF16 K/V is the slowest type, b02).
- **Metal:** trellis products (not used here).
- **Model loading and `qwen35.cpp`:** validates trellis metadata at load; a banded embedding and LM head (16
  frequency bands); decode shortcuts for coded models (Gated DeltaNet state updated in place for one-sequence decode,
  fused q/k L2 norm). LoRA on coded weights is refused.
- **Speculative decoding:** a check that refuses drafters which would share the target's embedding or output head
  (EAGLE3, DFlash), because those are trellis-coded here. A separate draft model with its own embedding is allowed.
- **Converter, tests, `nariq/` tooling** (`run.sh` launcher, release notes, a qualification record), and the
  upstream CI workflows removed.

A grep of the diff for network, process and file access found nothing outside upstream's own code. The only network
step in a build is upstream's web-UI asset download (`HF_UI_VERSION`). Stock llama.cpp cannot load these files.

### Use it

```bash
## 1. weights (pinned): nari-labs/Qwen3.8-27B-NariQ-GGUF @ f886dfa7581169661d218f22fc83a186b78e385a
##    -> $MODELS/qwen38-27b-nariq/nari-labs/
##      Qwen3.8-27B-NariQ-3.0bpw.gguf (10.12 GB), Qwen3.8-27B-NariQ-2.5bpw.gguf (8.44 GB),
##      Qwen3.8-27B-NariQ-mmproj-BF16.gguf (0.93 GB)
## 2. engine: nari-labs/nari-llama.cpp nariq/b12431 @ 2644f7de4, CUDA sm_86 (own worktree and build dir)
##    git -C $SCRATCH/llama.cpp/src-r2 remote add nari https://github.com/nari-labs/nari-llama.cpp
##    git -C $SCRATCH/llama.cpp/src-r2 fetch nari nariq/b12431
##    git -C $SCRATCH/llama.cpp/src-r2 worktree add $SCRATCH/llama.cpp/src-nari 2644f7de4
##    tools/build.sh                                  # -> $SCRATCH/llama.cpp/nari-2644f7de4/bin
## 3. the draft model: ggml-org/Qwen3.5-0.8B-GGUF @ 004fd086 Q8_0, requantized to Q4_K_M (8 s)
tools/make_draft.sh
## 4. serve (through gpu_run, OpenAI-compatible on 127.0.0.1:8109, model name qwen38-27b-nariq)
./serve.sh                                  # default: 2.5 bpw, 64k q4_0, ngram-mod + 0.8B draft
NQ_PROFILE=long ./serve.sh                  # 2.5 bpw, 112k q4_0, ngram-mod
VARIANT=3.0 ./serve.sh                      # 3.0 bpw, 40k q4_0, ngram-mod
VARIANT=3.0 NQ_PROFILE=fast ./serve.sh      # 3.0 bpw, 8k q4_0, ngram-mod + 0.8B draft
NQ_MMPROJ=cpu ./serve.sh                    # image input, projector on the CPU (any profile)
NQ_PROFILE=card ./serve.sh                  # the card's command (does not start on 12 GB)
NQ_PROFILE=stock ./serve.sh                 # the fork's run.sh start line (fit, 4k window, 1.7-2.8 tok/s)
NQ_DRY=1 ./serve.sh                         # print the llama-server command
```

The default command:
```
llama-server -m Qwen3.8-27B-NariQ-2.5bpw.gguf --alias qwen38-27b-nariq --no-mmproj \
  -ngl 99 --fit off -c 65536 -np 1 -t 6 -b 2048 -ub 256 -fa on -ctk q4_0 -ctv q4_0 \
  --spec-type ngram-mod,draft-simple -md Qwen3.5-0.8B-Q4_K_M-from-Q8_0-local.gguf -ngld 99 \
  --spec-draft-n-max 8 --spec-draft-n-min 0 --spec-draft-p-min 0.75 -ctkd q4_0 -ctvd q4_0 \
  --jinja --reasoning-format deepseek --reasoning on \
  --temp 1.0 --top-p 0.95 --top-k 20 --min-p 0 --repeat-penalty 1.0 --presence-penalty 0 --host 127.0.0.1 --port 8109
```

Notes for these flags:
- **`-ub 256`:** the trellis prefill compute buffer grows with the ubatch; 256 costs ~2% prefill against 512 and
  buys window (3.0 bpw does not fit ub 512 at all).
- **`-ctk/-ctv q4_0`:** costs nothing in decode speed here (b11) and KLD 0.002–0.005 (b10).
- **`--spec-type ngram-mod,draft-simple`:** ngram-mod first (free, wins on text that repeats the context), then the
  draft model. n 8 and p-min 0.75 came out best of 4–16 and 0–0.9 (b05, b07).
- **`-ctkd/-ctvd q4_0`:** the draft's own K/V; with the Q4_K_M draft this saves ~0.36 GB against the Q8_0 draft at q8_0.
- **`-np 1`:** the auto setting makes 4 slots that share the window.
- **Samplers:** the card's thinking-mode set. **Thinking:** on; pass `"chat_template_kwargs": {"enable_thinking": false}`
  per request, or `NQ_THINK=off` server-wide.

### Limits

- **Prefill is slow:** 360–372 tok/s at 8k and 273 at 106k (60–75% of the practical compute ceiling), so a 108k
  prompt takes 400 s before the first token.
- **Deep decode without the draft:** 11.6 tok/s at 106k (2.5 long) and 16.4 at 38k (3.0); the attention over a long
  q4_0 cache is not at bandwidth.
- **The 0.8B draft model costs window:** with it 2.5 bpw keeps 64k (112k without) and 3.0 bpw only 8k (40k without).
  It helps least with thinking on (+12% over ngram-only).
- **No layers in RAM:** the CPU trellis path runs at ~6–7 GB/s, so offloading even a few layers costs more than any
  window it frees (b16b). Every profile keeps all 65 layers on the GPU.
- **The card's `-c 131072` and BF16 K/V:** 131k does not fit 12 GB with either file, and BF16 K/V is the slowest type
  on SM86 (the fork's BF16 flash-attention path targets SM90/SM120).
- **Not measured:** error against BF16 (no reference on disk), concurrency, the 2.0 bpw file, answers above 8k tokens.
- **Memory cap:** `GPU_RUN_MEM=24G`; the cgroup peak reached 18.7 GB with both files in the page cache.

### Licences

- **The model files:** Apache-2.0 (the card and its NOTICE), inherited from Qwen3.8-27B (Apache-2.0).
- **The fork:** MIT like llama.cpp; the vendored `libtrellis` is Apache-2.0.
- **The draft model:** ggml-org's GGUF of Qwen3.5-0.8B (Apache-2.0). The Q4_K_M copy is made locally by
  `tools/make_draft.sh` and not redistributed.

### Tools

| Tool | What it does |
|---|---|
| `serve.sh` | the launcher: `VARIANT=3.0\|2.5`, `NQ_PROFILE=default\|fast\|long\|card\|stock`, speculation, window, K/V, mmproj; holds the GPU lock while serving |
| `tools/build.sh` | builds the fork in its own build dir with the box's CUDA flags; checks that the trellis kernels were configured |
| `tools/make_draft.sh` | the Q4_K_M draft model from ggml-org's Q8_0 |
| `tools/srv.sh <label> [ENV=…] -- <cmd>` | one server start/stop through `../scripts/with_server.sh` on port 8109; records the command and env in `runs/` |
| `tools/gpu_batch.sh`, `tools/launch.sh` | one GPU-lock hold per batch (`GPU_RUN_MEM=24G`), detached, logged to `runs/batches/` |
| `tools/srvtest.py` | prefill, decode (with draft acceptance), needle and code-edit client on llama-server's own timings |
| `tools/measure.sh <label> <window>` | the measurement set: prefill 8k/32k/92%, decode empty and deep, needles 50%/95%, codeeval, greedy, memory |
| `tools/kld.sh`, `tools/kld2ledger.py` | KL divergence of a change against the 3.0 bpw file; ledger rows from its logs |
| `tools/bench2ledger.py` | ledger rows from `llama-bench` output in a batch log |
| `tools/image_test.py` | image input check through the projector (stdlib-drawn PNG, three shapes) |
| `tools/greedy.py`, `tools/longans.py`, `tools/codeeval_lenient.py` | temperature-0 answers to fixed prompts; long answers with loop flags; codeeval also counting bare code |
| `tools/gguf_info.py` | GGUF header and tensor summary including the TRL types (`runs/gguf-*.txt`) |
| `tools/mkconfigs.py` | writes `configs/<label>.json` from each run's command, env and ledger rows |
| `tools/mem.sh`, `tools/concurrent.py` | memory and startup of a running server; N simultaneous requests |

### Credits

- **[Nari Labs](https://huggingface.co/nari-labs)**, for NariQ: the trellis-coded
  [Qwen3.8-27B GGUFs](https://huggingface.co/nari-labs/Qwen3.8-27B-NariQ-GGUF), the BF16 projector, the
  [llama.cpp fork](https://github.com/nari-labs/nari-llama.cpp) with `libtrellis`, its benchmarks and the
  [tech report](https://arxiv.org/abs/2611.26157).
- **[Qwen](https://huggingface.co/Qwen/Qwen3.8-27B)**, for Qwen3.8-27B and its architecture, and for Qwen3.5-0.8B,
  the draft model.
- **[exllamav3](https://github.com/turboderp-org/exllamav3)** (turboderp), whose EXL3 trellis layout NariQ's kernels read.
- **[ggml-org](https://huggingface.co/ggml-org/Qwen3.5-0.8B-GGUF)**, for the Qwen3.5-0.8B GGUF, and
  **[llama.cpp](https://github.com/ggml-org/llama.cpp)**, for the engine the fork is built on, ngram-mod and
  draft-model speculation and `llama-perplexity`.
- **Sibling recipes on the same base model:** [`../qwen38-27b-family/`](../qwen38-27b-family/),
  [`../kintsugi-27b/`](../kintsugi-27b/) and [`../ternary-bonsai-27b/`](../ternary-bonsai-27b/).
