Revert "serve: --lookup-long-match N, a lookup window past 8 rows only where the matched context is N tokens or more (opt-in, with --lookup-max-t)"

This reverts commit 394af4cd0f.
This commit is contained in:
Niko1221 committed 2026-11-01 06:51:24 +01:00
1 parent d10d67b005
commit e208427797
4 files changed
+2 -28

No files matched your search

-5
View File
@@ -81,10 +81,6 @@ public:
/// The window sizes a lookup or chained window may use, as a bit mask (bit t = size t; bit 1 is always kept).
void set_sizes(unsigned mask);
/// Copy-heavy gate (--lookup-long-match N, opt-in): a lookup window longer than `from_t` rows is taken only when the
/// matched context is at least `min_match` tokens (a rewrite or a repeat; a list or ordinary prose matches short), so
/// the wide sizes cost nothing on text that does not copy. 0: no gate.
void set_long_gate(int from_t, int min_match) { long_from_ = std::max(2, from_t); long_match_ = std::max(0, min_match); }
void disable(int t); // drop one size (its window graph did not fit)
bool allowed(int t) const { return t >= 1 && t <= max_t_ && ((sizes_ >> t) & 1u); }
/// The largest allowed size <= t (1 if none).
@@ -117,7 +113,6 @@ private:
int max_t_;
double margin_;
int long_from_ = 8, long_match_ = 0; // set_long_gate
unsigned sizes_ = ~0u; // allowed window sizes (bit t)
std::array<std::array<double, kMaxT + 1>, kCtxBuckets> cost_{}, cost_n_{}; // round ms by context bucket and window size
int bk_ = 0; // the current context bucket
-6
View File
@@ -916,8 +916,6 @@ struct Options {
int lookup_max_t = 0;
/// --lookup-sizes A,B,.. : the lookup window sizes above the MTP's (default with --lookup-max-t N: MTP+1, MTP+2, N)
std::string lookup_sizes;
/// --lookup-long-match N (opt-in, 0 = off): a lookup window longer than 8 rows only where the matched context is N tokens or more
int lookup_long_match = 0;
/// --mtp-hnorm stream (opt-in): the draft layer's pre_fc_norm_hidden normalizes each hyper-connection stream on
/// its own (llama.cpp's qwen4exp MTP graph) instead of one RMS over all four (the default, tools/mtp_probe.py).
bool mtp_hnorm_stream = false;
@@ -1074,7 +1072,6 @@ void usage() {
" --lookup-max-t N opt-in: prompt-lookup windows up to N (<= 16) tokens (the MTP keeps --spec); copy-heavy\n"
" edits gain, each extra window size costs a graph (~20-35 MiB of VRAM)\n"
" --lookup-sizes A,B the lookup window sizes past the MTP's (default: MTP+1, MTP+2 and N)\n"
" --lookup-long-match N opt-in: a lookup window past 8 tokens only where the matched context is N tokens or more\n"
" --spec N the MTP drafter's verify window: how many tokens it proposes per check (setup\n"
" writes 4; --suffix-draft lets it grow by 2, up to 8, where a repeat is likely)\n"
" --spec-min-p P how sure the draft layer must be to extend a verify window by another guess\n"
@@ -3471,7 +3468,6 @@ int main(int argc, char** argv) {
else if (a == "--mtp-max-t") o.mtp_max_t = std::max(0, std::atoi(next("--mtp-max-t")));
else if (a == "--lookup-max-t") o.lookup_max_t = std::max(0, std::atoi(next("--lookup-max-t")));
else if (a == "--lookup-sizes") o.lookup_sizes = next("--lookup-sizes");
else if (a == "--lookup-long-match") o.lookup_long_match = std::max(0, std::atoi(next("--lookup-long-match")));
else if (a == "--lookup-chain") o.lookup_chain = std::clamp(std::atoi(next("--lookup-chain")), 0, 7);
else if (a == "--lookup-chain-min") o.lookup_chain_min = std::max(3, std::atoi(next("--lookup-chain-min")));
else if (a == "--mtp-hnorm") {
@@ -12743,7 +12739,6 @@ int main(int argc, char** argv) {
return k;
});
policy.set_sizes(lookup_size_mask(o));
if (o.lookup_long_match > 0) policy.set_long_gate((int) strata::kernels::kVerifyNarrowT, o.lookup_long_match);
// a layer split's hand-off buffers hold kVerifyNarrowT rows: its windows stay at that
if (n_stages > 1) policy.set_sizes(policy.sizes() & ((2u << strata::kernels::kVerifyNarrowT) - 1u));
if (o.lookup_max_t > 0)
@@ -18925,7 +18920,6 @@ int main(int argc, char** argv) {
return k;
});
policy.set_sizes(lookup_size_mask(o));
if (o.lookup_long_match > 0) policy.set_long_gate((int) strata::kernels::kVerifyNarrowT, o.lookup_long_match);
std::vector<int32_t> sbuf((size_t) o.spec, 0);
int64_t sfx_windows = 0, sfx_drafts = 0, sfx_ok = 0;
int64_t chain_windows = 0, chain_drafts = 0, chain_ok = 0; // --lookup-chain's own counts
+2 -4
View File
@@ -142,16 +142,14 @@ DraftPolicy::Pick DraftPolicy::choose(int t_mtp, int lookup_k, int match) const
const double q = lookup_rate(match);
double e = 1.0, qi = 1.0, best = 0.0;
int best_t = 0;
// copy-heavy gate: without a long enough match the lookup window stops at long_from_ rows
const int cap_t = (long_match_ > 0 && match < long_match_) ? std::min(max_t_, long_from_) : max_t_;
for (int k = 1; k <= std::min(lookup_k, cap_t - 1); ++k) {
for (int k = 1; k <= std::min(lookup_k, max_t_ - 1); ++k) {
qi *= q;
e += qi;
if (!allowed(k + 1)) continue;
const double r = e / cost_ms(k + 1);
if (r > best) { best = r; best_t = k + 1; }
}
const int t_full = fit(std::min(lookup_k, cap_t - 1) + 1);
const int t_full = fit(std::min(lookup_k, max_t_ - 1) + 1);
if (best_t > 0 && best > base * (1.0 + margin_)) {
p.lookup = true;
p.t = best_t;
-13
View File
@@ -194,19 +194,6 @@ int main() {
}
check(cok, "sizes: a chained window's total is an allowed size");
}
{
// --lookup-long-match: a window past 8 rows only for a long enough match
DraftPolicy p(16);
p.set_sizes((1u << 1) | (1u << 2) | (1u << 3) | (1u << 4) | (1u << 8) | (1u << 16));
for (int i = 0; i < 50; ++i) p.observe(false, 4, 3, 0, cost(4));
for (int i = 0; i < 40; ++i) p.observe(true, 16, 15, 40, 19.0 + 3.0 * 15);
for (int i = 0; i < 40; ++i) p.observe(true, 8, 7, 40, 19.0 + 3.0 * 7);
check(p.choose(4, 15, 40).lookup && p.choose(4, 15, 40).t == 16, "gate off: the 16-token window is taken");
p.set_long_gate(8, 24);
check(p.choose(4, 15, 40).t == 16, "gate on, long match (40): the 16-token window is still taken");
const DraftPolicy::Pick s = p.choose(4, 15, 10);
check(!s.lookup || s.t <= 8, "gate on, short match (10): no window past 8 rows");
}
std::printf(g_fail ? "FAIL\n" : "PASS\n");
return g_fail ? 1 : 0;
}