sched: --draft-suffix on, SuffixDecoding as a step selector on the MTP chain

After each commit the scheduler looks in the sequence's own prompt and output
for the latest earlier occurrence of its last --draft-suffix-min-match tokens;
the next step then verifies what followed it (up to --draft-suffix-max rows,
cut where the product of the follower frequencies falls under
--draft-suffix-min-score) in place of the head's draft. The verify window
becomes the larger of the two while the head keeps its own rounds. A sequence
whose history ended in a recurring pattern is not issued ahead, since the step
is built after the commit where the lookup can read the committed end.

It works with the fixed MTP chain, with --draft-depth adaptive and with
--draft-verify traversal. A suffix chain carries no coupled row
(Request::draft_suffix): the sampler binds none of the head's staged states to
its rows, so each row is the target's plain draw and the rows are leaves of the
traversal walk; mtp_rrs_test checks the law with a negative control that fails.
--draft-verify block is refused. The window is at most 7 rows on Flash-Next (the
delta-net fold's register window).

On Flash-Next IQR-V4 (TP2) on our branch, window 7 on chain 3 with coupling:
+1.4% overall, +2.9% on repetitive tasks, +11% on quoting, free chat unchanged;
beside adaptive depth +0.2% [-1.0, +1.5] overall, code +1.0%. Off by default.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Code000andClaude Opus 5.5 committed 2026-11-17 22:11:30 +01:00
1 parent e78d484e60
commit b8bca7885a
22 files changed
+1112 -9

No files matched your search

+13
View File
@@ -17,6 +17,7 @@
#include "lookup.h"
#include "metrics.h"
#include "ngram.h"
#include "suffix.h"
#include "diag/diagnose.h"
#include <chrono>
@@ -82,6 +83,8 @@ struct SchedReq {
void drafter_reset() {
n_draft = 0;
draft_next = 0;
draft_suffix = false;
suffix_hot = false;
conv_cursor = 0;
draft_filled = 0;
draft_lo = 0;
@@ -93,6 +96,13 @@ struct SchedReq {
DraftAdapt adapt;
/* The proposal the step being planned carries came from prompt lookup (StepEntry::ngram). */
bool draft_ngram = false;
/* --draft-suffix (suffix.h): the proposal the step being planned carries is a suffix chain
* (StepEntry::suffix); and whether the last commit left the sequence's history ending in a
* recurring pattern, which keeps the next step from being issued ahead (it is built after the
* commit, where the lookup can run). */
bool draft_suffix = false;
bool suffix_hot = false;
SuffixIndex suffix_ix;
/* Prompt lookup's index over prompt ++ output (ngram.h), built at the sequence's first lookup
* and extended by each later one. It depends on the tokens alone, so preemption keeps it; it
* is keyed by request id, so a recycled slot starts over, and a closed request frees it. */
@@ -651,6 +661,9 @@ private:
* far the match behind the proposal runs back (NgramIndex::propose), -1 when the proposal did
* not come from the index (--debug-draft-oracle). */
int draft_ngram(SchedReq& s, int depth, int* match = nullptr) const;
/* --draft-suffix: the suffix proposal for `s`'s next step, over its committed history, into
* `out` (RAD_SCHED_MAX_SPEC entries). Returns its length, 0 for none. */
int suffix_propose(SchedReq& s, int32_t* out, int* match = nullptr);
/* Prompt lookup is the deployment's only drafter and --draft-window adaptive is on: its
* proposals feed each sequence's estimate and are capped by its window, as a head's are. */
bool lookup_adapt_ = false;