All opt-in; with none of them given the engine runs exactly as before. - --lookup-chain K [--lookup-chain-min M]: after the MTP's drafts, the suffix drafter matches the context plus those drafts and appends up to K of the tokens that followed the match to the same verify window (the window grows to at most 8). Greedy verification keeps the output. Own counts: a stderr line per request and five more DONE fields when on. - include/strata/spec/draft_source.hpp: a DraftSource interface (the request's own text is PromptLookupSource; other sources register in extra_draft_sources() and the longest match wins). - --mtp-hnorm stream: the draft layer's pre_fc_norm_hidden as one RMS per hyper-connection stream (llama.cpp's qwen4exp MTP graph) instead of one over all four (vLLM's qwen4_exp MTP, the default). New kernel native_qsa_rms_norm_grouped; the batched prompt K/V pass follows the switch. - Diagnostics: STRATA_MTP_FULL_HEAD=1 drafts over the whole vocabulary; STRATA_MTP_TOP2=1 counts how often the draft layer's runner-up is the token verify picked where a draft was rejected.
37 lines
1.1 KiB
C++
37 lines
1.1 KiB
C++
// src/spec/draft_source.cpp - see include/strata/spec/draft_source.hpp.
|
|
#include "strata/spec/draft_source.hpp"
|
|
|
|
#include <vector>
|
|
|
|
namespace strata::spec {
|
|
|
|
std::vector<std::unique_ptr<DraftSource>>& extra_draft_sources() {
|
|
static std::vector<std::unique_ptr<DraftSource>> sources;
|
|
return sources;
|
|
}
|
|
|
|
int propose_from_sources(DraftSource& own, const int32_t* tail, int n_tail, int n_pending, int max_k, int min_match,
|
|
int32_t* out, int* match, int* source) {
|
|
*match = 0;
|
|
*source = -1;
|
|
if (max_k <= 0) return 0;
|
|
int best = 0;
|
|
std::vector<int32_t> buf((size_t) max_k);
|
|
auto ask = [&](DraftSource& s, int index) {
|
|
int m = 0;
|
|
const int k = s.propose(tail, n_tail, n_pending, max_k, buf.data(), &m);
|
|
if (k <= 0 || m < min_match || m <= *match) return;
|
|
for (int i = 0; i < k && i < max_k; ++i) out[i] = buf[(size_t) i];
|
|
best = k < max_k ? k : max_k;
|
|
*match = m;
|
|
*source = index;
|
|
};
|
|
ask(own, 0);
|
|
int index = 1;
|
|
for (auto& s : extra_draft_sources())
|
|
if (s) ask(*s, index++);
|
|
return best;
|
|
}
|
|
|
|
} // namespace strata::spec
|