koboldcpp/common
Aman Gupta 255582687b
llama + spec: MTP Support (#22673)
* spec: support MTP

* fix batch size

* rename files

* cont : simplify (#7)

* MTP: clean-up (#9)

* MTP: clean-up

* review: use llama_context_type instead of llama_graph_type

* review: remove llama_model_has_mtp

* review: fix convert issues

* convert: fix pycheck

* review: formatting

* use `mtp-` for identifying mtp models

* convert: fix mtp conversion

* mtp -> draft-mtp

* remove unused llama_arch

* add need_embd in speculative

* llama: allow partial seq_rm for GDN models for speculative decoding

Currently speculative checkpoint needs to restart from a checkpoint
after some draft tokens are not accepted, this leads to some wastage in
running the target again. This PR adds the ability to rollback upto
`draft_max` by storing the GDN intermediates.

* fix pending state

* vulkan: add GDN partial rollback

* meta: extend check to axis 1

* metal: add GDN partial rollback

Extend the gated delta net kernel to store intermediate states for
partial rollback support on the Metal backend.

- Add K (snapshot slot count) as a function constant
- Read input state from slot 0 of the 3D state tensor
- Write intermediate states to different slots during token loop
- For K=1, maintain backward-compatible single-slot behavior

Ref: 8c05923630

Assisted-by: llama.cpp:local pi

* delta_net_base: use ggml_pad instead of new_tensor

* review: add need_rs_seq

* review: rename part_bounded to n_rs

* review: deslop comments

* review: rename, add asserts

* server : adjust checkpoint logic (#11)

* server : adjust checkpoint logic

* cont : rm asserts

* server-context: fix early exit

* spec : fix compatibility with n-gram and add TODOs (#13)

* metal : cleanup

* llama : fix faulty bitwise check in recurrent memory

* server : disable RS-based MTP in combination with other spec types

* spec : add TODOs

* cont : fix comment

* cont : update comment

* common : fix logic for ngram + mtp compat

* llama-memory: enable checkpointing with partial rollback

* cont: add test-case for loading into a dirty ctx

* llama-memory-recurrent: clear rs_idx in clear

* download: fix mtp path

* llama-arch: fix enorm op

* docs: update docs

* conversion: fix type annotations

---------

Co-authored-by: Georgi Gerganov <ggerganov@gmail.com>
2026-05-16 20:06:23 +08:00
..
jinja common : fix jinja warnings with clang 21 (#22313) 2026-04-24 12:36:02 +02:00
arg.cpp llama + spec: MTP Support (#22673) 2026-05-16 20:06:23 +08:00
arg.h mtmd, server, common: expose modalities to /v1/models (#22952) 2026-05-12 19:08:07 +02:00
base64.hpp llava : expose as a shared library for downstream projects (#3613) 2023-11-07 00:36:23 +03:00
build-info.cpp.in libs : rename libcommon -> libllama-common (#21936) 2026-04-17 11:11:46 +03:00
build-info.h libs : rename libcommon -> libllama-common (#21936) 2026-04-17 11:11:46 +03:00
chat-auto-parser-generator.cpp common : do not wrap raw strings in schema parser for tagged parsers (#22827) 2026-05-08 15:33:17 -05:00
chat-auto-parser-helpers.cpp common : replace wrap_for_generation with a prefix convenience function and fix gpt-oss (#20912) 2026-03-23 22:21:47 -05:00
chat-auto-parser-helpers.h chat : avoid including json in chat.h (#21306) 2026-04-03 09:07:59 +03:00
chat-auto-parser.h autoparser: support case of JSON_NATIVE with per-call markers (test case: Reka-Edge) (#21892) 2026-04-15 10:51:50 +02:00
chat-diff-analyzer.cpp common/autoparser: fixes for newline handling / forced tool calls (#22654) 2026-05-04 13:18:11 +02:00
chat-peg-parser.cpp common/autoparser: fixes for newline handling / forced tool calls (#22654) 2026-05-04 13:18:11 +02:00
chat-peg-parser.h common/autoparser: fixes for newline handling / forced tool calls (#22654) 2026-05-04 13:18:11 +02:00
chat.cpp common/chat : preserve media markers for typed-content templates (#22634) 2026-05-07 12:50:56 -05:00
chat.h common/chat : preserve media markers for typed-content templates (#22634) 2026-05-07 12:50:56 -05:00
CMakeLists.txt fit-params : refactor + add option to output estimated memory per device (#22171) 2026-04-21 09:54:36 +03:00
common.cpp llama + spec: MTP Support (#22673) 2026-05-16 20:06:23 +08:00
common.h llama + spec: MTP Support (#22673) 2026-05-16 20:06:23 +08:00
console.cpp cli: fix stripping of \n in multiline input (#21485) 2026-04-06 20:54:06 +02:00
console.h cli : add command and file auto-completion (#19985) 2026-03-05 10:47:28 +01:00
debug.cpp common: fix missing exports in llama-common (#22340) 2026-04-27 08:06:39 +03:00
debug.h common: fix missing exports in llama-common (#22340) 2026-04-27 08:06:39 +03:00
download.cpp llama + spec: MTP Support (#22673) 2026-05-16 20:06:23 +08:00
download.h llama + spec: MTP Support (#22673) 2026-05-16 20:06:23 +08:00
fit.cpp logs : reduce (#23021) 2026-05-14 13:05:52 +03:00
fit.h fit-params : refactor + add option to output estimated memory per device (#22171) 2026-04-21 09:54:36 +03:00
hf-cache.cpp common : check for null getpwuid in hf-cache (#22550) 2026-04-30 21:32:41 +02:00
hf-cache.h common : fix split model migration (#21019) 2026-03-26 12:04:37 +01:00
http.h server: Parse port numbers from MCP server URLs in CORS proxy (#20208) 2026-03-09 17:47:54 +01:00
json-partial.cpp common : Generalized XML-style tool-call parsing with streaming support (GLM 4.5/4.6 + MiniMax M2 + SeedOSS + Kimi-K2 + Qwen3-Coder + Apriel-1.5 + Xiaomi-MiMo) (#16932) 2025-11-18 18:54:15 +01:00
json-partial.h cli : fix reasoning responses in CLI (#18961) 2026-01-20 18:23:25 +01:00
json-schema-to-grammar.cpp common/json-schema: fix: handle non-capturing groups (?:...) in JSON schema pattern converter (#21124) 2026-03-28 17:55:38 +01:00
json-schema-to-grammar.h common : add nemotron 3 parsing (#18077) 2025-12-16 04:05:23 -06:00
llguidance.cpp sampling : add support for backend sampling (#17004) 2026-01-04 22:22:16 +02:00
log.cpp logs : reduce (#23021) 2026-05-14 13:05:52 +03:00
log.h logs : reduce (#23021) 2026-05-14 13:05:52 +03:00
ngram-cache.cpp spec : add self‑speculative decoding (no draft model required) + refactor (#18471) 2026-01-28 19:42:42 +02:00
ngram-cache.h spec : add self‑speculative decoding (no draft model required) + refactor (#18471) 2026-01-28 19:42:42 +02:00
ngram-map.cpp server : speculative checkpointing (#19493) 2026-04-19 10:24:06 +03:00
ngram-map.h fix: correct misspellings in code comments (#21217) 2026-03-31 13:50:51 +02:00
ngram-mod.cpp spec : add ngram-mod (#19164) 2026-01-30 18:21:48 +02:00
ngram-mod.h ngram-mod : fix build [no ci] (#19216) 2026-01-30 21:27:27 +02:00
peg-parser.cpp common/gemma4 : handle parsing edge cases (#21760) 2026-04-13 18:18:18 -05:00
peg-parser.h common/gemma4 : handle parsing edge cases (#21760) 2026-04-13 18:18:18 -05:00
preset.cpp mtmd, server, common: expose modalities to /v1/models (#22952) 2026-05-12 19:08:07 +02:00
preset.h mtmd, server, common: expose modalities to /v1/models (#22952) 2026-05-12 19:08:07 +02:00
reasoning-budget.cpp reasoning-budget: clone should do a deep-copy (#23095) 2026-05-15 11:59:07 +02:00
reasoning-budget.h common : do not pass prompt tokens to reasoning budget sampler (#22488) 2026-04-29 14:10:58 -05:00
regex-partial.cpp common : fix iterator::end() dereference (#20445) 2026-03-16 08:50:38 +02:00
regex-partial.h common: add partial regex support (#12808) 2025-05-14 19:50:57 +01:00
sampling.cpp backend sampling: support returning post-sampling probs (#22622) 2026-05-10 19:12:02 +02:00
sampling.h common : do not pass prompt tokens to reasoning budget sampler (#22488) 2026-04-29 14:10:58 -05:00
speculative.cpp llama + spec: MTP Support (#22673) 2026-05-16 20:06:23 +08:00
speculative.h llama + spec: MTP Support (#22673) 2026-05-16 20:06:23 +08:00
unicode.cpp common/parser: handle reasoning budget (#20297) 2026-03-11 10:26:12 +01:00
unicode.h common/parser: handle reasoning budget (#20297) 2026-03-11 10:26:12 +01:00