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

+51
View File
@@ -10997,6 +10997,57 @@ TEST(flashnext_steps_lint_clean_at_one_two_and_four_ranks) {
}
}
/* --draft-suffix: the verify window is widened to 7 drafts (`max_spec` 7: the delta-net fold serves 8
* query rows) while the head still drafts 3 rounds. A suffix step is an eight-row verify, then the
* head's history pass over all eight rows (round 1 on the last) and rounds 2 and 3; the head's own
* step in the same deployment is four rows and the same passes. Both lint clean, and every pass issues
* the same ops by name, the same number of times, as the head's step at its own window does: only row
* counts differ, and round 3 of a deployment whose head declared more rounds than it runs carries one
* `cast` more (its hidden state on to a round 4 the core does not issue; a few microseconds). */
TEST(flashnext_a_suffix_step_issues_the_heads_ops_over_eight_rows_and_lints_clean) {
MetaKV mk = q4_small();
const RadModelMeta& meta = *mk.meta();
std::vector<std::map<std::string, size_t>> pattern[3];
int idx = 0;
for (const auto& cfg : { std::pair<int, int>{ 3, 4 }, std::pair<int, int>{ 7, 8 }, std::pair<int, int>{ 7, 4 } }) {
RadBuilder b;
b.encs = { { "draft_head", u2_head() } };
RadBuildCtx ctx = q4_ctx(0, 1);
ctx.max_spec = cfg.first;
REQUIRE_EQ(qwen4exp_fp8::declare(&b, &meta, &ctx), RAD_OK);
REQUIRE_EQ((int)b.drafter.kind, (int)RAD_DRAFT_SERIAL);
const auto ver = kit(b, std::vector<int>(1, cfg.second), {});
CHECK_EQ((int)ver->b.n_spec, cfg.second - 1);
const auto his = history_pass(b, *ver);
CHECK_EQ((int)his->b.n_tok, cfg.second); /* every verified position */
CHECK_EQ(his->dout[0], cfg.second - 1); /* round 1 on the last row */
const auto r2 = round_pass(b, 1, 2), r3 = round_pass(b, 1, 3);
const auto v = run_passes(b, qwen4exp_fp8::step, { ver.get(), his.get(), r2.get(), r3.get() });
CHECK_PASSES(b, v);
std::set<std::string> names;
for (const RecOp& o : b.ops) names.insert(o.op);
for (size_t pass = 0; pass < v.size(); ++pass) {
std::map<std::string, size_t> m;
for (const std::string& nm : names) m[nm] = issues_of(b, *v[pass], nm.c_str()).size();
pattern[idx].push_back(m);
}
++idx;
}
for (size_t pass = 0; pass < 4; ++pass)
for (int o = 1; o < 3; ++o) {
std::map<std::string, std::pair<size_t, size_t>> d;
for (const auto& [nm, n] : pattern[0][pass])
if (pattern[o][pass].at(nm) != n) d[nm] = { n, pattern[o][pass].at(nm) };
if (pass == 3) {
CHECK_EQ(d.size(), (size_t)1);
CHECK_EQ(d.at("cast").first, (size_t)0);
CHECK_EQ(d.at("cast").second, (size_t)1);
} else {
CHECK_EQ(d.size(), (size_t)0);
}
}
}
/* Sparse attention issues one row per query, chunked by the split-KV scratch it declared, never
* by `max_seqs`: with four sequences allowed, a 1024-token chunk after a long history is one
* launch of the gated form, or four of 256 rows where only the plain form resolves. Rows of four