mirror of
https://github.com/ggml-org/llama.cpp.git
synced 2026-09-20 01:31:31 +02:00
common : enable default speculative config
Assisted-by: pi:llama.cpp/DeepSeek-V4-Flash-Vision-Exp
This commit is contained in:
@@ -254,6 +254,117 @@ static void test(void) {
|
||||
assert(true == common_params_parse(argv.size(), list_str_to_char(argv).data(), params, LLAMA_EXAMPLE_SPECULATIVE));
|
||||
assert(params.speculative.draft.n_max == 123);
|
||||
|
||||
{
|
||||
const auto types_ngram_mod = std::vector<enum common_speculative_type>{ COMMON_SPECULATIVE_TYPE_NGRAM_MOD };
|
||||
const auto types_draft_mtp = std::vector<enum common_speculative_type>{ COMMON_SPECULATIVE_TYPE_DRAFT_MTP };
|
||||
const auto types_none = std::vector<enum common_speculative_type>{ COMMON_SPECULATIVE_TYPE_NONE };
|
||||
|
||||
{
|
||||
common_params spec_params;
|
||||
argv = {"binary_name"};
|
||||
assert(true == common_params_parse(argv.size(), list_str_to_char(argv).data(), spec_params, LLAMA_EXAMPLE_SERVER));
|
||||
assert(spec_params.speculative.types == types_ngram_mod);
|
||||
}
|
||||
|
||||
{
|
||||
common_params spec_params;
|
||||
argv = {"binary_name", "--no-spec-type", "ngram-mod"};
|
||||
assert(true == common_params_parse(argv.size(), list_str_to_char(argv).data(), spec_params, LLAMA_EXAMPLE_SERVER));
|
||||
assert(spec_params.speculative.types == types_none);
|
||||
}
|
||||
|
||||
{
|
||||
common_params spec_params;
|
||||
argv = {"binary_name", "--spec-type", "draft-mtp"};
|
||||
assert(true == common_params_parse(argv.size(), list_str_to_char(argv).data(), spec_params, LLAMA_EXAMPLE_SERVER));
|
||||
assert(spec_params.speculative.types == std::vector<enum common_speculative_type>({ COMMON_SPECULATIVE_TYPE_NGRAM_MOD, COMMON_SPECULATIVE_TYPE_DRAFT_MTP }));
|
||||
}
|
||||
|
||||
{
|
||||
common_params spec_params;
|
||||
argv = {"binary_name", "--spec-type", "ngram-mod"};
|
||||
assert(true == common_params_parse(argv.size(), list_str_to_char(argv).data(), spec_params, LLAMA_EXAMPLE_SERVER));
|
||||
assert(spec_params.speculative.types == types_ngram_mod);
|
||||
}
|
||||
|
||||
{
|
||||
common_params spec_params;
|
||||
argv = {"binary_name", "--spec-type", "ngram-mod,draft-mtp"};
|
||||
assert(true == common_params_parse(argv.size(), list_str_to_char(argv).data(), spec_params, LLAMA_EXAMPLE_SERVER));
|
||||
assert(spec_params.speculative.types == std::vector<enum common_speculative_type>({ COMMON_SPECULATIVE_TYPE_NGRAM_MOD, COMMON_SPECULATIVE_TYPE_DRAFT_MTP }));
|
||||
}
|
||||
|
||||
{
|
||||
common_params spec_params;
|
||||
argv = {"binary_name", "--no-spec-type", "ngram-mod", "--spec-type", "draft-mtp"};
|
||||
assert(true == common_params_parse(argv.size(), list_str_to_char(argv).data(), spec_params, LLAMA_EXAMPLE_SERVER));
|
||||
assert(spec_params.speculative.types == types_draft_mtp);
|
||||
}
|
||||
|
||||
{
|
||||
common_params spec_params;
|
||||
argv = {"binary_name", "--spec-type", "draft-mtp", "--no-spec-type", "ngram-mod"};
|
||||
assert(true == common_params_parse(argv.size(), list_str_to_char(argv).data(), spec_params, LLAMA_EXAMPLE_SERVER));
|
||||
assert(spec_params.speculative.types == types_draft_mtp);
|
||||
}
|
||||
|
||||
{
|
||||
common_params spec_params;
|
||||
argv = {"binary_name", "--no-spec-type", "draft-mtp"};
|
||||
assert(true == common_params_parse(argv.size(), list_str_to_char(argv).data(), spec_params, LLAMA_EXAMPLE_SERVER));
|
||||
assert(spec_params.speculative.types == types_ngram_mod);
|
||||
}
|
||||
|
||||
{
|
||||
common_params spec_params;
|
||||
argv = {"binary_name", "--no-spec-type", "ngram-mod", "--spec-type", "ngram-mod"};
|
||||
assert(true == common_params_parse(argv.size(), list_str_to_char(argv).data(), spec_params, LLAMA_EXAMPLE_SERVER));
|
||||
assert(spec_params.speculative.types == types_ngram_mod);
|
||||
}
|
||||
|
||||
{
|
||||
common_params spec_params;
|
||||
argv = {"binary_name", "--no-spec-type", "ngram-mod", "--spec-type", "ngram-mod,draft-mtp"};
|
||||
assert(true == common_params_parse(argv.size(), list_str_to_char(argv).data(), spec_params, LLAMA_EXAMPLE_SERVER));
|
||||
assert(spec_params.speculative.types == std::vector<enum common_speculative_type>({ COMMON_SPECULATIVE_TYPE_NGRAM_MOD, COMMON_SPECULATIVE_TYPE_DRAFT_MTP }));
|
||||
}
|
||||
|
||||
{
|
||||
common_params spec_params;
|
||||
argv = {"binary_name", "--spec-type", "none"};
|
||||
assert(true == common_params_parse(argv.size(), list_str_to_char(argv).data(), spec_params, LLAMA_EXAMPLE_SERVER));
|
||||
assert(spec_params.speculative.types == types_none);
|
||||
}
|
||||
|
||||
{
|
||||
common_params spec_params;
|
||||
argv = {"binary_name", "--no-spec-type", "none"};
|
||||
assert(true == common_params_parse(argv.size(), list_str_to_char(argv).data(), spec_params, LLAMA_EXAMPLE_SERVER));
|
||||
assert(spec_params.speculative.types == types_none);
|
||||
}
|
||||
|
||||
{
|
||||
common_params spec_params;
|
||||
argv = {"binary_name", "--spec-type", "none", "--spec-type", "draft-mtp"};
|
||||
assert(true == common_params_parse(argv.size(), list_str_to_char(argv).data(), spec_params, LLAMA_EXAMPLE_SERVER));
|
||||
assert(spec_params.speculative.types == types_draft_mtp);
|
||||
}
|
||||
|
||||
{
|
||||
common_params spec_params;
|
||||
argv = {"binary_name", "--spec-default"};
|
||||
assert(true == common_params_parse(argv.size(), list_str_to_char(argv).data(), spec_params, LLAMA_EXAMPLE_SERVER));
|
||||
assert(spec_params.speculative.types == types_ngram_mod);
|
||||
}
|
||||
|
||||
{
|
||||
common_params spec_params;
|
||||
argv = {"binary_name", "--spec-default", "--no-spec-type", "ngram-mod"};
|
||||
assert(true == common_params_parse(argv.size(), list_str_to_char(argv).data(), spec_params, LLAMA_EXAMPLE_SERVER));
|
||||
assert(spec_params.speculative.types == types_none);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
common_params synth_params;
|
||||
argv = {"binary_name", "--spec-synth-len", "3.4"};
|
||||
|
||||
@@ -453,6 +453,13 @@ static void test_task_assembly() {
|
||||
// -hfd on a repo without sidecars keeps resolving a full model as draft
|
||||
common_params params;
|
||||
assemble({"server", "-hf", "test/main:Q8_0", "-hfd", "test/small"}, params);
|
||||
REQUIRE(params.speculative.types == std::vector<enum common_speculative_type>{COMMON_SPECULATIVE_TYPE_NGRAM_MOD});
|
||||
REQUIRE_EQ(params.speculative.draft.mparams.path, cached("test/small", "draft-model-Q4_K_M.gguf"));
|
||||
}
|
||||
{
|
||||
// --no-spec-type removes the default speculative type and keeps the fallback draft resolution
|
||||
common_params params;
|
||||
assemble({"server", "-hf", "test/main:Q8_0", "-hfd", "test/small", "--no-spec-type", "ngram-mod"}, params);
|
||||
REQUIRE(params.speculative.types == std::vector<enum common_speculative_type>{COMMON_SPECULATIVE_TYPE_NONE});
|
||||
REQUIRE_EQ(params.speculative.draft.mparams.path, cached("test/small", "draft-model-Q4_K_M.gguf"));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user