koboldcpp/common
Toby 3733366720
model : BailingMoE3 Support (#26608)
* Adding support for bailingmoe3

* Adds speculative decoding support

* Make BailingMoE3 safe gate metadata optional

* bailingmoe3: apply trained SwiGLU clamps

* common: fix Bailing V3 tool argument parsing

* llama-model-saver, instantiate float vector metadata writer

* bailingmoe3: support Q-LoRA (Ling-3.0-tiny)

Ling-3.0-flash sets q_lora_rank: None and projects Q directly, so the current
implementation loads a single ATTN_Q tensor. Ling-3.0-tiny sets q_lora_rank: 256
and routes Q through a LoRA bottleneck instead:

    q_a_proj -> q_a_layernorm -> q_b_proj

Conversion therefore failed with:

    ValueError: Can not map tensor 'model.layers.3.attention.q_a_layernorm.weight'

Add the missing path, mirroring the existing deepseek2 MLA implementation:

  * constants.py       - add ATTN_Q_A / ATTN_Q_B / ATTN_Q_A_NORM to BAILINGMOE3
  * tensor_mapping.py  - map model.layers.{bid}.attention.q_{a,b}_proj and
                         q_a_layernorm
  * conversion         - emit attention.q_lora_rank when the config has it
  * bailingmoe3.cpp    - read n_lora_q; create the Q-LoRA tensors and build Q
                         through the bottleneck when q_lora_rank > 0

Everything is gated on q_lora_rank > 0. Ling-3.0-flash's config has no
q_lora_rank, the converter only emits the key when present, hparams.n_lora_q
defaults to 0, and get_key(..., required=false) leaves the target untouched when
the key is absent - so flash keeps taking the existing direct-Q branch.

The LoRA path produces the same shape as the direct projection, so the
nope/rope split, RoPE application and wk_b absorption downstream are unchanged.

* small mtp change

* bailingmoe3: support separate MTP GGUF and Q-LoRA MTP

* gguf: remove duplicate add_kda_gate_lower_bound definition

---------

Co-authored-by: bloomer <bloomer@booper.brushtail.me>
Co-authored-by: Dyluhn <dylanranejohnston1@gmail.com>
2026-08-17 09:49:49 +02:00
..
jinja chat: refactor handling supports_string_content / supports_typed_content (#27130) 2026-08-16 12:45:33 +02:00
arg.cpp mtmd, common: various fixes (#27071) 2026-08-14 23:34:56 +02:00
arg.h mtmd: support Qwen3-TTS (note: breaking change to llama-tts binary) (#26254) 2026-08-04 17:26:15 +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 cmake : introduce semantic versioning (#26839) 2026-08-12 14:15:03 +02:00
build-info.h cmake : introduce semantic versioning (#26839) 2026-08-12 14:15:03 +02:00
chat-auto-parser-generator.cpp Add support for Laguna XS.2 & M.1 (#25165) 2026-07-22 09:54:08 +08:00
chat-auto-parser-helpers.cpp server: fix checkpoints creation (#22929) 2026-05-25 08:56:18 +03: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 Add support for Laguna XS.2 & M.1 (#25165) 2026-07-22 09:54:08 +08:00
chat-diff-analyzer.cpp model : BailingMoE3 Support (#26608) 2026-08-17 09:49:49 +02:00
chat-peg-parser.cpp chat : fix LFM2 tool call arg name prefix ambiguity (#26960) 2026-08-13 18:18:44 +02:00
chat-peg-parser.h chat : add qwen3 specialized parser (#26252) 2026-08-02 04:13:20 -05:00
chat.cpp chat: refactor handling supports_string_content / supports_typed_content (#27130) 2026-08-16 12:45:33 +02:00
chat.h common/chat: add specialized minimax m3 parser (#26210) 2026-07-28 04:27:20 -05:00
CMakeLists.txt cmake : introduce semantic versioning (#26839) 2026-08-12 14:15:03 +02:00
common.cpp common: apply CPU parameters across tools (#27026) 2026-08-13 20:40:59 +02:00
common.h common: apply CPU parameters across tools (#27026) 2026-08-13 20:40:59 +02: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 common: support the DSpark sidecar resolution (#26458) 2026-08-02 19:25:27 +02:00
download.h common: support the DSpark sidecar resolution (#26458) 2026-08-02 19:25:27 +02:00
fit.cpp fit: Fix memory allocation for MTP layers (#26605) 2026-08-05 13:29:45 +02:00
fit.h fit : wrap llama_device_memory_data (#24522) 2026-06-13 08:09:52 +03:00
hf-cache.cpp server: (router) add model management API (#23976) 2026-06-17 18:04:58 +02:00
hf-cache.h server: (router) add model management API (#23976) 2026-06-17 18:04:58 +02:00
http.h cli : move to HTTP-based implementation (#24948) 2026-07-08 14:52:43 +02:00
imatrix-loader.cpp fix: check gguf array type before reading (#27075) 2026-08-15 11:45:30 +02:00
imatrix-loader.h Move duplicated imatrix code into single common imatrix-loader.cpp (#22445) 2026-06-04 17:45:40 +02:00
json-schema-to-grammar.cpp common/json-schema-to-grammar : align spacing rules with parsers (#24835) 2026-06-20 17:43:04 -05:00
json-schema-to-grammar.h common : add nemotron 3 parsing (#18077) 2025-12-16 04:05:23 -06:00
llguidance.cpp llama : support multi-output backend sampling (#25532) 2026-08-10 16:58:56 +03:00
log.cpp common: update logging to enforce max_capacity and optimize queue resizing (#24490) 2026-06-17 09:19:11 +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 speculative : fix out-of-bounds read in ngram-map on prompt shrink (#23936) 2026-07-07 10:25:04 +03:00
ngram-map.h fix: correct misspellings in code comments (#21217) 2026-03-31 13:50:51 +02:00
ngram-mod.cpp ngram-mod : Add missing include (#23857) 2026-05-29 09:21:37 +03:00
ngram-mod.h ngram-mod : fix build [no ci] (#19216) 2026-01-30 21:27:27 +02:00
peg-parser.cpp common/peg : suppress incomplete escape sequences (#26780) 2026-08-11 07:10:31 +03:00
peg-parser.h common/peg : implement ac parser for stricter grammar generation (#24869) 2026-06-21 16:20:58 -05:00
preset.cpp common: support --models-dir loading MTP assistant models (#24431) 2026-08-15 13:17:35 +02:00
preset.h common: add system-level config file (#26118) 2026-08-13 00:02:27 +02:00
reasoning-budget.cpp llama : support multi-output backend sampling (#25532) 2026-08-10 16:58:56 +03:00
reasoning-budget.h common : add support for multiple end sequences in the reasoning budget sampler (#25544) 2026-07-25 11:58:09 +02:00
sampling.cpp llama : support multi-output backend sampling (#25532) 2026-08-10 16:58:56 +03:00
sampling.h llama : support multi-output backend sampling (#25532) 2026-08-10 16:58:56 +03:00
speculative.cpp spec : auto-detect mtp draft model type (#27005) 2026-08-13 13:39:16 +02:00
speculative.h common : auto-detect spec type from draft GGUF metadata (#26814) 2026-08-13 12:34:27 +02:00
subproc.cpp common: add subproc.h wrapper, disabled on android/ios (#26102) 2026-07-26 20:54:25 +02:00
subproc.h common: add subproc.h wrapper, disabled on android/ios (#26102) 2026-07-26 20:54:25 +02:00
trie.cpp common : add support for multiple end sequences in the reasoning budget sampler (#25544) 2026-07-25 11:58:09 +02:00
trie.h common : add support for multiple end sequences in the reasoning budget sampler (#25544) 2026-07-25 11:58:09 +02: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