Skip to content

Commit 635cdd5

Browse files
authored
common : auto-download dflash- and eagle3- HF sidecars (ggml-org#25811)
* common: auto-download dflash- and eagle3- HF sidecars Mirror the existing mtp- sidecar logic to support auto-discovery and download of DFlash (dflash-) and Eagle3 (eagle3-) speculative decoding sidecars from Hugging Face repos. Changes: - Add --dflash and --eagle3 CLI flags to trigger sidecar download - Add find_best_dflash() and find_best_eagle3() using find_best_sibling - Exclude dflash- and eagle3- filenames from primary model selection - Filter dflash- and eagle3- from cached model listings - Wire download tasks that set speculative.draft.mparams as fallback Assisted-by: pi:llama.cpp/Qwen3.6-27B * docs : regen
1 parent 11fd0a6 commit 635cdd5

6 files changed

Lines changed: 91 additions & 11 deletions

File tree

common/arg.cpp

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,14 @@ common_models_handler common_models_handler_init(const common_params & params, l
361361
params.speculative.types.end(),
362362
COMMON_SPECULATIVE_TYPE_DRAFT_MTP) != params.speculative.types.end();
363363

364+
const bool spec_type_draft_dflash = std::find(params.speculative.types.begin(),
365+
params.speculative.types.end(),
366+
COMMON_SPECULATIVE_TYPE_DRAFT_DFLASH) != params.speculative.types.end();
367+
368+
const bool spec_type_draft_eagle3 = std::find(params.speculative.types.begin(),
369+
params.speculative.types.end(),
370+
COMMON_SPECULATIVE_TYPE_DRAFT_EAGLE3) != params.speculative.types.end();
371+
364372
// only download mmproj if the current example is using it
365373
bool use_mmproj = false;
366374
for (const auto & ex : mmproj_examples) {
@@ -373,6 +381,8 @@ common_models_handler common_models_handler_init(const common_params & params, l
373381
opts.bearer_token = params.hf_token;
374382
opts.offline = params.offline;
375383
opts.download_mtp = spec_type_draft_mtp;
384+
opts.download_eagle3 = spec_type_draft_eagle3;
385+
opts.download_dflash = spec_type_draft_dflash;
376386
opts.download_mmproj = use_mmproj && !params.no_mmproj
377387
&& params.mmproj.path.empty() && params.mmproj.url.empty();
378388

@@ -546,6 +556,26 @@ void common_models_handler_apply(common_models_handler & handler, common_params
546556
}
547557
});
548558
}
559+
if (!plan.dflash.local_path.empty() && !had_spec_url) {
560+
tasks.emplace_back(plan.dflash, opts, [&]() {
561+
// only fall back to the discovered DFlash sidecar when no draft was explicitly provided
562+
if (params.speculative.draft.mparams.empty()) {
563+
params.speculative.draft.mparams.path = hf_cache::finalize_file(plan.dflash);
564+
} else {
565+
hf_cache::finalize_file(plan.dflash);
566+
}
567+
});
568+
}
569+
if (!plan.eagle3.local_path.empty() && !had_spec_url) {
570+
tasks.emplace_back(plan.eagle3, opts, [&]() {
571+
// only fall back to the discovered Eagle3 sidecar when no draft was explicitly provided
572+
if (params.speculative.draft.mparams.empty()) {
573+
params.speculative.draft.mparams.path = hf_cache::finalize_file(plan.eagle3);
574+
} else {
575+
hf_cache::finalize_file(plan.eagle3);
576+
}
577+
});
578+
}
549579
if (!plan.preset.local_path.empty()) {
550580
tasks.emplace_back(plan.preset, opts, [&]() {
551581
// if HF repo is a preset repo, we simply run server in router mode with the preset.ini file
@@ -2815,6 +2845,20 @@ common_params_context common_params_parser_init(common_params & params, llama_ex
28152845
params.speculative.types.push_back(COMMON_SPECULATIVE_TYPE_DRAFT_MTP);
28162846
}
28172847
).set_examples({LLAMA_EXAMPLE_DOWNLOAD}));
2848+
add_opt(common_arg(
2849+
{"--dflash"},
2850+
"also download the DFlash sidecar, if available (default: unused)",
2851+
[](common_params & params) {
2852+
params.speculative.types.push_back(COMMON_SPECULATIVE_TYPE_DRAFT_DFLASH);
2853+
}
2854+
).set_examples({LLAMA_EXAMPLE_DOWNLOAD}));
2855+
add_opt(common_arg(
2856+
{"--eagle3"},
2857+
"also download the Eagle3 sidecar, if available (default: unused)",
2858+
[](common_params & params) {
2859+
params.speculative.types.push_back(COMMON_SPECULATIVE_TYPE_DRAFT_EAGLE3);
2860+
}
2861+
).set_examples({LLAMA_EXAMPLE_DOWNLOAD}));
28182862
add_opt(common_arg(
28192863
{"--context-file"}, "FNAME",
28202864
"file to load context from (use comma-separated values to specify multiple files)",

common/download.cpp

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,16 @@ static hf_cache::hf_file find_best_mtp(const hf_cache::hf_files & files,
620620
return find_best_sibling(files, model, "mtp-");
621621
}
622622

623+
static hf_cache::hf_file find_best_eagle3(const hf_cache::hf_files & files,
624+
const std::string & model) {
625+
return find_best_sibling(files, model, "eagle3-");
626+
}
627+
628+
static hf_cache::hf_file find_best_dflash(const hf_cache::hf_files & files,
629+
const std::string & model) {
630+
return find_best_sibling(files, model, "dflash-");
631+
}
632+
623633
static bool gguf_filename_is_model(const std::string & filepath) {
624634
if (!string_ends_with(filepath, ".gguf")) {
625635
return false;
@@ -632,7 +642,9 @@ static bool gguf_filename_is_model(const std::string & filepath) {
632642

633643
return filename.find("mmproj") == std::string::npos &&
634644
filename.find("imatrix") == std::string::npos &&
635-
filename.find("mtp-") == std::string::npos;
645+
filename.find("mtp-") == std::string::npos &&
646+
filename.find("eagle3-") == std::string::npos &&
647+
filename.find("dflash-") == std::string::npos;
636648
}
637649

638650
static hf_cache::hf_file find_best_model(const hf_cache::hf_files & files,
@@ -740,6 +752,12 @@ common_download_hf_plan common_download_get_hf_plan(const common_params_model &
740752
if (opts.download_mtp) {
741753
plan.mtp = find_best_mtp(all, primary.path);
742754
}
755+
if (opts.download_dflash) {
756+
plan.dflash = find_best_dflash(all, primary.path);
757+
}
758+
if (opts.download_eagle3) {
759+
plan.eagle3 = find_best_eagle3(all, primary.path);
760+
}
743761

744762
return plan;
745763
}
@@ -911,8 +929,10 @@ std::vector<common_cached_model_info> common_list_cached_models() {
911929
for (const auto & f : files) {
912930
auto split = get_gguf_split_info(f.path);
913931
if (split.index != 1 || split.tag.empty() ||
914-
split.prefix.find("mmproj") != std::string::npos ||
915-
split.prefix.find("mtp-") != std::string::npos) {
932+
split.prefix.find("mmproj") != std::string::npos ||
933+
split.prefix.find("mtp-") != std::string::npos ||
934+
split.prefix.find("eagle3-") != std::string::npos ||
935+
split.prefix.find("dflash-") != std::string::npos) {
916936
continue;
917937
}
918938
if (seen.insert(f.repo_id + ":" + split.tag).second) {

common/download.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,10 @@ struct common_download_opts {
5555
std::string bearer_token;
5656
common_header_list headers;
5757
bool offline = false;
58-
bool download_mmproj = false;
59-
bool download_mtp = false;
58+
bool download_mmproj = false;
59+
bool download_mtp = false;
60+
bool download_eagle3 = false;
61+
bool download_dflash = false;
6062
common_download_callback * callback = nullptr;
6163
};
6264

@@ -106,6 +108,8 @@ struct common_download_hf_plan {
106108
hf_cache::hf_files model_files;
107109
hf_cache::hf_file mmproj;
108110
hf_cache::hf_file mtp;
111+
hf_cache::hf_file eagle3;
112+
hf_cache::hf_file dflash;
109113
hf_cache::hf_file preset; // if set, only this file is downloaded
110114
};
111115
common_download_hf_plan common_download_get_hf_plan(const common_params_model & model, const common_download_opts & opts);

tools/cli/README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
| `-ctv, --cache-type-v TYPE` | KV cache data type for V<br/>allowed values: f32, f16, bf16, q8_0, q4_0, q4_1, iq4_nl, q5_0, q5_1<br/>(default: f16)<br/>(env: LLAMA_ARG_CACHE_TYPE_V) |
5555
| `-dt, --defrag-thold N` | KV cache defragmentation threshold (DEPRECATED)<br/>(env: LLAMA_ARG_DEFRAG_THOLD) |
5656
| `-np, --parallel N` | number of parallel sequences to decode (default: 1)<br/>(env: LLAMA_ARG_N_PARALLEL) |
57+
| `--rpc SERVERS` | comma-separated list of RPC servers (host:port)<br/>(env: LLAMA_ARG_RPC) |
5758
| `--mlock` | force system to keep model in RAM rather than swapping or compressing<br/>(env: LLAMA_ARG_MLOCK) |
5859
| `--mmap, --no-mmap` | whether to memory-map model. (if mmap disabled, slower load but may reduce pageouts if not using mlock) (default: enabled)<br/>(env: LLAMA_ARG_MMAP) |
5960
| `-dio, --direct-io, -ndio, --no-direct-io` | use DirectIO if available. (default: disabled)<br/>(env: LLAMA_ARG_DIO) |
@@ -142,6 +143,7 @@
142143

143144
| Argument | Explanation |
144145
| -------- | ----------- |
146+
| `--server-base URL` | connect to this server instead of starting a new one, example: 'http://localhost:8080' (default: none) |
145147
| `--verbose-prompt` | print a verbose prompt before generation (default: false) |
146148
| `--display-prompt, --no-display-prompt` | whether to print prompt at generation (default: true) |
147149
| `-co, --color [on\|off\|auto]` | Colorize output to distinguish prompt and user input from generations ('on', 'off', or 'auto', default: 'auto')<br/>'auto' enables colors when output is to a terminal |
@@ -164,17 +166,19 @@
164166
| `--image, --audio, --video FILE` | path to an image, audio, or video file. use with multimodal models, use comma-separated values for multiple files |
165167
| `--image-min-tokens N` | minimum number of tokens each image can take, only used by vision models with dynamic resolution (default: read from model)<br/>(env: LLAMA_ARG_IMAGE_MIN_TOKENS) |
166168
| `--image-max-tokens N` | maximum number of tokens each image can take, only used by vision models with dynamic resolution (default: read from model)<br/>(env: LLAMA_ARG_IMAGE_MAX_TOKENS) |
169+
| `-o, --output, --output-file FNAME` | output file (default: '') |
167170
| `--chat-template-kwargs STRING` | sets additional params for the json template parser, must be a valid json object string, e.g. '{"key1":"value1","key2":"value2"}'<br/>(env: LLAMA_ARG_CHAT_TEMPLATE_KWARGS) |
168171
| `--jinja, --no-jinja` | whether to use jinja template engine for chat (default: enabled)<br/>(env: LLAMA_ARG_JINJA) |
169172
| `--reasoning-format FORMAT` | controls whether thought tags are allowed and/or extracted from the response, and in which format they're returned; one of:<br/>- none: leaves thoughts unparsed in `message.content`<br/>- deepseek: puts thoughts in `message.reasoning_content`<br/>- deepseek-legacy: keeps `<think>` tags in `message.content` while also populating `message.reasoning_content`<br/>(default: auto)<br/>(env: LLAMA_ARG_THINK) |
170173
| `-rea, --reasoning [on\|off\|auto]` | Use reasoning/thinking in the chat ('on', 'off', or 'auto', default: 'auto' (detect from template))<br/>(env: LLAMA_ARG_REASONING) |
171174
| `--reasoning-budget N` | token budget for thinking: -1 for unrestricted, 0 for immediate end, N>0 for token budget (default: -1)<br/>(env: LLAMA_ARG_THINK_BUDGET) |
172175
| `--reasoning-budget-message MESSAGE` | message injected before the end-of-thinking tag when reasoning budget is exhausted (default: none)<br/>(env: LLAMA_ARG_THINK_BUDGET_MESSAGE) |
176+
| `--reasoning-preserve, --no-reasoning-preserve` | preserve reasoning trace in the full history, not just the last assistant message (default: template default)<br/>compatible with certain templates having 'supports_preserve_reasoning' capability<br/>example: https://docs.z.ai/guides/capabilities/thinking-mode#preserved-thinking<br/>(env: LLAMA_ARG_REASONING_PRESERVE) |
173177
| `--chat-template JINJA_TEMPLATE` | set custom jinja chat template (default: template taken from model's metadata)<br/>if suffix/prefix are specified, template will be disabled<br/>only commonly used templates are accepted (unless --jinja is set before this flag):<br/>list of built-in templates:<br/>bailing, bailing-think, bailing2, chatglm3, chatglm4, chatml, command-r, deepseek, deepseek-ocr, deepseek2, deepseek3, exaone-moe, exaone3, exaone4, falcon3, gemma, gigachat, glmedge, gpt-oss, granite, granite-4.0, granite-4.1, grok-2, hunyuan-dense, hunyuan-moe, hunyuan-vl, kimi-k2, llama2, llama2-sys, llama2-sys-bos, llama2-sys-strip, llama3, llama4, megrez, minicpm, mistral-v1, mistral-v3, mistral-v3-tekken, mistral-v7, mistral-v7-tekken, monarch, openchat, orion, pangu-embedded, phi3, phi4, rwkv-world, seed_oss, smolvlm, solar-open, vicuna, vicuna-orca, yandex, zephyr<br/>(env: LLAMA_ARG_CHAT_TEMPLATE) |
174178
| `--chat-template-file JINJA_TEMPLATE_FILE` | set custom jinja chat template file (default: template taken from model's metadata)<br/>if suffix/prefix are specified, template will be disabled<br/>only commonly used templates are accepted (unless --jinja is set before this flag):<br/>list of built-in templates:<br/>bailing, bailing-think, bailing2, chatglm3, chatglm4, chatml, command-r, deepseek, deepseek-ocr, deepseek2, deepseek3, exaone-moe, exaone3, exaone4, falcon3, gemma, gigachat, glmedge, gpt-oss, granite, granite-4.0, granite-4.1, grok-2, hunyuan-dense, hunyuan-moe, hunyuan-vl, kimi-k2, llama2, llama2-sys, llama2-sys-bos, llama2-sys-strip, llama3, llama4, megrez, minicpm, mistral-v1, mistral-v3, mistral-v3-tekken, mistral-v7, mistral-v7-tekken, monarch, openchat, orion, pangu-embedded, phi3, phi4, rwkv-world, seed_oss, smolvlm, solar-open, vicuna, vicuna-orca, yandex, zephyr<br/>(env: LLAMA_ARG_CHAT_TEMPLATE_FILE) |
175179
| `--skip-chat-parsing, --no-skip-chat-parsing` | force a pure content parser, even if a Jinja template is specified; model will output everything in the content section, including any reasoning and/or tool calls (default: disabled)<br/>(env: LLAMA_ARG_SKIP_CHAT_PARSING) |
176180
| `--simple-io` | use basic IO for better compatibility in subprocesses and limited consoles |
177-
| `--log-prompts-dir PATH` | Log prompts to directory (only used for debugging, default: disabled) |
181+
| `--log-prompts-dir PATH` | Log prompts to directory (auto-created if not present; only used for debugging, default: disabled) |
178182
| `--spec-draft-hf, -hfd, -hfrd, --hf-repo-draft <user>/<model>[:quant]` | Same as --hf-repo, but for the draft model (default: unused)<br/>(env: LLAMA_ARG_SPEC_DRAFT_HF_REPO) |
179183
| `--spec-draft-threads, -td, --threads-draft N` | number of threads to use during generation (default: same as --threads) |
180184
| `--spec-draft-threads-batch, -tbd, --threads-batch-draft N` | number of threads to use during batch and prompt processing (default: same as --threads-draft) |
@@ -198,7 +202,7 @@
198202
| `--spec-draft-device, -devd, --device-draft <dev1,dev2,..>` | comma-separated list of devices to use for offloading the draft model (none = don't offload)<br/>use --list-devices to see a list of available devices |
199203
| `--spec-draft-ngl, -ngld, --gpu-layers-draft, --n-gpu-layers-draft N` | max. number of draft model layers to store in VRAM, either an exact number, 'auto', or 'all' (default: auto)<br/>(env: LLAMA_ARG_N_GPU_LAYERS_DRAFT) |
200204
| `--spec-draft-model, -md, --model-draft FNAME` | draft model for speculative decoding (default: unused)<br/>(env: LLAMA_ARG_SPEC_DRAFT_MODEL) |
201-
| `--spec-type none,draft-simple,draft-eagle3,draft-mtp,ngram-simple,ngram-map-k,ngram-map-k4v,ngram-mod,ngram-cache` | comma-separated list of types of speculative decoding to use (default: none)<br/><br/>(env: LLAMA_ARG_SPEC_TYPE) |
205+
| `--spec-type none,draft-simple,draft-eagle3,draft-mtp,draft-dflash,ngram-simple,ngram-map-k,ngram-map-k4v,ngram-mod,ngram-cache` | comma-separated list of types of speculative decoding to use (default: none)<br/><br/>(env: LLAMA_ARG_SPEC_TYPE) |
202206
| `--spec-ngram-mod-n-min N` | minimum number of ngram tokens to use for ngram-based speculative decoding (default: 48) |
203207
| `--spec-ngram-mod-n-max N` | maximum number of ngram tokens to use for ngram-based speculative decoding (default: 64) |
204208
| `--spec-ngram-mod-n-match N` | ngram-mod lookup length (default: 24) |

tools/completion/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ llama-completion.exe -m models\gemma-1.1-7b-it.Q4_K_M.gguf --ignore-eos -n -1
137137
| `-ctv, --cache-type-v TYPE` | KV cache data type for V<br/>allowed values: f32, f16, bf16, q8_0, q4_0, q4_1, iq4_nl, q5_0, q5_1<br/>(default: f16)<br/>(env: LLAMA_ARG_CACHE_TYPE_V) |
138138
| `-dt, --defrag-thold N` | KV cache defragmentation threshold (DEPRECATED)<br/>(env: LLAMA_ARG_DEFRAG_THOLD) |
139139
| `-np, --parallel N` | number of parallel sequences to decode (default: 1)<br/>(env: LLAMA_ARG_N_PARALLEL) |
140+
| `--rpc SERVERS` | comma-separated list of RPC servers (host:port)<br/>(env: LLAMA_ARG_RPC) |
140141
| `--mlock` | force system to keep model in RAM rather than swapping or compressing<br/>(env: LLAMA_ARG_MLOCK) |
141142
| `--mmap, --no-mmap` | whether to memory-map model. (if mmap disabled, slower load but may reduce pageouts if not using mlock) (default: enabled)<br/>(env: LLAMA_ARG_MMAP) |
142143
| `-dio, --direct-io, -ndio, --no-direct-io` | use DirectIO if available. (default: disabled)<br/>(env: LLAMA_ARG_DIO) |
@@ -253,6 +254,7 @@ llama-completion.exe -m models\gemma-1.1-7b-it.Q4_K_M.gguf --ignore-eos -n -1
253254
| `-rea, --reasoning [on\|off\|auto]` | Use reasoning/thinking in the chat ('on', 'off', or 'auto', default: 'auto' (detect from template))<br/>(env: LLAMA_ARG_REASONING) |
254255
| `--reasoning-budget N` | token budget for thinking: -1 for unrestricted, 0 for immediate end, N>0 for token budget (default: -1)<br/>(env: LLAMA_ARG_THINK_BUDGET) |
255256
| `--reasoning-budget-message MESSAGE` | message injected before the end-of-thinking tag when reasoning budget is exhausted (default: none)<br/>(env: LLAMA_ARG_THINK_BUDGET_MESSAGE) |
257+
| `--reasoning-preserve, --no-reasoning-preserve` | preserve reasoning trace in the full history, not just the last assistant message (default: template default)<br/>compatible with certain templates having 'supports_preserve_reasoning' capability<br/>example: https://docs.z.ai/guides/capabilities/thinking-mode#preserved-thinking<br/>(env: LLAMA_ARG_REASONING_PRESERVE) |
256258
| `--chat-template JINJA_TEMPLATE` | set custom jinja chat template (default: template taken from model's metadata)<br/>if suffix/prefix are specified, template will be disabled<br/>only commonly used templates are accepted (unless --jinja is set before this flag):<br/>list of built-in templates:<br/>bailing, bailing-think, bailing2, chatglm3, chatglm4, chatml, command-r, deepseek, deepseek-ocr, deepseek2, deepseek3, exaone-moe, exaone3, exaone4, falcon3, gemma, gigachat, glmedge, gpt-oss, granite, granite-4.0, granite-4.1, grok-2, hunyuan-dense, hunyuan-moe, hunyuan-vl, kimi-k2, llama2, llama2-sys, llama2-sys-bos, llama2-sys-strip, llama3, llama4, megrez, minicpm, mistral-v1, mistral-v3, mistral-v3-tekken, mistral-v7, mistral-v7-tekken, monarch, openchat, orion, pangu-embedded, phi3, phi4, rwkv-world, seed_oss, smolvlm, solar-open, vicuna, vicuna-orca, yandex, zephyr<br/>(env: LLAMA_ARG_CHAT_TEMPLATE) |
257259
| `--chat-template-file JINJA_TEMPLATE_FILE` | set custom jinja chat template file (default: template taken from model's metadata)<br/>if suffix/prefix are specified, template will be disabled<br/>only commonly used templates are accepted (unless --jinja is set before this flag):<br/>list of built-in templates:<br/>bailing, bailing-think, bailing2, chatglm3, chatglm4, chatml, command-r, deepseek, deepseek-ocr, deepseek2, deepseek3, exaone-moe, exaone3, exaone4, falcon3, gemma, gigachat, glmedge, gpt-oss, granite, granite-4.0, granite-4.1, grok-2, hunyuan-dense, hunyuan-moe, hunyuan-vl, kimi-k2, llama2, llama2-sys, llama2-sys-bos, llama2-sys-strip, llama3, llama4, megrez, minicpm, mistral-v1, mistral-v3, mistral-v3-tekken, mistral-v7, mistral-v7-tekken, monarch, openchat, orion, pangu-embedded, phi3, phi4, rwkv-world, seed_oss, smolvlm, solar-open, vicuna, vicuna-orca, yandex, zephyr<br/>(env: LLAMA_ARG_CHAT_TEMPLATE_FILE) |
258260
| `--skip-chat-parsing, --no-skip-chat-parsing` | force a pure content parser, even if a Jinja template is specified; model will output everything in the content section, including any reasoning and/or tool calls (default: disabled)<br/>(env: LLAMA_ARG_SKIP_CHAT_PARSING) |

0 commit comments

Comments
 (0)