Qwen3.8-Flash-Next on any consumer hardware: one-click install for Windows / Linux. Strata inference engine, OpenAI/Anthropic API on localhost, optional image input.
C++
--mtp-q4 all|proj|head: the projections and the draft head separately
Niko12212c697fdacec8
diff --git a/include/strata/core/mtp.hpp b/include/strata/core/mtp.hppindex 8f290a739..9073877d5 100644--- a/include/strata/core/mtp.hpp+++ b/include/strata/core/mtp.hpp@@ -55,7 +55,7 @@ public:/// --mtp-q4 (opt-in; before load): the draft layer's Q8_0 projections and its draft head run from 4-bit (Q4_0)/// copies made at load/bind - fewer bytes per draft step; drafts only, the verify window decides every token./// (The prompt path's batched K/V pass keeps the Q8_0 originals.)- void set_q4(bool on) { q4_ = on; }+ void set_q4(bool proj, bool head) { q4_ = proj; q4_head_ = head; }/// --mtp-draft-vocab FILE (opt-in; before bind): the draft head's token subset from FILE instead of/// rt/draft_vocab.bin (e.g. data/draft_vocab_en.bin, 40K tokens)void set_draft_vocab(const std::string& path) { dvocab_path_ = path; }@@ -145,7 +145,7 @@ private:int device_ = -1; ///< the device `load` ran on: the public calls switch to it (layer split)int max_drafts_ = 1 << 30;bool hnorm_stream_ = false;- bool q4_ = false;+ bool q4_ = false, q4_head_ = false;uint8_t* dense4_ = nullptr; ///< --mtp-q4: Q4_0 copies of the Q8_0 tensorsstd::vector<std::pair<std::string, uint64_t>> q4_off_;int dhead_type_ = -1; ///< the draft head subset's ggml type (the main head's, or Q4_0)diff --git a/src/core/mtp.cpp b/src/core/mtp.cppindex d2f605183..2c1c13e1d 100644--- a/src/core/mtp.cpp+++ b/src/core/mtp.cpp@@ -555,7 +555,7 @@ bool MtpDrafter::bind(const WeightTable& wt, const NativeHead* head, const floatstd::fprintf(stderr, "strata mtp: draft head over %lld tokens (%.1f MiB)\n", (long long) n_dvocab_,(double) (n_dvocab_ * row_bytes) / 1048576.0);dhead_type_ = head->type();- if (q4_ && !make_q4_head(err)) return false;+ if (q4_head_ && !make_q4_head(err)) return false;}}if (coupled_draft_env() && cparams_ == nullptr && !setup_coupled(err)) return false;diff --git a/src/program/generate.cpp b/src/program/generate.cppindex 2a46bb06a..804af6d77 100644--- a/src/program/generate.cpp+++ b/src/program/generate.cpp@@ -420,7 +420,7 @@ struct Options {/// 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;/// --mtp-q4 (opt-in): the draft layer's projections and draft head from 4-bit copies (fewer bytes per draft step)- bool mtp_q4 = false;+ std::string mtp_q4; ///< "" (off), all, proj (the projections only) or head (the draft head only)/// --mtp-draft-vocab FILE (opt-in): the draft head's token subset from FILE instead of <mtp>/draft_vocab.binstd::string mtp_draft_vocab;/// A control vector on the residual stream (strata/kernels/cvec.hpp), with llama.cpp's flags: the@@ -526,7 +526,7 @@ void usage() {" --lookup-chain-min M the shortest context match --lookup-chain extends on (default 3)\n"" --mtp-hnorm pooled|stream the draft layer's hidden-input norm: one RMS over all four streams\n"" (default) or one per stream (llama.cpp's MTP graph)\n"- " --mtp-q4 opt-in: the draft layer's projections and draft head as 4-bit copies\n"+ " --mtp-q4 all|proj|head opt-in: the draft layer's projections and/or draft head as 4-bit copies\n"" --mtp-draft-vocab FILE opt-in: the draft head's token subset (default <mtp>/draft_vocab.bin)\n"" --control-vector-scaled FILE:SCALE[,...] a control vector GGUF on the residual stream (llama.cpp's\n"" format; --control-vector FILE = scale 1). --serve: requests switch it (cvec=0|1)\n"@@ -1223,7 +1223,13 @@ int main(int argc, char** argv) {}o.mtp_hnorm_stream = v == "stream";}- else if (a == "--mtp-q4") o.mtp_q4 = true;+ else if (a == "--mtp-q4") {+ o.mtp_q4 = next("--mtp-q4");+ if (o.mtp_q4 != "all" && o.mtp_q4 != "proj" && o.mtp_q4 != "head") {+ std::fprintf(stderr, "strata generate: --mtp-q4 takes all, proj or head\n");+ return 2;+ }+ }else if (a == "--mtp-draft-vocab") o.mtp_draft_vocab = next("--mtp-draft-vocab");else if (a == "--control-vector") o.cvec_files.push_back({next("--control-vector"), 1.0f});else if (a == "--control-vector-scaled") {@@ -2575,7 +2581,7 @@ int main(int argc, char** argv) {}if (!o.mtp.empty()) mtp.set_prompt_len((int64_t) o.tokens.size());mtp.set_hnorm_per_stream(o.mtp_hnorm_stream); // --mtp-hnorm stream (opt-in), before any capture- mtp.set_q4(o.mtp_q4); // --mtp-q4 (opt-in), before load+ mtp.set_q4(o.mtp_q4 == "all" || o.mtp_q4 == "proj", o.mtp_q4 == "all" || o.mtp_q4 == "head"); // before loadif (!o.mtp_draft_vocab.empty()) mtp.set_draft_vocab(o.mtp_draft_vocab);// the draft layer is the canonical model's MTP head (512 experts) even when the target is pruned,// so it always sees the canonical geometry; `static` because MtpDrafter keeps a reference