Document Spark support and add reference differential

This commit is contained in:
Constantin authored and StillDeadcode committed 2026-11-03 19:08:58 +01:00
1 parent 1483a1ae17
commit 125854df79
3 files changed
+229

No files matched your search

+36
View File
@@ -20,6 +20,7 @@ plugin claims.
| `arch/glm5next` | `glm5next` | *(empty)* | GLM-5.3-Flash from AMD's Quark MXFP4 export: four mHC residual streams over 34 KDA and 11 sparse latent-attention (MLA) layers with a DSA indexer, 288 MXFP4 experts at top-8 under sigmoid routing, block-FP8 attention and dense layers at f32 scales, each weight served as stored; its MTP layer is a serial drafter. Pictures through its vision tower (`arch/common/rad_block_glm_vision.h`); bf16 KV |
| `arch/bailing_hybrid` | `bailinghybrid` | *(empty)* | Ling-3.0-flash and its fine-tunes (Ling-3.0-flash-Sante) from the bf16 checkpoint: 35 KDA and 7 dense latent-attention (MLA) layers with a rotary part and a head-wise gate, 512 experts at top-8 under group-limited sigmoid routing with an ungated shared expert, the routed experts as the recipe stores them (`data/recipes/ling3-w4a8-rtn.recipe`); its MTP layer is a serial drafter; bf16 KV |
| `arch/lfm2_bf16` | `lfm2` | *(empty)* | LiquidAI's LFM2 and LFM2-VL, bf16, one rank |
| `arch/spark25_bf16` | `spark25` | *(empty)* | Spark X2.6, bf16 checkpoint, mixed sliding/full attention, one rank ([geometry](#spark25-spark-x26)) |
| `arch/embgemma2` | `embeddinggemma2` | *(empty)* | EmbeddingGemma 2: a bidirectional encoder with Gemma 4's vision tower and audio conformer, pooled to one vector |
| `arch/nomicbert` | `nomicbert` | *(empty)* | nomic-embed-text-v2-moe: a bidirectional post-norm encoder, 12 layers with 8 experts at top 2 on every second layer, mean-pooled to one vector an input |
| `arch/nemotron35_embed` | `mistral3` | *(empty)* | Nemotron 3.5 Embed 1B/8B and Rerank 8B: native BF16 bidirectional text/image retrieval with a Pixtral tower, TP1 ([geometry and contracts](#nemotron35_embed-embedding-models)) |
@@ -70,6 +71,41 @@ comes first in one and second in the other. The tables, by plugin:
---
# `spark25`: Spark X2.6
`model_type: spark2_5` / `Spark2_5ForCausalLM`. The 4B checkpoint has 36 layers, hidden size
2560, 16 query heads and 4 KV heads at head dimension 256, a 10240-wide gated MLP and a tied
131072-token embedding. It has no q/k norms or projection biases. The residual is accumulated in
f32; norms write bf16 before the projections.
The checkpoint's fused Q/K/V matrix is split by rows in that order at conversion; gate and up are
joined in that order. The MLP uses **exact erf GELU**, not `gelu_mul`'s tanh approximation. Each
attention head's output is multiplied by its own sigmoid gate before the output projection.
`layer_types` is authoritative: sliding layers use window 512 and full-head NeoX rotary at theta
10000; full layers use 64 rotary dimensions at theta 5000000. Both use the full KV group, with the
window applied by the local attention op, so prefix caching remains valid.
The initial implementation serves BF16 at TP1, tied embeddings, headwise sigmoid gates and the
checkpoint's own rotary parameters. It does not implement DSpark, quantisation recipes, other gate
activations or rotary-scaling overrides. The tokenizer and its template come from the checkpoint;
the architecture declares the `<think>`/`</think>` reasoning markers and the
`<tool_call>name<arg_key>...` tool-call format.
For a CPU differential against the reference implementation's `configuration_spark.py` and
`modeling_spark.py`, with Python's torch, transformers and safetensors installed:
```sh
python3 tests/spark25_reference.py --reference /path/to/XHToken-Spark-X2.6-4B --build build
SPARK25_REFERENCE_TEMPLATE=/path/to/XHToken-Spark-X2.6-4B/chat_template.jinja \
build/tests/spark25_chat_test
```
The first builds a small deterministic checkpoint and compares prefill, chunked prefill and cached
decode against the reference without a GPU. The second also exercises the checkpoint's actual chat
template, which is not redistributed in this tree.
---
# `llama`: the plain decoder
`model_type: llama` with `LlamaForCausalLM`. Every layer is full attention; unlike `qwen35_fp8`