Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
3fd2fcf
conformance: cancel and evict gates, a cut reply and an evicted promp…
jschmied Nov 9, 2026
ed9a36c
conformance: skip takes only cancel and evict, --plant refuses a skip…
jschmied Nov 9, 2026
29755e7
conformance: the Metal profile runs cancel and evict, a lost free lan…
jschmied Nov 9, 2026
8948e0d
conformance: cancel and evict wait for an idle server before they tak…
jschmied Nov 9, 2026
890ba93
conformance: qwen27-metal skips evict with the measured reason; a lif…
jschmied Nov 9, 2026
4e39272
changelog: #2611 under Unreleased
ashhart Nov 9, 2026
6bbc53d
docs: the end-token pair for replies that quote a template marker
javierbits Nov 7, 2026
63d39fd
docs: stop on <|endoftext|> and <|im_start|> together, state the /tok…
javierbits Nov 9, 2026
51e20b9
Bind persisted prompt states to loaded execution policies
ashhart Nov 5, 2026
9309aa9
Include every indexed shard in persisted checkpoint keys
ashhart Nov 5, 2026
daafc65
Use portable indexed shard fixtures for every disk owner
ashhart Nov 5, 2026
562a1c6
Key what persisted prompt states were computed with, not what was ask…
ashhart Nov 9, 2026
3d8d809
persistence tests: the identity rewrite moves the shard's mtime a sec…
ashhart Nov 9, 2026
4e8e994
Key Flash Next CUDA and Nemotron disk states by what their prompt pas…
ashhart Nov 9, 2026
bfa1413
Key the lane's half-tile threshold for Flash Next CUDA and Nemotron d…
ashhart Nov 9, 2026
fd1fc52
Key the captured attention variant Nemotron CUDA's context picks
ashhart Nov 9, 2026
b4d6f1c
Check from source that Nemotron's keys take their resolved policies
ashhart Nov 9, 2026
d6fc432
persisted-serving-keys: name the lane and captured-variant keys, and …
ashhart Nov 9, 2026
af0c25f
persisted-serving-keys: name the unkeyed lane-parts setting, apart fr…
ashhart Nov 9, 2026
33a9e42
persistence fixture: on Windows, rely on NTFS's moving write time ins…
ashhart Nov 9, 2026
ae3c57c
changelog: #2287 under Unreleased
ashhart Nov 9, 2026
25a657a
tokenizer memo: keep segments of 64 bytes or more, not 1,024
mrv777 Nov 8, 2026
8464813
changelog: the tokenizer memo line names #2509
mrv777 Nov 8, 2026
1f7ea3a
tokenizer memo: each kept segment counts its entry and key against th…
mrv777 Nov 9, 2026
a4a45e5
tokenizer memo: the cap test fixes its cap in text and id bytes, so i…
mrv777 Nov 9, 2026
2be7335
changelog: one line for the tokenizer memo
ashhart Nov 9, 2026
27691af
changelog: #2509's line from lines/2509.txt in place of its own
ashhart Nov 9, 2026
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
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ Each release's page on GitHub has its notes and measurements. See [the 1.0.0 rel

## Unreleased

- Server: the tokenizer's memo keeps segments of 64 bytes or more, not 1,024, so a chat's short earlier messages and tool calls are tokenized once instead of on each of a request's renders, with the same ids. On real agent conversations (Qwen3.8-27B tokenizer, up to 60K tokens) a warm encode of the longest takes about 150 µs instead of 690 µs, and a one-off prompt is no slower (#2509). Thanks to @mrv777.

- Persisted prompt states (the prompt cache's disk tier and `--learn-conversations`): every family that saves states to disk now keys them by what its loaded run actually computed with, not only the flags as set: resolved arithmetic and kernel choices, every indexed weight shard (subfolders included), and external loaded inputs such as the CUDA Qwen rotary table, a Flash Next pack outside its folder, Flash Next on CUDA's chunk heights and kernel forms, and Nemotron's precision, expert ranks, ModelOpt lane and captured attention variant. A state computed differently now misses instead of resuming, and a resumed state still equals a fresh one. Upgrading starts every kept state once cold, and so does changing a GLM or Qwen Metal prompt chunk height. `GLM_EHPROJ_NAX` now takes only `0` or `1`; other text, which used to read as on, is refused at start (#2287, part of #2131).

- Conformance: the cancel and evict gates check that a cut reply and an evicted prompt leave the server as a fresh one, with a planted fault for each; the Qwen3.8-27B Metal profile skips evict with its measured reason, and the CUDA profiles run both (#2611). Thanks to @jschmied.

- HIP: the qwen3_5 engine builds the DFlash2 drafter's kernels (tap gathers, key ring, dynamic conv, block attention), tested and in the kernel contract; nothing launches them yet (#2545, part 3 of #1563). Thanks to @AbrahamCete.

- CUDA: Qwen3.8-27B can draft with Tencent's DSpine-b16 when `--drafter` names its folder (never the default). Its code bridge and exact-sender table run on affine-4 projections, and the draft tree walker moves into `core/lanes` so every backend shares it. Replies are unchanged: every drafted reply equals the same request with drafts off. On a GB10, agent-shaped requests decoded 3-20% faster than with DFlash2, and chat and code 9-19% slower, which is why it is opt-in (#2633, refs #2592). Thanks to @jschmied.
Expand Down Expand Up @@ -307,6 +313,8 @@ Each release's page on GitHub has its notes and measurements. See [the 1.0.0 rel
is refused by name; `TF_LANE_TRACE` gains a `cancel` line for a request cancelled between two prompt calls (#2458,
part of #2324). Thanks to @laudney.

- Docs: a reply that quotes a template marker can finish with `ignore_eos` and a stop list for the model's end-of-text and next-turn-open spellings, then a strip of the trailing turn marker; measured on two Qwen checkpoints on a GB10, with the agent-shaped runs reported in #2399 (#2437, refs #2399). Thanks to @javierbits and @robertung88.

## 1.2.4

- Docs: four subcommand-flag fixes checked against the code: `slide audit --threshold`'s range, `benchmark --context` and `--kv-cache`, `info` on Flash Next, and `run --device` and `--carveout` on CUDA builds (#2348).
Expand Down
26 changes: 26 additions & 0 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,32 @@ token or the reply limit; the server returns the reply only up to the match. Whe
`ignore_eos`, end tokens inside the reply are decoded into its text, as on MLX, and `finish_reason` is `length`
unless a stop string or a tool call ended the reply.

### Replies that quote a template marker

Some templates encode their turn-end spelling as one added token: Qwen3.8-Flash-Next's tokenizer encodes
`<|im_end|>` to one id, while `<|tool_call_begin|>` stays seven ordinary tokens, as `POST /tokenize` with
`{"prompt": "<spelling>", "add_special_tokens": false}` shows ([#2399]). A reply can quote that spelling with
ordinary tokens and finish normally; when it draws the one-token spelling instead, the turn ends there even inside
a code span. The server stops on the token the model drew; it does not sample past the end token and decide
afterwards, because that would change the reply.

A plain request already finishes on the checkpoints measured so far: they spell a quoted marker with ordinary
tokens, and the server stops on the end token when the model draws it. A client that still uses `ignore_eos`
should stop on `["<|endoftext|>", "<|im_start|>"]` and not on `<|im_end|>` or end-of-text alone. With
`ignore_eos`, the end token no longer stops the reply, and behind an agent prompt the model often opens the next
turn instead of writing end-of-text, so a stop on end-of-text alone never fires; the invented turns run on, and a
tool parser returns their tool calls ([#2399]). Strip a trailing `<|im_end|>` and the whitespace after it before
display. The cost is the same for both stops: a stop string matches the spelling however it is tokenized, so a
reply that quotes `<|endoftext|>`, `<|im_start|>` or `<|im_end|>` as text is cut there. A `stop` for `<|im_end|>`
cuts at least where the end token would, and also where the reply spells it with ordinary tokens.

Measured greedy on a GB10 with a finished tool call and its result in the conversation, on Qwen3.5-2B MLX
4-bit and Qwen3.6-35B-A3B NVFP4: both checkpoints wrote the quoted marker with ordinary tokens, so the plain request
finished; with `ignore_eos` and `stop: ["<|endoftext|>", "<|im_start|>"]` all replies stopped right after their
first end, and each ended with the drawn `<|im_end|>` for the client to strip. On an agent-shaped body, the runs
reported in #2399 gave 0/9 runaways with the pair, against 7/9 with end-of-text alone, on stock Qwen3.8-Flash-Next
weights.

On MLX, `--parallel auto` is the default: requests share rounds within the configured concurrency and memory
budget. Every admitted prompt prefills a chunk at a time beside the others. Each chunk goes to a foreground prompt
before a background one, then to the prompt with the fewest tokens left, and a prompt passed over for 8 chunks takes
Expand Down
1 change: 1 addition & 0 deletions docs/environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Diagnostics quote and escape the supplied text so it cannot create another termi
| `TF_GLM_DRAFT_CONFIDENCE` | Finite number 0 through 1 where a DFlash2 chain's chance product stops it; default 0.7 |
| `TF_PROMPT_ROWS` | Native serving: a multiple of 16 from 128 through 2048; unset keeps the chip/family default |
| `TF_ANE_COLUMNS` | Whole u32 count; zero disables the experimental share; default zero |
| `GLM_EHPROJ_NAX` | GLM-5.3-Flash on Metal: exactly `0` or `1`; `0` serves the MTP head's prompt eh_proj on the scalar kernel; default 1, the tile kernel where it builds |
| `XPU_A8_BITS` | Exactly `4` or `8`, for the XPU quantization study; unset keeps the study's existing setting |
| `LFM3_FUSE` | Whole u32 fusion mask; default 7 |
| `TF_SLIDE_POCKET_KEY` | Exactly `auto`, `reply`, `subject` or `both`; default `auto` |
Expand Down
48 changes: 39 additions & 9 deletions docs/recipes/persisted-serving-keys.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ Old files remain in their original namespace and follow the existing cache budge

| Persistence owner | Source and arithmetic | Checkpoint | KV and draft state | Weight learning |
| --- | --- | --- | --- | --- |
| Nemotron, Metal | Binary, kernel texts, precision mode, probe, OS build and GPU | Config, index, shard stamps and MTP header | Canonical snapshot, head flag and probe | Shared host clears RAM and detaches disk stores when weights move |
| Dense Qwen hybrid, Metal | Binary, shared/family shader texts, tensor/ANE modes, probe, OS build and GPU | Config, index and shard stamps for target and external drafter | Canonical recurrence/KV/tap image and draft end | Unsupported learners refuse; the store remains scoped to its loaded model |
| GLM, Metal | Binary, compiled source hash, rank/chunk modes, probe, OS build and GPU | Config/index identity plus current shard stamps | Canonical KDA/MLA image and checked snapshot header | Unsupported learner on this adapter |
| Flash Next, Metal | Binary, actual loaded shader texts/bindings, rotary/precision policy, probe, OS build and GPU | Pack metadata identity plus current shard stamps | Checked snapshot layout; canonical session image | Unsupported learner on this adapter |
| Nemotron, CUDA | Binary, embedded images, captured manifest and cubin bytes, probe, GPU and driver | Config, index and shard stamps | Head flag and canonical state image | Shared host clears RAM and detaches disk stores when weights move |
| Qwen dense/MoE hybrids, CUDA | Same shared CUDA identity | Same shared checkpoint identity | Explicit BF16/FP8 format, tap flag and prompt-int8 mode; image states stay off disk | Same shared learning barrier |
| Flash Next, CUDA | Same shared CUDA identity | Same shared checkpoint identity | Head flag and canonical recurrence/KV/PLE image; tensor-rank disk persistence is refused | Same shared learning barrier |
| Nemotron, Metal | Binary, kernel texts, precision mode, prompt step, loaded coop K-slice split and its scratch rows, probe, OS build and GPU | Config, index, shard stamps and MTP header | Canonical snapshot, head flag and probe | Shared host clears RAM and detaches disk stores when weights move |
| Dense Qwen hybrid, Metal | Binary, shared/family shader texts, tensor mode, loaded ANE columns and prompt policy, probe, OS build and GPU | Config, index and shard stamps for target and external drafter | Canonical recurrence/KV/tap image and draft end | Unsupported learners refuse; the store remains scoped to its loaded model |
| GLM, Metal | Binary, compiled source hash, resolved rank/route/prompt policy, probe, OS build and GPU | Config/index identity plus current shard stamps | Canonical KDA/MLA image and checked snapshot header | Unsupported learner on this adapter |
| Flash Next, Metal | Binary, actual loaded shader texts/bindings, rotary/precision and resolved execution policy, probe, OS build and GPU | Pack metadata identity, current source and loaded-pack stamps, loaded reference bytes | Checked snapshot layout; canonical session image | Unsupported learner on this adapter |
| Nemotron, CUDA | Binary, embedded images, captured manifest and cubin bytes, resolved checkpoint math, expert ranks, NVFP4 decode form, lane half-tile threshold, expert grids and captured attention variant, probe, GPU and driver | Config, index and shard stamps | Head flag and canonical state image | Shared host clears RAM and detaches disk stores when weights move |
| Qwen dense/MoE hybrids, CUDA | Same shared CUDA identity | Same shared checkpoint identity | Explicit BF16/FP8 format, tap flag, prompt-int8 mode and actual rotary table; image states stay off disk | Same shared learning barrier |
| Flash Next, CUDA | Same shared CUDA identity, plus resolved prompt chunk heights, prompt kernel forms and tile thresholds, expert grids and captured-set use | Same shared checkpoint identity | Head flag and canonical recurrence/KV/PLE image; tensor-rank disk persistence is refused | Same shared learning barrier |
| DeepSeek sessions, CUDA reference path | Config/options/mode, checkpoint digest, rank, selected layers and piece layout | Checkpoint digest required | Versioned lossless session pieces and exact token prefix | No learner; the disk tier starts fresh for each process |

Other native family adapters have no attached cross-process serving-state tier. Their snapshots remain owned by one
Expand All @@ -28,11 +28,40 @@ boundaries, while the shared cache compares decoded spans and image identities.
rendered answer text. No separate hot-swappable LoRA state is admitted by these persistence adapters; checkpoint
changes and supported external drafters use the identities above.

GLM and Flash Next now include safetensors shard names, sizes, inode and modification/change stamps. A weight
Checkpoint keys include every validated indexed shard path, including subfolders and any suffix accepted by the loader, plus
auxiliary top-level safetensors files. Their names, sizes, inodes and modification/change stamps are bound. A weight
write with unchanged config, index, tensor header and size moves their namespace even when a fixed probe does not
visit the changed tensor. Flash Next also hashes the loaded variant text and input/output/meta bindings in sorted
function-name order. Captured CUDA sets hash each cubin named by the parsed manifest, through the same loader
paths and size limit. A missing or changed file fails identity construction instead of opening an old namespace.
paths and size limit. A missing or changed file fails identity construction instead of opening an old namespace;
a shard the index names but the folder lacks is refused as `IndexedShardMissing`, as the loaders refuse it.

Resolved policies are bound even when a fixed startup probe does not exercise their difference. The Metal Qwen
key includes loaded ANE columns and the prompt chunk height, not the frame's buffer rows. GLM includes effective
rank slices, routing, its prompt chunk height and sparse kernel, and whether the MTP head's prompt eh_proj runs on
the tile kernel as the load built it (`GLM_EHPROJ_NAX=0` or a failed tile build: scalar). A different chunk height
starts these two stores cold: GLM's prompt windows and chunks sum in different orders (#743), and Qwen's may too.
Flash Next includes its resolved execution branches, including the DeltaNet window kernels, but not the serial
encoder choice, which orders the same launches. It also binds stamps of the files actually indexed (including an
external weight pack) and the bytes of loaded metadata such as a supplied reference. Descriptor and mapping order
do not change that key. CUDA Qwen keys include the rotary table the target consumes, for dense and routed
checkpoints. These additions change the optional disk namespace; snapshot payloads and layouts are unchanged.

Flash Next on CUDA keys what its prompt passes resolved at load: the solo and busy chunk heights (a different
`TF_FLASHNEXT_CHUNK` or `_CHUNK_SOLO`, or `--parallel 1` taking the larger pass, starts cold), the DeltaNet, read-out,
hyper-connection and in-pass mark forms, the NVFP4 prompt-tile threshold, K32 tile, BF16 prompt tiles and the SM count
they are weighed against, the lane's half-tile threshold (`TF_QMMF_HALF_BELOW`), the experts' decode warps and resident
grids, and whether a captured set runs with which entries on our glue. `TF_FLASHNEXT_KV_PAGES` and `_KV_PAGES_ALL` are
keyed through the profile rows. Its draft, window, round, graph, lane-parts (`TF_FLASHNEXT_LANE_PARTS`), load-thread, I/O and dense-split settings and
`TF_FLASHNEXT_KV_PAGE_TEST` are not keyed: kept states come only from prompt passes, which those settings either never
reach, reach with the same launches or the same kernels addressing pages, or refuse for disk at `--tp 2`.
Nemotron on CUDA keys `--precision checkpoint`'s math, the expert ranks of `TF_NEMOTRON_WORLD`, a ModelOpt
checkpoint's NVFP4 decode warps and lane half-tile threshold, the experts' resident grids and, with a captured set, the
attention variant `--context` picks by its chunk count. Its pages, poison fill, carveout, segments, graph log and trace,
and the context on our own glue, are not keyed: they place memory, fill pages before use, log, run only passes that
keep no state (segments), or set a stride our merge ignores. Nemotron on Metal also keys `TF_COOP_SPLIT` as loaded and,
with the split on, the scratch rows a prompt chunk's partials must fit; its page plan and stream count otherwise only
size buffers.

The executable and kernel fingerprints use a 32 KiB read buffer and check file stamps across the read. Checkpoints,
executables and kernel assets must remain stable while a model opens and serves. The existing learner owns runtime
Expand All @@ -43,6 +72,7 @@ Host checks:
```sh
zig build test-persistence-identity-host test-cuda-persistence-source-host compile-persistence-host -j1
zig build test-checkpoint-identity test-cuda-disk-open-host test-sessions test-frame-cache-identity-host -j1
zig build test-disk-identity-host -j1
```

The first command's Metal consumer compile and checkpoint fixtures require a macOS host but execute no GPU call.
Expand Down
Loading
Loading