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: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Each release's page on GitHub has its notes and measurements. See [the 1.0.0 rel

## Unreleased

- Metal: Recursive's Flint (40B-A2.5B MoE) is served natively from `RecursiveSI/flint-int4` on M5-class Macs, with its kernels and 2048-wide router under the kernel contract, a 262,144-token window, copy drafts and the prompt cache; `FLINT_LOAD_LIMIT_GB` caps its memory, and Step-5 now shares the same load budget, so a `STEP5_LOAD_LIMIT_GB` above the Mac's RAM is refused by name (#1177, fixes #1175). Thanks to @BobClawblaw.

- CI: a newer push to main cancels main's older No GPU run (a landing train pushes one commit a PR, and the train's own run has tested the tree), the nightly keeps its own run, and the app checks run on pushes to main only (#3230).

- Intel XPU: Qwen3.8-27B's prompt `gdn_out` kernel keeps its scale bookkeeping in cheaper exact forms, for 22.6% less kernel time on an Arc Pro B70 (734 to 569 ms over a 32K prompt) with byte-identical outputs, its fallback included (#2921, refs #2859). Thanks to @dinadur.
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ Conversions are explicitly marked: their upstream weights need the linked conver
| Gemma 4 12B, converted MLX 4-bit | `hf download google/gemma-4-12B-it --revision 707f0a3b8a3c7ad586ed01e27eafbad8a27dd0f7 --local-dir ~/models/gemma-4-12b-hf`<br>`hf download google/gemma-4-12B-it-assistant --revision 46d4c6f13f0ac0ad827b915669b8df9b81c64c51 --local-dir ~/models/gemma-4-12b-assistant` | One Mac (M5 Ultra checked); converted text weights 6.3 GB, image weights 100 MB, plus assistant/caches. MLX 4-bit also served on one GB10. Pre-M5 Metal has a row path; the MTP assistant requires M5 tensor units. | [Convert and serve](docs/recipes/gemma-4-12b-native.md). Upstream download needs `hf`; conversion needs Python, mlx and mlx-lm. Serving is native; [CUDA qualification](CHANGELOG.md#114) includes the MTP assistant. |
| Step-5-Preview, converted affine | `hf download stepfun-ai/Step-5-Preview --local-dir ~/models/step5-preview-fp8` | One 256 GB Mac; text 166.9 GiB, MTP adds 2.5 GiB and vision 3.7 GiB. | [Convert and serve](docs/recipes/step-5-preview.md). The documented 256 GB setup serves converted affine weights; converting the upstream FP8 download needs Python and mlx. |
| MiniMax-M3.1-Flash, community affine 3/4-bit | `hf download BobClawblaw/MiniMax-M3.1-Flash-MLX-mix34 --revision 9524999057e0d277d26438606e033e2191fb465c --local-dir ~/models/MiniMax-M3.1-Flash-MLX-mix34`<br>`hf download BobClawblaw/MiniMax-M3.1-Flash-MLX-mix256k --revision 916e7ca1044f1c3e7566163096243c940327224d --local-dir ~/models/MiniMax-M3.1-Flash-MLX-mix256k` | One 256 GB M5 Ultra; 203.7 GiB (32,768-token window) or 189.2 GiB (147,456), plus caches. | [MiniMax-M3.1-Flash](docs/recipes/minimax-m3.1-flash.md). Set `MINIMAX_LOAD_LIMIT_GB`; images with `--vision`. Community checkpoints: lossy conversions of MiniMax's NVFP4 release (KL 0.244 / 0.295). MiniMax Community License. |
| Recursive Flint 40B-A2.5B, MLX INT4 | `hf download RecursiveSI/flint-int4 --revision 3b93f9053b530488405ae9fca51d4900d6ce21f0 --local-dir ~/models/flint-int4` | One M5 Mac; M5 Ultra checked; 21.4 GiB resident plus caches. M1-M4 untested. | [Flint](docs/recipes/flint.md). Text and tools; always reasons; no draft head. |
| Kolibri-1, block FP8 (research) | `tensorfold pull Aleph-Alpha/Kolibri-1@e52eb4627d11516b0c01de49210ab5a4e4061444` | One NVIDIA GPU; GB10 measured; 74 GB checkpoint. | [Kolibri](docs/recipes/kolibri-1.md). Text only; copy drafts, no EAGLE-3/neural drafter. |
| Liquid AI d1-3B, decisions | Not documented yet. | Native CUDA; RAM minimum not published. | [API section below](#serve-flags). `/v1/systemone` and `/v1/decisions`. |
| Fish Audio Drama 3, speech | Not documented yet. | Native Metal or CUDA; GB10 measured. | [Release audio instructions](CHANGELOG.md#110), [reference voices and dialogue speakers](docs/drama-http-voices.md). `/v1/audio/speech` with [sampling controls](docs/speech-sampling.md); checkpoint and `codec.pth` required. |
Expand Down
1 change: 1 addition & 0 deletions docs/recipes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ For agent-assisted contributions, read the [TensorFold contributor skill](SKILL.
| LFM2.5-24B-A2B | [Native Metal, MLX 4-bit, shared rounds](lfm2.5-24b-a2b.md) |
| Spark-X2.6-4B | [Native CUDA](spark-x2.6-4b-cuda.md), [native Metal, the bf16 release, contexts to 1M](spark-x2.6-4b-metal.md) |
| Nanbeige4.3-33B | [Native Metal, the bf16 and INT4 releases, the Llama family](nanbeige-4.3-33b-metal.md) |
| Recursive Flint | [Native Metal, the publisher's affine 4-bit export, reasoning and tool calls](flint.md) |

[Persisted serving-state identities](persisted-serving-keys.md) lists the disk owners, their compatibility keys and stale-state host checks.

Expand Down
54 changes: 54 additions & 0 deletions docs/recipes/flint.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Recursive Flint

This page describes the native Zig engine serving Recursive's Flint (`RecursiveSI/flint`) on a Mac. Flint is a
40B-A2.5B mixture of experts: 49 layers of GQA (32 query heads, 4 key heads, head size 128), 35 of them sliding
(a 513-token window, with RoPE) and 14 full (no positional encoding), every head with a learned attention sink and
per-head q/k norms; two dense SwiGLU layers, then 47 layers of 256 routed experts (6 a token, sigmoid scores
renormalized) beside an always-on shared expert. Text in, text out, with reasoning and tool calls.

## Weights

The engine serves Recursive's own MLX export, `RecursiveSI/flint-int4`: affine 4-bit groups of 64 for the
projections, the experts and the head, 8-bit for the embedding (22.6 GB on disk, 21.4 GiB resident).

Licenses: Recursive publishes Flint's weights (`RecursiveSI/flint` and `RecursiveSI/flint-int4`) under Apache-2.0.
The kernels round where Recursive's MLX engine does (`rec_mlx` in `recursive-oss/rec`, release v0.1.0 at e53663b2,
Apache-2.0).

```bash
hf download RecursiveSI/flint-int4 --revision 3b93f9053b530488405ae9fca51d4900d6ce21f0 --local-dir ~/models/flint-int4
```

## Serving

```bash
FLINT_LOAD_LIMIT_GB=48 tensorfold-native serve ~/models/flint-int4 --port 8888 --parallel 4 --prompt-cache-gib 16 \
--temperature 1.0 --top-p 0.95 --top-k 20
```

The sampling flags are the model card's defaults for requests that set none. Structured output and required tool
calls need `libtfgrammar` beside the binary (release archives ship it; from source, `zig build grammar
-Dxgrammar=DIR` with an xgrammar v0.2.8 checkout).

- **Context.** 262,144 tokens, the checkpoint's window. Sliding layers keep a ring of their window and one prompt
chunk; the 14 full layers keep every position, 28 KiB a token (7 GiB a stream at the full window).
- **Memory.** Weights, scratch and every stream's caches stay under 75% of RAM, or `FLINT_LOAD_LIMIT_GB` (GB, at most
the Mac's RAM, capped at the GPU's working set); the prompt cache takes what the streams leave, up to
`--prompt-cache-gib`. On a Mac that serves other models, set both.
- **Streams.** `--parallel N` streams share each decode forward, each reply equal to its run alone.
- **Prompt cache.** Kept states hold the full layers' keys and values and the sliding layers' last window; a resumed
prompt gives the same reply as the same prompt sent fresh.
- **Reasoning.** Flint always reasons: its chat template has no switch, so the server advertises `thinking_switch:
false` and refuses a request's `enable_thinking: false` with a 400 (thinking off is not supported by this chat
template); leave the flag out. Give hard requests a large `max_tokens`; the card suggests 32,768.
- **Tools.** The template's `<tool_call>name<arg_key>…</arg_key><arg_value>…</arg_value></tool_call>` calls are parsed
as GLM-style tool calls, and required or named tool choices are constrained by the grammar.
- **Drafts.** The checkpoint has no draft head; the lane engine's copy drafts apply.

## Checks

`tf-flint-run` runs the model outside the server: greedy tokens, every position's logits in 16-row windows, a
prompt's last logits, or forced steps along given tokens, for comparison with a reference forward; `exact` compares
one-row steps with 16-row windows bit for bit; `bench` times decode steps.

Only the M5's tensor units were checked; M1-M4 are untested.
1 change: 1 addition & 0 deletions zig/build/metal_targets.zig
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@ pub fn metalTargets(b: *std.Build, target: std.Build.ResolvedTarget, optimize: s
.{ .name = "tf-minimax-run", .path = "zig/tests/minimax_m3/run.zig", .about = "MiniMax-M3.1-Flash greedy tokens, every position's logits or a prompt's last logits, for the reference's check" },
.{ .name = "tf-minimax-vision", .path = "zig/tests/minimax_m3/vision.zig", .about = "MiniMax-M3.1-Flash's image tower alone: an image's patches and text rows, for tools/vision_ref.py's check" },
.{ .name = "tf-llama-run", .path = "zig/tests/llama/run.zig", .about = "Llama on Metal: greedy tokens, every position's logits or a prompt's last logits, for the reference's check" },
.{ .name = "tf-flint-run", .path = "zig/tests/flint/run.zig", .about = "Flint greedy tokens, every position's logits or a prompt's last logits, for the reference's check" },
.{ .name = "tf-qwen36-row-seam", .path = "zig/tests/qwen36_row_seam.zig", .about = "Model-free fixture: the row projection's bias sums stay fp32 at every width" },
};
// the tokenizer for the programs that tokenize prompts themselves (the engine module has none)
Expand Down
12 changes: 8 additions & 4 deletions zig/kernels/metal/core/moe_route.metal
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,21 @@ using namespace metal;
#define TF_OUT_T float
#endif
constant constexpr int ITERS = TF_K / 32;
constant constexpr int PERL = ITERS / 32; // the 32-wide slices of k each lane takes
constant constexpr int PER = (TF_E + 31) / 32;

// Logits [rows, E] = x W^T, tg 4 experts x 4 rows; simdgroup s: k=32i+4s+tm, lane l: i=4l..4l+3; 8 partials in order.
// Logits [rows, E] = x W^T, tg 4 experts x 4 rows; simdgroup s: k=32i+4s+tm, lane l: PERL i's from PERL*l; 8 partials.
[[kernel]] void tf_route_logits(const device bfloat* X [[buffer(0)]], const device uint4* RP [[buffer(1)]],
constant int& rows [[buffer(2)]], device TF_OUT_T* OUT [[buffer(3)]],
uint2 tg [[threadgroup_position_in_grid]], uint2 tpos [[thread_position_in_threadgroup]],
uint lane [[thread_index_in_simdgroup]], uint s [[simdgroup_index_in_threadgroup]]) {
threadgroup float part[8][16];
const int q = int(tg.x), r0 = int(tg.y) * 4;
const device uint4* w = RP + ((size_t(q) * 8 + s) * ITERS + 4 * lane) * 2;
const device uint4* w = RP + ((size_t(q) * 8 + s) * ITERS + PERL * lane) * 2;
float acc[4][4]; // [row][expert]
for (int c = 0; c < 4; c++)
for (int tn = 0; tn < 4; tn++) acc[c][tn] = 0.0f;
for (int ii = 0; ii < 4; ii++) {
for (int ii = 0; ii < PERL; ii++) {
float inter[4][4];
for (int h = 0; h < 2; h++) {
const uint4 v = w[ii * 2 + h];
Expand All @@ -30,7 +31,7 @@ constant constexpr int PER = (TF_E + 31) / 32;
inter[(e + 1) / 4][(e + 1) % 4] = as_type<float>(words[j] & 0xffff0000u);
}
}
const int k = 32 * (4 * int(lane) + ii) + 4 * int(s);
const int k = 32 * (PERL * int(lane) + ii) + 4 * int(s);
for (int c = 0; c < 4; c++) {
const device bfloat* x = X + size_t(min(r0 + c, rows - 1)) * TF_K + k;
for (int tm = 0; tm < 4; tm++) {
Expand All @@ -49,6 +50,9 @@ constant constexpr int PER = (TF_E + 31) / 32;
if (o < 16 && r0 + o / 4 < rows) {
float v = part[0][o];
for (int k = 1; k < 8; k++) v += part[k][o];
#ifdef TF_ROUND_LOGITS
v = float(bfloat(v));
#endif
OUT[size_t(r0 + o / 4) * TF_E + 4 * q + o % 4] = static_cast<TF_OUT_T>(v);
}
}
Expand Down
Loading
Loading