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

+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