Repository navigation
🔨 feat(model): add BailingMoeV3 (Ling 3.0) support - #63
Merged
Merged
Conversation
Ling-3.0-flash is a 124B total / 5.1B active hybrid-linear MoE: 35 KDA (linear attention) layers interleaved 5:1 with 7 gated MLA layers, on top of a bailing MoE with 512 routed experts (group-limited sigmoid routing, 8 groups / 4 used) and 1 shared expert. Dense FFN on the first 2 blocks. The layout is shared with KIMI_LINEAR, so the KDA path reuses the existing gated delta net operator. Differences that required a separate arch: - full-rank KDA forget/output gate projections (config: no_kda_lora), new ssm_f / ssm_g tensors instead of the low-rank a/b pairs - the KDA log-decay is clamped from below (config: kda_safe_gate, kda_lower_bound = -5.0) - MLA layers apply partial RoPE. HF rotates de-interleaved pairs, which is equivalent to the NORM rope type here, as the permutation cancels in q*k - MLA layers carry a head-wise sigmoid output gate applied to the attention output before the output projection The MTP block is dropped during conversion. The tokenizer is identical to Ling 2.0, so the existing bailingmoe2 pre-tokenizer is reused. Converts and runs: BF16 GGUF loads and generates coherent output on CPU. Numerical validation against the HF reference is still in progress.
The KDA kernel switches the whole gate activation when a lower bound is
configured, it does not clamp the softplus form (fla/ops/kda, both the
chunked and the recurrent kernel):
lower_bound * sigmoid(exp(A_log) * (g + dt_bias)) if lower_bound
-exp(A_log) * softplus(g + dt_bias) otherwise
Ling 3.0 sets kda_safe_gate with kda_lower_bound = -5.0, so it takes the
first branch. The conversion script now stores exp(A_log) rather than
-exp(A_log), and the bound is carried in a new kda.lower_bound key.
Measured against a layer-by-layer HF reference forward (32 tokens, bf16),
mean KL over the vocabulary drops from 2.98e-2 to 4.8e-4, and the cosine
similarity of the first block output rises from 0.9959 to 0.99999.
The arch declared its own LLM_KV_KDA_LOWER_BOUND but never registered a
name for it, so llama_model_load threw map::at before reading the file.
Kimi K3 already carries the same safe gate with kda.gate_lower_bound,
hparams.kda_gate_lower_bound and add_kda_gate_lower_bound, so drop the
duplicate key, hparam and writer helper and use the existing ones.
Both models compute the same decay, so sharing the key keeps a single
spelling for it in the GGUF:
g = gate_lower_bound * sigmoid(exp(A_log) * (g_raw + dt_bias))
test-llama-archs builds a tiny model per architecture from a generic set of hyperparameters. bailingmoe3 cannot be described that way: the layer types come from a per-layer head_kv array and the loader needs the MLA and KDA keys, so the generated dense fixture fails to load and takes test-generate-models and the recurrent-state-rollback fixture down with it. Kimi K3 is skipped for the same reason.
NighmareGit
added a commit
to NighmareGit/atomic-llama-cpp-turboquant
that referenced
this pull request
Aug 13, 2026
Brings E-1 (generation-salted RPC uid, BUG-002a fix) + stable-uid default ON (da02606 flip) into the fabric branch so the E3 re-run is un-confounded (the original E3 coherence-gate KILL ran on the default-uid path corrupted by BUG-013/002a - LEDGER AtomicBot-ai#61 vs AtomicBot-ai#63/AtomicBot-ai#65). Conflict resolution (ggml-backend.cpp, both hunks resolved to good-prototype): - ggml_sched_rpc_stable_uid: default ON (unset -> ON, =0 opt-out) - split_graph uid: E-1 salted uid = topo_hash ^ (uid_generation * golden_ratio) Fabric E3 wiring (3c56bb0: layer assignment, inner-sched, FABH hop, logits routing, --rpc-fabric) preserved intact via auto-merge.
NighmareGit
added a commit
to NighmareGit/atomic-llama-cpp-turboquant
that referenced
this pull request
Aug 13, 2026
The server-side s_copy probe (added in E-1 d0fff25) logged cached-graph I32 leaf tensors on every recompute (~30+ lines/token spam). Purpose served: the E-1 verification's server RPC_DEBUG command stream already discriminated M1 (stale binding) vs M2 (verify write-back); LEDGER AtomicBot-ai#63 recommends the revert. No behavior change on the compute path - removes only the fprintf block.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds support for
inclusionAI/Ling-3.0-flash(BailingMoeV3ForCausalLM,model_type: bailing_hybrid) as a newbailingmoe3architecture.Model
124B total / 5.1B active. 42 decoder blocks:
layer_group_size = 6)Implementation
The KDA + MLA layout is shared with
KIMI_LINEAR, so the linear path reuses the existing gated delta net operator. A separate arch was needed for four differences:f_a/f_b,g_a/g_bf_proj/g_proj(no_kda_lora)kda_safe_gate,kda_lower_bound = -5.0)rope_theta = 6e6On RoPE: the reference implementation rotates de-interleaved pairs (
view(d/2, 2).transpose()followed byrotate_half), which is equivalent to theNORMrope type on the original layout. The permutation stays inside the rope slice and cancels inq * k, so no weight reordering is needed in the converter.The tokenizer is byte-identical to Ling 2.0, so the existing
bailingmoe2pre-tokenizer applies unchanged.Status
model.safetensors.index.json)Test