Repository navigation
[Engine] Ling 3.0 Flash and Tiny (bailingmoe3) - #201
Open
yudhanjaya wants to merge 2 commits into
Open
yudhanjaya wants to merge 2 commits into
yudhanjaya wants to merge 2 commits into
Conversation
A new strata-poly engine, src/poly/ling3.cpp, from llama.cpp's bailingmoe3 graph. Some layers' attention is MLA over cached latents (512 latent + 64 rotary values a row, a sigmoid gate on each head's output; Tiny's query is low rank) on the existing attend()/attend_batch() kernels; the others are KDA with full-rank gates, on GLM 5.3 Flash's kernels. Dense first layers, then routed experts picked from the best 4 of 8 groups (sigmoid gates + bias, normalised, x2.5) and one shared expert. Flash's draft block (blk.42.nextn) runs as the engine's MTP block. - setup: family "ling3", Ling 3.0 Flash from bloomer010's GGUFs (Q4_K_M, Q3_K_M, UD-Q2_K_XL), pinned and checksummed; its configs pass --no-draft (no faster here, slower deep in a long context). Tiny runs on the engine but is not offered: its experts fit in most cards' VRAM. - tools/strata_tokenizer.py: llama.cpp's bailingmoe pre-tokenizer pattern; serve/models.py and tools/strata_inspect.py know the architecture; metal/CMakeLists.txt builds the engine (not compiled on a Mac). - docs/models/ling3.md, docs/BACKENDS.md (what runs, the parity table and how it was checked), README. - tools/test_setup_ling3.py; tools/test_setup_menu.py's family order. Checked against llama.cpp on one Linux PC (RTX 4080 SUPER + RTX 3080), five chat prompts of 35 to 8,036 tokens, 64 tokens each: Flash Q4_K_M within 0.28 (8 of its 12 departures at a near tie, the other four explained in BACKENDS.md), Tiny Q4_K_M within 0.19 (all six at a near tie). A prompt read in one call and in two gives the same tokens with every expert on the CPU. CUDA only; HIP and Metal not built.
main split the repository into engine/ (the C++/CUDA/HIP/SYCL/Metal engines) and terminal/ (setup.py, the server, the tools), and moved on 6,780 commits since this branch was cut. Everything Ling touches moved with it: - src/poly/ling3.cpp and ling3.hpp -> engine/src/poly/; tools/test_setup_ling3.py -> terminal/tools/. - The root CMakeLists.txt is gone: its poly targets now live in engine/cmake/strata_poly.cmake, and ling3.cpp goes into all five that link engine.cpp (poly_gdn_mma_state_test, strata-poly, poly_draft_race_test, and the two that did not exist when this branch was cut: poly_layer_split_picks_test and poly_logits_dump). - setup.py -> terminal/setup.py, serve/models.py -> terminal/serve/models.py, tools/strata_inspect.py and tools/strata_tokenizer.py -> terminal/tools/. The Ling and Inkling 2 entries sit side by side in each registry. - docs/BACKENDS.md says ten architectures now that Ling is the tenth, and setup.py's two references to docs/LING.md point at docs/models/ling3.md. strata-tokenizer keeps both pre-tokenizers: bailingmoe next to laguna and inkling2, with inkling2 still in IGNORE_MERGES. Checked: ling3.cpp compiles standalone against the merged headers (CUDA 13.0, sm_86, no warnings); tools/test_setup_ling3.py's 5 tests and tools/test_setup_menu.py's 26 pass, and the setup suite's 4 errors (test_setup_amd, test_setup_rammode, test_setup_prompts, test_setup_dl_fix) are the same 4 on a clean main checkout, from jinja2 not being installed here.
Contributor
Author
|
@VecSzn , I updated https://github.com/yudhanjaya/PolyStrata/tree/ling3 to account for the new changes to PS. ling3.cpp compiles standalone against merged headers (CUDA 13.0, sm_86, no warnings); test_setup_ling3.py 5/5; test_setup_menu.py 26/26. ling3.cpp now links to poly_layer_split_picks_test and poly_logits_dump as well.
|
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.
Title
Ling 3.0 flash and tiny (bailingmoe3) support; first asked for in #1
Summary
This is ling3.cpp, a strata-poly engine for llama.cpp's
bailingmoe3architecture which covers both Ling 3.0 Flash (124B, 5.1B active) and Ling 3.0 Tiny.It works! Built from llama.cpp's graph (
src/models/bailingmoe3.cpp) and tested on my PC (Linux, RTX 4080 SUPER 16 GB + RTX 3080 10 GB, Ryzen 7 5800X3D, 62 GB of RAM), Flash Q4_K_M at a 128K context on a layer split.Comapred vs llama.cpp (PR #32517 build,
--fit, 4,096-token batches) on the same file:--prompt-batch 512 --no-draft)On the 4080 SUPER alone on the polystrata benchmark (
polystrata.py benchmark --prompt-tokens 24000, 32K): 835-1,048 tok/s reading the prompt, 6.6-13.0 writing after it.Numbers on that first "writes new prompt" row are the lowest I saw and the highest I saw over several runs. Lowest was when I was while watching a GamersNexus video on Chrome with like 30 tabs open, so that's most of the variation right there; the cpu had other work to do.
includes a setup family for Flash.
Changes
src/poly/ling3.cpp,ling3.hpp: the engine.the query's non-rotary part goes through
attn_k_band the output's latent throughattn_v_b, so the existingattend()/attend_batch()run it as one 576-wide key head. A per-head sigmoid output gate (attn_gate).Tiny's low-rank query (
attn_q_a,attn_q_a_norm,attn_q_b).ssm_f_a+ssm_dt.bias) and output gate(
ssm_g_a).exp_probs_b, the best 4 of 8 groups by their top-two sums, 8 experts,normalised and x2.5; one shared expert; dense lead layers.
blk.42.nextnruns as the engine's MTP block (nextn.shared_head_normread fromlayer_output_norm).src/poly/engine.cpp,CMakeLists.txt,metal/CMakeLists.txt: the engine named and built.tools/strata_tokenizer.py: llama.cpp'sbailingmoepre-tokenizer pattern (the GGUFs saybailingmoe2).serve/models.py,tools/strata_inspect.py: the architecture.setup.py: familyling3, Ling 3.0 Flash from bloomer010's GGUFs (Q4_K_M, Q3_K_M, UD-Q2_K_XL), pinned tocommit 3797301d and checked against their SHA-256; its configs pass
--no-draft. A smallno_draftfamily key addsthat flag in
poly_setup.docs/models/ling3.md,docs/BACKENDS.md(what runs, the parity table, how it was checked),README.md(English only; I haven't touched the translations).
tools/test_setup_ling3.py, andtools/test_setup_menu.py's family order.Extra Notes
Test proof (Linux, CUDA 13.0, sm_86 + sm_89, branch tip on main 3e16421):
Builds:
strata-poly,poly_draft_race_test,poly_gdn_mma_state_test; no compiler warnings fromling3.cpp.Parity against llama.cpp, five chat prompts of 35 to 8,036 tokens, 64 tokens each, top-5 probabilities:
Tiny's six departures and 8 of Flash's 12 are at a near tie. The other four are Flash's: the 4,034-token prompt at
its 34th token in all three rows (llama.cpp 0.57 / 0.43, this engine 0.60-0.69 for the second), and the 8,036-token
prompt at its 4th without the draft block. llama.cpp itself, with 512-token batches instead of 4,096, leaves its own
tokens at that same 4th token. Details in BACKENDS.md.
A prompt read in one call and in two (4,096 tokens from the conversation cache, then 10,563) gives the same 64
tokens with every expert on the CPU.
tools/test_setup_*.py: all 52 pass, plus the newtest_setup_ling3.py.Not done: HIP and Metal builds (I don't have the hardware); Windows; the Q3_K_M and UD-Q2_K_XL files (only Q4_K_M was
run, but the others should run without issue).
Two things I noticed that might be worth a future issue - or at least some more fixes:
--stage-read-mib) took VRAM past--vram-reserve-mib: 0.2 GB free with a reserve of 1,100 MiB, 0.8 GB with 1,900. That card drives my display, so this was somehat annoying.--stage-mibto anything but its default also turns off that growth, which cut Ling's long-prompt readingfrom 704 to 110 tok/s on a layer split . . . which was an earlier problem I was having.