Merge branch 'f-0291-df2-mem' into f-0291-df2-primary

This commit is contained in:
Niko1221 committed 2026-11-02 00:32:35 +01:00
commit 1c2aba90fa
1 file changed
+13 -7
+13 -7
View File
@@ -926,11 +926,12 @@ struct Options {
/// --mtp-draft-vocab FILE (opt-in): the draft head's token subset from FILE instead of <mtp>/draft_vocab.bin
std::string mtp_draft_vocab;
/// --draft dflash2 --draft-model PACK (opt-in, CUDA / HIP): the DFlash2 block drafter for Qwen3.8-Flash-Next (tools/dflash2_pack.py) drafts instead
/// of the MTP layer, which stays loaded as the fallback. Needs --mtp, --spec and a native pack; a missing pack falls back to the MTP.
/// of the MTP layer, which is not loaded (--draft-fallback mtp loads it too, as the fallback). Needs --mtp DIR (its draft_vocab.bin), --spec, --draft-model and a native pack; DFlash2 that cannot start is an error unless the fallback is mtp.
std::string draft, draft_model;
/// --draft-fallback mtp|none (with --draft dflash2): none = the MTP layer is NOT loaded, DFlash2 is the only drafter (the draft vocabulary still comes
/// from <mtp>/draft_vocab.bin). A DFlash2 that cannot start then ends the start with an error: nothing drafts instead. A per-run choice, not a per-round one.
std::string draft_fallback = "mtp";
/// Unset: `--draft dflash2` means none (the owner's order: the DFlash2 and the MTP layer are never loaded together unless asked); `--draft auto` needs both.
std::string draft_fallback;
double draft_conf = 0.0; ///< --draft-conf P: with --draft dflash2 the window ends where the product of the selector's probabilities falls below P (replaces --spec-min-p)
/// --draft auto (serve): both drafters stay current and each request picks one (its key draft=mtp|dflash2, else draft_rule); the CLI treats auto as dflash2
bool draft_auto = false;
@@ -1095,8 +1096,9 @@ void usage() {
" --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"
" --draft mtp|dflash2 the draft source (default mtp); dflash2 needs --draft-model PACK (tools/dflash2_pack.py)\n"
" and keeps the MTP layer loaded as the fallback (opt-in, Flash-Next, CUDA / HIP)\n"
" --draft-fallback none with --draft dflash2 (not auto): do not load the MTP layer at all; DFlash2 is the only drafter and a DFlash2 that cannot start is an error\n"
" and loads no MTP layer (--draft-fallback mtp keeps it as the fallback) (opt-in, Flash-Next, CUDA / HIP)\n"
" --draft-fallback mtp|none with --draft dflash2 (default none): none = the MTP layer is not loaded at all, DFlash2 is the only drafter and a DFlash2 that cannot start is an error;\n"
" mtp = load both, the MTP drafts if DFlash2 cannot start (--draft auto always loads both)\n"
" (the MTP layer's ~0.9 GiB of VRAM goes to the expert cache; --mtp DIR is still needed for DIR/draft_vocab.bin)\n"
" --draft-conf P with --draft dflash2: end the window where the product of the selector's probabilities falls below P (default 0 = --spec-min-p)\n"
" --draft auto (serve) both drafters stay current; a request picks one: draft=mtp|dflash2, else --draft-rule df2|mtp|learn;\n"
@@ -5234,9 +5236,13 @@ int main(int argc, char** argv) {
auto df2_vocab_path = [&]() -> std::string { // the draft vocabulary file DFlash2 binds its head from
return df2_solo ? df2_vocab_file : o.mtp_draft_vocab.empty() ? o.mtp + "/draft_vocab.bin" : o.mtp_draft_vocab;
};
if (o.draft == "dflash2" && o.draft_fallback == "none") {
if (o.draft_auto || o.mtp.empty() || o.spec < 2 || o.draft_model.empty()) {
std::fprintf(stderr, "strata generate: --draft-fallback none needs --draft dflash2 (not auto), --draft-model PACK, --spec 2 or more and --mtp DIR (for DIR/draft_vocab.bin)\n");
if (o.draft == "dflash2" && o.draft_auto && o.draft_fallback == "none") {
std::fprintf(stderr, "strata generate: --draft auto keeps both drafters (a request picks one); --draft-fallback none is for --draft dflash2\n");
return 2;
}
if (o.draft == "dflash2" && !o.draft_auto && o.draft_fallback != "mtp") { // (unset or none)
if (o.mtp.empty() || o.spec < 2 || o.draft_model.empty()) {
std::fprintf(stderr, "strata generate: --draft dflash2 drafts without the MTP layer (--draft-fallback mtp loads it too) and needs --draft-model PACK, --spec 2 or more and --mtp DIR (for DIR/draft_vocab.bin)\n");
return 2;
}
df2_vocab_file = o.mtp_draft_vocab.empty() ? o.mtp + "/draft_vocab.bin" : o.mtp_draft_vocab;