patrickbdevaney commited on
Commit
c6fbbd3
Β·
verified Β·
1 Parent(s): dfe3665

MTP block is runnable: recurrent-state rollback + draft repack

Browse files
Files changed (1) hide show
  1. README.md +50 -10
README.md CHANGED
@@ -48,9 +48,10 @@ cmake -B build -DGGML_CUDA=ON -DCMAKE_BUILD_TYPE=Release
48
  cmake --build build -j --target llama-completion llama-server llama-quantize
49
  ```
50
 
51
- The patch is 12 commits. Everything needed to load and run these files is in the first three; the
52
  rest is DSA (DeepSeek sparse attention) work that is **gated off by default** and does not change
53
- behaviour, plus the EOG conversion fix described above.
 
54
 
55
  What the patch adds:
56
 
@@ -118,8 +119,8 @@ The source exists in three independent places, so no single one going away stran
118
 
119
  1. **GitHub** β€” [`patrickbdevaney/llama.cpp`](https://github.com/patrickbdevaney/llama.cpp) branch
120
  `glm5_next`, tag `glm5-next-reap50-gguf-v1`.
121
- 2. **The patch here** β€” `glm5-next-llama.cpp.patch`, 12 commits, applies to upstream `761797ff`.
122
- 3. **`glm5-next-llama.cpp.bundle`** β€” a complete git bundle: full history, all 12 commits, and the
123
  upstream base commit included, depending on no repository staying reachable at all:
124
 
125
  ```bash
@@ -211,14 +212,53 @@ not be read as one quant beating another. If Q4_K_S measures below Q4_K_M here,
211
  variance, not evidence that the smaller file is better β€” the gate exists to catch a broken quant
212
  (nan, or a number an order of magnitude off), and it is sized for that job only.
213
 
214
- ## The MTP block ships, and llama.cpp cannot run it
215
 
216
- Layer 45 is a full multi-token-prediction block (3.81B params, ~2 GiB at Q4_K_M). llama.cpp
217
- loads NextN/MTP tensors and never executes them β€” no architecture does today. The weights are
218
- here so the files are ready if that changes. **They do nothing right now**, and this is not a
219
- roadmap promise.
 
220
 
221
- Speculative decoding via `-md` with a separate draft model works normally.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
222
 
223
  ## Vision
224
 
 
48
  cmake --build build -j --target llama-completion llama-server llama-quantize
49
  ```
50
 
51
+ The patch is 15 commits. Everything needed to load and run these files is in the first three; the
52
  rest is DSA (DeepSeek sparse attention) work that is **gated off by default** and does not change
53
+ behaviour, the EOG conversion fix described above, and the three commits that make the MTP block
54
+ runnable (see below) β€” none of which alter ordinary decoding.
55
 
56
  What the patch adds:
57
 
 
119
 
120
  1. **GitHub** β€” [`patrickbdevaney/llama.cpp`](https://github.com/patrickbdevaney/llama.cpp) branch
121
  `glm5_next`, tag `glm5-next-reap50-gguf-v1`.
122
+ 2. **The patch here** β€” `glm5-next-llama.cpp.patch`, 15 commits, applies to upstream `761797ff`.
123
+ 3. **`glm5-next-llama.cpp.bundle`** β€” a complete git bundle: full history, all 15 commits, and the
124
  upstream base commit included, depending on no repository staying reachable at all:
125
 
126
  ```bash
 
212
  variance, not evidence that the smaller file is better β€” the gate exists to catch a broken quant
213
  (nan, or a number an order of magnitude off), and it is sized for that job only.
214
 
215
+ ## The MTP block runs now β€” but it will not make you faster yet
216
 
217
+ Layer 45 is a full multi-token-prediction block (3.81B params, ~2 GiB at Q4_K_M), and every quant
218
+ here carries it. Stock llama.cpp loads those tensors and never executes them. The patched build
219
+ does: `make_mtp_draft.py` (in this repository) lifts `blk.45` out of any of these files into a standalone
220
+ ~2.3 GiB draft model, and `-md` picks it up automatically β€” the draft announces its architecture,
221
+ so there is no extra flag.
222
 
223
+ ```bash
224
+ python make_mtp_draft.py GLM-5.3-Flash-REAP50-IQ3_M.gguf \
225
+ GLM-5.3-Flash-REAP50-IQ3_M-MTP-draft.gguf # ~35 s, no requantisation
226
+ ./build/bin/llama-speculative-simple -m GLM-5.3-Flash-REAP50-IQ3_M.gguf \
227
+ -md GLM-5.3-Flash-REAP50-IQ3_M-MTP-draft.gguf -ngl 24 --draft-max 3
228
+ ```
229
+
230
+ Make the draft from **the same file you are serving**. Hidden states differ measurably between
231
+ quants (IQ3_M vs IQ4_XS cosine 0.891, against 0.999 for a same-quant control), and the draft
232
+ consumes the target's hidden state.
233
+
234
+ **Two things had to be fixed for this to work at all, and one is not fixed.**
235
+
236
+ Speculation rejects a drafted token by removing it from the KV cache, and 34 of these 45 layers
237
+ are KDA linear attention, whose rolling state has no per-token history to rewind to β€”
238
+ `llama_memory_recurrent::seq_rm` refuses the removal. The patch checkpoints the recurrent state
239
+ (145.56 MiB, fixed by the model, not by context length) and replays the accepted tokens. Worth
240
+ knowing if you are on an older build: that failure was *silent*. `llama_decode` returned -1,
241
+ nothing checked it, and generation continued from stale logits while reporting an acceptance rate
242
+ for tokens it had never verified.
243
+
244
+ What is not fixed is the economics. Acceptance is real β€” **46.5% at depth 2, 58.5% at depth 3**,
245
+ with the block exactly as GLM shipped it β€” but end to end it is *slower* than not speculating:
246
+
247
+ | | baseline | depth 2 | depth 3 |
248
+ |---|---|---|---|
249
+ | IQ3_M, `-ngl 24`, Thor | 2.99 t/s | 1.73 t/s | 1.85 t/s |
250
+
251
+ The draft is not the problem (5.3 ms/token) and neither is the checkpoint (~11 ms). The target's
252
+ cost per token barely falls with batch size until 32 tokens β€” 334 ms at batch 1, still 233 ms at
253
+ batch 16, then 43 ms at batch 32 β€” because `op_offload_min_batch_size` defaults to 32, and below it
254
+ the layers `-ngl 24` leaves in system memory are computed on the CPU. A draft of depth K produces a
255
+ batch of K+1, which is always on the wrong side of that. So verifying costs nearly as much as
256
+ decoding, and the ceiling at depth 3 is 1.29x before any overhead. (`GGML_OP_OFFLOAD_MIN_BATCH`
257
+ lowers the threshold and segfaults below 32 β€” do not reach for it.)
258
+
259
+ **So: use this if you want to measure or improve the head, not to go faster today.** Speculative
260
+ decoding via `-md` with an ordinary separate draft model works normally and is subject to exactly
261
+ the same batch-size ceiling.
262
 
263
  ## Vision
264