Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ compiled at run time with NVRTC, and the same kernels run on Vulkan: no C++ buil
fit in VRAM run on the CPU at the same time as the GPU work, and the expert placement adapts to the routing it sees.

Supported models: Qwen3, Qwen3-Next, Qwen3.5/3.6, Qwen3.8-Flash-Next, Recursive Flint, Gemma 4, DeepSeek-V4.1-Flash,
GLM-5.3-Flash, Hy4-flash and Inkling 2 Mini. The architectures, the GGUF types and the notes for each model are in
GLM-5.3-Flash, Hy4-flash, Inkling 2 Mini and Kolibri 1.1. The architectures, the GGUF types and the notes for each model are in
[docs/MODELS.md](docs/MODELS.md).

Version 1.3.1.
Expand Down
39 changes: 39 additions & 0 deletions docs/BENCHMARKS.md
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,45 @@ used part of the GPU during that run. Alternating runs of the old and new build
CUDA 25.4 to 33.5 tok/s, Vulkan 16.6 to 25.4 tok/s, prefill unchanged (within 1-4%). Most of the Vulkan gain is the
IQ4_NL expert matvec (105 to 270 GB/s on 8 experts of 2304x2304).

## Kolibri 1.1 Q4_K_M (43.4 GB)

`Kolibri-1.1-Q4_K_M.gguf` (architecture `kolibri1`), measured 2026-11-25 on the reference machine (RTX 3060 12 GB,
30 GB RAM, NVMe). The file does not fit in RAM plus VRAM. Both engines run as servers and answer the same streamed
`/v1/chat/completions` request with 128 reply tokens, greedy: prefill is the prompt tokens over the time to the first
token, decode is the other 127 tokens over the rest. Each server first answers a 0.5k-token request that is not
counted. RustingStrata: `serve --model <file>` with default flags (9.7 GB of VRAM). llama.cpp: the Kolibri fork at
5f4d22289, CUDA build, `llama-server -c 40000` with `-ngl 4` (its best prefill here) and with `-ngl 99 -cmoe` (its
best decode here). Mean, the range of the runs in brackets, the number of runs after it.

| Prompt | | Prefill (tok/s) | Decode (tok/s) | Runs |
|---|---|---|---|---|
| 0.5k (561 tokens) | RustingStrata | 181.0 (156.9-199.6) | 33.4 (32.0-35.8) | 5 |
| | llama.cpp `-ngl 4` | 145.4 (93.8-165.5) | 15.5 (14.6-16.8) | 5 |
| | llama.cpp `-ngl 99 -cmoe` | 98.5 (10.7-173.7) | 27.0 (9.7-34.8) | 5 |
| 3.8k (3860) | RustingStrata | 148.7 (141.9-152.9) | 23.0 (22.4-23.4) | 3 |
| | llama.cpp `-ngl 4` | 41.3 | 5.9 | 1 |
| | llama.cpp `-ngl 99 -cmoe` | 27.9 | 10.6 | 1 |
| 16k (16163) | RustingStrata | 139.1 (130.8-147.4) | 21.0 (20.9-21.1) | 2 |
| | llama.cpp `-ngl 4` | 48.4 | 3.8 | 1 |
| | llama.cpp `-ngl 99 -cmoe` | 30.0 | 8.7 | 1 |
| 32k (31443) | RustingStrata | 158.8 (146.8-170.9) | 21.1 (20.1-22.0) | 2 |
| | llama.cpp `-ngl 4` | 34.0 | 3.3 | 1 |
| | llama.cpp `-ngl 99 -cmoe` | 32.9 | 9.3 | 1 |

Quality vs llama.cpp, same GGUF, teacher-forced: the fork's greedy tokens (`-ngl 4`, 48 tokens) go through
`rustingstrata score` and the top token is compared at every step: 45, 46, 44 and 46 of 48 after prompts of 2k, 3.8k,
16k and 32k tokens. The fork against itself (CPU against GPU layers, or `-ngl 2` against `-ngl 4`) gives 45, 45, 40
and 44 of 48. Every miss is at a step where the reference's two best tokens are close.

Caveats: the llama.cpp rows at 3.8k and above are one run each, and the llama.cpp runs were made before the last
RustingStrata prefill change, in the same night and not interleaved with it (the 0.5k RustingStrata row before that
change, run between the two llama.cpp rows, was 132.4 (110.0-148.0) / 33.2). The low ends of the llama.cpp ranges at
0.5k are its first runs, with the experts not yet in the page cache; its later runs reach 148-166 (`-ngl 4`) and
129-174 (`-cmoe`) tok/s of prefill. llama.cpp counts 564 tokens for the 0.5k prompt.
`--moe-cache-mib 5000` and `--moe-cache-mib 8000 --moe-cache-cpu-share 0.5` were also tried for llama.cpp at 3.8k
and were slower in decode than `-cmoe` alone (34.9 / 3.8 and 37.6 / 6.6). Speed on this file depends on the drive
and on how much of the file the page cache holds.

## Not yet measured

- Qwen3-Next against llama.cpp in one table.
Expand Down
37 changes: 37 additions & 0 deletions docs/MODELS.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ The engine picks the code path from `general.architecture` in the file.
| [DeepSeek-V4.1-Flash](#deepseek-v41-flash-iq2_xxs-249-gb) | `deepseek41` | own forward, matvecs and expert cache on the CUDA card, greedy only |
| [GLM-5.3-Flash](#glm-53-flash-ud-q2_k_xl-119-gb) | `glm5-next` | own forward, matvecs and expert cache on the CUDA card, greedy only |
| [Hy4-flash](#hy4-flash-iq2_siq2_xxs-85-gb) | `hy_v4_flash` | own forward, matvecs and expert cache on CUDA or Vulkan, greedy only |
| [Kolibri 1.1](#kolibri-11-q4_k_m-434-gb) | `kolibri1` | own forward, matvecs, expert cache and attention on the CUDA card, greedy only |
| [Inkling 2 Mini](#inkling-2-mini-iq4_nl-176-gb) | `inkling2_loop`, `inkling2` | own forward, matvecs and expert cache on CUDA or Vulkan |

The models with their own forward open the GPU by themselves (no `--gpu` flag), have nothing to calibrate and load
Expand Down Expand Up @@ -70,6 +71,42 @@ The 1.3.0 prefill is the wall time less the load and the decode; it had no timer
host round trip for each group of matrix products of each layer, and no llama.cpp run was made on this machine; the
report in issue #81 has llama.cpp well ahead on an RTX 4070 SUPER.

## Kolibri 1.1 (Q4_K_M, 43.4 GB)

`chat`, `generate`, `serve`, `score` and `bench` detect the `kolibri1` architecture
([Aleph-Alpha/Kolibri-1.1-GGUF](https://huggingface.co/Aleph-Alpha/Kolibri-1.1-GGUF)) and run its own forward: 50
layers, 384 experts a layer with 6 routed and one shared, a sliding window of 513 positions on four layers of every
five, and on every fifth layer an attention over the 2048 keys that an indexer picks (K and V rounded to NVFP4).

```bash
rustingstrata chat --model Kolibri-1.1-Q4_K_M.gguf
rustingstrata serve --model Kolibri-1.1-Q4_K_M.gguf --port 8080
```

The matrix products, both kinds of attention and the routed experts that fit run on the CUDA card; the other experts
run on the CPU at the same time. A prompt goes through the layers in chunks of 1024 tokens (`STRATA_DS_CHUNK`), and a
layer's experts on the card take one round trip for the whole chunk. `STRATA_KOL_CPU_ATTN=1` keeps the attention of a
chunk on the CPU. The chat template is ChatML with the model's "Reasoning effort" system section (`--think`).

Reference machine (RTX 3060 12 GB, 30 GB RAM), server to server, a streamed chat request with 128 reply tokens,
prefill / decode in tok/s (the table with ranges is in [BENCHMARKS.md](BENCHMARKS.md#kolibri-11-q4_k_m-434-gb)):

| Prompt | RustingStrata | llama.cpp `-ngl 4` | llama.cpp `-ngl 99 -cmoe` |
|---|---|---|---|
| 0.5k tokens | 181 / 33.4 | 145 / 15.5 | 99 / 27.0 |
| 3.8k | 149 / 23.0 | 41 / 5.9 | 28 / 10.6 |
| 16k | 139 / 21.0 | 48 / 3.8 | 30 / 8.7 |
| 32k | 159 / 21.1 | 34 / 3.3 | 33 / 9.3 |

Quality: llama.cpp's greedy tokens fed through RustingStrata's forward give the same top token at 45, 46, 44 and 46
of 48 steps after prompts of 2k, 3.8k, 16k and 32k tokens. Two llama.cpp runs of the same file (CPU against GPU
layers) agree with each other at 40-45 of 48; the misses are near ties.

Caveats: the file is larger than the RAM and VRAM of the reference machine together, so the experts that are not on
the card are read from the drive through the page cache, and the first request after a start is slower. CUDA only
(no Vulkan kernel for the attention over picked keys; without a card it runs on the CPU). Decoding is greedy, there
are no stop strings, and the model's thinking arrives inside `content`.

## DeepSeek-V4.1-Flash (IQ2_XXS, 249 GB)

`chat`, `generate` and `serve` detect the `deepseek41` architecture and run it on the CPU reference forward, with the
Expand Down
4 changes: 2 additions & 2 deletions docs/USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ other MCP clients use, and pass it with `--mcp <file>` (or `STRATA_MCP`; the def
## Flags

- `--backend NAME` GPU backend: `cuda`, `vulkan` or `hip` (AMD cards through ROCm, one device per run, see [HIP.md](HIP.md)). Without it CUDA is used when it loads, else Vulkan.
- `--ctx` KV cache size in tokens (default 4096). For Inkling 2, Hy4, GLM, DeepSeek and Gemma 4 it is the prompt plus reply limit instead, and the default is the context the model was trained on; their caches grow with the text.
- `--ctx` KV cache size in tokens (default 4096). For Inkling 2, Hy4, GLM, DeepSeek, Kolibri and Gemma 4 it is the prompt plus reply limit instead, and the default is the context the model was trained on; their caches grow with the text.
- `--mtp [N]` speculative decoding with the model's draft head. Greedy tokens stay the same; sampling keeps its
distribution. Needs a GGUF with an MTP head (for example the Qwen3.6-35B-A3B MTP files).
Qwen3.8-Flash-Next (`qwen4exp`) takes its head from a companion file: `--mtp-model mtp-...-shared-Q8_0.gguf`.
Expand Down Expand Up @@ -156,7 +156,7 @@ other MCP clients use, and pass it with `--mcp <file>` (or `STRATA_MCP`; the def
- `--alias prism` (`serve`) is the model name in `/v1/models` and in the replies, whatever file is loaded (default: the
file name), so clients set up for `prism` keep working when another model is loaded. Calibration and the expert
profile stay per file.
- Inkling 2, Hy4, GLM, DeepSeek and Gemma 4 run on their own code path. The server loads them like any other model
- Inkling 2, Hy4, GLM, DeepSeek, Kolibri and Gemma 4 run on their own code path. The server loads them like any other model
(`serve --model <file>`, or from the chat page of a running server, in either direction), with these limits: one
request at a time, greedy (Inkling 2 also samples: `temperature`, `top_k`, `top_p`, `seed`; a seed repeats its
text only with `STRATA_FIXED_EXPERTS=1`, because the adaptive expert split moves the logits a little),
Expand Down
4 changes: 4 additions & 0 deletions src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,10 @@ pub trait Backend: Send {
/// Inkling 2 sigmoid top-k router for `rows` tokens: picks top `k` from `logits` (`[rows, n_expert]`) using
/// `sigmoid(logit) + bias`, writes indices `[rows, k]` to `ids`, normalized unbiased probs * `exp_scale` (* `dn_sc[id]`
/// if non-null) to `wts`, and optional `gu_sc[id]` (or `1.0`) to `gsc_out`.
/// Attention of `nt` queries, each over its own key list: row t of `idx` (`ns` u32 positions, the first `cnt[t]`
/// valid) names the rows of the f16 caches `kc`/`vc` (`[(pos * nkv + g) * hd]`) that query t attends. `q` and
/// `out` are f32 `[t][head][hd]`. Kolibri's sparse layers.
fn attn_sel(&self, _q: u64, _kc: u64, _vc: u64, _idx: u64, _cnt: u64, _out: u64, _nt: usize, _nh: usize, _nkv: usize, _hd: usize, _ns: usize, _scale: f32) -> anyhow::Result<()> { anyhow::bail!("{}: attention over key lists not implemented", self.name()) }
fn ink_route(&self, _logits: u64, _bias: u64, _ids: u64, _wts: u64, _gu_sc: u64, _dn_sc: u64, _gsc_out: u64, _n_expert: usize, _k: usize, _exp_scale: f32, _rows: usize) -> anyhow::Result<()> { anyhow::bail!("{}: Inkling 2 router not implemented", self.name()) }
/// Gyro files (`config::Hadamard`): each of `rows` rows of n floats at `x` (times silu(x) * u first when `u` is
/// not 0) becomes H (s x) per `block` values, written to `out`, which may be `x`. `s`: the row's n signs as floats.
Expand Down
2 changes: 1 addition & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ pub struct ModelConfig {
}

/// Architectures with their own forward and server outside `ModelConfig` (`src/main.rs` dispatches on them).
pub const OWN_ARCHS: [&str; 6] = ["gemma4", "glm5-next", "deepseek41", crate::hy4::ARCH, crate::inkling2::ARCH, crate::inkling2::ARCH_RUNS];
pub const OWN_ARCHS: [&str; 7] = ["gemma4", "glm5-next", "deepseek41", crate::hy4::ARCH, crate::kolibri::ARCH, crate::inkling2::ARCH, crate::inkling2::ARCH_RUNS];

impl ModelConfig {
pub fn from_gguf(g: &Gguf) -> anyhow::Result<ModelConfig> {
Expand Down
Loading
Loading