Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
1fa93f9
compact bias on the existing FLASH_ATTN_EXT for CUDA, ROCm and Vulkan
pwilkin Nov 21, 2026
d29f9d4
fixup! compact bias on the existing FLASH_ATTN_EXT for CUDA, ROCm and…
pwilkin Nov 21, 2026
37608cd
Build mask in chunks
pcuenca Nov 21, 2026
ff91e4f
fixup! compact bias on the existing FLASH_ATTN_EXT for CUDA, ROCm and…
pwilkin Nov 21, 2026
56a4ac9
Copy one head mask and broadcast rather than 24 copies
pcuenca Nov 21, 2026
808fd1c
fixup! compact bias on the existing FLASH_ATTN_EXT for CUDA, ROCm and…
pwilkin Nov 22, 2026
be0bf1f
remove the Vulkan support from this PR
pwilkin Nov 22, 2026
6ed4222
conversion
ngxson Nov 22, 2026
8ccecab
init cpp side
ngxson Nov 22, 2026
eacd398
handle temp > 0
ngxson Nov 22, 2026
e4b1cb5
dspark : fix Inkling2 draft state width, reseeding and draw order
pwilkin Nov 22, 2026
9cd1953
move the CUDA/HIP and Inkling 2 graph changes out of this PR
pwilkin Nov 22, 2026
79980c5
CPU reference implementation of the indexed bias
pwilkin Nov 22, 2026
0b51bb2
server: support /models/sse on single-model mode (#32398)
ngxson Nov 22, 2026
1014775
chat : implement token aware parsing (#29307)
aldehir Nov 22, 2026
e14a2d3
skill: Pay attention to tokenizer flags (#32819)
pcuenca Nov 22, 2026
56eea9e
server : add offset pagination to grep_search tool (#32792)
angt Nov 22, 2026
8c6f0c0
move the indexed bias test to test-backend-ops, add the bias in F32 o…
pwilkin Nov 22, 2026
d2bceda
vocab: enable ignore_merges for inkling2 (#32799)
rinpatch Nov 22, 2026
5bacb7c
llama : copy all experts of a host weight shared by several nodes (#3…
pwilkin Nov 22, 2026
5e02c71
Merge ggml-org/llama.cpp master 5bacb7c86
rafasmour Nov 22, 2026
844a96a
Merge ggml-org/llama.cpp#32752
rafasmour Nov 22, 2026
cd1fdf7
Merge ggml-org/llama.cpp#32218
rafasmour Nov 22, 2026
6896348
Merge ggml-org/llama.cpp#32740
rafasmour Nov 22, 2026
2d2e833
CUDA/HIP: indexed bias in the vec and tile flash attention kernels, u…
rafasmour Nov 22, 2026
977a600
CUDA: fuse the l2 clip, tanh gate and add + scale chains of Inkling 2
rafasmour Nov 22, 2026
1cd2adc
inkling2: stack the depth-mix blocks once, transpose the conv window …
rafasmour Nov 22, 2026
cc46885
inkling2: one zero sinks tensor per graph
rafasmour Nov 22, 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
10 changes: 5 additions & 5 deletions common/arg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ static bool parse_bool_value(const std::string & value) {
// common_models_handler
//

static std::string get_default_local_path(const std::string & url) {
std::string common_get_default_local_path(const std::string & url) {
auto f = string_split<std::string>(url, '#').front();
f = string_split<std::string>(f, '?').front();
return fs_get_cache_file(string_split<std::string>(f, '/').back()).string();
Expand Down Expand Up @@ -436,7 +436,7 @@ static std::vector<common_download_task> build_url_tasks(const common_params_mod
if (parts.size() == 1) {
common_download_task task;
task.url = parts[0];
task.local_path = model.path.empty() ? get_default_local_path(parts[0]) : model.path;
task.local_path = model.path.empty() ? common_get_default_local_path(parts[0]) : model.path;
task.opts = opts;
tasks.push_back(std::move(task));
return tasks;
Expand All @@ -454,7 +454,7 @@ static std::vector<common_download_task> build_url_tasks(const common_params_mod
task.url = part;
task.opts = opts;

std::string local = get_default_local_path(part);
std::string local = common_get_default_local_path(part);
if (!base_dir.empty()) {
auto pos = local.rfind('/');
std::string name = pos == std::string::npos ? local : local.substr(pos + 1);
Expand Down Expand Up @@ -487,7 +487,7 @@ void common_models_handler_apply(common_models_handler & handler, common_params
auto handle_url = [&](common_params_model & model) {
if (!model.url.empty()) {
if (model.path.empty()) {
model.path = get_default_local_path(model.url);
model.path = common_get_default_local_path(model.url);
}
}
};
Expand All @@ -498,7 +498,7 @@ void common_models_handler_apply(common_models_handler & handler, common_params
// optionally, if docker repo is set, resolve it
if (!params.model.docker_repo.empty()) {
params.model.url = common_docker_resolve_model(params.model.docker_repo);
params.model.path = get_default_local_path(params.model.url);
params.model.path = common_get_default_local_path(params.model.url);
}

// handle plain "url" tasks (non-hf)
Expand Down
3 changes: 3 additions & 0 deletions common/arg.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ common_models_handler common_models_handler_init(const common_params & params, l
// check if the model is a preset repo (i.e. has a preset file)
bool common_models_handler_is_preset_repo(const common_models_handler & handler);

// the cache path a model downloaded from a plain url is stored at
std::string common_get_default_local_path(const std::string & url);

// download and update params with the downloaded model path
void common_models_handler_apply(common_models_handler & handler, common_params & params, common_download_callback * callback = nullptr);

Expand Down
10 changes: 6 additions & 4 deletions common/chat-auto-parser-generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,9 @@ common_peg_parser analyze_tools::build_tool_parser_tag_tagged(parser_build_conte
auto & p = ctx.p;
const auto & inputs = ctx.inputs;

auto until_suffix = p.rule("until-suffix", p.until(arguments.value_suffix));
// A raw string value needs a suffix to end on, without one it is parsed as JSON
bool raw_strings = !arguments.value_suffix.empty();
auto until_suffix = raw_strings ? p.rule("until-suffix", p.until(arguments.value_suffix)) : p.eps();

common_peg_parser tool_choice = p.choice();

Expand All @@ -389,9 +391,9 @@ common_peg_parser analyze_tools::build_tool_parser_tag_tagged(parser_build_conte
p.tool_arg(p.tool_arg_open(arguments.name_prefix + p.tool_arg_name(p.literal(param.name)) +
arguments.name_suffix) +
arguments.value_prefix +
(param.schema->may_be_string() ?
p.ac(p.tool_arg_string_value(until_suffix) +
p.tool_arg_close(p.literal(arguments.value_suffix)), arguments.value_suffix) :
(raw_strings && param.schema->may_be_string() ?
p.through(p.tool_arg_string_value(until_suffix),
p.tool_arg_close(p.literal(arguments.value_suffix))) :
(p.tool_arg_json_value(p.schema(
p.json(), "tool-" + std::to_string(tool_index) + "-arg-" + std::to_string(param_index) + "-schema", doc, *param.schema)) +
p.tool_arg_close(p.literal(arguments.value_suffix)))));
Expand Down
1 change: 1 addition & 0 deletions common/chat-auto-parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ struct generation_params {
bool is_inference = true;
bool add_inference = false;
bool mark_input = true; // whether to mark input strings in the jinja context
common_peg_tokens specials;

bool has_continuation() const {
return continue_final_message != COMMON_CHAT_CONTINUATION_NONE && !continue_msg.empty();
Expand Down
11 changes: 11 additions & 0 deletions common/chat-peg-parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ constexpr size_t COMMON_CHAT_MAX_PERMUTE = 6;

class common_chat_peg_builder : public common_peg_parser_builder {
public:
common_chat_peg_builder() = default;
explicit common_chat_peg_builder(common_peg_tokens tokens) : common_peg_parser_builder(std::move(tokens)) {}

// Tag constants (from former common_chat_peg_base_builder)
static constexpr const char * REASONING_BLOCK = "reasoning-block";
static constexpr const char * REASONING = "reasoning";
Expand Down Expand Up @@ -200,6 +203,14 @@ inline common_peg_arena build_chat_peg_parser(
return builder.build();
}

inline common_peg_arena build_chat_peg_parser(
const common_peg_tokens & specials,
const std::function<common_peg_parser(common_chat_peg_builder & builder)> & fn) {
common_chat_peg_builder builder(specials);
builder.set_root(fn(builder));
return builder.build();
}

class tag_based_peg_mapper {
public:
std::map<std::string, std::string> tags;
Expand Down
20 changes: 18 additions & 2 deletions common/chat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ struct common_chat_templates {
bool add_bos;
bool add_eos;
bool has_explicit_template; // Model had builtin template or template overridden was specified.
common_peg_tokens specials;
std::unique_ptr<common_chat_template> template_default; // always set (defaults to chatml)
std::unique_ptr<common_chat_template> template_tool_use;
std::unique_ptr<common_chat_template> template_tts; // the prompt of a text to speak
Expand Down Expand Up @@ -802,6 +803,10 @@ void common_chat_templates_free(struct common_chat_templates * tmpls) {
delete tmpls;
}

void common_chat_templates_set_specials(struct common_chat_templates * tmpls, common_peg_tokens specials) {
tmpls->specials = std::move(specials);
}

bool common_chat_templates_was_explicit(const struct common_chat_templates * tmpls) {
return tmpls->has_explicit_template;
}
Expand Down Expand Up @@ -978,6 +983,7 @@ common_chat_templates_ptr common_chat_templates_init(const struct llama_model *
std::string token_eos = eos_token_override;
bool add_bos = false;
bool add_eos = false;
common_peg_tokens specials;
if (model) {
const auto * vocab = llama_model_get_vocab(model);
const auto get_token = [&](llama_token token, const char * name, const char * jinja_variable_name) {
Expand All @@ -997,11 +1003,13 @@ common_chat_templates_ptr common_chat_templates_init(const struct llama_model *
token_eos = get_token(llama_vocab_eos(vocab), "EOS", "eos_token");
add_bos = llama_vocab_get_add_bos(vocab);
add_eos = llama_vocab_get_add_eos(vocab);
specials = common_peg_tokens(vocab);
}
common_chat_templates_ptr tmpls(new common_chat_templates());
tmpls->has_explicit_template = has_explicit_template;
tmpls->add_bos = add_bos;
tmpls->add_eos = add_eos;
tmpls->specials = std::move(specials);
try {
tmpls->template_default = std::make_unique<common_chat_template>(default_template_src, token_bos, token_eos);
} catch (const std::exception & e) {
Expand Down Expand Up @@ -1543,6 +1551,7 @@ static common_chat_params common_chat_templates_apply_jinja(const struct common_
params.add_generation_prompt = inputs.add_generation_prompt;
params.add_bos = tmpls->add_bos;
params.add_eos = tmpls->add_eos;
params.specials = tmpls->specials;

params.continue_final_message = inputs.continue_final_message;
if (params.continue_final_message != COMMON_CHAT_CONTINUATION_NONE) {
Expand Down Expand Up @@ -1825,6 +1834,7 @@ common_chat_input common_chat_input_tokenize(const llama_vocab * vocab, const st
}
if (input.text != text) {
// the pieces do not give back the same text, keep the text without tokens
LOG_WRN("%s: token pieces do not match the text, parsing without token ids\n", __func__);
return common_chat_input(text);
}
return input;
Expand Down Expand Up @@ -1935,11 +1945,17 @@ common_chat_session::common_chat_session(const common_chat_templates * tm
thinking_ends = std::move(applied.thinking_end_tags);

parser_params.format = applied.format;
parser_params.generation_prompt = vocab ? common_chat_input_tokenize(vocab, applied.generation_prompt)
: common_chat_input(applied.generation_prompt);
parser_params.debug = params.debug;
parser_params.parser = std::move(applied.parser);

if (vocab) {
parser_params.generation_prompt = common_chat_input_tokenize(vocab, applied.generation_prompt);
} else if (params.tokenize) {
parser_params.generation_prompt = params.tokenize(applied.generation_prompt);
} else {
parser_params.generation_prompt = common_chat_input(applied.generation_prompt);
}

delimiters = std::move(applied.message_delimiters);

if (vocab) {
Expand Down
6 changes: 6 additions & 0 deletions common/chat.h
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,9 @@ common_chat_templates_ptr common_chat_templates_init(const struct llama_model *
const std::string & bos_token_override = "",
const std::string & eos_token_override = "");

// override special tokens for testing
void common_chat_templates_set_specials(struct common_chat_templates * tmpls, common_peg_tokens specials);

bool common_chat_templates_was_explicit(const struct common_chat_templates * tmpls);
std::string common_chat_templates_source(const struct common_chat_templates * tmpls, const std::string & variant = "");

Expand All @@ -397,6 +400,9 @@ common_chat_msg common_chat_peg_parse(const common_peg_arena & src_parser, const
struct common_chat_session_params {
bool echo = false; // include the assistant prefill in the output when continuing a message
bool debug = false; // enable debug output for the PEG parser

// tokenize the generation prompt when there is no vocab for testing
std::function<common_chat_input(const std::string &)> tokenize;
};

class common_chat_session {
Expand Down
26 changes: 20 additions & 6 deletions common/download.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ class ProgressBar : public common_download_callback {
std::string filename;
size_t len = 0;

// the caller's callback, if any, still receives every event
common_download_callback * next;

static void cleanup(const ProgressBar * line) {
lines.erase(line);
if (lines.empty()) {
Expand All @@ -110,9 +113,12 @@ class ProgressBar : public common_download_callback {
}

public:
ProgressBar() = default;
ProgressBar(common_download_callback * next) : next(next) {}

void on_start(const common_download_progress & p) override {
if (next) {
next->on_start(p);
}
filename = url_get_filename(p.url);

for (size_t i = 0; i < filename.size(); ++i) {
Expand All @@ -126,12 +132,22 @@ class ProgressBar : public common_download_callback {
}
}

void on_done(const common_download_progress &, bool) override {
void on_done(const common_download_progress & p, bool ok) override {
if (next) {
next->on_done(p, ok);
}
std::lock_guard<std::mutex> lock(mutex);
cleanup(this);
}

bool is_cancelled() const override {
return next && next->is_cancelled();
}

void on_update(const common_download_progress & p) override {
if (next) {
next->on_update(p);
}
if (!p.total || !is_output_a_tty()) {
return;
}
Expand Down Expand Up @@ -519,11 +535,9 @@ int common_download_file_single(const std::string & url,
const std::string & lock_path,
const std::string & alt_path) {
if (!opts.offline) {
ProgressBar tty_cb;
ProgressBar tty_cb(opts.callback);
common_download_opts online_opts = opts;
if (!online_opts.callback) {
online_opts.callback = &tty_cb;
}
online_opts.callback = &tty_cb;
return common_download_file_single_online(url, path, online_opts, skip_etag, lock_path, alt_path);
}

Expand Down
4 changes: 2 additions & 2 deletions common/json-schema-to-grammar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -676,8 +676,8 @@ class common_chat_schema_converter {
const auto & node = trie.nodes[idx];
std::string rejects;
auto first = true;
for (const auto & [cpt, child] : node.children) {
std::string c = common_unicode_cpt_to_utf8(cpt);
for (const auto & [sym, child] : node.children) {
std::string c = common_unicode_cpt_to_utf8(sym.value);
rejects += c;
if (first) {
first = false;
Expand Down
Loading
Loading