spec: --draft-verify token|block|traversal for the coupled MTP chain

--draft-coupling verifies each row of the chain on its own. Two lossless
sequence-level verifiers accept more drafts from the same chain: Block
Verification (arXiv 2403.10444) decides the whole chain at once, Traversal
Verification (arXiv 2505.12398) walks a path from its last draft back to its
first. --draft-verify token (default) is the engine as it was; block switches
the coupling on; traversal needs it and is refused otherwise.

Block: the sampler marks the consecutive bound rows of a request with the
block's length (RadMtpCoupleState::blk) and mtp_couple_verify decides the block
on the workgroup of its round-1 row, every FP64 sum a fixed lane tree so the
result is the host reference's bit for bit. The wide-plane serial helper is a
kernel of its own, which leaves couple_verify without scratch.

Traversal: a new op mtp_trav_verify takes the step's topology (parent row, draft
token per row) and decides a request on one workgroup, 0 bytes of scratch: the
target's law as integer masses of a fixed-point exponential, the walk in FP64.
Its header and kernel also handle nodes with several children (Gumbel-top-k and
RheoSampling siblings); the serial head here drafts one, so that part has no
producer yet and is covered by the tests only.

RadMtpCoupleState grows from 152 to 168 bytes (nkids, scheme, blk), so
RAD_ABI_VERSION is 41.

Exactness: mtp_block_test enumerates the draft tree of a toy model and runs
chi-square over the real verify code; mtp_rrs_test runs chi-square and an
exhaustive enumeration of the walk (worst |joint - P| 7e-14) with negative
controls that fail; spechub_device_test compares the device rows with the host
rows. Measured on Qwen3.8-Flash-Next IQR-V4 (TP2, MTP chain 3, coupling) on our
branch: about +1% tok/s with traversal, +4.6% at T 1.0 top_k 0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Code000andClaude Opus 5.5 authored and StillDeadcode committed 2026-11-17 21:49:45 +01:00
1 parent 9b6eba80c6
commit d0fd4aa1bb
31 files changed
+5022 -30

No files matched your search

+1
View File
@@ -2423,6 +2423,7 @@ switch is set with `true`. The fleet's own keys (a model's `aliases`, `priority`
| `draft-window: MODE` | fixed | `fixed` drafts N every step; `adaptive` follows each sequence's acceptance and the measured step cost, for a serial draft head or prompt lookup alone (§4.6) |
| `draft-short-from: N` | auto | a block drafter that declares a shorter block runs it from N decoding sequences on, its own block again two below or at one sequence; 0 never; auto never for a chain and 2 for a tree drafter, which then verifies the short block's nodes (§4.6) |
| `draft-coupling: MODE` | off | `on`: a linear MTP drafter with a 2-bit candidate head (Qwen3.8-Flash-Next) samples each proposal from its reranked top-8 and the sampler maximally couples the target's draw to it. The output distribution is unchanged and a fixed seed yields other tokens than `off`. The head's law is taken at temperature 1, so it pays at high request temperatures and costs at low ones: on Flash-Next TP2 at 2x R9700, tokens per decode step +18% at temperature 1.0 and c1, +11% at 0.7 and c4, -4% at 0.3. Greedy rows are unchanged. A DFlash2 drafter (Qwen3.5/3.8) couples its candidate walk instead: each position is sampled from the softmax of the walk's own scores over its best eight candidates, at temperature 0.6 (fixed in `qwen35_fp8`, where acceptance peaked); on Qwen3.8-27B MXFP4 TP2 at 2x R9700 and request temperature 1, tokens per verify step +8% on held-out prompts at c4 (3.53 to 3.82) and decode +2..8% per stream at c1/c4. Any other drafter is refused at startup |
| `draft-verify: MODE` | token | how a coupled draft chain is verified: `token` decides each row on its own (maximal coupling); `block` decides the whole chain at once (Block Verification, arXiv 2403.10444) and switches `draft-coupling` on; `traversal` walks the chain bottom-up (Traversal Verification, arXiv 2505.12398) and needs `draft-coupling: on`. The output distribution is the same in all three, every draft a step accepts is one the target's own law would have produced, and `block` and `traversal` accept at least as many drafts a step as `token`. Sampled rows only: a greedy row is verified as before. The verify runs as one workgroup a request, with no scratch (§6) |
| `draft-model: PATH` | | not implemented: merge the drafter at convert time |
**Server**
+1 -1
View File
@@ -43,7 +43,7 @@ libavx/ the same vocabulary in x86 SIMD, host domain: the production h
built on every x86-64 build because the engine refuses to serve an op that
resolves only to libref (without debug-accept-reference-kernels)
libquant/ the built-in quantisers rad-convert's recipes name: grids, transforms, rtn, gptq
plugin/spechub/ the draft-coupling ops (`mtp_couple_propose`, `mtp_couple_verify`,
plugin/spechub/ the draft-coupling ops (`mtp_couple_propose`, `mtp_couple_verify`, `mtp_trav_verify`,
`dflash_couple_propose`, `draft-coupling: on`): schemas and shapes on the host,
launches on the card and in a host reference
arch/<id>/ one architecture plugin per directory
+3
View File
@@ -718,9 +718,11 @@ Rows declaring an optional hook (tuning, fusion, weight layout):
| `ref_dflash_couple_propose` | `dflash_couple_propose` |
| `ref_mtp_couple_propose` | `mtp_couple_propose` |
| `ref_mtp_couple_verify` | `mtp_couple_verify` |
| `ref_mtp_trav_verify` | `mtp_trav_verify` |
| `spechub_dflash_couple_propose` | `dflash_couple_propose` |
| `spechub_mtp_couple_propose` | `mtp_couple_propose` |
| `spechub_mtp_couple_verify` | `mtp_couple_verify` |
| `spechub_mtp_trav_verify` | `mtp_trav_verify` |
`libref`: 179 row(s) not reached:
@@ -1073,6 +1075,7 @@ on a marked row is a hole this model falls into.
| `moe_scatter_inv` | | - | device | - | - |
| `mtp_couple_propose` | | - | - | device+host | - |
| `mtp_couple_verify` | | - | - | device+host | - |
| `mtp_trav_verify` | | - | - | device+host | - |
| `mtp_enter` | | host | device | - | host |
| `mul` | | host | device | - | host |
| `mul_weight` | yes | host | device | - | host |
+17 -3
View File
@@ -2998,10 +2998,11 @@ resolutions of one op. The one exception is `sample_chain` (below).
| `sample_logprobs` | `M`(range) `n_vocab` `k` `vocab_off`/opt | `logits`, `params`? → `stats` |
| `mtp_couple_propose` | `M`(range) `n_vocab` `round` `max_rounds` | `idx`:inout, `val`, `seq_ids`, `draw` → `state`:inout |
| `mtp_couple_verify` | `M`(range) `n_cand` `n_vocab` | `cand_idx`, `cand_val`, `params`, `state` → `token`:inout |
| `mtp_trav_verify` | `M`(range) `n_cand` `n_vocab` | `cand_idx`, `cand_val`, `params`, `state` → `token`:inout, `topo` |
| `dflash_couple_propose` | `M`(range) `steps` `top_k` `rank` `n_vocab` `anchor_stride` `max_rounds` `q_temp`:f64/opt | `cand`, `unary`, `hp`?, `anchor`, `pred`w, `succ`w, `seq_ids`, `draw`, `tokens`:inout → `state`:inout |
`mtp_couple_propose`, `dflash_couple_propose` and `mtp_couple_verify` are the speculative coupling
(`draft-coupling: on`), and nothing else in the engine knows about coupling. Turning coupling on
`mtp_couple_propose`, `dflash_couple_propose`, `mtp_couple_verify` and `mtp_trav_verify` are the
speculative coupling (`draft-coupling: on`), and nothing else in the engine knows about coupling. Turning coupling on
requires a linear chain of drafts: a serial head's rounds, or a block drafter whose architecture
declares the coupled walk (DFlash2); no drafter, or a block drafter without the walk, is refused at
bringup, because neither has a per-round draw to couple. The `spechub` plugin ships every row and
@@ -3020,7 +3021,20 @@ token the target itself drew at that position, and otherwise the token is a draw
residual `(P - Q)+`. Both use 53-bit uniforms at `params.pos`; a row whose state is not bound to
that seed and position keeps the ordinary token. `P` is FP64-normalised where `sample_pick` is
FP32/24-bit, so a coupled row realizes the ideal filtered target law and is **not** seed-identical
to the ordinary pick.
to the ordinary pick. A state whose `blk` is at least 1 is the first row of a block, which the same
op decides together with the rows after it (`draft-verify: block`, Block Verification, arXiv
2403.10444, abi/rad_mtp_block.h): the workgroup of its round-1 row writes the tokens of rows 0 ..
tau and the block's other rows return.
`mtp_trav_verify` replaces `mtp_couple_verify` under `draft-verify: traversal` (Traversal
Verification, arXiv 2505.12398, abi/rad_mtp_traversal.h). Its sixth operand `topo` is `[M, 2]` int32
per sampled row: the parent's row in the step (-1 for a request's first row, the root of its tree)
and the row's own draft token; the rows of a request are contiguous, root first, parents before
children. One workgroup a request, on its root row, decides the whole request: the target's law of
each row as integer masses of a fixed-point exponential, the walk from the last draft back to the
first in FP64, and the tokens of the accepted path and the final token written into `token`. Rows
whose state is not eligible are leaves and keep the ordinary token. Any `n_cand`. The kernel has no
scratch segment. It emits the same law as the row-wise verify and accepts at least as many drafts.
`dflash_couple_propose` is DFlash2's block walk sampled (abi/rad_spechub.h,
`rad_dflash_couple_step`). It runs right after `dflash_select` over the same lattice, one workgroup a