koboldcpp/docs
王金旭 9cd719af21
model: support speculators-format checkpoints for DSpark (#26275)
* dspark: support speculators-format checkpoints (SpecForge exports)

Speculators-format DSpark drafts (e.g. SpecForge exports for the
Gemma-4-26B-A4B target) differ from the dense DeepSpec checkpoints in
three ways:

- the config nests the backbone hparams under transformer_layer_config
  and gives the extract layers as aux_hidden_state_layer_ids
- the block is the DFlash 1+N fill-in layout: the anchor slot is a bonus
  token, not a prediction slot. Written as dflash.bonus_anchor; such
  drafts build the block and read the mask positions exactly like
  DFlash (n_max drafts from a 1+n_max block), only the Markov/confidence
  sampling comes from DSpark
- the draft output vocab may be reduced (draft_vocab_size < vocab_size)
  with a d2t remap table. The converter expands lm_head/markov_w2 back
  to the full vocab and synthesizes an lm_head bias of -1e9 on the rows
  the draft cannot produce, so the runtime needs no d2t remapping. Such
  drafts ship their own (now optional) token_embd/output tensors instead
  of sharing the target's

Verified against gemma4-26b-a4b-dspark: greedy outputs are byte-identical
with and without the draft; acceptance 0.46, mean draft len 3.7 (n_max 6).

Co-authored-by: desovo7 <942845546@qq.com>
Assisted-by: Claude Fable 5

* dspark: fold the speculators draft class into DSparkModel

One class now covers every DSpark variant. What used to pick the class is
a single flag, because the arch name turns out to be the only thing that
separates the two families: SpecForge also exports a flat schema that
carries no speculators_* fields yet still uses the 1+N bonus-anchor block,
so keying on those fields would silently mis-read its drafts.

Also rename i0 to i_first_pred in the draft read loop and the Markov head,
and give the head a real bonus_anchor bool instead of testing i0 > 0.

Converting the Qwen3-8B DeepSpec draft and both gemma-4 speculators drafts
produces byte-identical GGUFs. The one behaviour change is that the
markov_head_type check now also covers the DeepSpec checkpoints, which
previously skipped it.

Co-authored-by: desovo7 <942845546@qq.com>
Assisted-by: Claude Opus 5

* dspark: address review comments

- rename bonus_anchor to sample_from_anchor (GGUF key and code), matching
  the checkpoint config field; absent key still means anchor-first
- rework the reduced draft vocab to match EAGLE3: d2t is written as I64
  absolute target ids and the logits are scattered at runtime, instead of
  expanding lm_head/markov_w2 and synthesizing an output bias at conversion
- move the t2d skip to modify_tensors, like EAGLE3
- drop _is_specforge: the arch name only picks the sample_from_anchor
  default, embed/lm_head sharing is decided by the draft vocab size
- deduplicate the tok_embd create_tensor left behind by the rebase

Verified with the RedHat gemma-4-31b speculator draft: greedy output is
byte-identical with and without the draft; acceptance 0.26 (n_max 7).

Co-authored-by: desovo7 <942845546@qq.com>
Assisted-by: Claude Fable 5

* dspark: fold the sample_from_anchor read into the block_size block

* dspark: fix flake8 continuation indent

* clean up

* dspark: key the sample_from_anchor default off the export format

  Co-authored-by: desovo7 <942845546@qq.com>
  Assisted-by: Claude Fable

* dspark: drop t2d in filter_tensors

  Co-authored-by: desovo7 <942845546@qq.com>
  Assisted-by: Claude Fable

* dspark: map model.lm_head instead of bypassing the dflash prefix

  Co-authored-by: desovo7 <942845546@qq.com>
  Assisted-by: Claude Fable

---------

Co-authored-by: desovo7 <942845546@qq.com>
Co-authored-by: ruixiang63 <wangruixiang07@outlook.com>
2026-08-17 13:51:06 +02:00
..
android android: fix missing screenshots for Android.md (#18156) 2025-12-19 09:32:04 +02:00
backend common: migrate the deprecated --mmap/--no-mmap to --load-mode (#26934) 2026-08-15 16:35:53 +08:00
development convert: add @ModelBase.example (#27208) 2026-08-17 10:15:11 +02:00
multimodal docs : fix duplicated "the" in granitevision and model-conversion docs (#23767) 2026-05-27 09:34:06 +02:00
ops [SYCL] support OP OPT_STEP_ADAMW, OPT_STEP_SGD (#25268) 2026-08-17 07:31:29 +03:00
android.md docs/android.md: Add dependency libandroid-spawn for building in termux (#21812) 2026-06-22 05:48:31 +02:00
autoparser.md common : fix env names to all have LLAMA_ARG_ prefix (#23778) 2026-05-27 14:52:47 +03:00
build-riscv64-spacemit.md ci : update spacemit toolchain url and enhance curl command (#23642) 2026-05-25 10:43:24 +02:00
build-s390x.md docs: update s390x build docs (#19643) 2026-02-16 00:33:34 +08:00
build.md HIP: remove rocWMMA FlashAttention (#26046) 2026-07-24 17:53:54 +02:00
completions.md readme : refresh (#26280) 2026-07-30 16:14:37 +03:00
docker.md sycl : Improve SYCL doc (#23025) 2026-06-04 08:02:54 +03:00
function-calling.md docs: Update documentation with Granite 4.0/4.1 (#23404) 2026-05-22 20:35:46 +08:00
install.md docs: Adapt conda-forge package name (#26229) 2026-07-28 16:51:20 +02:00
llguidance.md llguidance build fixes for Windows (#11664) 2025-02-14 12:46:08 -08:00
models.md readme : refresh (#26280) 2026-07-30 16:14:37 +03:00
multi-gpu.md Write a readme on Multi-GPU usage in llama.cpp (#22729) 2026-05-07 17:48:40 +02:00
multimodal.md mtmd: refactor preprocessor, add mtmd_image_preproc_out (#24736) 2026-06-18 12:04:39 +02:00
ops.md [SYCL] support OP OPT_STEP_ADAMW, OPT_STEP_SGD (#25268) 2026-08-17 07:31:29 +03:00
preset.md common: add system-level config file (#26118) 2026-08-13 00:02:27 +02:00
release.md ci : allow make-release to target a specific commit (#27234) 2026-08-17 11:52:46 +03:00
speculative.md model: support speculators-format checkpoints for DSpark (#26275) 2026-08-17 13:51:06 +02:00
xcframework.md readme : refresh (#26280) 2026-07-30 16:14:37 +03:00