spec: --draft-depth adaptive stops the MTP chain inside the step

A coupled serial chain stops as soon as the product of the head's own
probabilities along it falls under --draft-depth-stop (default 0.85; top or
path statistic, at most --draft-depth-max rounds, at least --draft-depth-min),
and the next verify carries exactly the drafts made. The decision trails the
chain by --draft-depth-lag rounds (default 1), so the host's readback of one
state row and its issue of the next round hide behind the running round.

The rule reads the draft's laws and the tokens drawn before the one a decision
admits, never the target and never the admitted token, so the row-wise and the
traversal verify stay exact; mtp_rrs_test checks it by chi-square with two rules
that must fail (one reads the admitted draft's own mass, one the target).

It excludes --draft-window adaptive, which picks the next step's window from
earlier acceptance and step cost and so is a second controller on the same chain.

The recorded-pass cache holds 48 passes instead of 24: every row count is its
own pass shape and the adaptive chain makes more of them than 24 hold.

On Flash-Next IQR-V4 (TP2) on our branch, against chain 3 with coupling and
traversal: +3.0% tok/s [+1.0, +5.0] over 117 paired requests; the 48-entry cache
is +1.7% [+1.1, +2.3] of that for this mode.

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 d0fd4aa1bb
commit e78d484e60
13 files changed
+1054 -4

No files matched your search

+37
View File
@@ -29,6 +29,7 @@
#include "runtime/ctx.h" /* KVStageRun */
#include "sched/mem_iface.h"
#include "sched/scheduler.h"
#include "sched/draft_depth.h" /* --draft-depth adaptive: the stop rule */
#include "sample/vocab_view.h"
#include "runtime/rank_barrier.h"
#include "text/tokenizer.h"
@@ -677,6 +678,42 @@ private:
bool couple_evidence_ = false; /* the completed-verify line was written (once a process) */
bool couple_host_note_ = false; /* the host-domain counterpart was written (once) */
bool couple_malformed_note_ = false; /* a status -1 round was reported (once) */
int64_t couple_planes_ = 0; /* the rounds the state plane holds */
/* --draft-depth adaptive (sched/draft_depth.h, engine_draft.cpp): the chain of a step stops by
* the head's own laws, so its rounds are issued one decision at a time. After the pass of
* round r the engine copies that round's state rows to depth_rb_ and records depth_ev_[r - 1];
* the driver waits for the event of the round a decision needs, reads the statistic and issues
* the next round or ends the chain. depth_of_[i] is drafting row i's final depth, which
* expect_draft, set_draft and the coupling's bind all take in place of the rounds that ran. */
DraftDepthCfg depth_cfg_;
RadEvent depth_ev_[RAD_MTP_COUPLE_MAX_ROUNDS] = {};
bool depth_issued_[RAD_MTP_COUPLE_MAX_ROUNDS] = {};
RadMtpCoupleState* depth_rb_ = nullptr; /* pinned [rounds, couple_rows_] */
std::vector<DraftDepthRow> depth_row_;
std::vector<int32_t> depth_of_;
int depth_seen_ = 0; /* rounds observed this step */
int64_t depth_spin_us_ = 3000; /* RADIANCE_DEPTH_SPIN_US: poll this long, then block */
struct DepthStats {
uint64_t steps = 0, rows = 0, rounds = 0, drafts = 0, lawless = 0, waits = 0, blocked = 0;
uint64_t hist[RAD_MTP_COUPLE_MAX_ROUNDS + 1] = {};
double wait_us = 0;
uint64_t late = 0;
/* By the drafts a step made (d): the card's cycle from that step's first statistic to the
* next step's (its later rounds, the verify of d + 1 rows, the sampler, the next history
* pass), and what the verify of d drafts accepted. */
double cyc_us[RAD_MTP_COUPLE_MAX_ROUNDS + 1] = {};
uint64_t cyc_n[RAD_MTP_COUPLE_MAX_ROUNDS + 1] = {};
uint64_t acc[RAD_MTP_COUPLE_MAX_ROUNDS + 1] = {}, acc_n[RAD_MTP_COUPLE_MAX_ROUNDS + 1] = {};
} depth_stats_;
std::chrono::steady_clock::time_point depth_e1_{}; /* the last step's first statistic */
uint64_t depth_logged_ = 0; /* depth_stats_.rows at the last line */
int depth_last_ = 0; /* and the deepest chain that step made */
/* Drafting row i's depth after issue_serial_drafter: its own under the adaptive rule, else the
* rounds every row ran. */
int depth_row_nodes(int i) const;
int depth_readback_issue(int round, int n);
int depth_observe_upto(int round, int n, const StepOut& so);
void depth_log_stats(const char* when);
/* `rows` are serial_row_ or block_row_ (Scheduler::SerialRow / BlockRow). */
template <class Row> int stage_couple_draws(const Row* rows, int n);
int bind_couple(uint64_t seq, int i, int done, bool drafted, int32_t card);