]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commit
llama + spec: MTP Support (#22673)
authorAman Gupta <redacted>
Sat, 16 May 2026 12:06:23 +0000 (20:06 +0800)
committerGitHub <redacted>
Sat, 16 May 2026 12:06:23 +0000 (20:06 +0800)
commit255582687b8dd211fdbc582e43ab842491554e94
treea58a01ebd9e7cf38ba9d4499785e126c288da026
parentb81c2cdd748dc2704d5989cf03936325554c12d3
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: https://github.com/ggml-org/llama.cpp/commit/8c05923630110223669f069af2000e9cf10c02bc

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 <redacted>
54 files changed:
common/arg.cpp
common/common.cpp
common/common.h
common/download.cpp
common/download.h
common/speculative.cpp
common/speculative.h
conversion/base.py
conversion/qwen.py
convert_hf_to_gguf.py
ggml/include/ggml.h
ggml/src/ggml-backend-meta.cpp
ggml/src/ggml-cpu/ggml-cpu.c
ggml/src/ggml-cpu/ops.cpp
ggml/src/ggml-cuda/gated_delta_net.cu
ggml/src/ggml-metal/ggml-metal-device.cpp
ggml/src/ggml-metal/ggml-metal.metal
ggml/src/ggml-vulkan/ggml-vulkan.cpp
ggml/src/ggml-vulkan/vulkan-shaders/gated_delta_net.comp
ggml/src/ggml.c
gguf-py/gguf/constants.py
include/llama.h
src/llama-arch.cpp
src/llama-arch.h
src/llama-context.cpp
src/llama-context.h
src/llama-cparams.h
src/llama-ext.h
src/llama-graph.cpp
src/llama-graph.h
src/llama-hparams.cpp
src/llama-hparams.h
src/llama-memory-hybrid-iswa.cpp
src/llama-memory-hybrid-iswa.h
src/llama-memory-hybrid.cpp
src/llama-memory-hybrid.h
src/llama-memory-recurrent.cpp
src/llama-memory-recurrent.h
src/llama-memory.h
src/llama-model-loader.cpp
src/llama-model-loader.h
src/llama-model.cpp
src/models/delta-net-base.cpp
src/models/models.h
src/models/qwen35.cpp
src/models/qwen35moe.cpp
src/models/qwen3next.cpp
tests/CMakeLists.txt
tests/test-backend-ops.cpp
tests/test-recurrent-state-rollback.cpp [new file with mode: 0644]
tools/cli/README.md
tools/completion/README.md
tools/server/README.md
tools/server/server-context.cpp