Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
15af30d
ricursive cuda: structured output and forced tool calls, a grammar's …
jrb-ai Nov 26, 2026
1632253
ricursive docs: the CUDA recipe's structured output and forced tool c…
jrb-ai Nov 26, 2026
a452519
ricursive contract: tf_grammar_mask at Ripple's rows through the gate…
jrb-ai Nov 27, 2026
8039e45
ricursive docs: the CUDA recipe no longer says logprobs are refused
jrb-ai Nov 27, 2026
985b01e
changelog: #5363 under Unreleased
jrb-ai Nov 27, 2026
82b81fb
ricursive cuda: the drafter's taps (tf_rc_tap), setTaps and the featu…
jrb-ai Nov 6, 2026
8fb3dff
ricursive cuda: the DFlash2 config parse shared with Metal, the draft…
jrb-ai Nov 6, 2026
f371233
ricursive cuda: the DFlash2 drafter's glue and draft attention kernel…
jrb-ai Nov 6, 2026
d6bd29c
ricursive cuda: the DFlash2 drafter runtime, served with --drafter; d…
jrb-ai Nov 6, 2026
d3d4cd0
cuda: a drafted server offers structured output only when the family …
jrb-ai Nov 7, 2026
e49346e
contract: the drafter's nine launches' nvcc 13.3 receipts on all five…
jrb-ai Nov 7, 2026
b897ed5
contract: drop the drafter records' TODO lines; the receipts are in p…
jrb-ai Nov 7, 2026
5c3cac1
ricursive cuda: zig fmt the drafter's scratch table
jrb-ai Nov 7, 2026
39d2cc8
docs: the Ripple CUDA recipe's drafter section, kernel contract and s…
jrb-ai Nov 7, 2026
a28516d
ricursive cuda: time shared rounds of every stream at load and price …
jrb-ai Nov 7, 2026
f83b8f7
ricursive cuda: shared round prices only past the lone sweep's 16 rows
jrb-ai Nov 7, 2026
095d4ab
CUDA calibration: keep a drafter sweep's shared-round costs
jrb-ai Nov 8, 2026
c51000d
ricursive cuda: time shared rounds in their own file, after the windo…
jrb-ai Nov 9, 2026
8958f3e
docs: the Ripple CUDA recipe's eight-stream speeds with shared-round …
jrb-ai Nov 9, 2026
8aed5d4
Ripple: preserve main behavior and keep rebased files within 600 lines
ashhart Nov 21, 2026
53fa332
ricursive: a drafter server serves logprobs' first row, on Metal and …
ashhart Nov 23, 2026
a5da73e
ricursive tools: the gate compare checks a kl-format reference's fed …
ashhart Nov 23, 2026
746b9e8
changelog: #2475 under Unreleased
jrb-ai Nov 25, 2026
58a23ed
ricursive cuda: ripple-drafted runs its streams under a grammar's mas…
jrb-ai Nov 26, 2026
4357306
ricursive docs: with the drafter, structured output and forced tool c…
jrb-ai Nov 27, 2026
ee6d581
changelog: #2475 and #5363 back under Unreleased, not under 1.3.7
jrb-ai Nov 28, 2026
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,10 @@ Each release's page on GitHub has its notes and measurements. See [the 1.0.0 rel

- Prompt cache: a state the disk tier recalls within `min_gap` under the rewind point becomes the rewind state, so the store no longer keeps a second copy of the rewind beside it (about 684 MiB less in the RAM tier per rewind turn at 21k tokens, same replies) (#5738).

- CUDA: Ripple-65B-Preview (ricursive) takes the publisher's DFlash2 drafter (`ricursiveAI/Ripple-65B-Preview-DFlash2`) with `--drafter`, with drafted replies equal to plain ones; several streams' shared rounds are priced by times taken at load, and structured output (`response_format`) and forced tool calls are served with the drafter as without it (#2475, fixes #2474). Thanks to @jrb-ai.

- Ripple-65B-Preview on CUDA serves structured output (`response_format`) and forced tool calls (`tool_choice` `"required"` or a named function): a grammar's rows are drawn on the GPU from a copy with the disallowed tokens at -inf, by the same draw and argmax kernels, and logprob rows read the unmasked logits; a request with no grammar runs the launches it ran before (#5363, fixes #5252). Thanks to @jrb-ai.


## 1.3.7

Expand Down
2 changes: 1 addition & 1 deletion THIRD_PARTY_NOTICES.md
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,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/families/ricursive/dflash2.zig`, `zig/src/families/ricursive/cuda_dflash2*.zig`, `zig/kernels/metal/ricursive/dflash2.metal`, `zig/kernels/cuda/ricursive_dflash2.cu`, `zig/kernels/cuda/ricursive_dflash2.cuh` and `zig/kernels/cuda/ricursive_dflash2_attn.cu` (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
54 changes: 46 additions & 8 deletions docs/recipes/ripple-65b-cuda.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ read in place from its shards with nothing converted:
`99eea4477a001a41b86914e41feb4b2ed86105e5`, 53 GiB): ModelOpt NVFP4 MLPs, attention, embeddings and head in bf16.

The bf16 release is refused by name (`RicursiveCudaNeedsNvfp4`): at 121 GiB it does not fit a GB10, and the CUDA
family reads only the NVFP4 MLPs.
family reads only the NVFP4 MLPs. 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 with `--drafter`; a drafted reply equals the plain
one.

It was brought up on a DGX Spark (GB10, sm_121, 121.7 GiB shared with the host, CUDA 13). The kernels build for
sm_80, 86, 89, 120 and 121 and their launches fit each, but only GB10 was run.
Expand All @@ -19,16 +22,22 @@ sm_80, 86, 89, 120 and 121 and their launches fit each, but only GB10 was run.
hf download ricursiveAI/Ripple-65B-Preview-NVFP4 --revision 99eea4477a001a41b86914e41feb4b2ed86105e5 \
--local-dir models/ripple-65b-nvfp4
zig build native -Dnvcc=/usr/local/cuda/bin/nvcc -Dsm=121
zig build grammar -Dxgrammar=PATH_TO_XGRAMMAR_v0.2.8 # structured output and forced tool calls
zig-out/native/bin/tensorfold-native serve models/ripple-65b-nvfp4 --name ripple --port 8888 --context 32768
```

At `--context 32768` admission gives eight streams of 2.78 GiB and a 16.0 GiB prompt cache, after a 12.2 GiB
reserve. A stream's caches: 64 of the 80 layers slide over 1,024 keys and keep a 3,072-row ring each; every fifth
layer is global and keeps every key, in 512-row pages.

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 keeps 10.09 GiB for its weights, scratch and eight streams' rings; at `--context 32768`
admission still gives eight streams (3.01 GiB each), and the prompt cache drops to 11.2 GiB.

Thinking follows the chat template, as on Metal: Ripple writes `<think>` itself when it thinks and answers bare
otherwise, and the server files a reply without the block as answer. Its think markers are spelled from several
tokens, so a thinking budget and logprobs are refused by name.
tokens, so a thinking budget is refused by name. Logprobs are served.

## What the family is

Expand All @@ -46,6 +55,12 @@ the release's `modeling_ricursive.py` as the reference:
block, for Ripple's group of 10.
- **Serving.** The lane host's shared rounds as CUDA graphs, greedy or sampled draws, copy drafts, verify windows,
kept states and the prompt cache.
- **DFlash2 drafter** (`cuda_dflash2*.zig`, `ricursive_dflash2.cu`, `ricursive_dflash2_attn.cu`), in the Metal
drafter's op order and bf16 rounding points. The target writes the residual after layers 1, 20, 39, 58 and 77 into a
2,064-row tap ring a stream, inside the round graphs. A round runs the 16-row block through the five layers for
every stream in one launch a step: the 4-tap convolution in Metal's rounding order; draft attention that reads each
of the 8 KV heads once for its 10 query heads and all 16 rows; the target's head; a top-32 a row; then the selector
walk on the host. Chain verify only (one draft a stream), as on Metal.

**Activations stay bf16**, as on Metal: the engine serves the NVFP4 weights with bf16 activations and fp32 sums, not
the publisher's W4A4 kernels.
Expand All @@ -54,7 +69,9 @@ Every kernel is registered with the kernel contract, with planted controls that
GB10 (nvcc 13.3, sm_121):

```
SUMMARY ricursive: 20 kernels, 20 pass gates 1-4, 0 fail; 24 controls: 24 red as planted, 0 missed
SUMMARY ricursive: 22 kernels, 22 pass gates 1-4, 0 fail; 27 controls: 27 red as planted, 0 missed
SUMMARY ricursive dflash2: 10 kernels, 10 pass gates 1-4, 0 fail; 19 controls: 19 red as planted, 0 missed
SUMMARY ricursive dflash2 attention: 3 kernels, 3 pass gates 1-4, 0 fail; 6 controls: 6 red as planted, 0 missed
```

## Correctness (GB10)
Expand All @@ -81,6 +98,20 @@ pick by at most 0.25 nats.
- Served replies are bit-identical alone, beside seven other streams and one at a time (greedy and sampled). A
conversation sent again, reusing 79 to 81 cached tokens, equals its first reply, and 60 repeats of a reply equal the
first. Seeded replies equal their repeats, and streamed text equals the reply sent whole.
- Structured output and forced tool calls draw under the grammar's mask on the GPU: a row's copy with its disallowed
tokens at -inf, through the draw and argmax kernels of a row with no grammar. The first token and a 4-row window
under masks equal the plain draw over the same rows with the other tokens at -inf, greedy and sampled; the model's
rows keep their bits and the logprob rows read them; streams with no grammar in a round beside a masked stream
equal each alone. Served: 11 request forms (`response_format` json_object and json_schema; `guided_json`,
`guided_regex`, `guided_choice` and `guided_grammar`; `structured_outputs` json, json_object, regex, choice and
grammar), greedy and sampled, give valid replies, and tool calls with `tool_choice` `"auto"`, `"required"`, a named
function and a streamed required call agree. The plain dumps and reply hashes above are unchanged.
- With `--drafter`, every reply equals the plain server's at the same seed: 22 of 22, greedy and sampled, at 1, 2
and 8 streams. Each drafted reply also equals itself alone and with `"draft": false`, and cold 2,048- and
8,192-token prompts give the plain reply. With the drafter's code built in, the plain engine's logits are unchanged
bit for bit on all 2,586 rows. Structured output and forced tool calls are served with the drafter too: 44
structured and 5 tool requests equal the plain server's, and 8 structured requests alone, 2 at once and 8 at once
equal it with drafts accepted at each level (158 of 339, 42 of 89 and 149 of 365).

## Measured (GB10, NVFP4 release, `--context 32768`, no other model busy)

Expand All @@ -93,6 +124,16 @@ at 518-520 tok/s at 2,586 rows. Greedy 256-token essays, thinking off, all strea
| 4 | 15.54 |
| 8 | 29.93 |

With `--drafter`, 256 tokens, median of 3 (code is a raw text completion, prose a chat reply): one stream from
`tools/bench_openai.py`, eight streams together from `tools/bench_concurrent.py --levels 8` (all eight streams' tokens):

| reply | 1 stream, plain | 1 stream, drafted | 8 streams, plain | 8 streams, drafted |
|---|---:|---:|---:|---:|
| code, greedy | 5.2 | 26.1 | 37.5 | 124.3 |
| code, sampled (T=1.0) | 4.5 | 18.4 | 30.4 | 72.5 |
| prose, greedy | 4.4 | 10.0 | 32.5 | 58.5 |
| prose, sampled (T=1.0) | 4.0 | 11.2 | 30.4 | 42.7 |

At `--context 131072` admission gives four streams of 8.78 GiB and a 7.1 GiB prompt cache. Cold prompts there
(`tools/bench_cache.py --require-cold`), time to first token: 3.76 s at 2,048 tokens (545 tok/s), 15.6 s at 8,192
(524), 68.4 s at 32,768 (479) and 150.7 s at 65,536 (435). Each reply equals its repeat and itself beside a second.
Expand All @@ -106,11 +147,8 @@ budget.

## Not done

Structured output (`response_format`) and forced tool calls (`tool_choice` `"required"` or a named function) are not
supported on CUDA yet: the server refuses them, because the CUDA family has no masked sampling. Tool calls with
`tool_choice` `"auto"` work. No quality suite was run. Past 131,072 tokens, only the one near-cap prompt above was
run. Only GB10 was run. The publisher's DFlash2 drafter (`ricursiveAI/Ripple-65B-Preview-DFlash2`) is not served
on CUDA yet.
No quality suite was run. Past 131,072 tokens, only the one near-cap prompt above was run. Only GB10 was run. Draft
trees (several drafts a stream) are not done, and the drafter's kernel speed is not tuned.

## Licence

Expand Down
5 changes: 5 additions & 0 deletions tools/zig/ricursive_gate_compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ def run_kl(a: argparse.Namespace) -> int:
eng, fed = open_logits(a.engine, a.vocab)
if ref.shape[0] > len(ids):
ref = ref[: len(ids)] # a causal model: the first rows of a longer run are the shorter run's
if ref_fed is not None: # a kl-format reference says which token it fed after each row: the chat's, as the engine's
ref_fed = ref_fed[: len(ids)]
wrong = np.flatnonzero(np.asarray(ref_fed[:-1]) != np.asarray(ids[1 : len(ref_fed)], dtype=np.uint32))
if wrong.size:
raise SystemExit(f"the reference's file fed other tokens than the ids at {wrong.size} rows, first row {wrong[0]}")
if fed is None and eng.shape[0] > len(ids):
eng = eng[: len(ids)] # the same for a raw file, so two reference passes compare over the chat's rows
if ref.shape != eng.shape or ref.shape[0] != len(ids):
Expand Down
2 changes: 2 additions & 0 deletions zig/build/cuda_kernels.zig
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,10 @@ pub const kernels = [_]Kernel{
// ours: Inkling 2's DSpark drafter glue
.{ .name = "inkling2_dspark", .src = "inkling2/dspark", .flags = glue },
.{ .name = "inkling2_dflash2", .src = "inkling2/dflash2", .flags = glue }, // Mini's external DFlash2 block, attention and selector
.{ .name = "ricursive_dflash2_attn", .flags = glue }, // ours: Ripple's DFlash2 draft attention (split over keys, merged) and top-32
.{ .name = "ricursive", .flags = glue }, // ours: Ripple's glue (embed, add-norms, output gate, FFN activation), glue.metal step for step
.{ .name = "ricursive_prep", .flags = glue }, // ours: Ripple's attention prep (q/k head norms, RoPE, K and V into rings or pages)
.{ .name = "ricursive_dflash2", .flags = glue }, // ours: Ripple's DFlash2 drafter glue (norms, attention prep, block conv, SiLU), dflash2.metal step for step
// ours: Inkling 2's grouped experts, plus Mini's tensor-path epilogue and ascending combine
.{ .name = "inkling2_experts", .src = "inkling2/experts", .flags = &.{ "-O3", "--expt-relaxed-constexpr" } },
.{ .name = "inkling2_modelopt", .src = "inkling2/modelopt", .flags = &.{ "-O3", "--expt-relaxed-constexpr" } }, // Mini packed experts on BF16 activations
Expand Down
15 changes: 14 additions & 1 deletion zig/kernels/cuda/contract_ricursive_controls.cuh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Planted controls for Ripple's attention prep (ricursive_prep.cu): each keeps one fault its gate must catch.
// Planted controls for Ripple's attention prep (ricursive_prep.cu) and grammar mask (sample.cu), one fault each.

// Included by contract_controls_set.cu after contract_controls.cu, whose headers it reuses.

Expand All @@ -22,3 +22,16 @@ extern "C" __global__ void __launch_bounds__(tf_rcp::NT) tf_ctl_rc_prep_rows(
tf_rcp::prep_rows(XQ, XK, XV, inv, qw, kw, Q, KC, VC, rows, heads, kv_heads, pos, nullptr, ring, rope, eps, tab, page,
tok, stride, keep);
}

// Gate 3: sample.cu's tf_grammar_mask reading a word's bits from the top (token t at bit 31 - t % 32); shapes go red.
extern "C" __global__ void __launch_bounds__(256) tf_ctl_rc_grammar_mask(__nv_bfloat16* L, unsigned V, const unsigned* BITS, unsigned W) {
const unsigned row = blockIdx.x;
__nv_bfloat16* x = L + static_cast<size_t>(row) * V;
for (unsigned w = threadIdx.x; w < W; w += blockDim.x) {
const unsigned allowed = BITS[static_cast<size_t>(row) * W + w];
for (unsigned b = 0; b < 32u; b++) {
const unsigned t = w * 32u + b;
if (t < V && ((allowed >> (31u - b)) & 1u) == 0u) x[t] = __ushort_as_bfloat16(static_cast<unsigned short>(0xFF80u));
}
}
}
Loading
Loading