Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions config/recipes.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
{
"about": "Tuned llama-server settings per model and route, applied by `1bit serve` (docs/recipes.md). A recipe never overrides a flag already on the backend's command line or a variable already set. Every recipe carries the measurement behind it; re-measure with tools/bench.py before changing one.",
"recipes": []
"about": "Tuned llama-server settings per model and route, applied by `1bit serve` (docs/recipes.md). A recipe never overrides a flag already on the backend's command line or a variable already set. Every recipe carries the measurement behind it; re-measure with tools/bench.py before changing one.",
"recipes": [
{
"id": "qwen35-dflash-p-min-0",
"match": {"device": ["hrx"], "architecture": ["qwen35"], "drafter": ["dflash"]},
"args": ["--spec-draft-p-min", "0"],
"why": "DFlash2 proposes and verifies whole 8-token blocks, so a non-zero draft p-min discards blocks whose first tokens look unlikely and the loss lands on prose; 0 keeps every block whole. The flag is pinned here rather than left to llama-server's default, because the measurement below is what the recipe is for.",
"measured": "Qwen3.8-27B UD-Q4_K_XL, 1bit serve --dflash with the Q8_0 drafter, greedy 256-token chats, medians of 3, performance mode, 2026-10-24: p-min 0 gives 56.6 / 30.8 / 20.6 tok/s on code / prose / short (acceptance 0.88 / 0.42 / 0.23); p-min 0.2, 0.4 and 0.6 cut prose to 22.5-23.3. The Q4_K drafter reaches 58.8 on code at p-min 0. Strict placement on: the drafter's graphs run on HRX in one graph split.",
"source": "TDFLASH-HRX / TDFLASH-STRICT"
},
{
"id": "qwen35-mtp-max-3",
"match": {"device": ["hrx"], "architecture": ["qwen35"], "drafter": ["mtp"]},
"args": ["--mtp-max", "3"],
"why": "The model's own MTP head accepts about two thirds of its three drafts, and acceptance collapses past seven, so a longer verify batch costs more than the extra drafts return. Capping at 3 is what the measurement below is for; do not raise it past 7.",
"measured": "Qwen3.8-27B UD-Q4_K_XL with its in-file MTP head, greedy 256-token chats, medians of 3, performance mode, 2026-10-24: --mtp-max 3 gives 32.6 / 26.9 / 28.0 tok/s on code / prose / short (12.1 / 12.1 / 12.5 without drafting). --mtp-max 7 --mtp-p-min 0 gives 37.9 / 22.4 / 22.4 and --mtp-max 15 33.6 / 14.9 / 13.5, with 0.17-0.60 acceptance past 8 drafts.",
"source": "TDFLASH-HRX / TDFLASH-STRICT"
}
]
}
4 changes: 4 additions & 0 deletions docs/hrx.md
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,10 @@ in [hrx.md at 0baf286](https://github.com/1bit-MONSTER/engine/blob/0baf286/docs/
- **PrismML tile bytes** ([llama.cpp #74](https://github.com/1bit-MONSTER/llama.cpp/pull/74)): the low-token
SwiGLU sized PQ2_0 / PTQ1_0 weight rows from a tile size of 0, so every row read row 0. Ternary-Bonsai-1.7B
PQ2_0 decode perplexity 1,225,624 -> 20.65 (CPU 20.70); the 27B files took another kernel and were unaffected.
- **NVFP4 (ggml type 40) and Q2_0 (type 42)**: prompt and decode on HRX through our HIP kernels
(private add-on, 2026-10-24), no extra flag or environment: a Qwen3.8-27B file of either type loads
and runs with **one graph split**. Measured on the 27B, performance mode: NVFP4 pp512 613 / tg128
12.7 tok/s, KLD vs the CPU 0.00144; Q2_0 pp512 632 / tg128 23.1 tok/s, KLD vs the CPU 0.00055.
- **TQ1_0 / TQ2_0** ([llama.cpp #69](https://github.com/1bit-MONSTER/llama.cpp/pull/69)): ggml's ternary types
in the shared dequantizer and on the K-quant decode kernels. Ternary-Bonsai-1.7B, HRX0 vs CPU: KLD 0.000523,
same top token 98.67%; pp512 / tg128 TQ1_0 3542 / 113, TQ2_0 4100 / 156 tok/s.
Expand Down
13 changes: 10 additions & 3 deletions docs/recipes.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,16 @@ It adds each variable in `env` unless it is already set. Serve prints what it ad

## The built-in recipes

None, for now. Every recipe the engine had was measured on a build RFC #213 stage 3 removed:
`rotated-moe-ub1024` and `rocm-dflash-p-min-0.4` (the lean ROCm build) and `dflash-p-min-0` (a no-op
on our HRX llama.cpp, whose default draft p-min is already 0). New ones come with HRX measurements.
Two, both for Qwen3.8-27B (`qwen35`) on `hrx`, from the 2026-10-24 HRX drafter measurements:

| id | matches | adds | measured |
|---|---|---|---|
| `qwen35-dflash-p-min-0` | `hrx`, `qwen35`, drafter `dflash` | `--spec-draft-p-min 0` | 56.6 / 30.8 / 20.6 tok/s code / prose / short with the Q8_0 drafter; a non-zero threshold cut prose to 22.5-23.3 |
| `qwen35-mtp-max-3` | `hrx`, `qwen35`, drafter `mtp` | `--mtp-max 3` | 32.6 / 26.9 / 28.0 tok/s; acceptance falls to 0.17-0.60 past 7 drafts, so do not raise it |

Both carry their full `measured` line in `config/recipes.json`. Older recipes were measured on build
RFC #213 stage 3 removed: `rotated-moe-ub1024` and `rocm-dflash-p-min-0.4` (the lean ROCm build). New
ones come with HRX measurements.

Recipes apply in file order. The first recipe to add a flag wins, so a narrower recipe goes before
a broader one for the same flag.
Expand Down
56 changes: 36 additions & 20 deletions docs/serve.md
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,14 @@ found; it has not been repeated on HRX. The sweep (draft length x

Use the default for chat and `--mtp-max 6 --mtp-p-min 0.5` for code (3.4x): code is
predictable enough to keep long drafts, prose is not. Draft length 8 collapses on every
prompt. Adding n-gram drafting to MTP gains nothing. Small-active MoE models are the
prompt. Adding n-gram drafting to MTP gains nothing.

**Cap the draft on HRX**: `config/recipes.json` pins `--mtp-max 3` for `qwen35` on `hrx`, which is
also llama-server's default — 32.6 / 26.9 / 28.0 tok/s on the 27B on 2026-10-24. Do not raise it
past 7: from 8 drafts on, acceptance falls to 0.17-0.60 and the longer verify batch costs more than
the drafts return (`--mtp-max 7 --mtp-p-min 0`: 37.9 / 22.4 / 22.4; `--mtp-max 15`: 33.6 / 14.9 /
13.5, even with 16-token verify kernels). Code is the one case where a longer draft still pays, and
only up to 7. Small-active MoE models are the
opposite case: on Qwen3-Coder-30B-A3B (3B active, 88 tok/s then) every draft model
tried (Qwen3 0.6B / 1.7B / 4B) was slower than no drafting, even at 82-87% acceptance.

Expand Down Expand Up @@ -643,32 +650,41 @@ llama-quantize dflash2-bf16.gguf dflash2-q8_0.gguf Q8_0
1bit serve -m Qwen3.8-27B-Q4_0.gguf --dflash dflash2-q8_0.gguf
```

Measured through `1bit serve` on the removed Vulkan build on Strix Halo (not yet re-measured on
HRX), Qwen3.8-27B Q4_0 (Unsloth), the
same three chat prompts as above (code / prose / short, decode tok/s), runs back to back on a
shared box, 2026-09-28:
Measured through `1bit serve` on Strix Halo on 2026-10-24: Qwen3.8-27B UD-Q4_K_XL, the same three
chat prompts as above (code / prose / short, decode tok/s), greedy 256-token answers, medians of
three fresh servers, performance mode, **strict placement on** — the drafter's candidate selector
(its top-k, fill and row-gather nodes) runs on HRX, so the whole drafter graph is on the GPU in one
graph split:

| Drafter | tok/s | Prompt t/s (1,838 tokens) |
|---|---|---|
| none | 11.1 / 11.8 / 12.4 | 330 |
| `--mtp` (Q4_0 MTP head, draft length 3) | 31.7 / 25.8 / **28.2** | 267 |
| `--dflash` (DFlash2, Q8_0, full blocks) | **45.7** / **28.3** / 17.8 | 255 |

DFlash2 is the pick for code (4.1x, +44% over MTP) and ties or beats MTP on prose. MTP wins
short answers (the translation prompt stops after ~16 tokens, too few to fill blocks). The Q8_0
drafter is faster than BF16 (42.5 vs 38.9 on code, direct llama-server). A drafted token is
kept only when the model agrees, so the output is the model's own.
| Drafter | code | prose | short |
|---|---|---|---|
| none | 12.1 | 12.1 | 12.5 |
| `--mtp` (the file's own head, draft length 3) | 32.6 | 26.9 | 28.0 |
| `--dflash` (DFlash2 Q8_0, whole blocks) | **56.6** | **30.8** | 20.6 |
| `--dflash` (DFlash2 Q4_K, whole blocks) | **58.8** | — | — |

DFlash2 is the pick for code (+73% over MTP, 4.7x without drafting) and about level on prose, but a
short answer stops before a block is worth filling, so it loses a third there. **The default stays
MTP for chat; `--dflash` is for code-heavy serving.** Acceptance on the three prompts is 0.88 / 0.42
/ 0.23, and a drafted token is kept only when the model's verify pass agrees, so the output is the
model's own. The Q8_0 drafter is what the numbers above use; a Q8_0 file is also what the drafter's
own README recommends over BF16.

Without `--mtp-max`, `--dflash` drafts the drafter's block minus one (its `dflash.block_size`; 16
when the file does not say). Our HRX llama.cpp's default draft p-min is already 0, which keeps
DFlash blocks whole; `--mtp-p-min` sets another. (The DFlash2 one-server route on the lean ROCm
build is gone, above.)
when the file does not say). **DFlash2's block is 8 tokens**, not 16: the seven drafts per verify
step are what `1bit serve --dflash` asks for, and they fit the 2-8-token verify kernels.

A non-zero draft threshold throws whole blocks away: on the 27B, `--spec-draft-p-min` 0.2 / 0.4 /
0.6 cut prose from 30.8 to 22.5-23.3 tok/s, so `config/recipes.json` pins `--spec-draft-p-min 0`
for `qwen35` on `hrx` (docs/recipes.md). `--mtp-p-min` sets the same threshold. (The DFlash2
one-server route on the lean ROCm build is gone, above.)

## Recipes (`--recipes`, `--no-recipes`)

Tuned llama-server settings that depend on the model and route go in `config/recipes.json` as
recipes, each with the measurement behind it. The built-in set is empty for now: the recipes the
engine had were measured on builds RFC #213 stage 3 removed ([recipes.md](recipes.md#the-built-in-recipes)). Serve prints each recipe it applies. Anything serve sets
recipes, each with the measurement behind it. The built-in set has two entries today, both for
Qwen3.8-27B on `hrx`: `--spec-draft-p-min 0` with a DFlash2 drafter and `--mtp-max 3` with the file's
own MTP head ([recipes.md](recipes.md#the-built-in-recipes)). Serve prints each recipe it applies. Anything serve sets
itself wins over a recipe. `--recipes FILE` replaces the built-in set and `--no-recipes` turns
recipes off ([recipes.md](recipes.md)). To measure a setting before making it a recipe, use
[`tools/bench.py`](bench.md).
Expand Down
4 changes: 2 additions & 2 deletions tests/recipes_route.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
# limitations under the License.
#
# How `1bit serve` applies recipes (config/recipes.json, docs/recipes.md), without a GPU:
# - the built-in set is empty (RFC #213 stage 3 dropped the ROCm-measured recipes): serve adds
# nothing, with or without a drafter,
# - the built-in set is scoped to Qwen3.8-27B (`qwen35`) on `hrx` (config/recipes.json), so a plain
# or MoE test file gets nothing, with or without a drafter,
# - a recipe file's flag is added and named on stderr, and a flag serve already set wins
# (--mtp-p-min 0.5 stays the only p-min),
# - --no-recipes adds nothing, --recipes FILE replaces the built-in set (flags and environment),
Expand Down
Loading