Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
5f82404
vulkan: add Apple AGX (Borealis/Honeykrisp) device tuning, MoE tile s…
astaff Nov 15, 2026
0c8698c
vulkan: add fence wait modes, submit batching, and graph dispatch dia…
astaff Nov 15, 2026
7d59309
llama, vulkan: support BF16-exact gate weights and in-place Gated Del…
astaff Nov 15, 2026
7bbfed0
vulkan: add 0-ULP SwiGLU, GDN L2/output-gate, M-RoPE, and mat-vec epi…
astaff Nov 15, 2026
231b1dd
vulkan: add paired mat-vec/mat-vec-id pipelines, row-split multi-subg…
astaff Nov 15, 2026
62bde0c
vulkan: add batch-invariant speculative verification mode and intra-s…
astaff Nov 15, 2026
aa0bfa4
vulkan: add command-buffer replay cache, prealloc rings, and multi-ad…
astaff Nov 17, 2026
892205f
vulkan: add 8x8x8 mul_mv_mma, single-wave GDN/SSM kernels, and 16 KB …
astaff Nov 17, 2026
cda9dcf
vulkan, common: add wide-tile FP16 MoE mma, dual F32+F16 norms, 512-t…
astaff Nov 17, 2026
cdd4b4d
vulkan, common: add Q8_0 roofline DMMV, magic-bias mma dequant, and f…
astaff Nov 19, 2026
d9f837a
vulkan(s16-trackA): F1 Q8_0 subgroup magic-bias, F2 Vulkan_Repack pla…
astaff Nov 20, 2026
c866bbc
vulkan, loader: restore HYBRID Q8_0 (0-ULP iter2) and compact 1-sb 0-…
astaff Nov 20, 2026
bd4f38d
vulkan, loader: 0-ULP 1-sb Vulkan_Repack parity and Track A hardening
astaff Nov 20, 2026
444a955
vulkan, loader: default GGML_GEN_BF16_EXACT=0 and hoist REPACK_PLANAR…
astaff Nov 20, 2026
cd8b34f
server: scope GGML_VK_BATCH_INVARIANT to speculative router child ins…
astaff Nov 20, 2026
a0e8e8d
inkling2, server: add chunked relative-bias FA (unsloth #385), hybrid…
astaff Nov 25, 2026
b8e8d12
vulkan, inkling2, dspark: add NVFP4 Vulkan kernels, Inkling 2 loop fu…
astaff Nov 25, 2026
638d42a
vulkan, inkling2, dspark: add 0-ULP router/kq_b/conv-residual fusions…
astaff Nov 25, 2026
67aba57
vulkan, inkling2, dspark, parser: add 0-ULP planar NVFP4, loop-ctrl f…
astaff Nov 25, 2026
f170e3b
vulkan, llama, server: add multi-chunk replay, zero-spin fence wait, …
astaff Nov 25, 2026
eb649ce
vulkan, common, loader, server: add long-ctx V-row FA packing, dorman…
astaff Nov 25, 2026
6ccbe2e
vulkan, llama: fix GDN CONTIG_VEC4 replay/stride guards and DSpark wa…
astaff Nov 25, 2026
b9ff369
vulkan, speculative: AGX GQA=3 FA occupancy & adaptive n_max=5 DSpark…
astaff Nov 25, 2026
d312f79
vulkan, inkling2: fuse banded relative bias & 2D dynamic sinks into F…
astaff Nov 25, 2026
ac9662a
vulkan, inkling2: coalesce Q8_0 attention projections, BF16 loop cont…
astaff Nov 25, 2026
7fac0c5
vulkan: fuse MoE gate_up + SITU with FP16 inter-stage pipe in mul_mv_…
astaff Nov 25, 2026
fbbc0a7
vulkan: active-span Q8_0 KV dequant_transpose, CM1 verify & split_k
astaff Nov 25, 2026
150561d
vulkan, inkling2, dspark: single-CB replay, fence-epoch events, 44/44…
astaff Nov 26, 2026
61efda5
vulkan: decode Q8_0 K/V in-register in flash_attn_cm1 and flash_attn_…
astaff Nov 26, 2026
86cb787
vulkan: fuse topk_moe expert_counts on VIEW ids, dual-write F16 MoE i…
astaff Nov 26, 2026
9c08740
vulkan: fuse Q8_0 KV set_rows into inkling_l2_clip and rms_norm
astaff Nov 26, 2026
403a220
s23(b1): quantize dspark_markov_w2 onto Vulkan0_Repack for 48 MiB SLC…
astaff Nov 26, 2026
5723b7f
s23(b3): propagate rs_idx on seq_cp and add can_direct_scopy WAR guard
astaff Nov 26, 2026
8a31901
s23(b3): bind direct_scopy in convolve for multi-seq recurrent decode
astaff Nov 26, 2026
f78a46d
s23(b3): route pure-greedy Inkling2 -bs to batched softcap_argmax
astaff Nov 26, 2026
e7800cc
s23(b2): add logit-margin 2-branch speculative tree and rejection ver…
astaff Nov 26, 2026
f41a651
s23(b1,b3): default dspark_markov_w2 to Q8_0 and guard direct_scopy g…
astaff Nov 26, 2026
fcba42f
server, sampling, dspark: flush deferred ctx_dft rows on stop and add…
astaff Nov 26, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion common/arg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4214,7 +4214,8 @@ common_params_context common_params_parser_init(common_params & params, llama_ex
if (value < 0) {
throw std::invalid_argument("invalid value");
}
params.speculative.draft.n_max = value;
params.speculative.draft.n_max = value;
params.speculative.draft.n_max_set = true;
}
).set_spec().set_examples({LLAMA_EXAMPLE_SPECULATIVE, LLAMA_EXAMPLE_LOOKUP, LLAMA_EXAMPLE_SERVER, LLAMA_EXAMPLE_CLI}).set_env("LLAMA_ARG_SPEC_DRAFT_N_MAX"));
add_opt(common_arg(
Expand Down
27 changes: 26 additions & 1 deletion common/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1153,6 +1153,8 @@ struct common_init_result::impl {
std::vector<llama_sampler_seq_config> samplers_seq_config;
};

extern "C" void llama_s23_set_single_slot_tree_swa(bool v);

static const std::map<common_decision_type, std::string> COMMON_DECISION_TYPE_NAMES = {
{ COMMON_DECISION_TYPE_OPENJEV, "openjev" },
{ COMMON_DECISION_TYPE_LEV, "lev" },
Expand Down Expand Up @@ -1318,10 +1320,21 @@ common_init_result::common_init_result(common_params & params, bool model_only)
cparams.n_outputs_max = std::max(cparams.n_outputs_max, (uint32_t) COMMON_DECISION_LFM3_D1_SET_SIZE);
}

char arch_buf[64] = {};
const bool is_inkling2_arch =
llama_model_meta_val_str(model, "general.architecture", arch_buf, sizeof(arch_buf)) >= 0 &&
std::strncmp(arch_buf, "inkling2", 8) == 0;

bool s23_single_slot_tree_swa = false;
if (llama_model_classifier_free_guidance(model)) {
params.kv_unified = true;
cparams.kv_unified = true;
cparams.n_seq_max *= 2;
} else if (is_inkling2_arch && params.n_parallel == 1 && params.speculative.has_dft() &&
!cparams.embeddings && getenv("LLAMA_DSPARK_ENABLE_2BRANCH") && !getenv("LLAMA_DSPARK_NO_TREE")) {
s23_single_slot_tree_swa = (!params.kv_unified && cparams.n_seq_max == 1);
cparams.kv_unified = true;
cparams.n_seq_max = std::max<uint32_t>(cparams.n_seq_max, 2);
}

// embeddings need the whole batch in one ubatch, so n_batch must not be larger than n_ubatch
Expand Down Expand Up @@ -1383,12 +1396,24 @@ common_init_result::common_init_result(common_params & params, bool model_only)
pimpl->samplers_seq_config[i] = { i, common_sampler_get(pimpl->samplers[i].get()) };
}

if (params.sampling.backend_sampling) {
const bool init_pure_greedy_fast =
is_inkling2_arch &&
!pimpl->samplers.empty() &&
params.sampling.n_probs == 0 &&
common_sampler_is_pure_argmax(pimpl->samplers[0].get()) &&
!getenv("LLAMA_FORCE_BACKEND_ARGMAX_CHAIN");
if (params.sampling.backend_sampling && !init_pure_greedy_fast) {
cparams.samplers = pimpl->samplers_seq_config.data();
cparams.n_samplers = pimpl->samplers_seq_config.size();
}

if (s23_single_slot_tree_swa) {
llama_s23_set_single_slot_tree_swa(true);
}
llama_context * lctx = llama_init_from_model(model, cparams);
if (s23_single_slot_tree_swa) {
llama_s23_set_single_slot_tree_swa(false);
}
if (lctx == NULL) {
COM_ERR("failed to create context with model '%s'\n", params.model.path.c_str());
return;
Expand Down
5 changes: 4 additions & 1 deletion common/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ struct common_params_model {
struct common_params_speculative_draft {
int32_t n_max = 3; // maximum number of tokens to draft during speculative decoding
int32_t n_min = 0; // minimum number of draft tokens to use for speculative decoding
bool n_max_set = false; // true if --spec-draft-n-max was explicitly provided

float p_split = 0.1f; // speculative decoding split probability
float p_min = 0.0f; // minimum speculative decoding probability (greedy)
Expand Down Expand Up @@ -424,7 +425,9 @@ struct common_params_speculative {
t == COMMON_SPECULATIVE_TYPE_DRAFT_LILICORR;
});

return needs_rs_seq ? draft.n_max : 0u;
const bool has_dspark = std::find(types.begin(), types.end(), COMMON_SPECULATIVE_TYPE_DRAFT_DSPARK) != types.end();
const int32_t eff_n_max = (has_dspark && !draft.n_max_set) ? std::max<int32_t>(draft.n_max, 7) : draft.n_max;
return needs_rs_seq ? eff_n_max : 0u;
}
};

Expand Down
50 changes: 50 additions & 0 deletions common/json-schema-to-grammar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,30 @@ static size_t gbnf_escape_length(const std::string & pattern, size_t pos) {
return 2 + n_hex;
}

static const char * gbnf_shorthand_to_rule(char c) {
switch (c) {
case 'd': return "[0-9]";
case 'D': return "[^0-9]";
case 's': return "[ \\t\\n\\r\\x0B\\x0C]";
case 'S': return "[^ \\t\\n\\r\\x0B\\x0C]";
case 'w': return "[0-9A-Za-z_]";
case 'W': return "[^0-9A-Za-z_]";
default: return nullptr;
}
}

static const char * gbnf_shorthand_in_char_class(char c) {
switch (c) {
case 'd': return "0-9";
case 'D': return "\\x00-\\x2F\\x3A-\\U0010FFFF";
case 's': return " \\t\\n\\r\\x0B\\x0C";
case 'S': return "\\x00-\\x08\\x0E-\\x1F\\x21-\\U0010FFFF";
case 'w': return "0-9A-Za-z_";
case 'W': return "\\x00-\\x2F\\x3A-\\x40\\x5B-\\x5E\\x60\\x7B-\\U0010FFFF";
default: return nullptr;
}
}

class common_chat_schema_converter {
private:
friend std::string build_grammar(const std::function<void(const common_grammar_builder &)> & cb, const common_grammar_options & options);
Expand Down Expand Up @@ -522,14 +546,34 @@ class common_chat_schema_converter {
} else if (c == '[') {
std::string square_brackets = std::string(1, c);
i++;
if (i < length && sub_pattern[i] == '^') {
square_brackets += '^';
i++;
}
while (i < length && sub_pattern[i] != ']') {
if (sub_pattern[i] == '\\') {
if (i + 1 < length) {
if (const char * expanded = gbnf_shorthand_in_char_class(sub_pattern[i + 1])) {
square_brackets += expanded;
i += 2;
if (i < length && sub_pattern[i] == '-' && i + 1 < length && sub_pattern[i + 1] != ']') {
square_brackets += "\\-";
i++;
}
continue;
}
}
auto escape_length = gbnf_escape_length(sub_pattern, i);
if (escape_length == 0) {
throw unsupported_pattern("unsupported escape in character class: " + sub_pattern.substr(i, 2));
}
square_brackets += sub_pattern.substr(i, escape_length);
i += escape_length;
} else if (sub_pattern[i] == '-' &&
i + 1 < length && sub_pattern[i + 1] == '\\' &&
i + 2 < length && gbnf_shorthand_in_char_class(sub_pattern[i + 2]) != nullptr) {
square_brackets += "\\-";
i++;
} else {
square_brackets += sub_pattern[i];
i++;
Expand All @@ -541,6 +585,9 @@ class common_chat_schema_converter {
square_brackets += ']';
i++;
seq.emplace_back(square_brackets, false);
} else if (c == '\\' && i + 1 < length && gbnf_shorthand_to_rule(sub_pattern[i + 1]) != nullptr) {
seq.emplace_back(gbnf_shorthand_to_rule(sub_pattern[i + 1]), false);
i += 2;
} else if (c == '|') {
seq.emplace_back("|", false);
i++;
Expand Down Expand Up @@ -614,6 +661,9 @@ class common_chat_schema_converter {
throw invalid_pattern("trailing backslash");
}
char next = sub_pattern[i + 1];
if (gbnf_shorthand_to_rule(next) != nullptr) {
break;
}
if (ESCAPED_IN_REGEXPS_BUT_NOT_IN_LITERALS.find(next) != ESCAPED_IN_REGEXPS_BUT_NOT_IN_LITERALS.end()) {
i++;
literal += sub_pattern[i];
Expand Down
69 changes: 65 additions & 4 deletions common/parsers/inkling.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#include "parsers.h"

#include <algorithm>
#include "log.h"

bool is_inkling_template(const std::string & src) {
return src.find("<|message_user|>") != std::string::npos &&
src.find("<|content_image|>") != std::string::npos;
Expand Down Expand Up @@ -122,9 +125,9 @@ common_chat_params common_chat_params_init_inkling(const common_chat_template &

// the call takes the name in the JSON
auto tool_json = p.token(TOOL_JSON);
auto tool_body = [&](const common_peg_parser & json_name) {
auto tool_body = [&](const common_peg_parser & json_name, const common_peg_parser & args_parser) {
return p.tool_open(p.literal("{")) << p.json_member("name", p.literal("\"") + p.tool_name(json_name) + p.literal("\"")) << p.literal(",")
<< p.json_member("args", p.tool_args(p.json())) << p.tool_close(p.literal("}")) + end;
<< p.json_member("args", p.tool_args(args_parser)) << p.tool_close(p.literal("}")) + end;
};

if (inputs.tool_choice == COMMON_CHAT_TOOL_CHOICE_REQUIRED) {
Expand All @@ -134,17 +137,75 @@ common_chat_params common_chat_params_init_inkling(const common_chat_template &
std::string name = function.at("name");
std::string quoted = json(name).dump();

auto args_inner = p.json();
try {
auto params = common_chat_tool_parameters(function);
auto doc = std::make_shared<const common_chat_schema_document>(common_chat_schema_from_json(params));
const auto * obj = dynamic_cast<const common_chat_schema_object *>(doc->root.get());
if (obj && !obj->additional_properties) {
if (obj->properties.empty()) {
args_inner = p.literal("{") + p.optional(p.space()) + p.literal("}");
} else {
std::vector<const common_chat_schema_property *> sorted;
sorted.reserve(obj->properties.size());
for (const auto & prop : obj->properties) {
sorted.push_back(&prop);
}
std::sort(sorted.begin(), sorted.end(), [](const auto * a, const auto * b) {
return a->name < b->name;
});
size_t first_req = sorted.size();
for (size_t j = 0; j < sorted.size(); ++j) {
if (sorted[j]->required) {
first_req = j;
break;
}
}
if (first_req < sorted.size()) {
std::vector<common_peg_parser> kv_rules;
kv_rules.reserve(sorted.size());
for (size_t j = 0; j < sorted.size(); ++j) {
const std::string base = "tool-" + std::to_string(tool_index) + "-p" + std::to_string(j);
auto val = p.schema(p.json(), base + "-val", doc, *sorted[j]->schema);
kv_rules.push_back(p.rule(base + "-kv",
p.literal(json(sorted[j]->name).dump()) + p.optional(p.space()) +
p.literal(":") + p.optional(p.space()) + val));
}
auto comma = p.optional(p.space()) + p.literal(",") + p.optional(p.space());
auto chain = kv_rules[first_req];
for (size_t j = first_req + 1; j < sorted.size(); ++j) {
chain = sorted[j]->required ? (chain + comma + kv_rules[j])
: (chain + p.optional(comma + kv_rules[j]));
}
for (size_t j = first_req; j > 0; --j) {
chain = p.optional(kv_rules[j - 1] + comma) + chain;
}
args_inner = p.literal("{") + p.optional(p.space()) + chain + p.optional(p.space()) + p.literal("}");
} else if (params.contains("properties") && params.at("properties").is_object()) {
json sorted_props = json::object();
for (const auto * sp : sorted) {
sorted_props[sp->name] = params.at("properties").at(sp->name);
}
params["properties"] = sorted_props;
args_inner = p.schema(p.json(), "tool-" + std::to_string(tool_index) + "-schema", params);
}
}
}
} catch (const std::exception & e) {
LOG_WRN("%s: tool %s uses generic JSON args: %s\n", __func__, name.c_str(), e.what());
}

// The research model does not generate a tool name before the tool call token
auto json_name = p.literal(quoted.substr(1, quoted.size() - 2));
tool_choice |= p.rule("tool-" + std::to_string(tool_index), p.tool(p.optional(p.literal(name)) + tool_json + tool_body(json_name)));
tool_choice |= p.rule("tool-" + std::to_string(tool_index), p.tool(p.optional(p.literal(name)) + tool_json + tool_body(json_name, args_inner)));
});

auto calls = inputs.parallel_tool_calls ? tool_choice + p.zero_or_more(header + tool_choice) : tool_choice;
return blocks + header + calls;
}

auto name = p.until(tool_json);
auto body = tool_body(p.string_content('"'));
auto body = tool_body(p.string_content('"'), p.json());
auto next = p.rule("tool-call", header + p.tool(name + tool_json + body));
auto more = inputs.parallel_tool_calls ? p.zero_or_more(next) : p.eps();
auto calls = header + name + p.trigger_rule("tool-calls", tool_json, body + more);
Expand Down
Loading
Loading