Skip to content

BailingMoE3 Support - #26608

Merged
CISC merged 13 commits into
ggml-org:masterfrom
aetherbird:bailingmoe3-support
Aug 17, 2026
Merged

CISC merged 13 commits into
ggml-org:masterfrom
aetherbird:bailingmoe3-support

Conversation

@aetherbird

Copy link
Copy Markdown
Contributor

Overview

Adding support for BailingMoE 3,

Additional information

This allows for running the new Ling 3.0 flash model with MTP support. This addresses issue #26590.

Requirements

@github-actions github-actions Bot added model Model specific testing Everything test related conversion labels Aug 5, 2026
@hitman249

hitman249 commented Aug 5, 2026 •

Copy link
Copy Markdown

Testing on Strix Halo

It freezes on Vulkan (120 Gb VRAM)
env GGML_VK_PREFER_HOST_MEMORY=1 GGML_VK_REALLOC=1 \
./llama-server --host 0.0.0.0 --port 11434 \
-m /home/user/models/Ling-3.0-flash-MXFP4_MOE.gguf \
-ngl 999 -fa on -c 65536 -dev Vulkan0 --metrics --jinja \
--spec-type draft-mtp \
-b 512 -ub 256 --cache-reuse 256 -n -1 -np 1 --timeout 999999 \
--reasoning-budget 4096 --temp 0.6 --top-p 0.95 --top-k 20
0.00.291.545 I cmn  common_param: common_params_print_info: verbosity = 3 (adjust with the `-lv N` CLI arg)
0.00.291.961 W srv  llama_server: -----------------
0.00.291.963 W srv  llama_server: CORS is set to allow all origins ('*') and no API key is set
0.00.291.964 W srv  llama_server: this can be a security risk (cross-origin attacks)
0.00.291.964 W srv  llama_server: more info: https://github.com/ggml-org/llama.cpp/pull/25655
0.00.291.964 W srv  llama_server: -----------------
0.00.293.402 I srv    load_model: loading model '/home/user/models/Ling-3.0-flash-MXFP4_MOE.gguf'
0.00.710.402 W load: special_eos_id is not in special_eog_ids - the tokenizer config may be incorrect
0.51.844.312 I common_speculative_init_result: creating MTP draft context against the target model '/home/user/models/Ling-3.0-flash-MXFP4_MOE.gguf'
0.52.022.740 I srv    load_model: initializing, n_slots = 1, n_ctx_slot = 65536, kv_unified = 'false'
0.52.078.033 I srv          init: chat template supports preserving reasoning, consider enabling it via --reasoning-preserve
0.52.078.078 I srv  llama_server: model loaded
0.52.078.093 I srv  llama_server: listening on http://0.0.0.0:11434
0.56.629.628 I slot get_availabl: id  0 | task -1 | selected slot by LRU, t_last = -1
0.56.629.919 I slot launch_slot_: id  0 | task 0 | processing task, is_child = 0
1.09.903.868 I slot print_timing: id  0 | task 0 | n_decoded =    101, tg =   8.38 t/s, tg_3s =   8.38 t/s
1.13.322.784 I slot print_timing: id  0 | task 0 | n_decoded =    125, tg =   8.08 t/s, tg_3s =   7.02 t/s
1.16.653.452 I slot print_timing: id  0 | task 0 | n_decoded =    151, tg =   8.03 t/s, tg_3s =   7.81 t/s
1.19.954.128 I slot print_timing: id  0 | task 0 | n_decoded =    182, tg =   8.23 t/s, tg_3s =   9.39 t/s
1.22.956.605 I slot print_timing: id  0 | task 0 | n_decoded =    202, tg =   8.05 t/s, tg_3s =   6.66 t/s
1.26.341.931 I slot print_timing: id  0 | task 0 | n_decoded =    228, tg =   8.00 t/s, tg_3s =   7.68 t/s
1.29.370.333 I slot print_timing: id  0 | task 0 | n_decoded =    247, tg =   7.84 t/s, tg_3s =   6.27 t/s
1.32.593.047 I slot print_timing: id  0 | task 0 | n_decoded =    266, tg =   7.66 t/s, tg_3s =   5.90 t/s
1.36.011.313 I slot print_timing: id  0 | task 0 | n_decoded =    293, tg =   7.68 t/s, tg_3s =   7.90 t/s
1.39.425.169 I slot print_timing: id  0 | task 0 | n_decoded =    319, tg =   7.67 t/s, tg_3s =   7.62 t/s
1.42.788.466 I slot print_timing: id  0 | task 0 | n_decoded =    346, tg =   7.70 t/s, tg_3s =   8.03 t/s
1.46.194.752 I slot print_timing: id  0 | task 0 | n_decoded =    373, tg =   7.72 t/s, tg_3s =   7.93 t/s
1.49.522.407 I slot print_timing: id  0 | task 0 | n_decoded =    400, tg =   7.74 t/s, tg_3s =   8.11 t/s
1.52.932.498 I slot print_timing: id  0 | task 0 | n_decoded =    425, tg =   7.72 t/s, tg_3s =   7.33 t/s
1.56.346.189 I slot print_timing: id  0 | task 0 | n_decoded =    448, tg =   7.66 t/s, tg_3s =   6.74 t/s
1.59.348.071 I slot print_timing: id  0 | task 0 | n_decoded =    472, tg =   7.68 t/s, tg_3s =   7.99 t/s
2.02.727.893 I slot print_timing: id  0 | task 0 | n_decoded =    498, tg =   7.68 t/s, tg_3s =   7.69 t/s
2.06.050.103 I slot print_timing: id  0 | task 0 | n_decoded =    523, tg =   7.67 t/s, tg_3s =   7.53 t/s
2.09.402.146 I slot print_timing: id  0 | task 0 | n_decoded =    546, tg =   7.63 t/s, tg_3s =   6.86 t/s
2.12.791.549 I slot print_timing: id  0 | task 0 | n_decoded =    572, tg =   7.63 t/s, tg_3s =   7.67 t/s
^C23.32.448.352 I srv    operator(): operator(): cleaning up before exit...
Infinite launch on ROCm (120 Gb VRAM)
env HSA_OVERRIDE_GFX_VERSION=11.5.1 GGML_HIP_ENABLE_UNIFIED_MEMORY=1 \
./llama-server --host 0.0.0.0 --port 11434 \
-m /home/user/models/Ling-3.0-flash-MXFP4_MOE.gguf \
-ngl 999 -fa on -c 100000 -dev ROCm0 --metrics --jinja \
--spec-type draft-mtp --spec-draft-n-max 0 -ngld 0 \
-b 512 -ub 256 --cache-reuse 256 -n -1 -np 1 --timeout 999999 \
--reasoning-budget 4096 --temp 0.6 --top-p 0.95 --top-k 20
0.00.342.675 I cmn  common_param: common_params_print_info: verbosity = 3 (adjust with the `-lv N` CLI arg)
0.00.343.039 W srv  llama_server: -----------------
0.00.343.040 W srv  llama_server: CORS is set to allow all origins ('*') and no API key is set
0.00.343.041 W srv  llama_server: this can be a security risk (cross-origin attacks)
0.00.343.041 W srv  llama_server: more info: https://github.com/ggml-org/llama.cpp/pull/25655
0.00.343.041 W srv  llama_server: -----------------
0.00.344.259 I srv    load_model: loading model '/home/user/models/Ling-3.0-flash-MXFP4_MOE.gguf'
0.00.804.032 W load: special_eos_id is not in special_eog_ids - the tokenizer config may be incorrect
You can't opt ​​out of MTP
env GGML_VK_PREFER_HOST_MEMORY=1 \
./llama-server --host 0.0.0.0 --port 11434 \
-m /home/user/models/Ling-3.0-flash-MXFP4_MOE.gguf \
-ngl 999 -fa on -c 131072 -dev Vulkan0 --metrics \
-b 1024 -ub 256 --cache-reuse 256 -n -1 -np 1 --timeout 999999 \
--reasoning-budget 4096 --temp 0.6 --top-p 0.95 --top-k 20
0.00.279.379 I cmn  common_param: common_params_print_info: verbosity = 3 (adjust with the `-lv N` CLI arg)
0.00.279.735 W srv  llama_server: -----------------
0.00.279.736 W srv  llama_server: CORS is set to allow all origins ('*') and no API key is set
0.00.279.736 W srv  llama_server: this can be a security risk (cross-origin attacks)
0.00.279.737 W srv  llama_server: more info: https://github.com/ggml-org/llama.cpp/pull/25655
0.00.279.737 W srv  llama_server: -----------------
0.00.280.971 I srv    load_model: loading model '/home/user/models/Ling-3.0-flash-MXFP4_MOE.gguf'
0.00.559.164 W load: special_eos_id is not in special_eog_ids - the tokenizer config may be incorrect
0.00.584.569 W model has unused tensor blk.42.attn_norm.weight (size = 10240 bytes) -- ignoring
0.00.584.573 W model has unused tensor blk.42.attn_q.weight (size = 16711680 bytes) -- ignoring
0.00.584.574 W model has unused tensor blk.42.attn_kv_a_mqa.weight (size = 1566720 bytes) -- ignoring
0.00.584.576 W model has unused tensor blk.42.attn_kv_a_norm.weight (size = 2048 bytes) -- ignoring
0.00.584.577 W model has unused tensor blk.42.attn_k_b.weight (size = 2228224 bytes) -- ignoring
0.00.584.579 W model has unused tensor blk.42.attn_v_b.weight (size = 2228224 bytes) -- ignoring
0.00.584.580 W model has unused tensor blk.42.attn_gate.weight (size = 87040 bytes) -- ignoring
0.00.584.582 W model has unused tensor blk.42.attn_output.weight (size = 11141120 bytes) -- ignoring
0.00.584.584 W model has unused tensor blk.42.ffn_norm.weight (size = 10240 bytes) -- ignoring
0.00.584.585 W model has unused tensor blk.42.ffn_gate_inp.weight (size = 5242880 bytes) -- ignoring
0.00.584.587 W model has unused tensor blk.42.exp_probs_b.bias (size = 2048 bytes) -- ignoring
0.00.584.588 W model has unused tensor blk.42.ffn_gate_exps.weight (size = 534773760 bytes) -- ignoring
0.00.584.590 W model has unused tensor blk.42.ffn_up_exps.weight (size = 534773760 bytes) -- ignoring
0.00.584.591 W model has unused tensor blk.42.ffn_down_exps.weight (size = 534773760 bytes) -- ignoring
0.00.584.593 W model has unused tensor blk.42.ffn_gate_shexp.weight (size = 2088960 bytes) -- ignoring
0.00.584.594 W model has unused tensor blk.42.ffn_up_shexp.weight (size = 2088960 bytes) -- ignoring
0.00.584.596 W model has unused tensor blk.42.ffn_down_shexp.weight (size = 2088960 bytes) -- ignoring
0.00.584.599 W model has unused tensor blk.42.nextn.eh_proj.weight (size = 13926400 bytes) -- ignoring
0.00.584.601 W model has unused tensor blk.42.nextn.enorm.weight (size = 10240 bytes) -- ignoring
0.00.584.602 W model has unused tensor blk.42.nextn.hnorm.weight (size = 10240 bytes) -- ignoring
0.00.584.604 W model has unused tensor blk.42.layer_output_norm.weight (size = 10240 bytes) -- ignoring
0.54.761.501 I srv    load_model: initializing, n_slots = 1, n_ctx_slot = 131072, kv_unified = 'false'
0.54.769.175 I srv          init: chat template supports preserving reasoning, consider enabling it via --reasoning-preserve
0.54.769.335 I srv  llama_server: model loaded
0.54.769.355 I srv  llama_server: listening on http://0.0.0.0:11434
^C1.09.669.339 I srv    operator(): operator(): cleaning up before exit...
Crash if you try to disable MTP with a hack
env GGML_VK_PREFER_HOST_MEMORY=1 \
./llama-server --host 0.0.0.0 --port 11434 \
-m /home/user/models/Ling-3.0-flash-MXFP4_MOE.gguf \
-ngl 999 -fa on -c 65536 -dev Vulkan0 --metrics --jinja \
--spec-type draft-mtp --spec-draft-n-max 0 -ngld 0 \
-b 512 -ub 256 --cache-reuse 256 -n -1 -np 1 --timeout 999999 \
--reasoning-budget 4096 --temp 0.6 --top-p 0.95 --top-k 20
0.00.350.341 I cmn  common_param: common_params_print_info: verbosity = 3 (adjust with the `-lv N` CLI arg)
0.00.350.703 W srv  llama_server: -----------------
0.00.350.704 W srv  llama_server: CORS is set to allow all origins ('*') and no API key is set
0.00.350.705 W srv  llama_server: this can be a security risk (cross-origin attacks)
0.00.350.705 W srv  llama_server: more info: https://github.com/ggml-org/llama.cpp/pull/25655
0.00.350.705 W srv  llama_server: -----------------
0.00.351.899 I srv    load_model: loading model '/home/user/models/Ling-3.0-flash-MXFP4_MOE.gguf'
0.00.785.121 W load: special_eos_id is not in special_eog_ids - the tokenizer config may be incorrect
0.50.513.526 I common_speculative_init_result: creating MTP draft context against the target model '/home/user/models/Ling-3.0-flash-MXFP4_MOE.gguf'
0.50.647.373 I srv    load_model: initializing, n_slots = 1, n_ctx_slot = 65536, kv_unified = 'false'
0.50.690.797 I srv          init: chat template supports preserving reasoning, consider enabling it via --reasoning-preserve
0.50.690.843 I srv  llama_server: model loaded
0.50.690.857 I srv  llama_server: listening on http://0.0.0.0:11434
1.58.704.946 I slot get_availabl: id  0 | task -1 | selected slot by LRU, t_last = -1
1.58.705.113 I slot launch_slot_: id  0 | task 0 | processing task, is_child = 0
/home/user/ling-llama.cpp/src/llama-context.cpp:2246: GGML_ASSERT(n_outputs_max <= cparams.n_outputs_max) failed
[New LWP 11982]
[New LWP 11981]
[New LWP 11980]
[New LWP 11979]
[New LWP 11978]
[New LWP 11977]
[New LWP 11976]
[New LWP 11975]
[New LWP 11974]
[New LWP 11973]
[New LWP 11972]
[New LWP 11971]
[New LWP 11970]
[New LWP 11969]
[New LWP 11968]
[New LWP 11967]
[New LWP 11966]
[New LWP 11965]
[New LWP 11964]
[New LWP 11963]
[New LWP 11962]
[New LWP 11961]
[New LWP 11960]
[New LWP 11959]
[New LWP 11958]
[New LWP 11957]
[New LWP 11956]
[New LWP 11955]
[New LWP 11954]
[New LWP 11953]
[New LWP 11952]
[New LWP 11951]
[New LWP 11950]
[New LWP 11949]
[New LWP 11947]
[New LWP 11946]
[New LWP 11944]
[New LWP 11943]

This GDB supports auto-downloading debuginfo from the following URLs:
  <ima:enforcing>
  <https://debuginfod.fedoraproject.org/>
  <ima:ignore>
Enable debuginfod for this session? (y or [n]) [answered N; input not from terminal]
Debuginfod has been disabled.
To make this setting permanent, add 'set debuginfod enabled off' to .gdbinit.
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".
0x00007fb4130ce7f2 in ?? () from /usr/lib/libc.so.6
#0  0x00007fb4130ce7f2 in ?? () from /usr/lib/libc.so.6
#1  0x00007fb4130c281c in ?? () from /usr/lib/libc.so.6
#2  0x00007fb4130c2864 in ?? () from /usr/lib/libc.so.6
#3  0x00007fb413132fcf in wait4 () from /usr/lib/libc.so.6
#4  0x00007fb41c512bbb in ggml_print_backtrace () from /home/user/ling-llama.cpp/build/bin/libggml-base.so.0
#5  0x00007fb41c512d56 in ggml_abort () from /home/user/ling-llama.cpp/build/bin/libggml-base.so.0
#6  0x00007fb41b2ee25f in llama_context::output_reserve(int) () from /home/user/ling-llama.cpp/build/bin/libllama.so.0
#7  0x00007fb41b2f8346 in llama_context::decode(llama_batch const&) () from /home/user/ling-llama.cpp/build/bin/libllama.so.0
#8  0x00007fb41b2fa71e in llama_decode () from /home/user/ling-llama.cpp/build/bin/libllama.so.0
#9  0x00007fb41bfd9d80 in server_context_impl::decode(int&, int, llama_batch&) () from /home/user/ling-llama.cpp/build/bin/libllama-server-impl.so
#10 0x00007fb41bfdbdfe in server_context_impl::update_slots() () from /home/user/ling-llama.cpp/build/bin/libllama-server-impl.so
#11 0x00007fb41bf6c8f1 in server_queue::start_loop(long) () from /home/user/ling-llama.cpp/build/bin/libllama-server-impl.so
#12 0x00007fb41beffca2 in llama_server(common_params&, int, char**) () from /home/user/ling-llama.cpp/build/bin/libllama-server-impl.so
#13 0x00007fb41bf027ea in llama_server(int, char**) () from /home/user/ling-llama.cpp/build/bin/libllama-server-impl.so
#14 0x00007fb413055781 in ?? () from /usr/lib/libc.so.6
#15 0x00007fb4130558b9 in __libc_start_main () from /usr/lib/libc.so.6
#16 0x0000563669c28075 in _start ()

@Green-Sky

Copy link
Copy Markdown
Collaborator

You can't opt ​​out of MTP

They are not loaded. Other models with baked in mtp behaved the same. "model has unused tensor" is proof its not loaded.


Looks like a very good model for its sparsity.
5:1 kda:mla means less kv use.
and with only 5.1B active out of 124B it is really sparse and should boost tg on mid range hardware.

@ngxson

ngxson commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

/bot review

@ggml-gh-bot

ggml-gh-bot Bot commented Aug 5, 2026 •

Copy link
Copy Markdown
Automated code review

I've completed a static review of PR #26608 (BailingMoE3 / Ling 3.0 flash support). The change adds a new hybrid arch (KDA recurrent + MLA attention + MoE + MTP) by adapting the established Kimi-Linear KDA, DeepSeek2/Kimi MLA, and Qwen3-Next MTP patterns. The core graph logic, tensor layouts, and MLA absorption path look correct, and the registration across constants.py/tensor_mapping.py/llama-arch.*/llama-model.cpp/llama-quant.cpp/the arch test is complete. Below are findings grouped by severity.

Will slow the review (verify before merge)

(point 1) Tokenizer pre-type is not added for the new model. conversion/bailingmoe3.py uses set_vocab -> _set_vocab_gpt2(), which hashes the tokenizer via get_vocab_base_pre() (conversion/base.py:1390). No new hash entry and no "bailingmoe3" case were added there, and src/llama-vocab.cpp:2324 has no "bailingmoe3" pre type. This only works if Ling 3.0 flash's tokenizer hash already matches an existing entry (most likely the "bailingmoe2" hash for Ling-mini-base-2.0, which maps to LLAMA_VOCAB_PRE_TYPE_BAILINGMOE). If the tokenizer changed, conversion will raise NotImplementedError (so it's self-diagnosing rather than silently wrong), but please confirm in the PR which tokenizer.pre the converted GGUF ends up with and that round-trip tokenization is correct. If it's a new tokenizer, add the hash + a bailingmoe3 pre-type branch.

(point 2) f_proj mapping is unconditional. In conversion/bailingmoe3.py:92-94, *.attention.f_proj.weight is always rewritten to SSM_F_A, but load_arch_tensors only creates ssm_f_a for recurrent (is_recr) layers (src/models/bailingmoe3.cpp:62-64). If any MLA/full-attention layer in the HF checkpoint also exposes an attention.f_proj tensor, it becomes an unused blk.<il>.ssm_f_a tensor that the loader silently ignores (src/llama-model-loader.cpp:1115-1118), so a real projection could be dropped without an error. The arch works only if MLA layers have no f_proj. Consider gating the rename on not self.is_full_attention(bid) (as g_proj already does) to make the assumption explicit and fail loudly if violated.

(point 3) MTP final-norm relies on a borrowed name mapping. load_arch_tensors loads the MTP final norm as LLM_TENSOR_LAYER_OUT_NORM (src/models/bailingmoe3.cpp:148), but the PR adds no bailingmoe3-specific entry to LAYER_OUT_NORM in gguf-py/gguf/tensor_mapping.py:730; it depends on the pre-existing "model.layers.{bid}.final_layernorm" (bailingmoe2) mapping. Confirm the Ling 3.0 flash MTP block actually names this weight final_layernorm; otherwise the tensor won't map and the (required) create_tensor will throw at load.

(point 4) MTP graph is not exercised by test-llama-archs. The test fixture never sets LLM_KV_NEXTN_PREDICT_LAYERS, so n_layer_nextn == 0 and graph_mtp is never built/decoded for this arch (only the KDA+MLA+MoE trunk is smoked). Since MTP is a headline feature of this PR, please ensure it's covered (manually or by extending the fixture), including the quantized-KV path (-ctk q8_0).

Nits / consistency

(point 5) MTP input class choice. graph_mtp uses llm_graph_input_embd and reuses its embd field for the hidden state h_nextn (src/models/bailingmoe3.cpp:351-357), whereas the sibling MLA+MTP models (deepseek4 src/models/deepseek4.cpp:1426, qwen35moe src/models/qwen35moe.cpp:567) use llm_graph_input_embd_h with a dedicated h field. It works for MTP (the hook batch sets ubatch->embd to the h_nextn row), but diverging from the established pattern makes the intent less clear. Consider llm_graph_input_embd_h for consistency.

(point 6) MXFP4_MOE heuristic fix is bailingmoe3-specific. src/llama-quant.cpp:474-486 special-cases LLM_ARCH_BAILINGMOE3 because its MLA attn_k_b/attn_v_b tensors are 3D and would otherwise be mis-quantized as expert tensors by the ne[2] > 1 test. The category-based check is the right idea, but scoping it to one arch leaves the same latent trap for other MLA archs (deepseek2/4, kimi-linear) if they're ever quantized with MXFP4_MOE. A general category == FFN_{UP,GATE,DOWN} check would be more robust; the current scoped form is safe but a little inelegant.

(point 7) Minor MTP deviation. graph_mtp omits build_cvec (src/models/bailingmoe3.cpp:439 region), matching qwen3next/qwen35moe but unlike deepseek4 (src/models/deepseek4.cpp:1520). Fine as long as control-vector/LoRA support isn't expected on the MTP head; just call it out if intentional.

(point 8) add_kv writes kda.safe_gate/kda.gate_lower_bound for every arch when saving (src/llama-model-saver.cpp:321-322). This matches the existing KDA_HEAD_DIM behavior (also unconditional), so it's consistent, but it does add noise metadata to all saved GGUFs.

Scope gate

The PR is single-purpose (one new arch), CPU-only inference path (no backend kernels added), addresses the linked issue #26590, and the AI-usage disclosure is filled in. No ggml_type/quant type, no public API, no new ggml ops, no new third-party deps. Nothing to reject on scope grounds.

This review was generated automatically by pi coding agent using zai-org/GLM-5.2. It may contain mistakes. Maintainers make the final call.

@p11o

p11o commented Aug 5, 2026

Copy link
Copy Markdown

Fails for vulkan on AMD.

cmake -B build -DGGML_VULKAN=1      
cmake --build build --config Release
llama cli -hf AtomicChat/Ling-3.0-flash-GGUF:IQ3_M

Loading model... |0.00.265.865 E llama_model_load: error loading model: error loading model hyperparameters: key not found in model: bailingmoe3.kda.safe_gate
0.00.265.868 E llama_model_load_from_file_impl: failed to load model
0.00.265.898 E common_fit_params: encountered an error while trying to fit params to free device memory: failed to load model
-0.00.315.702 E llama_model_load: error loading model: error loading model hyperparameters: key not found in model: bailingmoe3.kda.safe_gate
0.00.315.706 E llama_model_load_from_file_impl: failed to load model
0.00.315.713 E cmn  common_init_: failed to load model '/home/.cache/huggingface/hub/models--AtomicChat--Ling-3.0-flash-GGUF/snapshots/7664663faa0adb1385e3c8cd9b520a7da4675aa6/AD-IQ3_M/Ling-3.0-flash-AD-IQ3_M-00001-of-00002.gguf'
0.00.315.722 E srv    load_model: failed to load model, '/home/.cache/huggingface/hub/models--AtomicChat--Ling-3.0-flash-GGUF/snapshots/7664663faa0adb1385e3c8cd9b520a7da4675aa6/AD-IQ3_M/Ling-3.0-flash-AD-IQ3_M-00001-of-00002.gguf'
0.00.317.583 E srv  llama_server: exiting due to model loading error
llama_server exited with code 1
Error: the server exited before becoming ready

@aetherbird

Copy link
Copy Markdown
Contributor Author

Fails for vulkan on AMD.

cmake -B build -DGGML_VULKAN=1      
cmake --build build --config Release
llama cli -hf AtomicChat/Ling-3.0-flash-GGUF:IQ3_M

Loading model... |0.00.265.865 E llama_model_load: error loading model: error loading model hyperparameters: key not found in model: bailingmoe3.kda.safe_gate
0.00.265.868 E llama_model_load_from_file_impl: failed to load model
0.00.265.898 E common_fit_params: encountered an error while trying to fit params to free device memory: failed to load model
-0.00.315.702 E llama_model_load: error loading model: error loading model hyperparameters: key not found in model: bailingmoe3.kda.safe_gate
0.00.315.706 E llama_model_load_from_file_impl: failed to load model
0.00.315.713 E cmn  common_init_: failed to load model '/home/.cache/huggingface/hub/models--AtomicChat--Ling-3.0-flash-GGUF/snapshots/7664663faa0adb1385e3c8cd9b520a7da4675aa6/AD-IQ3_M/Ling-3.0-flash-AD-IQ3_M-00001-of-00002.gguf'
0.00.315.722 E srv    load_model: failed to load model, '/home/.cache/huggingface/hub/models--AtomicChat--Ling-3.0-flash-GGUF/snapshots/7664663faa0adb1385e3c8cd9b520a7da4675aa6/AD-IQ3_M/Ling-3.0-flash-AD-IQ3_M-00001-of-00002.gguf'
0.00.317.583 E srv  llama_server: exiting due to model loading error
llama_server exited with code 1
Error: the server exited before becoming ready

This was a metadata compatibility issue. AtomicChat’s converter assumes the safe-gate form and omits the bailingmoe3.kda.safe_gate field. The loader now defaults it to true when absent.

@hitman249

hitman249 commented Aug 6, 2026 •

Copy link
Copy Markdown

Retest on Strix Halo

Build
cmake -B build \
  -DCMAKE_BUILD_TYPE=Release \
  -DGGML_NATIVE=ON \
  -DGGML_HIP=ON \
  -DGGML_HIP_ROCWMMA_FATTN=ON \
  -DGGML_HIP_FA_ALL_QUANTS=ON \
  -DGGML_HIP_NO_VMM=ON \
  -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON \
  -DGGML_VULKAN_RAY_TRACING=OFF \
  -DGGML_VULKAN_RENDER_DOC_CAPTURE=OFF \
  -DGGML_VULKAN_VALIDATION_LAYERS=OFF \
  -DGGML_VULKAN_DEBUG=OFF \
  -DCMAKE_HIP_ARCHITECTURES="gfx1151" \
  -DGPU_TARGETS="gfx1151" \
  -DLLAMA_BUILD_SERVER=ON \
  -DLLAMA_BUILD_UI=OFF \
  -DLLAMA_USE_PREBUILT_UI=OFF \
  -DLLAMA_BUILD_TESTS=OFF \
  -DGGML_BUILD_TESTS=OFF \
  -DCMAKE_C_FLAGS="-march=x86-64-v4 -O3" \
  -DCMAKE_CXX_FLAGS="-march=x86-64-v4 -O3" \
  -DCMAKE_HIP_FLAGS="-mllvm --amdgpu-unroll-threshold-local=600"

cmake --build build --config Release -j$(nproc)
Launch via ROCm (7.2)
env HSA_OVERRIDE_GFX_VERSION=11.5.1 GGML_HIP_ENABLE_UNIFIED_MEMORY=1 \
./llama-server --host 0.0.0.0 --port 11434 \
-m /home/user/models/Ling-3.0-flash-MXFP4_MOE.gguf \
-ngl 999 -fa on -c 32000 --metrics --jinja --numa numactl \
--spec-type draft-mtp \
-b 512 -ub 256 --cache-reuse 256 -n -1 -np 1 --timeout 999999 \
--reasoning-budget 4096 --temp 0.6 --top-p 0.95 --top-k 20
0.00.212.943 I cmn  common_param: common_params_print_info: verbosity = 3 (adjust with the `-lv N` CLI arg)
0.00.213.182 W srv  llama_server: -----------------
0.00.213.183 W srv  llama_server: CORS is set to allow all origins ('*') and no API key is set
0.00.213.183 W srv  llama_server: this can be a security risk (cross-origin attacks)
0.00.213.183 W srv  llama_server: more info: https://github.com/ggml-org/llama.cpp/pull/25655
0.00.213.184 W srv  llama_server: -----------------
0.00.214.638 I srv    load_model: loading model '/home/user/models/Ling-3.0-flash-MXFP4_MOE.gguf'
0.00.657.588 W load: special_eos_id is not in special_eog_ids - the tokenizer config may be incorrect

The Laguna-S-2.1 / Qwen3.5-122B-A10B take about 3 minutes to start.
The Ling-3.0-flash still wouldn't start after 30 minutes.

UPD: Was able to launch it by adding the --load-mode dio flag

Launch via ROCm (7.2)
$ env HSA_OVERRIDE_GFX_VERSION=11.5.1 \
./llama-server --host 0.0.0.0 --port 11434 \
-m /home/user/models/Ling-3.0-flash-MXFP4_MOE.gguf \
-ngl 999 -fa on -c 32000 --metrics --jinja --numa numactl \
--spec-type draft-mtp --load-mode dio --reasoning-preserve \
-b 512 -ub 256 --cache-reuse 256 -n -1 -np 1 --timeout 999999 \
--reasoning-budget 4096 --temp 0.6 --top-p 0.95 --top-k 20
0.00.152.475 I cmn  common_param: common_params_print_info: verbosity = 3 (adjust with the `-lv N` CLI arg)
0.00.152.688 W srv  llama_server: -----------------
0.00.152.689 W srv  llama_server: CORS is set to allow all origins ('*') and no API key is set
0.00.152.689 W srv  llama_server: this can be a security risk (cross-origin attacks)
0.00.152.690 W srv  llama_server: more info: https://github.com/ggml-org/llama.cpp/pull/25655
0.00.152.690 W srv  llama_server: -----------------
0.00.153.933 I srv    load_model: loading model '/home/user/models/Ling-3.0-flash-MXFP4_MOE.gguf'
0.00.565.004 W load: special_eos_id is not in special_eog_ids - the tokenizer config may be incorrect
0.26.761.628 I common_speculative_init_result: creating MTP draft context against the target model '/home/user/models/Ling-3.0-flash-MXFP4_MOE.gguf'
0.26.835.527 I srv    load_model: initializing, n_slots = 1, n_ctx_slot = 32000, kv_unified = 'false'
0.26.835.620 W llama_sampler_backend_support: device 'ROCm0' does not have support for op TOP_K needed for sampler 'top-k'
0.26.854.979 I srv  llama_server: model loaded
0.26.854.987 I srv  llama_server: listening on http://0.0.0.0:11434

UPD2: I don't know why TOP_K hardware acceleration isn't supported, but I moved it to the CPU using the --no-spec-draft-backend-sampling flag and everything finally worked.

Launch via ROCm (7.2)
env HSA_OVERRIDE_GFX_VERSION=11.5.1 \
./llama-server --host 0.0.0.0 --port 11434 \
-m /home/user/models/Ling-3.0-flash-MXFP4_MOE.gguf \
-ngl 999 -fa on -c 32000 --metrics --jinja --numa numactl \
--spec-type draft-mtp --load-mode dio --reasoning-preserve --no-spec-draft-backend-sampling \
-b 512 -ub 256 --cache-reuse 256 -n -1 -np 1 --timeout 999999 \
--reasoning-budget 4096 --temp 0.6 --top-p 0.95 --top-k 20
0.00.167.568 I cmn  common_param: common_params_print_info: verbosity = 3 (adjust with the `-lv N` CLI arg)
0.00.167.786 W srv  llama_server: -----------------
0.00.167.787 W srv  llama_server: CORS is set to allow all origins ('*') and no API key is set
0.00.167.787 W srv  llama_server: this can be a security risk (cross-origin attacks)
0.00.167.788 W srv  llama_server: more info: https://github.com/ggml-org/llama.cpp/pull/25655
0.00.167.788 W srv  llama_server: -----------------
0.00.169.184 I srv    load_model: loading model '/home/user/models/Ling-3.0-flash-MXFP4_MOE.gguf'
0.00.602.178 W load: special_eos_id is not in special_eog_ids - the tokenizer config may be incorrect
0.26.751.994 I common_speculative_init_result: creating MTP draft context against the target model '/home/user/models/Ling-3.0-flash-MXFP4_MOE.gguf'
0.26.884.039 I srv    load_model: initializing, n_slots = 1, n_ctx_slot = 32000, kv_unified = 'false'
0.26.895.248 I srv  llama_server: model loaded
0.26.895.255 I srv  llama_server: listening on http://0.0.0.0:11434
1.17.260.287 I slot get_availabl: id  0 | task -1 | selected slot by LRU, t_last = -1
1.17.260.440 I slot launch_slot_: id  0 | task 0 | processing task, is_child = 0
1.20.881.339 I slot print_timing: id  0 | task 0 | n_decoded =    101, tg =  31.81 t/s, tg_3s =  31.81 t/s
1.23.889.739 I slot print_timing: id  0 | task 0 | n_decoded =    201, tg =  32.51 t/s, tg_3s =  33.24 t/s
1.26.978.760 I slot print_timing: id  0 | task 0 | n_decoded =    316, tg =  34.08 t/s, tg_3s =  37.23 t/s
1.29.984.944 I slot print_timing: id  0 | task 0 | n_decoded =    418, tg =  34.04 t/s, tg_3s =  33.93 t/s
1.33.025.007 I slot print_timing: id  0 | task 0 | n_decoded =    530, tg =  34.60 t/s, tg_3s =  36.84 t/s
1.36.093.494 I slot print_timing: id  0 | task 0 | n_decoded =    636, tg =  34.59 t/s, tg_3s =  34.54 t/s
1.39.120.145 I slot print_timing: id  0 | task 0 | n_decoded =    749, tg =  34.98 t/s, tg_3s =  37.33 t/s
1.42.174.070 I slot print_timing: id  0 | task 0 | n_decoded =    865, tg =  35.35 t/s, tg_3s =  37.98 t/s
1.45.260.304 I slot print_timing: id  0 | task 0 | n_decoded =    995, tg =  36.11 t/s, tg_3s =  42.12 t/s
1.48.290.966 I slot print_timing: id  0 | task 0 | n_decoded =   1099, tg =  35.93 t/s, tg_3s =  34.32 t/s
1.51.327.491 I slot print_timing: id  0 | task 0 | n_decoded =   1211, tg =  36.02 t/s, tg_3s =  36.88 t/s
1.54.340.189 I slot print_timing: id  0 | task 0 | n_decoded =   1317, tg =  35.95 t/s, tg_3s =  35.18 t/s
1.57.383.377 I slot print_timing: id  0 | task 0 | n_decoded =   1432, tg =  36.09 t/s, tg_3s =  37.79 t/s
2.00.480.885 I slot print_timing: id  0 | task 0 | n_decoded =   1540, tg =  36.00 t/s, tg_3s =  34.87 t/s
2.03.496.305 I slot print_timing: id  0 | task 0 | prompt eval time =     445.69 ms /    60 tokens (    7.43 ms per token,   134.62 tokens per second)
2.03.496.312 I slot print_timing: id  0 | task 0 |        eval time =   45790.11 ms /  1651 tokens (   27.73 ms per token,    36.06 tokens per second)
2.03.496.313 I slot print_timing: id  0 | task 0 |       total time =   46235.80 ms /  1711 tokens
2.03.496.330 I slot print_timing: id  0 | task 0 |    graphs reused =        417
2.03.496.335 I slot print_timing: id  0 | task 0 | draft acceptance = 0.55464 (  807 accepted /  1455 generated), mean len =  2.66
2.03.496.444 I slot      release: id  0 | task 0 | stop processing: n_tokens = 1710, truncated = 0

UPD3: There is also a problem with the model itself, it contains assembly errors.

0.00.602.178 W load: special_eos_id is not in special_eog_ids - the tokenizer config may be incorrect

Caution

This can lead to a loop, and increased consumption of the context window, but the --jinja flag should partially protect against this.

UPD4: I checked the Ling-3.0-flash-MXFP4_MOE.gguf model in the agent coding, and it is completely broken; the agent cannot read or modify the file (in an empty context).

Read file
read ~/player/src/audio/mp3-player.ts</arg_value><arg_key>offset</arg_key>                                
 <arg_value>260</arg_value><arg_key>limit</arg_key>                                                                             
 <arg_value>10                                                                                                                  
                                                                                                                                
 ENOENT: no such file or directory, access                                                                                      
 '/home/user/player/src/player/audio/mp3-player.ts</arg_value><arg_key>offset</arg_key>                         
 <arg_value>260</arg_value><arg_key>limit</arg_key>                                                                             
 <arg_value>10' 

@wbafy

wbafy commented Aug 6, 2026

Copy link
Copy Markdown

Tool calling with multiple arguments is broken on bailingmoe3 (Ling-3.0-flash). Single-argument calls parse correctly; 2+ argument calls have the first argument's value swallow the rest of the call as a literal string.

Reproduced identically across four independent combinations:

  • AtomicChat/Ling-3.0-flash-GGUF (AD-Q4_K_L, AD-Q5_K_M) on this branch (bailingmoe3-support)
  • bloomer010/Ling-3.0-flash-GGUF (Q4_K_M) on both this branch and a separate atomic-llama-cpp-turboquant fork

Example request/response:
tools: [{"name":"search","parameters":{"file":"string","pattern":"string","start_line":"integer"}}]
Result:
"arguments": "{"file":"app.log</arg_value><arg_key>pattern</arg_key>\n<arg_value>error</arg_value><arg_key>start_line</arg_key>\n<arg_value>100"}"

-lv 5 differential-analysis dump (verbatim):
tool_mode: TAG_WITH_TAGGED
per_call_start: '<tool_call>'
per_call_end: '</tool_call>'
arg_name_prefix: '<arg_key>'
arg_name_suffix: '</arg_key>\n'
arg_value_prefix: '<arg_value>'
arg_value_suffix: '</arg_value>\n' <- resolved from the LAST argument in the sample render, not from the separator between arguments. The model's actual output has no \n between </arg_value> and the next <arg_key> — only before the final </tool_call>. The Until(arg_value_suffix) rule built from this therefore only stops at the last </arg_value> in the whole call, not at the boundary between arguments.

Separately, but related: the stock embedded chat template does not stop generation at </tool_call> — the model emits a stray <|DSML|end|DSML|> token afterward, which the server doesn't recognize as end-of-generation, so it keeps emitting duplicate tool_calls until max_tokens is hit. special_eos_id is not in special_eog_ids warning appears at load. Patching the chat template to add a literal \n before </tool_call> (via --chat-template-file) fixes the runaway generation (finish_reason becomes "tool_calls" as expected) but does NOT fix the argument-corruption issue above.

Tried and ruled out via manual chat-template edits (multiple permutations of \n placement around <arg_key>/<arg_value>, including matching models/templates/GLM-4.6.jinja's exact layout): none produce correct multi-argument parsing; some regress to empty {} arguments instead.

Possibly the same root cause as #24807 (Qwen3.6-35B-A3B, same TAG_WITH_TAGGED tag-based argument format with tags instead of <arg_key>/<arg_value>, same class of Until()-over-capture bug).

Happy to provide full -lv 5 logs, curl repro commands, or test against a patch.

@aetherbird

Copy link
Copy Markdown
Contributor Author

The released Ling 3.0 configuration contains trained per-layer SwiGLU limits that were previously omitted. Commit c51308d adds the routed-expert and shared-expert clamp arrays during conversion and loads them as optional GGUF metadata. The existing graph implementation applies the clamps.

@aetherbird
aetherbird requested a review from a team as a code owner August 7, 2026 00:16
@aetherbird

Copy link
Copy Markdown
Contributor Author

Commit 0266ebc fixes the Bailing V3 argument delimiter inference and adds a regression test for multi-argument tool calls. The parser now uses </arg_value> as the value terminator and tolerates whitespace before </tool_call>. All 522 auto-parser assertions pass.

@p11o

p11o commented Aug 7, 2026

Copy link
Copy Markdown

Retried on my amd vulkan setup. For some reason it is trying to use ROCm?

0.33.287.462 W llama_context: n_ctx_seq (262144) > n_ctx_train (131072) -- possible training context overflow
0.33.288.586 W llama_kv_cache: the V embeddings have different sizes across layers and FA is not enabled - padding V cache to 512
0.33.703.640 E ggml_backend_cuda_buffer_type_alloc_buffer: allocating 34851.94 MiB on device 0: cudaMalloc failed: out of memory
0.33.703.647 E ggml_gallocr_reserve_n_impl: failed to allocate ROCm0 buffer of size 36544905088
0.33.703.648 E graph_reserve: failed to allocate compute buffers
0.33.775.743 E llama_init_from_model: failed to initialize the context: failed to allocate compute pp buffers

@aetherbird

aetherbird commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor Author

Retried on my amd vulkan setup. For some reason it is trying to use ROCm?

0.33.287.462 W llama_context: n_ctx_seq (262144) > n_ctx_train (131072) -- possible training context overflow
0.33.288.586 W llama_kv_cache: the V embeddings have different sizes across layers and FA is not enabled - padding V cache to 512
0.33.703.640 E ggml_backend_cuda_buffer_type_alloc_buffer: allocating 34851.94 MiB on device 0: cudaMalloc failed: out of memory
0.33.703.647 E ggml_gallocr_reserve_n_impl: failed to allocate ROCm0 buffer of size 36544905088
0.33.703.648 E graph_reserve: failed to allocate compute buffers
0.33.775.743 E llama_init_from_model: failed to initialize the context: failed to allocate compute pp buffers

Could you provide the complete CMake configuration, launch command, and --list-devices output?

Also, can you please retry with a fresh Vulkan-only build directory:

cmake -S . -B build-vulkan \
  -DGGML_VULKAN=ON \
  -DGGML_HIP=OFF
cmake --build build-vulkan --config Release -j

Then explicitly use -dev Vulkan0 -fa on, initially with -c 65536 -b 512 -ub 256. If that works, increase the context afterward. If ROCm0 is still selected with -dev Vulkan0, it may indicate a device-routing problem.

@RuthgerD

RuthgerD commented Aug 7, 2026

Copy link
Copy Markdown

anecdotal usage report: after a few turns and some context (~20k) the inference just hangs even though the GPU is still being utilized. Not sure how to provide useful information for this.

@gopinath87607

This comment has been minimized.

@gopinath87607

Copy link
Copy Markdown

i made some fixs and also after 160k token i am getting "/n" this word in the claude code and claude code doest recognizing it
https://huggingface.co/gopi87/Lingflashfixclaudecode

alpaca-matrix added a commit to alpaca-matrix/llama.cpp that referenced this pull request Aug 9, 2026
…pport

Weights are out under MIT, so the "still not released" verdict this file
carried is retired and the section moves to the top of the priority order.
Target slot is deep, not fast: 5.1B active is the same count gpt-oss-120b
carries.

From config.json - 124B/5.1B, 42 layers as 35 Kimi Delta Attention plus 7
gated MLA in a 5:1 stack, 512 routed experts top-8 plus 1 shared,
moe_intermediate_size 768, native 262144 with rope_scaling null, and
num_nextn_predict_layers 1 bundled in every GGUF.

IQ3_XXS (51.2 GB, 47.7 GiB, 3.30 bpw) is the tier that fits, and it is smaller
than deep is today at 59.0 GiB. Q3_K_M fits with about 10 GiB of margin,
MXFP4_MOE and everything from Q4_K_S up do not.

Predicted 16-20 t/s base by two methods that agree: decomposing active params
gives 1.89B routed experts, 2.79B non-expert of which KDA projections alone are
1.93B, and 0.40B token_embd, summing to 5.08B against the published 5.1B; at
IQ3_XXS with non-expert protected that is 3.0-3.7 GB/token, and 16-20 t/s at
the 60.5 GB/s hybrid correction. The tg_ceiling formula at the top of this file
independently gives 15.9. That is a wash with deep's measured 19.6.

Three reasons to track it. Only 7 of 42 layers hold a KV cache and those 7 are
MLA, so the full 262144 context costs about 1.1 GB - the MiniMax-M2.1 depth
collapse is structurally impossible here. The pin-tensor-types lever applies
harder than it did to Laguna, since publishers keep the 1.93B of KDA
projections at high precision and retargeting them to IQ4_XS predicts +38%.
And GPQA-D 85.0 with SWE-bench Pro 56.6 is the harder discriminator the deep
bar demands, since another 10/10 on reason-eval-hard cannot rank a replacement.

Four blockers. bailingmoe3 is in no shipping llama.cpp - not this tree, and a
code search of ggml-org/llama.cpp returns zero hits; support is PR ggml-org#26608, open
as of 2026-08-09, 850 additions over 17 files awaiting 2 of 3 code-owner
approvals. AtomicChat's model card claims it is already upstream, which is
false. Multi-argument tool calls are broken in that PR, the first argument
swallowing the rest as a literal string, which disqualifies it here on its own.
Vulkan freezes are reported and MTP cannot be disabled without crashing, on a
box that has already paid two hard power cycles - though the hard op is not
missing, this tree already ships gated_delta_net_f32_d128_kda. And 3.30 bpw
across 512 experts of 5.9M params each is the hardest quant case there is.

One open question the config cannot settle: mtp_loss_scaling_factor is 0. If
the head carried no loss term the speculation upside evaporates, so acceptance
is the first thing to measure - the record is split between KAT's grafted
donor head at 0.76 and GLM-4.7-Flash's declared-but-missing nextn tensors.

Nothing measured on this box. Do not download until the PR merges and the tool
calling bug closes.

Assisted-by: Claude Opus 5
@CISC

CISC commented Aug 14, 2026

Copy link
Copy Markdown
Member

specs: rtx 3060 12gb, 64gb 3200mhz ram PS: it loads properly on ik_llama.cpp, not a hardware issue.

And did you convert it, or download it from somewhere?

@lmganon16

Copy link
Copy Markdown

specs: rtx 3060 12gb, 64gb 3200mhz ram PS: it loads properly on ik_llama.cpp, not a hardware issue.

And did you convert it, or download it from somewhere?

https://huggingface.co/AtomicChat/Ling-3.0-flash-GGUF/blob/main/IQ4_XS_STOCK/Ling-3.0-flash-IQ4_XS_STOCK-00001-of-00002.gguf
downloaded it from here

@lmganon16

lmganon16 commented Aug 14, 2026 •

Copy link
Copy Markdown

specs: rtx 3060 12gb, 64gb 3200mhz ram PS: it loads properly on ik_llama.cpp, not a hardware issue.

And did you convert it, or download it from somewhere?

https://huggingface.co/AtomicChat/Ling-3.0-flash-GGUF/blob/main/IQ4_XS_STOCK/Ling-3.0-flash-IQ4_XS_STOCK-00001-of-00002.gguf downloaded it from here

hmm it seems to have updated, i just checked hashes and it mismatches from the latest one, redownloading

@CISC

CISC commented Aug 14, 2026

Copy link
Copy Markdown
Member

hmm it seems to have updated, i just checked hashes and it mismatches from the latest one, redownloading

TBH, it clearly says this is meant for some fork, not official llama.cpp so I wouldn't bother.

It might just be differently named tensors, if so supporting alternate names can be acceptable (follow-up though, not in this PR), but chances are there would be other issues.

@aetherbird

aetherbird commented Aug 15, 2026 •

Copy link
Copy Markdown
Contributor Author

For anyone looking to test this arch, reference GGUFs built with this branch's converter are available here:

Conversion notes and per-quant validation are on the model cards.

@snyderbunch

Copy link
Copy Markdown

Test report: Strix Halo (gfx1151 / Radeon 8060S, 128 GB unified) — Vulkan/RADV on Linux

Following the earlier freeze/hang reports on this hardware, I ran a structured stability test of this branch (db4480bc8) on a Framework Desktop (Ryzen AI MAX+ 395, 128 GB, Fedora 44, kernel 7.1.8, Mesa/RADV 26.1.6, Vulkan API 1.4.354). Models: @bloomer010's reference GGUFs reconverted 2026-08-15 with this branch's converter (kda.safe_gate=true / gate_lower_bound=-5.0 present in both headers) — Ling-3.0-tiny Q8_0 and Ling-3.0-flash Q4_K_M. All runs: llama-server -ngl 999 -fa on --jinja -c 32768, temperature 0.

TL;DR: the base arch looks fully stable and fast on RADV. The "inference hangs after a few turns" issue reproduces deterministically here and is specific to the MTP speculative path — the main thread blocks forever in ggml_vk_wait_for_fence under llama_get_embeddings_nextn. With MTP off I could not produce any failure. MTP=4 is also currently a net slowdown on this box, so disabling it costs nothing.

MTP off — all clean

  • tiny Q8_0: tg 103–116 t/s; 17,803-token prompt prefills at 2,033 t/s, needle retrieval correct; 4-turn cache-reuse conversation clean. (This GGUF carries no nextn tensors, so no MTP testing on tiny.)
  • flash Q4_K_M: tg 41.6–43.1 t/s short-context (math/prose/code all correct); 17.8k prompt: pp 371.6 t/s, tg 38.9 t/s at depth; multi-turn cache reuse clean.
  • No hang, no crash, no GGML_ASSERT (the earlier report of a crash with MTP disabled did not reproduce at db4480bc8), zero amdgpu kernel events, and no hard freeze across ~1h of load/inference cycles. FWIW this does not match the "tg far less than expected" report either — 41–43 t/s for a 124B/A5.1B at Q4_K_M is in line with other MoE of similar active size on this box.

MTP on (--spec-type draft-mtp --spec-draft-n-max 4), flash — three problems

  1. Net slowdown: math 38.9 t/s (draft acceptance 55%), prose 31.1 t/s (32%), code ~36 t/s (47%) — all below the 41.6–43.1 t/s MTP-off baseline.
  2. Temp-0 output divergence vs MTP-off: identical prompts produce different (and slightly ill-formed) text, e.g. prose opener "like a solitary sentinel" → "like a iron sentinel"; generated lengths shift 391→435 and 851→1195 tokens. Greedy spec decode should be output-invariant.
  3. Deterministic soft hang, reproduced 2/2 from fresh servers: the request sequence math → prose → code (temp 0, max_tokens 800/1200/1500) hangs mid-generation on the code request (~570–650 tokens in) every time. GPU drops to ~1% busy, /health stays OK, the slot cancels cleanly on client disconnect, nothing in the kernel log. The same code prompt sent standalone — or re-sent right after cancelling the hung one — completes fine, so it's server-state-dependent, which matches the earlier "after a few turns and some context" description. Repro prompts below.

Main-thread stack at hang (eu-stack, hang #2):

#0  ioctl
#1  drmIoctl
#2  drmSyncobjWait
#3  vk_drm_syncobj_wait_many
#4  __vk_sync_wait
#5  vk_common_WaitForFences
#6  ggml_vk_wait_for_fence(ggml_backend_vk_context*)
#7  ggml_vk_synchronize(ggml_backend_vk_context*)
#8  ggml_backend_vk_synchronize(ggml_backend*)
#9  ggml_backend_sched_synchronize
#10 llama_context::synchronize()
#11 llama_get_embeddings_nextn(llama_context*)
#12 common_speculative_impl_draft_mtp::process(llama_batch const&)
#13 common_speculative_process(common_speculative*, llama_batch const&)
#14 server_context_impl::decode(int&, int, llama_batch&)
#15 server_context_impl::update_slots()
#16 server_queue::start_loop(long)

All other threads are parked in normal waits — it's a fence that never signals on the MTP draft-context path, not a GPU fault (the GPU is idle and the kernel reports nothing).

Repro sequence (fresh server, send in order, temp 0):

  1. What is 17 * 23? Answer with just the number. (max_tokens 800)
  2. Write a vivid two-paragraph description of a lighthouse in a storm. (max_tokens 1200)
  3. Write a Python function that parses an ISO-8601 date string and returns the day of week. Include a docstring. (max_tokens 1500) ← hangs ~570–650 tokens into generation

I did not see the hard system freeze reported earlier on this stack (Fedora 44 / kernel 7.1.8 / Mesa 26.1.6) — possibly fixed by newer Mesa/kernel, or specific to the ROCm path/other setups.

Happy to run patched builds or extra diagnostics — this box reproduces the hang reliably.

@UsainBoat

Copy link
Copy Markdown

Test report: CUDA, GTX 1080ti on debian

Things seem to work well with the tiny model at Q8_0 quant. The only quirk I have caught so far is that in one chat it did not close the thinking tab when it gave the final response. I am not sure if this is a chat template thing, or just a hiccup.

@aetherbird
aetherbird force-pushed the bailingmoe3-support branch from 117745a to 3ba9516 Compare August 16, 2026 18:49
@robotnurse

Copy link
Copy Markdown

Metal (Apple Silicon) validation — runs clean, no fence-hang, but net-slower for this MoE

Tried this PR (commit db4480bc8) on an M3 Ultra (256 GB), macOS 26.5, GGML_METAL=ON, since the reported hangs looked RADV/Vulkan-specific and I didn't see any Metal results in the thread.

Setup — bloomer010/Ling-3.0-flash-GGUF (MXFP4_MOE, bundled MTP):

llama-server -m Ling-3.0-flash-MXFP4_MOE.gguf -ngl 999 -fa on --jinja -c 32768 \
  --spec-type draft-mtp --spec-draft-n-max 4

Results:

  • The MTP draft context loads cleanly (creating MTP draft context against the target model → model loaded), output is coherent, and the ggml_vk_wait_for_fence soft-hang does not reproduce on Metal — ran the math → prose → code sequence (~600 tokens into the code turn) with no stall.
  • Draft acceptance ≈ 48.7% (205/421 accepted, mean accepted len 2.93) at --spec-draft-n-max 4.
  • Decode is net-slower than AR on this hardware/model, however: ≈ 51.9 tok/s with --spec-type draft-mtp vs ≈ 56.5 tok/s with --spec-type none (same prompt, greedy). Ling-3.0-flash is a 124B / 5.1B-active MoE, so decode is already bandwidth-efficient and the draft+verify overhead isn't recovered at ~49% acceptance — consistent with what's generally seen for small-active MoEs (vs dense models) on Apple Silicon.

Net: on Metal the draft-mtp path looks correct and stable; it just doesn't yield a speedup for this particular model. Happy to test other quants or draft depths if that's useful.

@aetherbird

Copy link
Copy Markdown
Contributor Author

Lint fix pushed (04f9d09) and approvals were reset by the new commit. Ready for re-review.

@CISC
CISC merged commit 3733366 into ggml-org:master Aug 17, 2026
27 of 29 checks passed
brittlewis12 pushed a commit to brittlewis12/llama.cpp that referenced this pull request Aug 17, 2026
* 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 <[email protected]>
Co-authored-by: Dyluhn <[email protected]>
crusaderky pushed a commit to crusaderky/llama.cpp that referenced this pull request Aug 19, 2026
* 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 <[email protected]>
Co-authored-by: Dyluhn <[email protected]>
thecodacus pushed a commit to thecodacus/llama.cpp that referenced this pull request Sep 7, 2026
* 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 <[email protected]>
Co-authored-by: Dyluhn <[email protected]>
zbrad pushed a commit to zbrad/llama.cpp that referenced this pull request Sep 10, 2026
* 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 <[email protected]>
Co-authored-by: Dyluhn <[email protected]>
PamelaSprin47685ghall pushed a commit to PamelaSprin47685ghall/atomic-llama-cpp-turboquant that referenced this pull request Oct 17, 2026
Upstream llama.cpp (ggml-org#26608) names the full-rank KDA gates ssm_f_a/ssm_g_a
and keeps the MTP block as the last layer. Accept both names, skip the MTP
block, and ignore nextn_predict_layers in older files that set the key but
have no MTP tensors (otherwise the last trunk layer is lost).

Assisted-by: Claude
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

conversion model Model specific testing Everything test related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Model request: Ling-3.0-flash