Skip to content
Closed
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

- Ripple-65B-Preview on Metal: `--drafter` takes the publisher's DFlash2 drafter (`ricursiveAI/Ripple-65B-Preview-DFlash2`) beside either release, with drafted replies equal to plain ones; with the drafter the server opens two streams unless `--parallel` is named, and refuses a named `--parallel` above 2 (#2260, fixes #2259). Thanks to @BobClawblaw.

- MiniMax-M3 on CUDA: `TF_MINIMAX_GRAPHS=1` (opt-in) runs the decode verify window from one CUDA graph, re-recorded with each round's arguments and updated in place, so every kernel sees the same arguments as the eager path and tokens are unchanged (#4610).

- Server: `POST /v1/prompt_cache/flush` takes an optional `retain` count that keeps the most recently used prompt states in RAM and on disk; without it the flush is unchanged (#4856).
Expand Down
1 change: 1 addition & 0 deletions THIRD_PARTY_NOTICES.md
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ These follow a model's release code or a library's model code for their math, ro
- `tools/lfm3/ref64.py` and `zig/kernels/xpu/lfm3.cl`: `modeling_lfm3.py` in [LiquidAI/LFM3-1.7B](https://huggingface.co/LiquidAI/LFM3-1.7B). Copyright Liquid AI, LFM Open License v1.0; see [the license text](LICENSES/LFM-Open-1.0.txt).
- `zig/kernels/metal/minimax_m3/glue.metal`: the rounding points of `modeling_minimax_m3_vl.py` in [transformers](https://github.com/huggingface/transformers).
- `zig/src/families/ricursive/` (its layer order and rounding points), `zig/kernels/metal/ricursive/glue.metal`, `zig/kernels/cuda/ricursive.cu`, `ricursive.cuh`, `ricursive_prep.cu`, `ricursive_prep.cuh` and `tools/zig/ricursive_reference.py`: `modeling_ricursive.py` in [ricursiveAI/Ripple-65B-Preview](https://huggingface.co/ricursiveAI/Ripple-65B-Preview) at revision `240d5966cbe00f0627c699e59ef58560b60303cf`: the scaled embedding, the value residual, the per-head q/k norms, RoPE on sliding layers only, the fp32 sigmoid gate, the clamped SwiGLU and the four norms a layer. The release's SGLang model `inference/server/model.py` computes the same layers; what is in it alone is its serving (the W4A4 kernels, the capture of hidden states for a drafter), which this family does not take. Copyright ricursiveAI, Apache License 2.0; see [the license text](LICENSES/Apache-2.0.txt). The reference's `--release` and `--release-f64` modes import the release's own `modeling_ricursive.py` from the checkpoint at run time; TensorFold does not include it.
- `zig/src/families/ricursive/dflash2.zig` and `zig/kernels/metal/ricursive/dflash2.metal` (the DFlash2 drafter for ricursiveAI/Ripple-65B-Preview-DFlash2): `DFlash2DraftModel`, `GroupedDynamicCausalConv` and `CandidateSelector` in `dflash/model.py` of [z-lab/dflash](https://github.com/z-lab/dflash) at revision `07ebd93db9f472af339b644bb70221ad8428328a`, MIT License, Copyright © 2026 Z Lab, with its `apply_rotary_pos_emb`'s rounding points; the RMSNorm, rotary cos and sin, and SiLU MLP of the release's `modeling_ricursive.py` above (`RicursiveRMSNorm`, `RicursiveRotaryEmbedding`, `RicursiveMLP`), at the drafter's config. The target's taps are the hidden states `extract_context_feature` in that `model.py` takes (`hidden_states[layer_id + 1]`), here of `modeling_ricursive.py`'s `output_hidden_states`: a tapped layer's output, before the final norm. The NoPE layer is `no_rope_layers` in the drafter's `config.json` ([ricursiveAI/Ripple-65B-Preview-DFlash2](https://huggingface.co/ricursiveAI/Ripple-65B-Preview-DFlash2) at revision `35609b3be3dd08a822b3ba1257c1ea5dd6f87632`, Apache License 2.0); `zig/src/families/ricursive/fixtures/dflash2_config.json` is that `config.json`, unchanged. The 16,384-token draft window is from `inference/server/README.md` in the release above.
- `zig/src/vision/qwen_cuda.zig`: `Qwen3_5VisionModel` in transformers.
- `zig/src/core/picture/patches_test.zig`: recorded image-processor output data from `Lfm3VlImageProcessor` and `Qwen2VLImageProcessor` in transformers; the processing implementation is described below.
- `zig/src/families/flashnext/rotary_config.zig`: `_compute_yarn_parameters` in transformers, for the 64 rotary dims.
Expand Down
85 changes: 79 additions & 6 deletions docs/recipes/ripple-65b-metal.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ converted:
- [`ricursiveAI/Ripple-65B-Preview`](https://huggingface.co/ricursiveAI/Ripple-65B-Preview) (revision
`240d5966cbe00f0627c699e59ef58560b60303cf`, 121 GiB): the bf16 release, the exact model.

The publisher's DFlash2 drafter,
[`ricursiveAI/Ripple-65B-Preview-DFlash2`](https://huggingface.co/ricursiveAI/Ripple-65B-Preview-DFlash2) (revision
`35609b3be3dd08a822b3ba1257c1ea5dd6f87632`, 7.5 GiB, bf16), drafts for either release with `--drafter`; a drafted
reply equals the plain one bit for bit.

It was brought up on an M5 Ultra (256 GB); other Macs are untested. Prompts run on Metal 4 tensor units, so it needs
an M5 or later: M1 to M4 Macs are refused by name at load. Other `ricursive` checkpoints, and either release quantized
any other way, are refused by name.
Expand All @@ -26,6 +31,13 @@ zig-out/native/bin/tensorfold-native serve models/ripple-65b-nvfp4 --name ripple
--context 262144 --parallel 2
```

With the drafter (`hf download ricursiveAI/Ripple-65B-Preview-DFlash2 --revision
35609b3be3dd08a822b3ba1257c1ea5dd6f87632 --local-dir models/ripple-65b-dflash2`), add `--drafter
models/ripple-65b-dflash2`. It takes 7.7 GiB (its weights and its rings). With the drafter the server opens two
streams when `--parallel` is not named and refuses a named `--parallel` above 2 by name: each stream's block is its
own pass through the drafter, so at four streams drafted ties plain except on lists, and at seven it is slower on
every kind (the table under the drafter's speed below).

The bf16 release serves the same way from its own directory. A stream's caches take 16.75 GiB at 262,144
tokens: 64 of the 80 layers slide over 1,024 keys and keep a 3,072-slot ring each (the window and a 2,048-row prompt
chunk); every fifth layer is global and keeps every key, in bf16. Under the default load limit (75% of RAM) a 256 GB
Expand Down Expand Up @@ -55,6 +67,16 @@ model computes the same layers):
- **Attention.** Prompt chunks on the tensor units over the sliding ring or every key (`attention_nax.metal`); decode
rows over key blocks at absolute positions, so a row's bits never depend on the rows beside it.
- **Serving.** The lane host's shared rounds, greedy or `tf_sample_full` draws, copy drafts, the prompt cache.
- **DFlash2 drafter** (`dflash2.zig`, `kernels/metal/ricursive/dflash2.metal`), as z-lab's `DFlash2DraftModel`
(`dflash/model.py`) defines it, with the release's own RMSNorm, rotary and SiLU MLP (`modeling_ricursive.py`), the
NoPE layer of the drafter's `config.json` (`no_rope_layers: [4]`) and the draft window of ricursiveAI's
`inference/server/README.md`. The target writes the residual after layers 1, 20, 39, 58 and 77; the drafter folds
the five into one row (`fc`, then a norm) and keeps its five layers' keys and values from it, in bf16 rings: four
layers slide over 4,096 keys, the fifth (NoPE) over the release's 16,384-key draft window. A round runs a 16-row block
(the pending token and 15 masks) through its layers, each with its causal convolutions (4 taps, per-row kernels)
around attention and the MLP, reads the target's head on the 15 mask rows, keeps each row's 32 best tokens, and walks
them with the selector's codebooks (rank 256) to the draft. The lane core verifies each draft in one target window, so
a reply equals the plain one; the drafter only changes how many tokens a round keeps.

**Activations stay bf16.** The publisher serves the NVFP4 release with SGLang's `flashinfer_cutlass`, which also
quantizes activations to fp4 (W4A4). TensorFold does not run reduced-precision activations, so the engine serves the
Expand All @@ -64,11 +86,14 @@ publisher's W4A4 kernels.
Every kernel is registered with the kernel contract (`zig/tests/contract/metal_ricursive*.zig`, the roll call in
`contracts.zig`): the glue, decode and prompt attention for both layer kinds, the NVFP4 row kernels, dequantization and
GEMM, and llama's row projections, merge, argmax and GEMM again at Ripple's shapes (every reduction it runs: k 5,120,
10,240 for the attention output and 40,960). Fifteen planted controls each edit one kernel's source, and each must turn
its gate red. `tf-kernel-contract --only ricursive` on the M5 Ultra:
10,240 for the attention output and 40,960). The DFlash2 drafter adds its own kernels (the target's tap, the
drafter's embedding, norms, conv, rotation, attention, SiLU, top-k and walk), llama's row projections and GEMM at the
drafter's shapes, and the full-vocabulary sampler. Twenty-five planted controls (ten of them in the drafter's kernels)
each edit one kernel's source, and each must turn its gate red. `tf-kernel-contract --only ricursive` on the M5 Ultra
(23 Nov 2026):

```
SUMMARY 46 kernels: 46 pass gates 1-4, 0 fail, 0 known findings; 15 controls: 15 red as planted, 0 missed; 0 limit problems; gates 645430 ms, limits 140 ms
SUMMARY 75 kernels: 75 pass gates 1-4, 0 fail, 0 known findings; 25 controls: 25 red as planted, 0 missed; 0 limit problems; gates 874094 ms, limits 505 ms
```

## Correctness (M5 Ultra, 4 Nov 2026)
Expand Down Expand Up @@ -156,14 +181,62 @@ against 7.5 s cold, with the same reply as on a restarted server.
back exactly; the cold prompts take 273 s and 790 s to the first token. The bf16 release found it too, at 120k and
258k tokens.

With the DFlash2 drafter (5 Nov 2026, the NVFP4 release, the same settings plus `--drafter`; speed run with no other
model busy; a local build of `a869c4f32`):

| streams | prose | code | structured | list | first token | a round |
|---:|---:|---:|---:|---:|---:|---:|
| 1 | 15.5 | 27.5 | 17.8 | 19.8 | 0.53-0.65 s | 131.2 ms |
| 2 | 22.5 | 37.7 | 26.6 | 40.6 | 0.82-0.98 s | 166.2 ms |

1.5 to 2.7 times one plain stream, 1.2 to 2.16 times two. A round keeps 2.65 tokens on average with one stream (48% of
its drafted tokens accepted) and 2.65 with two (56%). The drafted serving checks equal the plain ones: drafted == plain
12/12 in the drafts suite and 12/12 under structured output, seeded sampling 9/9, the soak 60/60, concurrent 12/12,
structured 18/18, tools 5/5, and a resumed turn equal to the cold one (0.59 s against 7.8 s).

Past two streams the drafter gains little (6 Nov 2026, the NVFP4 release, `--context 262144 --parallel 7`, one local
build of `e1d719275` with and without `--drafter`, no other model busy; tokens a second, all streams together):

| streams | prose | code | structured | list | a round |
|---:|---:|---:|---:|---:|---:|
| 4, plain | 32.6 | 31.8 | 31.1 | 32.5 | 126.2 ms |
| 4, drafted | 30.3 | 32.0 | 31.3 | 43.1 | 277.6 ms |
| 7, plain | 43.2 | 42.9 | 41.6 | 43.4 | 165.5 ms |
| 7, drafted | 40.2 | 34.7 | 22.9 | 34.1 | 406.4 ms |

Each stream's block is its own pass through the drafter, so a round grows with the streams while the tokens it keeps
fall (2.35 tokens a round at four, 1.89 at seven). At four it ties plain except on lists; at seven it is slower on
every kind. With `--drafter`, the server opens two streams unless `--parallel` is named, and refuses a named
`--parallel` above 2 by name.

With the bf16 release (6 Nov 2026, `--context 262144 --parallel 2`, greedy 256-token replies, no other model busy; one
local build of `b7ff7854f` with and without `--drafter`):

| streams | prose | code | structured | list | first token | a round |
|---:|---:|---:|---:|---:|---:|---:|
| 1, plain | 6.4 | 6.4 | 6.4 | 6.4 | 0.52-1.20 s | 157.2 ms |
| 1, drafted | 13.4 | 30.7 | 13.3 | 18.7 | 0.39-1.06 s | 154.0 ms |

2.1 to 4.8 times plain with one stream; a round keeps 2.93 tokens. Drafted == plain 12/12 beside the bf16 release.

Two drafted streams beside the bf16 release do not decode together on a 256 GB M5 Ultra. With the drafter the server
keeps 129.5 GiB wired beside 60.5 GiB of caches, and macOS reports memory pressure as soon as it has loaded (22% free,
against 27% for the plain server); the engine then admits a stream only when none runs. A second request waits for the
first reply (queued 5.4 to 14.0 s in the server's log), so the two-stream ruler cells measured one stream at a time,
with first tokens of 3.24 to 7.98 s; they are left out of the table. Plain, two bf16 streams decode together (13.4 to
13.7 tokens a second in all, 0.79 to 1.78 s to the first token).

## Not done

No quality suite was run. Contexts past 258,039 tokens were not run, so `--context` stops at 262,144 and refuses
the card's 1M by name. Ripple's think markers are spelled from several tokens, not one each, so a thinking budget
(which forces a close) and logprobs (which cut the reply at its close token) are refused by name, and a reply's
`reasoning_tokens` reads 0. The family has no draft head: drafts come only from the lane core's copies. No images:
(which forces a close) is refused by name, and a reply's `reasoning_tokens` reads 0. Logprobs are served, with
`--drafter` too: on the NVFP4 release with the drafter (23 Nov 2026), a greedy and a seeded sampled request with
`top_logprobs: 3` gave the same tokens and rows with drafting on (3.58 and 3.56 tokens a round) and off. No images:
Ripple has no vision tower. Only the M5's tensor units were checked; M1 to M4 Macs are refused at load, and smaller
RAM is untested. The publisher's DFlash2 drafter (`ricursiveAI/Ripple-65B-Preview-DFlash2`) is not served yet.
RAM is untested. Beside the bf16 release the drafter was checked for drafted == plain and one stream's speed only (two
drafted streams run one at a time there, see above); its structured output, seeded sampling, soak and resumed turns were
run beside the NVFP4 release.

## Licence

Expand Down
Loading