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

+9
View File
@@ -89,6 +89,7 @@ set_target_properties(harness_fixture PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAK
# Binaries registered as several entries, <bin>_shard<k> running `<bin> --shard k/n`, so their
# cases run in parallel and no entry is the fast tier's long pole.
set(RAD_TEST_SHARDS_gbnf_test 4)
set(RAD_TEST_SHARDS_mtp_rrs_test 8) # chi-square statistics: eight ctest entries of under a minute each
# ------------------------------------------------------------------ the environment of every test
#
@@ -132,6 +133,8 @@ set(RAD_TEST_ENV ${RAD_TEST_CARD_ENV} "ROCR_VISIBLE_DEVICES=99")
# Binaries that need more CPU than the default budget, and what costs it. Lower an entry when its
# cost comes down, so the tripwire stays tight.
set(RAD_TEST_CPU_BUDGET_mtp_rrs_test 100) # chi-square over 2e5..4e5 seeds a case
set(RAD_TEST_CPU_BUDGET_mtp_block_test 40) # exact enumeration (g up to 4) plus ~1.6e6 chi-square steps over the real shared verify code
set(RAD_TEST_CPU_BUDGET_quant_ggml_test 25) # llama.cpp's iq1_s and iq2_* grid searches, ~13 s
set(RAD_TEST_CPU_BUDGET_tokenizer_test 20) # the reference encoder over every corpus: ~3 s built by GCC 16, ~10.5 s by GCC 14 (the image's Ubuntu)
set(RAD_TEST_CPU_BUDGET_arch_test 15) # every plugin's graph declared; ~10.8 s with the batched-tower case
@@ -350,6 +353,12 @@ if(TARGET spechub)
target_compile_definitions(spechub_wiring_test PRIVATE RAD_SPECHUB_WITH_DEVICE=1)
endif()
add_dependencies(spechub_wiring_test spechub)
# spechub_device_test runs the plugin's device verify rows against their host rows on a card
# (skips without one); it needs the same library path.
target_link_libraries(spechub_device_test PRIVATE ${CMAKE_DL_LIBS})
target_compile_definitions(spechub_device_test PRIVATE
RAD_SPECHUB_LIB="${RAD_PLUGIN_OUT}/kernels/spechub.so")
add_dependencies(spechub_device_test spechub)
# sample_test's coupling case declares a Sampler with draft_coupling set and needs the verify
# op the spechub plugin carries (its host row); it skips when the library is absent.
add_dependencies(sample_test spechub)